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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-event: browsertests Created 5 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 14 matching lines...) Expand all
25 25
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::Point(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::Point(30, 40), 0, time);
40 // TODO(tdresser): this redundant press with same id should be 40 // TODO(tdresser): this redundant press with same id should be
41 // ignored; however, there is at least one case where we need to 41 // ignored; however, there is at least one case where we need to
42 // allow a touch press from a currently used touch id. See 42 // allow a touch press from a currently used touch id. See
43 // crbug.com/373125 for details. 43 // crbug.com/373125 for details.
44 EXPECT_TRUE(provider()->OnTouchEvent(&press2)); 44 EXPECT_TRUE(provider()->OnTouchEvent(&press2));
45 } 45 }
46 46
47 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) { 47 TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) {
48 base::TimeDelta time = ui::EventTimeForNow(); 48 base::TimeDelta time = ui::EventTimeForNow();
49 TouchEvent press1(ET_TOUCH_PRESSED, gfx::PointF(10, 10), 0, time); 49 TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time);
50 EXPECT_TRUE(provider()->OnTouchEvent(&press1)); 50 EXPECT_TRUE(provider()->OnTouchEvent(&press1));
51 51
52 time += base::TimeDelta::FromMilliseconds(10); 52 time += base::TimeDelta::FromMilliseconds(10);
53 TouchEvent release1(ET_TOUCH_RELEASED, gfx::PointF(30, 40), 0, time); 53 TouchEvent release1(ET_TOUCH_RELEASED, gfx::Point(30, 40), 0, time);
54 EXPECT_TRUE(provider()->OnTouchEvent(&release1)); 54 EXPECT_TRUE(provider()->OnTouchEvent(&release1));
55 55
56 time += base::TimeDelta::FromMilliseconds(10); 56 time += base::TimeDelta::FromMilliseconds(10);
57 TouchEvent release2(ET_TOUCH_RELEASED, gfx::PointF(30, 45), 0, time); 57 TouchEvent release2(ET_TOUCH_RELEASED, gfx::Point(30, 45), 0, time);
58 EXPECT_FALSE(provider()->OnTouchEvent(&release1)); 58 EXPECT_FALSE(provider()->OnTouchEvent(&release1));
59 59
60 time += base::TimeDelta::FromMilliseconds(10); 60 time += base::TimeDelta::FromMilliseconds(10);
61 TouchEvent move1(ET_TOUCH_MOVED, gfx::PointF(70, 75), 0, time); 61 TouchEvent move1(ET_TOUCH_MOVED, gfx::Point(70, 75), 0, time);
62 EXPECT_FALSE(provider()->OnTouchEvent(&move1)); 62 EXPECT_FALSE(provider()->OnTouchEvent(&move1));
63 } 63 }
64 64
65 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) { 65 TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) {
66 const float kRadiusX = 20.f; 66 const float kRadiusX = 20.f;
67 const float kRadiusY = 30.f; 67 const float kRadiusY = 30.f;
68 const float kAngle = 0.321f; 68 const float kAngle = 0.321f;
69 const float kForce = 40.f; 69 const float kForce = 40.f;
70 const int kTouchId0 = 5; 70 const int kTouchId0 = 5;
71 const int kTouchId1 = 3; 71 const int kTouchId1 = 3;
72 72
73 base::TimeDelta time = ui::EventTimeForNow(); 73 base::TimeDelta time = ui::EventTimeForNow();
74 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time); 74 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::Point(9, 10), kTouchId0, time);
75 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1)); 75 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1));
76 76
77 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time); 77 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::Point(40, 40), kTouchId1, time);
78 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1)); 78 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1));
79 79
80 time += base::TimeDelta::FromMilliseconds(10); 80 time += base::TimeDelta::FromMilliseconds(10);
81 TouchEvent move0_1(ET_TOUCH_MOVED, 81 TouchEvent move0_1(ET_TOUCH_MOVED, gfx::Point(10, 10), 0, kTouchId0, time,
82 gfx::PointF(10, 10), 82 kRadiusX, kRadiusY, kAngle, kForce);
83 0,
84 kTouchId0,
85 time,
86 kRadiusX,
87 kRadiusY,
88 kAngle,
89 kForce);
90 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1)); 83 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1));
91 84
92 TouchEvent move1_1(ET_TOUCH_MOVED, 85 TouchEvent move1_1(ET_TOUCH_MOVED, gfx::Point(100, 200), 0, kTouchId1, time,
93 gfx::PointF(100, 200), 86 kRadiusX, kRadiusY, kAngle, kForce);
94 0,
95 kTouchId1,
96 time,
97 kRadiusX,
98 kRadiusY,
99 kAngle,
100 kForce);
101 EXPECT_TRUE(provider()->OnTouchEvent(&move1_1)); 87 EXPECT_TRUE(provider()->OnTouchEvent(&move1_1));
102 88
103 time += base::TimeDelta::FromMilliseconds(10); 89 time += base::TimeDelta::FromMilliseconds(10);
104 TouchEvent move0_2(ET_TOUCH_MOVED, 90 TouchEvent move0_2(ET_TOUCH_MOVED, gfx::Point(10, 10), 0, kTouchId0, time,
105 gfx::PointF(10, 10), 91 kRadiusX, kRadiusY, kAngle, kForce);
106 0,
107 kTouchId0,
108 time,
109 kRadiusX,
110 kRadiusY,
111 kAngle,
112 kForce);
113 // Nothing has changed, so ignore the move. 92 // Nothing has changed, so ignore the move.
114 EXPECT_FALSE(provider()->OnTouchEvent(&move0_2)); 93 EXPECT_FALSE(provider()->OnTouchEvent(&move0_2));
115 94
116 TouchEvent move1_2(ET_TOUCH_MOVED, 95 TouchEvent move1_2(ET_TOUCH_MOVED, gfx::Point(100, 200), 0, kTouchId1, time,
117 gfx::PointF(100, 200), 96 kRadiusX, kRadiusY, kAngle, kForce);
118 0,
119 kTouchId1,
120 time,
121 kRadiusX,
122 kRadiusY,
123 kAngle,
124 kForce);
125 // Nothing has changed, so ignore the move. 97 // Nothing has changed, so ignore the move.
126 EXPECT_FALSE(provider()->OnTouchEvent(&move1_2)); 98 EXPECT_FALSE(provider()->OnTouchEvent(&move1_2));
127 99
128 time += base::TimeDelta::FromMilliseconds(10); 100 time += base::TimeDelta::FromMilliseconds(10);
129 TouchEvent move0_3(ET_TOUCH_MOVED, 101 TouchEvent move0_3(ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId0, time, kRadiusX,
130 gfx::PointF(70, 75.1f), 102 kRadiusY, kAngle, kForce);
131 0, 103 move0_3.set_location_f(gfx::PointF(70, 75.1f));
132 kTouchId0, 104 move0_3.set_root_location_f(gfx::PointF(70, 75.1f));
133 time,
134 kRadiusX,
135 kRadiusY,
136 kAngle,
137 kForce);
138 // Position has changed, so don't ignore the move. 105 // Position has changed, so don't ignore the move.
139 EXPECT_TRUE(provider()->OnTouchEvent(&move0_3)); 106 EXPECT_TRUE(provider()->OnTouchEvent(&move0_3));
140 107
141 time += base::TimeDelta::FromMilliseconds(10); 108 time += base::TimeDelta::FromMilliseconds(10);
142 TouchEvent move0_4(ET_TOUCH_MOVED, 109 TouchEvent move0_4(ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId0, time, kRadiusX,
143 gfx::PointF(70, 75.1f), 110 kRadiusY + 1, kAngle, kForce);
144 0, 111 move0_4.set_location_f(gfx::PointF(70, 75.1f));
145 kTouchId0, 112 move0_4.set_root_location_f(gfx::PointF(70, 75.1f));
146 time,
147 kRadiusX,
148 kRadiusY + 1,
149 kAngle,
150 kForce);
151 } 113 }
152 114
153 // TODO(jdduke): Test whether event marked as scroll trigger. 115 // TODO(jdduke): Test whether event marked as scroll trigger.
154 116
155 } // namespace ui 117 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698