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

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

Issue 718153002: Indicate whether a touch event will cause scrolling (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
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.cc ('k') | ui/events/gestures/gesture_recognizer.h » ('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 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 15 matching lines...) Expand all
26 GestureProviderAura* provider() { return provider_.get(); } 26 GestureProviderAura* provider() { return provider_.get(); }
27 27
28 private: 28 private:
29 scoped_ptr<GestureProviderAura> provider_; 29 scoped_ptr<GestureProviderAura> provider_;
30 base::MessageLoopForUI message_loop_; 30 base::MessageLoopForUI message_loop_;
31 }; 31 };
32 32
33 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) { 33 TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) {
34 base::TimeDelta time = ui::EventTimeForNow(); 34 base::TimeDelta time = ui::EventTimeForNow();
35 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time); 35 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time);
36 EXPECT_TRUE(provider()->OnTouchEvent(press1)); 36 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
37 37
38 time += base::TimeDelta::FromMilliseconds(10); 38 time += base::TimeDelta::FromMilliseconds(10);
39 TouchEvent press2(ET_TOUCH_PRESSED, gfx::PointF(30, 40), 0, time); 39 TouchEvent press2(ET_TOUCH_PRESSED, gfx::PointF(30, 40), 0, time);
40 // Redundant press with same id is ignored. 40 // Redundant press with same id is ignored.
41 EXPECT_FALSE(provider()->OnTouchEvent(press2)); 41 EXPECT_FALSE(provider()->OnTouchEvent(&press2));
42 } 42 }
43 43
44 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) { 44 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) {
45 base::TimeDelta time = ui::EventTimeForNow(); 45 base::TimeDelta time = ui::EventTimeForNow();
46 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time); 46 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time);
47 EXPECT_TRUE(provider()->OnTouchEvent(press1)); 47 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
48 48
49 time += base::TimeDelta::FromMilliseconds(10); 49 time += base::TimeDelta::FromMilliseconds(10);
50 TouchEvent release1(ET_TOUCH_RELEASED, gfx::PointF(30, 40), 0, time); 50 TouchEvent release1(ET_TOUCH_RELEASED, gfx::PointF(30, 40), 0, time);
51 EXPECT_TRUE(provider()->OnTouchEvent(release1)); 51 EXPECT_TRUE(provider()->OnTouchEvent(&release1));
52 52
53 time += base::TimeDelta::FromMilliseconds(10); 53 time += base::TimeDelta::FromMilliseconds(10);
54 TouchEvent release2(ET_TOUCH_RELEASED, gfx::PointF(30, 45), 0, time); 54 TouchEvent release2(ET_TOUCH_RELEASED, gfx::PointF(30, 45), 0, time);
55 EXPECT_FALSE(provider()->OnTouchEvent(release1)); 55 EXPECT_FALSE(provider()->OnTouchEvent(&release1));
56 56
57 time += base::TimeDelta::FromMilliseconds(10); 57 time += base::TimeDelta::FromMilliseconds(10);
58 TouchEvent move1(ET_TOUCH_MOVED, gfx::PointF(70, 75), 0, time); 58 TouchEvent move1(ET_TOUCH_MOVED, gfx::PointF(70, 75), 0, time);
59 EXPECT_FALSE(provider()->OnTouchEvent(move1)); 59 EXPECT_FALSE(provider()->OnTouchEvent(&move1));
60 } 60 }
61 61
62 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) { 62 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) {
63 const float kRadiusX = 20.f; 63 const float kRadiusX = 20.f;
64 const float kRadiusY = 30.f; 64 const float kRadiusY = 30.f;
65 const float kAngle = 0.321f; 65 const float kAngle = 0.321f;
66 const float kForce = 40.f; 66 const float kForce = 40.f;
67 const int kTouchId0 = 5; 67 const int kTouchId0 = 5;
68 const int kTouchId1 = 3; 68 const int kTouchId1 = 3;
69 69
70 base::TimeDelta time = ui::EventTimeForNow(); 70 base::TimeDelta time = ui::EventTimeForNow();
71 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time); 71 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time);
72 EXPECT_TRUE(provider()->OnTouchEvent(press0_1)); 72 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1));
73 73
74 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time); 74 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time);
75 EXPECT_TRUE(provider()->OnTouchEvent(press1_1)); 75 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1));
76 76
77 time += base::TimeDelta::FromMilliseconds(10); 77 time += base::TimeDelta::FromMilliseconds(10);
78 TouchEvent move0_1(ET_TOUCH_MOVED, 78 TouchEvent move0_1(ET_TOUCH_MOVED,
79 gfx::PointF(10, 10), 79 gfx::PointF(10, 10),
80 0, 80 0,
81 kTouchId0, 81 kTouchId0,
82 time, 82 time,
83 kRadiusX, 83 kRadiusX,
84 kRadiusY, 84 kRadiusY,
85 kAngle, 85 kAngle,
86 kForce); 86 kForce);
87 EXPECT_TRUE(provider()->OnTouchEvent(move0_1)); 87 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1));
88 88
89 TouchEvent move1_1(ET_TOUCH_MOVED, 89 TouchEvent move1_1(ET_TOUCH_MOVED,
90 gfx::PointF(100, 200), 90 gfx::PointF(100, 200),
91 0, 91 0,
92 kTouchId1, 92 kTouchId1,
93 time, 93 time,
94 kRadiusX, 94 kRadiusX,
95 kRadiusY, 95 kRadiusY,
96 kAngle, 96 kAngle,
97 kForce); 97 kForce);
98 EXPECT_TRUE(provider()->OnTouchEvent(move1_1)); 98 EXPECT_TRUE(provider()->OnTouchEvent(&move1_1));
99 99
100 time += base::TimeDelta::FromMilliseconds(10); 100 time += base::TimeDelta::FromMilliseconds(10);
101 TouchEvent move0_2(ET_TOUCH_MOVED, 101 TouchEvent move0_2(ET_TOUCH_MOVED,
102 gfx::PointF(10, 10), 102 gfx::PointF(10, 10),
103 0, 103 0,
104 kTouchId0, 104 kTouchId0,
105 time, 105 time,
106 kRadiusX, 106 kRadiusX,
107 kRadiusY, 107 kRadiusY,
108 kAngle, 108 kAngle,
109 kForce); 109 kForce);
110 // Nothing has changed, so ignore the move. 110 // Nothing has changed, so ignore the move.
111 EXPECT_FALSE(provider()->OnTouchEvent(move0_2)); 111 EXPECT_FALSE(provider()->OnTouchEvent(&move0_2));
112 112
113 TouchEvent move1_2(ET_TOUCH_MOVED, 113 TouchEvent move1_2(ET_TOUCH_MOVED,
114 gfx::PointF(100, 200), 114 gfx::PointF(100, 200),
115 0, 115 0,
116 kTouchId1, 116 kTouchId1,
117 time, 117 time,
118 kRadiusX, 118 kRadiusX,
119 kRadiusY, 119 kRadiusY,
120 kAngle, 120 kAngle,
121 kForce); 121 kForce);
122 // Nothing has changed, so ignore the move. 122 // Nothing has changed, so ignore the move.
123 EXPECT_FALSE(provider()->OnTouchEvent(move1_2)); 123 EXPECT_FALSE(provider()->OnTouchEvent(&move1_2));
124 124
125 time += base::TimeDelta::FromMilliseconds(10); 125 time += base::TimeDelta::FromMilliseconds(10);
126 TouchEvent move0_3(ET_TOUCH_MOVED, 126 TouchEvent move0_3(ET_TOUCH_MOVED,
127 gfx::PointF(70, 75.1f), 127 gfx::PointF(70, 75.1f),
128 0, 128 0,
129 kTouchId0, 129 kTouchId0,
130 time, 130 time,
131 kRadiusX, 131 kRadiusX,
132 kRadiusY, 132 kRadiusY,
133 kAngle, 133 kAngle,
134 kForce); 134 kForce);
135 // Position has changed, so don't ignore the move. 135 // Position has changed, so don't ignore the move.
136 EXPECT_TRUE(provider()->OnTouchEvent(move0_3)); 136 EXPECT_TRUE(provider()->OnTouchEvent(&move0_3));
137 137
138 time += base::TimeDelta::FromMilliseconds(10); 138 time += base::TimeDelta::FromMilliseconds(10);
139 TouchEvent move0_4(ET_TOUCH_MOVED, 139 TouchEvent move0_4(ET_TOUCH_MOVED,
140 gfx::PointF(70, 75.1f), 140 gfx::PointF(70, 75.1f),
141 0, 141 0,
142 kTouchId0, 142 kTouchId0,
143 time, 143 time,
144 kRadiusX, 144 kRadiusX,
145 kRadiusY + 1, 145 kRadiusY + 1,
146 kAngle, 146 kAngle,
147 kForce); 147 kForce);
148 } 148 }
149 149
150 // TODO(jdduke): Test whether event marked as scroll trigger.
151
150 } // namespace ui 152 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.cc ('k') | ui/events/gestures/gesture_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698