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

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

Issue 613373004: Adopt ui::GestureConfiguration on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move all the methods to superclass Created 6 years, 1 month 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
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/test/aura_test_base.h" 12 #include "ui/aura/test/aura_test_base.h"
13 #include "ui/aura/test/test_window_delegate.h" 13 #include "ui/aura/test/test_window_delegate.h"
14 #include "ui/aura/test/test_windows.h" 14 #include "ui/aura/test/test_windows.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/aura/window_event_dispatcher.h" 16 #include "ui/aura/window_event_dispatcher.h"
17 #include "ui/base/hit_test.h" 17 #include "ui/base/hit_test.h"
18 #include "ui/base/ui_base_switches.h" 18 #include "ui/base/ui_base_switches.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/events/event_switches.h" 20 #include "ui/events/event_switches.h"
21 #include "ui/events/event_utils.h" 21 #include "ui/events/event_utils.h"
22 #include "ui/events/gestures/gesture_configuration.h" 22 #include "ui/events/gesture_detection/gesture_configuration.h"
23 #include "ui/events/gestures/gesture_recognizer_impl.h" 23 #include "ui/events/gestures/gesture_recognizer_impl.h"
24 #include "ui/events/gestures/gesture_types.h" 24 #include "ui/events/gestures/gesture_types.h"
25 #include "ui/events/test/event_generator.h" 25 #include "ui/events/test/event_generator.h"
26 #include "ui/events/test/events_test_utils.h" 26 #include "ui/events/test/events_test_utils.h"
27 #include "ui/gfx/point.h" 27 #include "ui/gfx/point.h"
28 #include "ui/gfx/rect.h" 28 #include "ui/gfx/rect.h"
29 29
30 #include <queue> 30 #include <queue>
31 31
32 namespace aura { 32 namespace aura {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 628
629 } // namespace 629 } // namespace
630 630
631 class GestureRecognizerTest : public AuraTestBase, 631 class GestureRecognizerTest : public AuraTestBase,
632 public ::testing::WithParamInterface<bool> { 632 public ::testing::WithParamInterface<bool> {
633 public: 633 public:
634 GestureRecognizerTest() {} 634 GestureRecognizerTest() {}
635 635
636 virtual void SetUp() override { 636 virtual void SetUp() override {
637 AuraTestBase::SetUp(); 637 AuraTestBase::SetUp();
638 ui::GestureConfiguration::set_show_press_delay_in_ms(2); 638 ui::GestureConfiguration::GetInstance()->set_show_press_delay_in_ms(2);
639 ui::GestureConfiguration::set_long_press_time_in_ms(3); 639 ui::GestureConfiguration::GetInstance()->set_long_press_time_in_ms(3);
640 } 640 }
641 641
642 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest); 642 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest);
643 }; 643 };
644 644
645 // Check that appropriate touch events generate tap gesture events. 645 // Check that appropriate touch events generate tap gesture events.
646 TEST_F(GestureRecognizerTest, GestureEventTap) { 646 TEST_F(GestureRecognizerTest, GestureEventTap) {
647 scoped_ptr<GestureEventConsumeDelegate> delegate( 647 scoped_ptr<GestureEventConsumeDelegate> delegate(
648 new GestureEventConsumeDelegate()); 648 new GestureEventConsumeDelegate());
649 TimedEvents tes; 649 TimedEvents tes;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 EXPECT_EQ(401, actual_point.x()); 931 EXPECT_EQ(401, actual_point.x());
932 EXPECT_EQ(149, actual_point.y()); 932 EXPECT_EQ(149, actual_point.y());
933 } 933 }
934 } 934 }
935 935
936 // Check that appropriate touch events generate scroll gesture events. 936 // Check that appropriate touch events generate scroll gesture events.
937 TEST_F(GestureRecognizerTest, GestureEventScroll) { 937 TEST_F(GestureRecognizerTest, GestureEventScroll) {
938 // We'll start by moving the touch point by (10.5, 10.5). We want 5 dips of 938 // We'll start by moving the touch point by (10.5, 10.5). We want 5 dips of
939 // that distance to be consumed by the slop, so we set the slop radius to 939 // that distance to be consumed by the slop, so we set the slop radius to
940 // sqrt(5 * 5 + 5 * 5). 940 // sqrt(5 * 5 + 5 * 5).
941 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( 941 ui::GestureConfiguration::GetInstance()
942 sqrt(5.f * 5 + 5 * 5)); 942 ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5));
943 scoped_ptr<GestureEventConsumeDelegate> delegate( 943 scoped_ptr<GestureEventConsumeDelegate> delegate(
944 new GestureEventConsumeDelegate()); 944 new GestureEventConsumeDelegate());
945 TimedEvents tes; 945 TimedEvents tes;
946 const int kWindowWidth = 123; 946 const int kWindowWidth = 123;
947 const int kWindowHeight = 45; 947 const int kWindowHeight = 45;
948 const int kTouchId = 5; 948 const int kTouchId = 5;
949 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 949 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
950 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 950 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
951 delegate.get(), -1234, bounds, root_window())); 951 delegate.get(), -1234, bounds, root_window()));
952 952
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 ui::ET_SCROLL_FLING_START, 1002 ui::ET_SCROLL_FLING_START,
1003 ui::ET_GESTURE_END); 1003 ui::ET_GESTURE_END);
1004 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 1004 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
1005 } 1005 }
1006 1006
1007 // Check that predicted scroll update positions are correct. 1007 // Check that predicted scroll update positions are correct.
1008 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) { 1008 TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
1009 // We'll start by moving the touch point by (5, 5). We want all of that 1009 // We'll start by moving the touch point by (5, 5). We want all of that
1010 // distance to be consumed by the slop, so we set the slop radius to 1010 // distance to be consumed by the slop, so we set the slop radius to
1011 // sqrt(5 * 5 + 5 * 5). 1011 // sqrt(5 * 5 + 5 * 5).
1012 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( 1012 ui::GestureConfiguration::GetInstance()
1013 sqrt(5.f * 5 + 5 * 5)); 1013 ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5));
1014 1014
1015 scoped_ptr<GestureEventConsumeDelegate> delegate( 1015 scoped_ptr<GestureEventConsumeDelegate> delegate(
1016 new GestureEventConsumeDelegate()); 1016 new GestureEventConsumeDelegate());
1017 TimedEvents tes; 1017 TimedEvents tes;
1018 const int kWindowWidth = 123; 1018 const int kWindowWidth = 123;
1019 const int kWindowHeight = 45; 1019 const int kWindowHeight = 45;
1020 const int kTouchId = 5; 1020 const int kTouchId = 5;
1021 gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight); 1021 gfx::Rect bounds(95, 195, kWindowWidth, kWindowHeight);
1022 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1022 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1023 delegate.get(), -1234, bounds, root_window())); 1023 delegate.get(), -1234, bounds, root_window()));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1074 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1075 kTouchId, 1075 kTouchId,
1076 tes.LeapForward(50)); 1076 tes.LeapForward(50));
1077 DispatchEventUsingWindowDispatcher(&release); 1077 DispatchEventUsingWindowDispatcher(&release);
1078 } 1078 }
1079 1079
1080 // Check that the bounding box during a scroll event is correct. 1080 // Check that the bounding box during a scroll event is correct.
1081 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { 1081 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
1082 TimedEvents tes; 1082 TimedEvents tes;
1083 for (float radius = 1; radius <= 10; ++radius) { 1083 for (float radius = 1; radius <= 10; ++radius) {
1084 ui::GestureConfiguration::set_default_radius(radius); 1084 ui::GestureConfiguration::GetInstance()->set_default_radius(radius);
1085 scoped_ptr<GestureEventConsumeDelegate> delegate( 1085 scoped_ptr<GestureEventConsumeDelegate> delegate(
1086 new GestureEventConsumeDelegate()); 1086 new GestureEventConsumeDelegate());
1087 const int kWindowWidth = 123; 1087 const int kWindowWidth = 123;
1088 const int kWindowHeight = 45; 1088 const int kWindowHeight = 45;
1089 const int kTouchId = 5; 1089 const int kTouchId = 5;
1090 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1090 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1091 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1091 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1092 delegate.get(), -1234, bounds, root_window())); 1092 delegate.get(), -1234, bounds, root_window()));
1093 1093
1094 const float kPositionX = 101; 1094 const float kPositionX = 101;
(...skipping 28 matching lines...) Expand all
1123 kPositionY + kScrollAmount), 1123 kPositionY + kScrollAmount),
1124 kTouchId, press.time_stamp() + 1124 kTouchId, press.time_stamp() +
1125 base::TimeDelta::FromMilliseconds(50)); 1125 base::TimeDelta::FromMilliseconds(50));
1126 DispatchEventUsingWindowDispatcher(&release); 1126 DispatchEventUsingWindowDispatcher(&release);
1127 EXPECT_EQ(gfx::RectF(kPositionX + kScrollAmount - radius, 1127 EXPECT_EQ(gfx::RectF(kPositionX + kScrollAmount - radius,
1128 kPositionY + kScrollAmount - radius, 1128 kPositionY + kScrollAmount - radius,
1129 radius * 2, 1129 radius * 2,
1130 radius * 2), 1130 radius * 2),
1131 delegate->bounding_box()); 1131 delegate->bounding_box());
1132 } 1132 }
1133 ui::GestureConfiguration::set_default_radius(0); 1133 ui::GestureConfiguration::GetInstance()->set_default_radius(0);
1134 } 1134 }
1135 1135
1136 // Check Scroll End Events report correct velocities 1136 // Check Scroll End Events report correct velocities
1137 // if the user was on a horizontal rail 1137 // if the user was on a horizontal rail
1138 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { 1138 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
1139 scoped_ptr<GestureEventConsumeDelegate> delegate( 1139 scoped_ptr<GestureEventConsumeDelegate> delegate(
1140 new GestureEventConsumeDelegate()); 1140 new GestureEventConsumeDelegate());
1141 TimedEvents tes; 1141 TimedEvents tes;
1142 const int kTouchId = 7; 1142 const int kTouchId = 7;
1143 gfx::Rect bounds(0, 0, 1000, 1000); 1143 gfx::Rect bounds(0, 0, 1000, 1000);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1232
1233 EXPECT_TRUE(delegate->fling()); 1233 EXPECT_TRUE(delegate->fling());
1234 EXPECT_FALSE(delegate->scroll_end()); 1234 EXPECT_FALSE(delegate->scroll_end());
1235 EXPECT_EQ(0, delegate->velocity_x()); 1235 EXPECT_EQ(0, delegate->velocity_x());
1236 EXPECT_GT(delegate->velocity_y(), 0); 1236 EXPECT_GT(delegate->velocity_y(), 0);
1237 } 1237 }
1238 1238
1239 // Check Scroll End Events report non-zero velocities if the user is not on a 1239 // Check Scroll End Events report non-zero velocities if the user is not on a
1240 // rail 1240 // rail
1241 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { 1241 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
1242 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(0); 1242 ui::GestureConfiguration::GetInstance()
1243 ->set_max_touch_move_in_pixels_for_click(0);
1243 scoped_ptr<GestureEventConsumeDelegate> delegate( 1244 scoped_ptr<GestureEventConsumeDelegate> delegate(
1244 new GestureEventConsumeDelegate()); 1245 new GestureEventConsumeDelegate());
1245 TimedEvents tes; 1246 TimedEvents tes;
1246 const int kTouchId = 7; 1247 const int kTouchId = 7;
1247 gfx::Rect bounds(0, 0, 1000, 1000); 1248 gfx::Rect bounds(0, 0, 1000, 1000);
1248 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1249 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1249 delegate.get(), -1234, bounds, root_window())); 1250 delegate.get(), -1234, bounds, root_window()));
1250 1251
1251 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1252 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1252 kTouchId, tes.Now()); 1253 kTouchId, tes.Now());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 delegate->Reset(); 1360 delegate->Reset();
1360 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 1361 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
1361 kTouchId, tes.LeapForward(10)); 1362 kTouchId, tes.LeapForward(10));
1362 DispatchEventUsingWindowDispatcher(&release1); 1363 DispatchEventUsingWindowDispatcher(&release1);
1363 EXPECT_FALSE(delegate->long_press()); 1364 EXPECT_FALSE(delegate->long_press());
1364 EXPECT_FALSE(delegate->tap_cancel()); 1365 EXPECT_FALSE(delegate->tap_cancel());
1365 } 1366 }
1366 1367
1367 // Check that appropriate touch events generate long tap events 1368 // Check that appropriate touch events generate long tap events
1368 TEST_F(GestureRecognizerTest, GestureEventLongTap) { 1369 TEST_F(GestureRecognizerTest, GestureEventLongTap) {
1369 ui::GestureConfiguration::set_max_touch_down_duration_for_click_in_ms(3); 1370 ui::GestureConfiguration::GetInstance()
1371 ->set_max_touch_down_duration_for_click_in_ms(3);
1370 scoped_ptr<GestureEventConsumeDelegate> delegate( 1372 scoped_ptr<GestureEventConsumeDelegate> delegate(
1371 new GestureEventConsumeDelegate()); 1373 new GestureEventConsumeDelegate());
1372 const int kWindowWidth = 123; 1374 const int kWindowWidth = 123;
1373 const int kWindowHeight = 45; 1375 const int kWindowHeight = 45;
1374 const int kTouchId = 2; 1376 const int kTouchId = 2;
1375 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1377 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1376 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1378 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1377 delegate.get(), -1234, bounds, root_window())); 1379 delegate.get(), -1234, bounds, root_window()));
1378 1380
1379 delegate->Reset(); 1381 delegate->Reset();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 // The rail should be broken 1567 // The rail should be broken
1566 EXPECT_TRUE(delegate->scroll_update()); 1568 EXPECT_TRUE(delegate->scroll_update());
1567 EXPECT_EQ(5, delegate->scroll_x()); 1569 EXPECT_EQ(5, delegate->scroll_x());
1568 EXPECT_EQ(5, delegate->scroll_y()); 1570 EXPECT_EQ(5, delegate->scroll_y());
1569 } 1571 }
1570 1572
1571 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { 1573 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
1572 // We'll start by moving the touch point by (5, 5). We want all of that 1574 // We'll start by moving the touch point by (5, 5). We want all of that
1573 // distance to be consumed by the slop, so we set the slop radius to 1575 // distance to be consumed by the slop, so we set the slop radius to
1574 // sqrt(5 * 5 + 5 * 5). 1576 // sqrt(5 * 5 + 5 * 5).
1575 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click( 1577 ui::GestureConfiguration::GetInstance()
1576 sqrt(5.f * 5 + 5 * 5)); 1578 ->set_max_touch_move_in_pixels_for_click(sqrt(5.f * 5 + 5 * 5));
1577 1579
1578 // First, tap. Then, do a scroll using the same touch-id. 1580 // First, tap. Then, do a scroll using the same touch-id.
1579 scoped_ptr<GestureEventConsumeDelegate> delegate( 1581 scoped_ptr<GestureEventConsumeDelegate> delegate(
1580 new GestureEventConsumeDelegate()); 1582 new GestureEventConsumeDelegate());
1581 TimedEvents tes; 1583 TimedEvents tes;
1582 const int kWindowWidth = 123; 1584 const int kWindowWidth = 123;
1583 const int kWindowHeight = 45; 1585 const int kWindowHeight = 45;
1584 const int kTouchId = 3; 1586 const int kTouchId = 3;
1585 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1587 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1586 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1588 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 EXPECT_FALSE(queued_delegate->scroll_begin()); 1827 EXPECT_FALSE(queued_delegate->scroll_begin());
1826 EXPECT_FALSE(queued_delegate->scroll_update()); 1828 EXPECT_FALSE(queued_delegate->scroll_update());
1827 EXPECT_FALSE(queued_delegate->scroll_end()); 1829 EXPECT_FALSE(queued_delegate->scroll_end());
1828 1830
1829 // Move the second touch-point enough so that it is considered a pinch. This 1831 // Move the second touch-point enough so that it is considered a pinch. This
1830 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures. 1832 // should generate both SCROLL_BEGIN and PINCH_BEGIN gestures.
1831 queued_delegate->Reset(); 1833 queued_delegate->Reset();
1832 delegate->Reset(); 1834 delegate->Reset();
1833 ui::TouchEvent move( 1835 ui::TouchEvent move(
1834 ui::ET_TOUCH_MOVED, 1836 ui::ET_TOUCH_MOVED,
1835 gfx::PointF( 1837 gfx::PointF(203 +
1836 203 + ui::GestureConfiguration::max_touch_move_in_pixels_for_click(), 1838 ui::GestureConfiguration::GetInstance()
1837 303), 1839 ->max_touch_move_in_pixels_for_click(),
1840 303),
1838 kTouchId2, 1841 kTouchId2,
1839 tes.Now()); 1842 tes.Now());
1840 DispatchEventUsingWindowDispatcher(&move); 1843 DispatchEventUsingWindowDispatcher(&move);
1841 EXPECT_FALSE(delegate->tap()); 1844 EXPECT_FALSE(delegate->tap());
1842 EXPECT_FALSE(delegate->tap_down()); 1845 EXPECT_FALSE(delegate->tap_down());
1843 EXPECT_FALSE(delegate->tap_cancel()); 1846 EXPECT_FALSE(delegate->tap_cancel());
1844 EXPECT_FALSE(delegate->begin()); 1847 EXPECT_FALSE(delegate->begin());
1845 EXPECT_FALSE(delegate->scroll_begin()); 1848 EXPECT_FALSE(delegate->scroll_begin());
1846 EXPECT_FALSE(delegate->scroll_update()); 1849 EXPECT_FALSE(delegate->scroll_update());
1847 EXPECT_FALSE(delegate->scroll_end()); 1850 EXPECT_FALSE(delegate->scroll_end());
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl(); 2131 ui::GestureRecognizer* gesture_recognizer = new ui::GestureRecognizerImpl();
2129 TimedEvents tes; 2132 TimedEvents tes;
2130 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer); 2133 ScopedGestureRecognizerSetter gr_setter(gesture_recognizer);
2131 2134
2132 ui::GestureConsumer* target; 2135 ui::GestureConsumer* target;
2133 const int kNumWindows = 4; 2136 const int kNumWindows = 4;
2134 2137
2135 scoped_ptr<GestureEventConsumeDelegate*[]> delegates( 2138 scoped_ptr<GestureEventConsumeDelegate*[]> delegates(
2136 new GestureEventConsumeDelegate*[kNumWindows]); 2139 new GestureEventConsumeDelegate*[kNumWindows]);
2137 2140
2138 ui::GestureConfiguration:: 2141 ui::GestureConfiguration::GetInstance()
2139 set_max_separation_for_gesture_touches_in_pixels(499); 2142 ->set_max_separation_for_gesture_touches_in_pixels(499);
2140 2143
2141 scoped_ptr<gfx::Rect[]> window_bounds(new gfx::Rect[kNumWindows]); 2144 scoped_ptr<gfx::Rect[]> window_bounds(new gfx::Rect[kNumWindows]);
2142 window_bounds[0] = gfx::Rect(0, 0, 1, 1); 2145 window_bounds[0] = gfx::Rect(0, 0, 1, 1);
2143 window_bounds[1] = gfx::Rect(500, 0, 1, 1); 2146 window_bounds[1] = gfx::Rect(500, 0, 1, 1);
2144 window_bounds[2] = gfx::Rect(0, 500, 1, 1); 2147 window_bounds[2] = gfx::Rect(0, 500, 1, 1);
2145 window_bounds[3] = gfx::Rect(500, 500, 1, 1); 2148 window_bounds[3] = gfx::Rect(500, 500, 1, 1);
2146 2149
2147 scoped_ptr<aura::Window*[]> windows(new aura::Window*[kNumWindows]); 2150 scoped_ptr<aura::Window*[]> windows(new aura::Window*[kNumWindows]);
2148 2151
2149 // Instantiate windows with |window_bounds| and touch each window at 2152 // Instantiate windows with |window_bounds| and touch each window at
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 EXPECT_FALSE(delegate->tap_cancel()); 3459 EXPECT_FALSE(delegate->tap_cancel());
3457 EXPECT_FALSE(delegate->scroll_update()); 3460 EXPECT_FALSE(delegate->scroll_update());
3458 EXPECT_FALSE(delegate->pinch_update()); 3461 EXPECT_FALSE(delegate->pinch_update());
3459 3462
3460 delegate->Reset(); 3463 delegate->Reset();
3461 } 3464 }
3462 3465
3463 // Checks that slow scrolls deliver the correct deltas. 3466 // Checks that slow scrolls deliver the correct deltas.
3464 // In particular, fix for http;//crbug.com/150573. 3467 // In particular, fix for http;//crbug.com/150573.
3465 TEST_F(GestureRecognizerTest, NoDriftInScroll) { 3468 TEST_F(GestureRecognizerTest, NoDriftInScroll) {
3466 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); 3469 ui::GestureConfiguration::GetInstance()
3470 ->set_max_touch_move_in_pixels_for_click(3);
3467 scoped_ptr<GestureEventConsumeDelegate> delegate( 3471 scoped_ptr<GestureEventConsumeDelegate> delegate(
3468 new GestureEventConsumeDelegate()); 3472 new GestureEventConsumeDelegate());
3469 const int kWindowWidth = 234; 3473 const int kWindowWidth = 234;
3470 const int kWindowHeight = 345; 3474 const int kWindowHeight = 345;
3471 const int kTouchId = 5; 3475 const int kTouchId = 5;
3472 TimedEvents tes; 3476 TimedEvents tes;
3473 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 3477 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
3474 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3478 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3475 delegate.get(), -1234, bounds, root_window())); 3479 delegate.get(), -1234, bounds, root_window()));
3476 3480
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3807 DispatchEventUsingWindowDispatcher(&move); 3811 DispatchEventUsingWindowDispatcher(&move);
3808 delegate->ReceivedAckPreventDefaulted(); 3812 delegate->ReceivedAckPreventDefaulted();
3809 3813
3810 // Wait until the timer runs out 3814 // Wait until the timer runs out
3811 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 3815 delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
3812 EXPECT_TRUE(delegate->long_press()); 3816 EXPECT_TRUE(delegate->long_press());
3813 } 3817 }
3814 3818
3815 // Tests that the deltas are correct when leaving the slop region very slowly. 3819 // Tests that the deltas are correct when leaving the slop region very slowly.
3816 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) { 3820 TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
3817 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); 3821 ui::GestureConfiguration::GetInstance()
3822 ->set_max_touch_move_in_pixels_for_click(3);
3818 scoped_ptr<GestureEventConsumeDelegate> delegate( 3823 scoped_ptr<GestureEventConsumeDelegate> delegate(
3819 new GestureEventConsumeDelegate()); 3824 new GestureEventConsumeDelegate());
3820 const int kWindowWidth = 234; 3825 const int kWindowWidth = 234;
3821 const int kWindowHeight = 345; 3826 const int kWindowHeight = 345;
3822 const int kTouchId = 5; 3827 const int kTouchId = 5;
3823 TimedEvents tes; 3828 TimedEvents tes;
3824 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 3829 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
3825 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 3830 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
3826 delegate.get(), -1234, bounds, root_window())); 3831 delegate.get(), -1234, bounds, root_window()));
3827 3832
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 EXPECT_TRUE(window != NULL); 4147 EXPECT_TRUE(window != NULL);
4143 4148
4144 // Wait until the timer runs out. 4149 // Wait until the timer runs out.
4145 delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); 4150 delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS);
4146 EXPECT_EQ(NULL, window); 4151 EXPECT_EQ(NULL, window);
4147 } 4152 }
4148 4153
4149 TEST_F(GestureRecognizerTest, GestureEventSmallPinchDisabled) { 4154 TEST_F(GestureRecognizerTest, GestureEventSmallPinchDisabled) {
4150 CommandLine::ForCurrentProcess()->AppendSwitch( 4155 CommandLine::ForCurrentProcess()->AppendSwitch(
4151 switches::kCompensateForUnstablePinchZoom); 4156 switches::kCompensateForUnstablePinchZoom);
4152 4157 ui::GestureConfiguration::GetInstance()->set_min_pinch_update_span_delta(
4158 ui::GestureConfiguration::GetInstance()
4159 ->min_pinch_update_distance_in_pixels());
4153 scoped_ptr<GestureEventConsumeDelegate> delegate( 4160 scoped_ptr<GestureEventConsumeDelegate> delegate(
4154 new GestureEventConsumeDelegate()); 4161 new GestureEventConsumeDelegate());
4155 TimedEvents tes; 4162 TimedEvents tes;
4156 const int kWindowWidth = 300; 4163 const int kWindowWidth = 300;
4157 const int kWindowHeight = 400; 4164 const int kWindowHeight = 400;
4158 const int kTouchId1 = 3; 4165 const int kTouchId1 = 3;
4159 const int kTouchId2 = 5; 4166 const int kTouchId2 = 5;
4160 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 4167 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
4161 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 4168 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
4162 delegate.get(), -1234, bounds, root_window())); 4169 delegate.get(), -1234, bounds, root_window()));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4306 ui::TouchEvent move3( 4313 ui::TouchEvent move3(
4307 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now()); 4314 ui::ET_TOUCH_MOVED, gfx::Point(65, 202), kTouchId1, tes.Now());
4308 DispatchEventUsingWindowDispatcher(&move3); 4315 DispatchEventUsingWindowDispatcher(&move3);
4309 4316
4310 delegate->ReceivedAck(); 4317 delegate->ReceivedAck();
4311 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE); 4318 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4312 } 4319 }
4313 4320
4314 } // namespace test 4321 } // namespace test
4315 } // namespace aura 4322 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698