OLD | NEW |
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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
12 #include "ui/events/gestures/motion_event_aura.h" | 12 #include "ui/events/gestures/motion_event_impl.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 ui::TouchEvent TouchWithType(ui::EventType type, int id) { | 16 ui::TouchEvent TouchWithType(ui::EventType type, int id) { |
17 return ui::TouchEvent( | 17 return ui::TouchEvent( |
18 type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(0)); | 18 type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(0)); |
19 } | 19 } |
20 | 20 |
21 ui::TouchEvent TouchWithPosition(ui::EventType type, | 21 ui::TouchEvent TouchWithPosition(ui::EventType type, |
22 int id, | 22 int id, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 base::TimeTicks MsToTicks(int ms) { | 64 base::TimeTicks MsToTicks(int ms) { |
65 return base::TimeTicks() + base::TimeDelta::FromMilliseconds(ms); | 65 return base::TimeTicks() + base::TimeDelta::FromMilliseconds(ms); |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 namespace ui { | 70 namespace ui { |
71 | 71 |
72 TEST(MotionEventAuraTest, PointerCountAndIds) { | 72 TEST(MotionEventImplTest, PointerCountAndIds) { |
73 // Test that |PointerCount()| returns the correct number of pointers, and ids | 73 // Test that |PointerCount()| returns the correct number of pointers, and ids |
74 // are assigned correctly. | 74 // are assigned correctly. |
75 int ids[] = {4, 6, 1}; | 75 int ids[] = {4, 6, 1}; |
76 | 76 |
77 MotionEventAura event; | 77 MotionEventImpl event; |
78 EXPECT_EQ(0U, event.GetPointerCount()); | 78 EXPECT_EQ(0U, event.GetPointerCount()); |
79 | 79 |
80 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); | 80 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); |
81 event.OnTouch(press0); | 81 event.OnTouch(press0); |
82 EXPECT_EQ(1U, event.GetPointerCount()); | 82 EXPECT_EQ(1U, event.GetPointerCount()); |
83 | 83 |
84 EXPECT_EQ(ids[0], event.GetPointerId(0)); | 84 EXPECT_EQ(ids[0], event.GetPointerId(0)); |
85 | 85 |
86 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 86 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
87 event.OnTouch(press1); | 87 event.OnTouch(press1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_EQ(1U, event.GetPointerCount()); | 119 EXPECT_EQ(1U, event.GetPointerCount()); |
120 | 120 |
121 EXPECT_EQ(ids[2], event.GetPointerId(0)); | 121 EXPECT_EQ(ids[2], event.GetPointerId(0)); |
122 | 122 |
123 TouchEvent release2 = TouchWithType(ET_TOUCH_RELEASED, ids[2]); | 123 TouchEvent release2 = TouchWithType(ET_TOUCH_RELEASED, ids[2]); |
124 event.OnTouch(release2); | 124 event.OnTouch(release2); |
125 event.CleanupRemovedTouchPoints(release2); | 125 event.CleanupRemovedTouchPoints(release2); |
126 EXPECT_EQ(0U, event.GetPointerCount()); | 126 EXPECT_EQ(0U, event.GetPointerCount()); |
127 } | 127 } |
128 | 128 |
129 TEST(MotionEventAuraTest, GetActionIndexAfterRemoval) { | 129 TEST(MotionEventImplTest, GetActionIndexAfterRemoval) { |
130 // Test that |GetActionIndex()| returns the correct index when points have | 130 // Test that |GetActionIndex()| returns the correct index when points have |
131 // been removed. | 131 // been removed. |
132 int ids[] = {4, 6, 9}; | 132 int ids[] = {4, 6, 9}; |
133 | 133 |
134 MotionEventAura event; | 134 MotionEventImpl event; |
135 EXPECT_EQ(0U, event.GetPointerCount()); | 135 EXPECT_EQ(0U, event.GetPointerCount()); |
136 | 136 |
137 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); | 137 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); |
138 event.OnTouch(press0); | 138 event.OnTouch(press0); |
139 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 139 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
140 event.OnTouch(press1); | 140 event.OnTouch(press1); |
141 TouchEvent press2 = TouchWithType(ET_TOUCH_PRESSED, ids[2]); | 141 TouchEvent press2 = TouchWithType(ET_TOUCH_PRESSED, ids[2]); |
142 event.OnTouch(press2); | 142 event.OnTouch(press2); |
143 EXPECT_EQ(3U, event.GetPointerCount()); | 143 EXPECT_EQ(3U, event.GetPointerCount()); |
144 | 144 |
145 TouchEvent release1 = TouchWithType(ET_TOUCH_RELEASED, ids[1]); | 145 TouchEvent release1 = TouchWithType(ET_TOUCH_RELEASED, ids[1]); |
146 event.OnTouch(release1); | 146 event.OnTouch(release1); |
147 event.CleanupRemovedTouchPoints(release1); | 147 event.CleanupRemovedTouchPoints(release1); |
148 EXPECT_EQ(1, event.GetActionIndex()); | 148 EXPECT_EQ(1, event.GetActionIndex()); |
149 EXPECT_EQ(2U, event.GetPointerCount()); | 149 EXPECT_EQ(2U, event.GetPointerCount()); |
150 | 150 |
151 TouchEvent release2 = TouchWithType(ET_TOUCH_RELEASED, ids[0]); | 151 TouchEvent release2 = TouchWithType(ET_TOUCH_RELEASED, ids[0]); |
152 event.OnTouch(release2); | 152 event.OnTouch(release2); |
153 event.CleanupRemovedTouchPoints(release2); | 153 event.CleanupRemovedTouchPoints(release2); |
154 EXPECT_EQ(0, event.GetActionIndex()); | 154 EXPECT_EQ(0, event.GetActionIndex()); |
155 EXPECT_EQ(1U, event.GetPointerCount()); | 155 EXPECT_EQ(1U, event.GetPointerCount()); |
156 | 156 |
157 TouchEvent release0 = TouchWithType(ET_TOUCH_RELEASED, ids[2]); | 157 TouchEvent release0 = TouchWithType(ET_TOUCH_RELEASED, ids[2]); |
158 event.OnTouch(release0); | 158 event.OnTouch(release0); |
159 event.CleanupRemovedTouchPoints(release0); | 159 event.CleanupRemovedTouchPoints(release0); |
160 EXPECT_EQ(0U, event.GetPointerCount()); | 160 EXPECT_EQ(0U, event.GetPointerCount()); |
161 } | 161 } |
162 | 162 |
163 TEST(MotionEventAuraTest, PointerLocations) { | 163 TEST(MotionEventImplTest, PointerLocations) { |
164 // Test that location information is stored correctly. | 164 // Test that location information is stored correctly. |
165 MotionEventAura event; | 165 MotionEventImpl event; |
166 | 166 |
167 const float kRawOffsetX = 11.1f; | 167 const float kRawOffsetX = 11.1f; |
168 const float kRawOffsetY = 13.3f; | 168 const float kRawOffsetY = 13.3f; |
169 | 169 |
170 int ids[] = {15, 13}; | 170 int ids[] = {15, 13}; |
171 float x; | 171 float x; |
172 float y; | 172 float y; |
173 float raw_x; | 173 float raw_x; |
174 float raw_y; | 174 float raw_y; |
175 | 175 |
(...skipping 21 matching lines...) Expand all Loading... |
197 | 197 |
198 EXPECT_EQ(2U, event.GetPointerCount()); | 198 EXPECT_EQ(2U, event.GetPointerCount()); |
199 EXPECT_FLOAT_EQ(x, event.GetX(1)); | 199 EXPECT_FLOAT_EQ(x, event.GetX(1)); |
200 EXPECT_FLOAT_EQ(y, event.GetY(1)); | 200 EXPECT_FLOAT_EQ(y, event.GetY(1)); |
201 EXPECT_FLOAT_EQ(raw_x, event.GetRawX(1)); | 201 EXPECT_FLOAT_EQ(raw_x, event.GetRawX(1)); |
202 EXPECT_FLOAT_EQ(raw_y, event.GetRawY(1)); | 202 EXPECT_FLOAT_EQ(raw_y, event.GetRawY(1)); |
203 | 203 |
204 // Test cloning of pointer location information. | 204 // Test cloning of pointer location information. |
205 scoped_ptr<MotionEvent> clone = event.Clone(); | 205 scoped_ptr<MotionEvent> clone = event.Clone(); |
206 { | 206 { |
207 const MotionEventAura* raw_clone_aura = | 207 const MotionEventImpl* raw_clone_aura = |
208 static_cast<MotionEventAura*>(clone.get()); | 208 static_cast<MotionEventImpl*>(clone.get()); |
209 EXPECT_EQ(2U, raw_clone_aura->GetPointerCount()); | 209 EXPECT_EQ(2U, raw_clone_aura->GetPointerCount()); |
210 EXPECT_FLOAT_EQ(x, raw_clone_aura->GetX(1)); | 210 EXPECT_FLOAT_EQ(x, raw_clone_aura->GetX(1)); |
211 EXPECT_FLOAT_EQ(y, raw_clone_aura->GetY(1)); | 211 EXPECT_FLOAT_EQ(y, raw_clone_aura->GetY(1)); |
212 EXPECT_FLOAT_EQ(raw_x, raw_clone_aura->GetRawX(1)); | 212 EXPECT_FLOAT_EQ(raw_x, raw_clone_aura->GetRawX(1)); |
213 EXPECT_FLOAT_EQ(raw_y, raw_clone_aura->GetRawY(1)); | 213 EXPECT_FLOAT_EQ(raw_y, raw_clone_aura->GetRawY(1)); |
214 } | 214 } |
215 | 215 |
216 x = 27.9f; | 216 x = 27.9f; |
217 y = 22.3f; | 217 y = 22.3f; |
218 raw_x = x + kRawOffsetX; | 218 raw_x = x + kRawOffsetX; |
(...skipping 14 matching lines...) Expand all Loading... |
233 TouchEvent move0 = | 233 TouchEvent move0 = |
234 TouchWithPosition(ET_TOUCH_MOVED, ids[0], x, y, raw_x, raw_y); | 234 TouchWithPosition(ET_TOUCH_MOVED, ids[0], x, y, raw_x, raw_y); |
235 event.OnTouch(move0); | 235 event.OnTouch(move0); |
236 | 236 |
237 EXPECT_FLOAT_EQ(x, event.GetX(0)); | 237 EXPECT_FLOAT_EQ(x, event.GetX(0)); |
238 EXPECT_FLOAT_EQ(y, event.GetY(0)); | 238 EXPECT_FLOAT_EQ(y, event.GetY(0)); |
239 EXPECT_FLOAT_EQ(raw_x, event.GetRawX(0)); | 239 EXPECT_FLOAT_EQ(raw_x, event.GetRawX(0)); |
240 EXPECT_FLOAT_EQ(raw_y, event.GetRawY(0)); | 240 EXPECT_FLOAT_EQ(raw_y, event.GetRawY(0)); |
241 } | 241 } |
242 | 242 |
243 TEST(MotionEventAuraTest, TapParams) { | 243 TEST(MotionEventImplTest, TapParams) { |
244 // Test that touch params are stored correctly. | 244 // Test that touch params are stored correctly. |
245 MotionEventAura event; | 245 MotionEventImpl event; |
246 | 246 |
247 int ids[] = {15, 13}; | 247 int ids[] = {15, 13}; |
248 | 248 |
249 float radius_x; | 249 float radius_x; |
250 float radius_y; | 250 float radius_y; |
251 float rotation_angle; | 251 float rotation_angle; |
252 float pressure; | 252 float pressure; |
253 | 253 |
254 radius_x = 123.45f; | 254 radius_x = 123.45f; |
255 radius_y = 67.89f; | 255 radius_y = 67.89f; |
(...skipping 19 matching lines...) Expand all Loading... |
275 | 275 |
276 EXPECT_EQ(2U, event.GetPointerCount()); | 276 EXPECT_EQ(2U, event.GetPointerCount()); |
277 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); | 277 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); |
278 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); | 278 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); |
279 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); | 279 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); |
280 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); | 280 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); |
281 | 281 |
282 // Test cloning of tap params | 282 // Test cloning of tap params |
283 scoped_ptr<MotionEvent> clone = event.Clone(); | 283 scoped_ptr<MotionEvent> clone = event.Clone(); |
284 { | 284 { |
285 const MotionEventAura* raw_clone_aura = | 285 const MotionEventImpl* raw_clone_aura = |
286 static_cast<MotionEventAura*>(clone.get()); | 286 static_cast<MotionEventImpl*>(clone.get()); |
287 EXPECT_EQ(2U, raw_clone_aura->GetPointerCount()); | 287 EXPECT_EQ(2U, raw_clone_aura->GetPointerCount()); |
288 EXPECT_FLOAT_EQ(radius_y, raw_clone_aura->GetTouchMajor(1) / 2); | 288 EXPECT_FLOAT_EQ(radius_y, raw_clone_aura->GetTouchMajor(1) / 2); |
289 EXPECT_FLOAT_EQ(radius_x, raw_clone_aura->GetTouchMinor(1) / 2); | 289 EXPECT_FLOAT_EQ(radius_x, raw_clone_aura->GetTouchMinor(1) / 2); |
290 EXPECT_FLOAT_EQ( | 290 EXPECT_FLOAT_EQ( |
291 rotation_angle, raw_clone_aura->GetOrientation(1) * 180 / M_PI); | 291 rotation_angle, raw_clone_aura->GetOrientation(1) * 180 / M_PI); |
292 EXPECT_FLOAT_EQ(pressure, raw_clone_aura->GetPressure(1)); | 292 EXPECT_FLOAT_EQ(pressure, raw_clone_aura->GetPressure(1)); |
293 } | 293 } |
294 | 294 |
295 radius_x = 76.98f; | 295 radius_x = 76.98f; |
296 radius_y = 321.54f; | 296 radius_y = 321.54f; |
297 rotation_angle = 64.f; | 297 rotation_angle = 64.f; |
298 pressure = 0.654f; | 298 pressure = 0.654f; |
299 TouchEvent move1 = TouchWithTapParams( | 299 TouchEvent move1 = TouchWithTapParams( |
300 ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure); | 300 ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure); |
301 event.OnTouch(move1); | 301 event.OnTouch(move1); |
302 | 302 |
303 EXPECT_EQ(2U, event.GetPointerCount()); | 303 EXPECT_EQ(2U, event.GetPointerCount()); |
304 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); | 304 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); |
305 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); | 305 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); |
306 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); | 306 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); |
307 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); | 307 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); |
308 } | 308 } |
309 | 309 |
310 TEST(MotionEventAuraTest, Timestamps) { | 310 TEST(MotionEventImplTest, Timestamps) { |
311 // Test that timestamp information is stored and converted correctly. | 311 // Test that timestamp information is stored and converted correctly. |
312 MotionEventAura event; | 312 MotionEventImpl event; |
313 int ids[] = {7, 13}; | 313 int ids[] = {7, 13}; |
314 int times_in_ms[] = {59436, 60263, 82175}; | 314 int times_in_ms[] = {59436, 60263, 82175}; |
315 | 315 |
316 TouchEvent press0 = TouchWithTime( | 316 TouchEvent press0 = TouchWithTime( |
317 ui::ET_TOUCH_PRESSED, ids[0], times_in_ms[0]); | 317 ui::ET_TOUCH_PRESSED, ids[0], times_in_ms[0]); |
318 event.OnTouch(press0); | 318 event.OnTouch(press0); |
319 EXPECT_EQ(MsToTicks(times_in_ms[0]), event.GetEventTime()); | 319 EXPECT_EQ(MsToTicks(times_in_ms[0]), event.GetEventTime()); |
320 | 320 |
321 TouchEvent press1 = TouchWithTime( | 321 TouchEvent press1 = TouchWithTime( |
322 ui::ET_TOUCH_PRESSED, ids[1], times_in_ms[1]); | 322 ui::ET_TOUCH_PRESSED, ids[1], times_in_ms[1]); |
323 event.OnTouch(press1); | 323 event.OnTouch(press1); |
324 EXPECT_EQ(MsToTicks(times_in_ms[1]), event.GetEventTime()); | 324 EXPECT_EQ(MsToTicks(times_in_ms[1]), event.GetEventTime()); |
325 | 325 |
326 TouchEvent move0 = TouchWithTime( | 326 TouchEvent move0 = TouchWithTime( |
327 ui::ET_TOUCH_MOVED, ids[0], times_in_ms[2]); | 327 ui::ET_TOUCH_MOVED, ids[0], times_in_ms[2]); |
328 event.OnTouch(move0); | 328 event.OnTouch(move0); |
329 EXPECT_EQ(MsToTicks(times_in_ms[2]), event.GetEventTime()); | 329 EXPECT_EQ(MsToTicks(times_in_ms[2]), event.GetEventTime()); |
330 | 330 |
331 // Test cloning of timestamp information. | 331 // Test cloning of timestamp information. |
332 scoped_ptr<MotionEvent> clone = event.Clone(); | 332 scoped_ptr<MotionEvent> clone = event.Clone(); |
333 EXPECT_EQ(MsToTicks(times_in_ms[2]), clone->GetEventTime()); | 333 EXPECT_EQ(MsToTicks(times_in_ms[2]), clone->GetEventTime()); |
334 } | 334 } |
335 | 335 |
336 TEST(MotionEventAuraTest, CachedAction) { | 336 TEST(MotionEventImplTest, CachedAction) { |
337 // Test that the cached action and cached action index are correct. | 337 // Test that the cached action and cached action index are correct. |
338 int ids[] = {4, 6}; | 338 int ids[] = {4, 6}; |
339 MotionEventAura event; | 339 MotionEventImpl event; |
340 | 340 |
341 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); | 341 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); |
342 event.OnTouch(press0); | 342 event.OnTouch(press0); |
343 EXPECT_EQ(MotionEvent::ACTION_DOWN, event.GetAction()); | 343 EXPECT_EQ(MotionEvent::ACTION_DOWN, event.GetAction()); |
344 EXPECT_EQ(1U, event.GetPointerCount()); | 344 EXPECT_EQ(1U, event.GetPointerCount()); |
345 | 345 |
346 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 346 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
347 event.OnTouch(press1); | 347 event.OnTouch(press1); |
348 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); | 348 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); |
349 EXPECT_EQ(1, event.GetActionIndex()); | 349 EXPECT_EQ(1, event.GetActionIndex()); |
(...skipping 17 matching lines...) Expand all Loading... |
367 EXPECT_EQ(1U, event.GetPointerCount()); | 367 EXPECT_EQ(1U, event.GetPointerCount()); |
368 | 368 |
369 TouchEvent release1 = TouchWithType(ET_TOUCH_RELEASED, ids[1]); | 369 TouchEvent release1 = TouchWithType(ET_TOUCH_RELEASED, ids[1]); |
370 event.OnTouch(release1); | 370 event.OnTouch(release1); |
371 EXPECT_EQ(MotionEvent::ACTION_UP, event.GetAction()); | 371 EXPECT_EQ(MotionEvent::ACTION_UP, event.GetAction()); |
372 EXPECT_EQ(1U, event.GetPointerCount()); | 372 EXPECT_EQ(1U, event.GetPointerCount()); |
373 event.CleanupRemovedTouchPoints(release1); | 373 event.CleanupRemovedTouchPoints(release1); |
374 EXPECT_EQ(0U, event.GetPointerCount()); | 374 EXPECT_EQ(0U, event.GetPointerCount()); |
375 } | 375 } |
376 | 376 |
377 TEST(MotionEventAuraTest, Cancel) { | 377 TEST(MotionEventImplTest, Cancel) { |
378 int ids[] = {4, 6}; | 378 int ids[] = {4, 6}; |
379 MotionEventAura event; | 379 MotionEventImpl event; |
380 | 380 |
381 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); | 381 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); |
382 event.OnTouch(press0); | 382 event.OnTouch(press0); |
383 EXPECT_EQ(MotionEvent::ACTION_DOWN, event.GetAction()); | 383 EXPECT_EQ(MotionEvent::ACTION_DOWN, event.GetAction()); |
384 EXPECT_EQ(1U, event.GetPointerCount()); | 384 EXPECT_EQ(1U, event.GetPointerCount()); |
385 | 385 |
386 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 386 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
387 event.OnTouch(press1); | 387 event.OnTouch(press1); |
388 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); | 388 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); |
389 EXPECT_EQ(1, event.GetActionIndex()); | 389 EXPECT_EQ(1, event.GetActionIndex()); |
390 EXPECT_EQ(2U, event.GetPointerCount()); | 390 EXPECT_EQ(2U, event.GetPointerCount()); |
391 | 391 |
392 scoped_ptr<MotionEvent> cancel = event.Cancel(); | 392 scoped_ptr<MotionEvent> cancel = event.Cancel(); |
393 EXPECT_EQ(MotionEvent::ACTION_CANCEL, cancel->GetAction()); | 393 EXPECT_EQ(MotionEvent::ACTION_CANCEL, cancel->GetAction()); |
394 EXPECT_EQ(2U, static_cast<MotionEventAura*>(cancel.get())->GetPointerCount()); | 394 EXPECT_EQ(2U, static_cast<MotionEventImpl*>(cancel.get())->GetPointerCount()); |
395 } | 395 } |
396 | 396 |
397 TEST(MotionEventAuraTest, ToolType) { | 397 TEST(MotionEventImplTest, ToolType) { |
398 MotionEventAura event; | 398 MotionEventImpl event; |
399 | 399 |
400 // For now, all pointers have an unknown tool type. | 400 // For now, all pointers have an unknown tool type. |
401 // TODO(jdduke): Expand this test when ui::TouchEvent identifies the source | 401 // TODO(jdduke): Expand this test when ui::TouchEvent identifies the source |
402 // touch type, crbug.com/404128. | 402 // touch type, crbug.com/404128. |
403 event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, 7)); | 403 event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, 7)); |
404 ASSERT_EQ(1U, event.GetPointerCount()); | 404 ASSERT_EQ(1U, event.GetPointerCount()); |
405 EXPECT_EQ(MotionEvent::TOOL_TYPE_UNKNOWN, event.GetToolType(0)); | 405 EXPECT_EQ(MotionEvent::TOOL_TYPE_UNKNOWN, event.GetToolType(0)); |
406 } | 406 } |
407 | 407 |
408 TEST(MotionEventAuraTest, Flags) { | 408 TEST(MotionEventImplTest, Flags) { |
409 int ids[] = {7, 11}; | 409 int ids[] = {7, 11}; |
410 MotionEventAura event; | 410 MotionEventImpl event; |
411 | 411 |
412 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); | 412 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); |
413 press0.set_flags(EF_CONTROL_DOWN); | 413 press0.set_flags(EF_CONTROL_DOWN); |
414 event.OnTouch(press0); | 414 event.OnTouch(press0); |
415 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); | 415 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); |
416 | 416 |
417 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 417 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
418 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN); | 418 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN); |
419 event.OnTouch(press1); | 419 event.OnTouch(press1); |
420 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN, event.GetFlags()); | 420 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN, event.GetFlags()); |
421 } | 421 } |
422 | 422 |
423 } // namespace ui | 423 } // namespace ui |
OLD | NEW |