Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 10831295: gesture recognizer: Change the way a processed touch-release event is handled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/timer.h" 7 #include "base/timer.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1876 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
1877 1877
1878 delegate->Reset(); 1878 delegate->Reset();
1879 delegate->ReceivedAck(); 1879 delegate->ReceivedAck();
1880 EXPECT_TRUE(delegate->tap_down()); 1880 EXPECT_TRUE(delegate->tap_down());
1881 delegate->Reset(); 1881 delegate->Reset();
1882 delegate->ReceivedAckPreventDefaulted(); 1882 delegate->ReceivedAckPreventDefaulted();
1883 EXPECT_FALSE(delegate->tap()); 1883 EXPECT_FALSE(delegate->tap());
1884 } 1884 }
1885 1885
1886 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
1887 scoped_ptr<QueueTouchEventDelegate> delegate(
1888 new QueueTouchEventDelegate(root_window()));
1889 const int kTouchId1 = 7;
1890 const int kTouchId2 = 5;
1891 gfx::Rect bounds(10, 20, 100, 100);
1892 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1893 delegate.get(), -1234, bounds, NULL));
1894 delegate->set_window(window.get());
1895
1896 delegate->Reset();
1897 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1,
1898 GetTime());
1899 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1,
1900 press.time_stamp() + base::TimeDelta::FromMilliseconds(200));
1901 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1,
1902 move.time_stamp() + base::TimeDelta::FromMilliseconds(50));
1903 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1904 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move);
1905 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
1906 delegate->Reset();
1907
1908 // Ack the press event.
1909 delegate->ReceivedAck();
1910 EXPECT_TRUE(delegate->tap_down());
1911 delegate->Reset();
1912
1913 // Ack the move event.
1914 delegate->ReceivedAck();
1915 EXPECT_TRUE(delegate->scroll_begin());
1916 delegate->Reset();
1917
1918 // Ack the release event. Although the release event has been processed, it
1919 // should still generate a scroll-end event.
1920 delegate->ReceivedAckPreventDefaulted();
1921 EXPECT_TRUE(delegate->scroll_end());
1922
1923 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), kTouchId2,
1924 GetTime());
1925 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(45, 85), kTouchId2,
1926 press2.time_stamp() + base::TimeDelta::FromMilliseconds(1000));
1927 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(45, 85), kTouchId2,
1928 move2.time_stamp() + base::TimeDelta::FromMilliseconds(14));
1929
1930 // Do a pinch.
1931 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1932 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move);
1933 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
1934 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
1935 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
1936 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release2);
1937
1938 // Ack the press and move events.
1939 delegate->Reset();
1940 delegate->ReceivedAck();
1941 EXPECT_TRUE(delegate->begin());
1942 EXPECT_TRUE(delegate->tap_down());
1943
1944 delegate->Reset();
1945 delegate->ReceivedAck();
1946 EXPECT_TRUE(delegate->scroll_begin());
1947
1948 delegate->Reset();
1949 delegate->ReceivedAck();
1950 EXPECT_TRUE(delegate->begin());
1951 EXPECT_FALSE(delegate->pinch_begin());
1952
1953 delegate->Reset();
1954 delegate->ReceivedAck();
1955 EXPECT_TRUE(delegate->pinch_begin());
1956
1957 // Ack the first release. Although the release is processed, it should still
1958 // generate a pinch-end event.
1959 delegate->Reset();
1960 delegate->ReceivedAckPreventDefaulted();
1961 EXPECT_TRUE(delegate->pinch_end());
1962 EXPECT_TRUE(delegate->end());
1963
1964 delegate->Reset();
1965 delegate->ReceivedAckPreventDefaulted();
1966 EXPECT_TRUE(delegate->scroll_end());
1967 EXPECT_TRUE(delegate->end());
1968 }
1969
1886 TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) { 1970 TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) {
1887 scoped_ptr<GestureEventConsumeDelegate> delegate( 1971 scoped_ptr<GestureEventConsumeDelegate> delegate(
1888 new GestureEventConsumeDelegate()); 1972 new GestureEventConsumeDelegate());
1889 TestGestureRecognizer* gesture_recognizer = 1973 TestGestureRecognizer* gesture_recognizer =
1890 new TestGestureRecognizer(root_window()); 1974 new TestGestureRecognizer(root_window());
1891 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1975 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1892 1976
1893 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1977 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1894 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL)); 1978 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL));
1895 EventGenerator generator(root_window()); 1979 EventGenerator generator(root_window());
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2733 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
2650 EXPECT_FALSE(delegate->tap()); 2734 EXPECT_FALSE(delegate->tap());
2651 EXPECT_FALSE(delegate->scroll_update()); 2735 EXPECT_FALSE(delegate->scroll_update());
2652 EXPECT_FALSE(delegate->pinch_update()); 2736 EXPECT_FALSE(delegate->pinch_update());
2653 2737
2654 delegate->Reset(); 2738 delegate->Reset();
2655 } 2739 }
2656 2740
2657 } // namespace test 2741 } // namespace test
2658 } // namespace aura 2742 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/base/gestures/gesture_sequence.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698