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

Side by Side Diff: ui/events/gestures/gesture_provider_aura_unittest.cc

Issue 679633005: Expose native, desktop and mobile gesture detection defaults (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/events/event_utils.h" 8 #include "ui/events/event_utils.h"
9 #include "ui/events/gestures/gesture_provider_aura.h" 9 #include "ui/events/gestures/gesture_provider_aura.h"
10 10
(...skipping 17 matching lines...) Expand all
28 GestureProviderAura* provider() { return provider_.get(); } 28 GestureProviderAura* provider() { return provider_.get(); }
29 29
30 private: 30 private:
31 scoped_ptr<GestureProviderAura> provider_; 31 scoped_ptr<GestureProviderAura> provider_;
32 base::MessageLoopForUI message_loop_; 32 base::MessageLoopForUI message_loop_;
33 }; 33 };
34 34
35 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) { 35 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) {
36 base::TimeDelta time = ui::EventTimeForNow(); 36 base::TimeDelta time = ui::EventTimeForNow();
37 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time); 37 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time);
38 EXPECT_TRUE(provider()->OnTouchEvent(press1)); 38 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
39 39
40 time += base::TimeDelta::FromMilliseconds(10); 40 time += base::TimeDelta::FromMilliseconds(10);
41 TouchEvent press2(ET_TOUCH_PRESSED, gfx::PointF(30, 40), 0, time); 41 TouchEvent press2(ET_TOUCH_PRESSED, gfx::PointF(30, 40), 0, time);
42 // Redundant press with same id is ignored. 42 // Redundant press with same id is ignored.
43 EXPECT_FALSE(provider()->OnTouchEvent(press2)); 43 EXPECT_FALSE(provider()->OnTouchEvent(&press2));
44 } 44 }
45 45
46 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) { 46 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) {
47 base::TimeDelta time = ui::EventTimeForNow(); 47 base::TimeDelta time = ui::EventTimeForNow();
48 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time); 48 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time);
49 EXPECT_TRUE(provider()->OnTouchEvent(press1)); 49 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
50 50
51 time += base::TimeDelta::FromMilliseconds(10); 51 time += base::TimeDelta::FromMilliseconds(10);
52 TouchEvent release1(ET_TOUCH_RELEASED, gfx::PointF(30, 40), 0, time); 52 TouchEvent release1(ET_TOUCH_RELEASED, gfx::PointF(30, 40), 0, time);
53 EXPECT_TRUE(provider()->OnTouchEvent(release1)); 53 EXPECT_TRUE(provider()->OnTouchEvent(&release1));
54 54
55 time += base::TimeDelta::FromMilliseconds(10); 55 time += base::TimeDelta::FromMilliseconds(10);
56 TouchEvent release2(ET_TOUCH_RELEASED, gfx::PointF(30, 45), 0, time); 56 TouchEvent release2(ET_TOUCH_RELEASED, gfx::PointF(30, 45), 0, time);
57 EXPECT_FALSE(provider()->OnTouchEvent(release1)); 57 EXPECT_FALSE(provider()->OnTouchEvent(&release1));
58 58
59 time += base::TimeDelta::FromMilliseconds(10); 59 time += base::TimeDelta::FromMilliseconds(10);
60 TouchEvent move1(ET_TOUCH_MOVED, gfx::PointF(70, 75), 0, time); 60 TouchEvent move1(ET_TOUCH_MOVED, gfx::PointF(70, 75), 0, time);
61 EXPECT_FALSE(provider()->OnTouchEvent(move1)); 61 EXPECT_FALSE(provider()->OnTouchEvent(&move1));
62 } 62 }
63 63
64 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) { 64 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) {
65 const float kRadiusX = 20.f; 65 const float kRadiusX = 20.f;
66 const float kRadiusY = 30.f; 66 const float kRadiusY = 30.f;
67 const float kAngle = 0.321f; 67 const float kAngle = 0.321f;
68 const float kForce = 40.f; 68 const float kForce = 40.f;
69 const int kTouchId0 = 5; 69 const int kTouchId0 = 5;
70 const int kTouchId1 = 3; 70 const int kTouchId1 = 3;
71 71
72 base::TimeDelta time = ui::EventTimeForNow(); 72 base::TimeDelta time = ui::EventTimeForNow();
73 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time); 73 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time);
74 EXPECT_TRUE(provider()->OnTouchEvent(press0_1)); 74 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1));
75 75
76 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time); 76 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time);
77 EXPECT_TRUE(provider()->OnTouchEvent(press1_1)); 77 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1));
78 78
79 time += base::TimeDelta::FromMilliseconds(10); 79 time += base::TimeDelta::FromMilliseconds(10);
80 TouchEvent move0_1(ET_TOUCH_MOVED, 80 TouchEvent move0_1(ET_TOUCH_MOVED,
81 gfx::PointF(10, 10), 81 gfx::PointF(10, 10),
82 0, 82 0,
83 kTouchId0, 83 kTouchId0,
84 time, 84 time,
85 kRadiusX, 85 kRadiusX,
86 kRadiusY, 86 kRadiusY,
87 kAngle, 87 kAngle,
88 kForce); 88 kForce);
89 EXPECT_TRUE(provider()->OnTouchEvent(move0_1)); 89 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1));
90 90
91 TouchEvent move1_1(ET_TOUCH_MOVED, 91 TouchEvent move1_1(ET_TOUCH_MOVED,
92 gfx::PointF(100, 200), 92 gfx::PointF(100, 200),
93 0, 93 0,
94 kTouchId1, 94 kTouchId1,
95 time, 95 time,
96 kRadiusX, 96 kRadiusX,
97 kRadiusY, 97 kRadiusY,
98 kAngle, 98 kAngle,
99 kForce); 99 kForce);
100 EXPECT_TRUE(provider()->OnTouchEvent(move1_1)); 100 EXPECT_TRUE(provider()->OnTouchEvent(&move1_1));
101 101
102 time += base::TimeDelta::FromMilliseconds(10); 102 time += base::TimeDelta::FromMilliseconds(10);
103 TouchEvent move0_2(ET_TOUCH_MOVED, 103 TouchEvent move0_2(ET_TOUCH_MOVED,
104 gfx::PointF(10, 10), 104 gfx::PointF(10, 10),
105 0, 105 0,
106 kTouchId0, 106 kTouchId0,
107 time, 107 time,
108 kRadiusX, 108 kRadiusX,
109 kRadiusY, 109 kRadiusY,
110 kAngle, 110 kAngle,
111 kForce); 111 kForce);
112 // Nothing has changed, so ignore the move. 112 // Nothing has changed, so ignore the move.
113 EXPECT_FALSE(provider()->OnTouchEvent(move0_2)); 113 EXPECT_FALSE(provider()->OnTouchEvent(&move0_2));
114 114
115 TouchEvent move1_2(ET_TOUCH_MOVED, 115 TouchEvent move1_2(ET_TOUCH_MOVED,
116 gfx::PointF(100, 200), 116 gfx::PointF(100, 200),
117 0, 117 0,
118 kTouchId1, 118 kTouchId1,
119 time, 119 time,
120 kRadiusX, 120 kRadiusX,
121 kRadiusY, 121 kRadiusY,
122 kAngle, 122 kAngle,
123 kForce); 123 kForce);
124 // Nothing has changed, so ignore the move. 124 // Nothing has changed, so ignore the move.
125 EXPECT_FALSE(provider()->OnTouchEvent(move1_2)); 125 EXPECT_FALSE(provider()->OnTouchEvent(&move1_2));
126 126
127 time += base::TimeDelta::FromMilliseconds(10); 127 time += base::TimeDelta::FromMilliseconds(10);
128 TouchEvent move0_3(ET_TOUCH_MOVED, 128 TouchEvent move0_3(ET_TOUCH_MOVED,
129 gfx::PointF(70, 75.1f), 129 gfx::PointF(70, 75.1f),
130 0, 130 0,
131 kTouchId0, 131 kTouchId0,
132 time, 132 time,
133 kRadiusX, 133 kRadiusX,
134 kRadiusY, 134 kRadiusY,
135 kAngle, 135 kAngle,
136 kForce); 136 kForce);
137 // Position has changed, so don't ignore the move. 137 // Position has changed, so don't ignore the move.
138 EXPECT_TRUE(provider()->OnTouchEvent(move0_3)); 138 EXPECT_TRUE(provider()->OnTouchEvent(&move0_3));
139 139
140 time += base::TimeDelta::FromMilliseconds(10); 140 time += base::TimeDelta::FromMilliseconds(10);
141 TouchEvent move0_4(ET_TOUCH_MOVED, 141 TouchEvent move0_4(ET_TOUCH_MOVED,
142 gfx::PointF(70, 75.1f), 142 gfx::PointF(70, 75.1f),
143 0, 143 0,
144 kTouchId0, 144 kTouchId0,
145 time, 145 time,
146 kRadiusX, 146 kRadiusX,
147 kRadiusY + 1, 147 kRadiusY + 1,
148 kAngle, 148 kAngle,
149 kForce); 149 kForce);
150 } 150 }
151 151
152 // TODO(jdduke): Test whether event marked as scroll trigger.
153
152 } // namespace ui 154 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698