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" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 EXPECT_FLOAT_EQ(rotation_angle, clone->GetOrientation(1) * 180 / M_PI); | 292 EXPECT_FLOAT_EQ(rotation_angle, clone->GetOrientation(1) * 180 / M_PI); |
293 EXPECT_FLOAT_EQ(pressure, clone->GetPressure(1)); | 293 EXPECT_FLOAT_EQ(pressure, clone->GetPressure(1)); |
294 } | 294 } |
295 | 295 |
296 radius_x = 76.98f; | 296 radius_x = 76.98f; |
297 radius_y = 321.54f; | 297 radius_y = 321.54f; |
298 rotation_angle = 64.f; | 298 rotation_angle = 64.f; |
299 pressure = 0.654f; | 299 pressure = 0.654f; |
300 TouchEvent move1 = TouchWithTapParams( | 300 TouchEvent move1 = TouchWithTapParams( |
301 ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure); | 301 ET_TOUCH_MOVED, ids[1], radius_x, radius_y, rotation_angle, pressure); |
302 move1.set_location(gfx::Point(20, 21)); | |
jdduke (slow)
2015/01/06 16:49:54
Can we get an additional test or 2 (or 3) covering
tdresser
2015/01/07 17:01:15
Done.
| |
302 event.OnTouch(move1); | 303 event.OnTouch(move1); |
303 | 304 |
304 EXPECT_EQ(2U, event.GetPointerCount()); | 305 EXPECT_EQ(2U, event.GetPointerCount()); |
305 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); | 306 EXPECT_FLOAT_EQ(radius_y, event.GetTouchMajor(1) / 2); |
306 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); | 307 EXPECT_FLOAT_EQ(radius_x, event.GetTouchMinor(1) / 2); |
307 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); | 308 EXPECT_FLOAT_EQ(rotation_angle, event.GetOrientation(1) * 180 / M_PI); |
308 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); | 309 EXPECT_FLOAT_EQ(pressure, event.GetPressure(1)); |
309 } | 310 } |
310 | 311 |
311 TEST(MotionEventAuraTest, Timestamps) { | 312 TEST(MotionEventAuraTest, Timestamps) { |
312 // Test that timestamp information is stored and converted correctly. | 313 // Test that timestamp information is stored and converted correctly. |
313 MotionEventAura event; | 314 MotionEventAura event; |
314 int ids[] = {7, 13}; | 315 int ids[] = {7, 13}; |
315 int times_in_ms[] = {59436, 60263, 82175}; | 316 int times_in_ms[] = {59436, 60263, 82175}; |
316 | 317 |
317 TouchEvent press0 = TouchWithTime( | 318 TouchEvent press0 = TouchWithTime( |
318 ui::ET_TOUCH_PRESSED, ids[0], times_in_ms[0]); | 319 ui::ET_TOUCH_PRESSED, ids[0], times_in_ms[0]); |
319 event.OnTouch(press0); | 320 event.OnTouch(press0); |
320 EXPECT_EQ(MsToTicks(times_in_ms[0]), event.GetEventTime()); | 321 EXPECT_EQ(MsToTicks(times_in_ms[0]), event.GetEventTime()); |
321 | 322 |
322 TouchEvent press1 = TouchWithTime( | 323 TouchEvent press1 = TouchWithTime( |
323 ui::ET_TOUCH_PRESSED, ids[1], times_in_ms[1]); | 324 ui::ET_TOUCH_PRESSED, ids[1], times_in_ms[1]); |
324 event.OnTouch(press1); | 325 event.OnTouch(press1); |
325 EXPECT_EQ(MsToTicks(times_in_ms[1]), event.GetEventTime()); | 326 EXPECT_EQ(MsToTicks(times_in_ms[1]), event.GetEventTime()); |
326 | 327 |
327 TouchEvent move0 = TouchWithTime( | 328 TouchEvent move0 = TouchWithTime( |
328 ui::ET_TOUCH_MOVED, ids[0], times_in_ms[2]); | 329 ui::ET_TOUCH_MOVED, ids[0], times_in_ms[2]); |
330 move0.set_location(gfx::PointF(12, 21)); | |
329 event.OnTouch(move0); | 331 event.OnTouch(move0); |
330 EXPECT_EQ(MsToTicks(times_in_ms[2]), event.GetEventTime()); | 332 EXPECT_EQ(MsToTicks(times_in_ms[2]), event.GetEventTime()); |
331 | 333 |
332 // Test cloning of timestamp information. | 334 // Test cloning of timestamp information. |
333 scoped_ptr<MotionEvent> clone = event.Clone(); | 335 scoped_ptr<MotionEvent> clone = event.Clone(); |
334 EXPECT_EQ(MsToTicks(times_in_ms[2]), clone->GetEventTime()); | 336 EXPECT_EQ(MsToTicks(times_in_ms[2]), clone->GetEventTime()); |
335 } | 337 } |
336 | 338 |
337 TEST(MotionEventAuraTest, CachedAction) { | 339 TEST(MotionEventAuraTest, CachedAction) { |
338 // Test that the cached action and cached action index are correct. | 340 // Test that the cached action and cached action index are correct. |
(...skipping 10 matching lines...) Expand all Loading... | |
349 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); | 351 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); |
350 EXPECT_EQ(1, event.GetActionIndex()); | 352 EXPECT_EQ(1, event.GetActionIndex()); |
351 EXPECT_EQ(2U, event.GetPointerCount()); | 353 EXPECT_EQ(2U, event.GetPointerCount()); |
352 | 354 |
353 // Test cloning of CachedAction information. | 355 // Test cloning of CachedAction information. |
354 scoped_ptr<MotionEvent> clone = event.Clone(); | 356 scoped_ptr<MotionEvent> clone = event.Clone(); |
355 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, clone->GetAction()); | 357 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, clone->GetAction()); |
356 EXPECT_EQ(1, clone->GetActionIndex()); | 358 EXPECT_EQ(1, clone->GetActionIndex()); |
357 | 359 |
358 TouchEvent move0 = TouchWithType(ET_TOUCH_MOVED, ids[0]); | 360 TouchEvent move0 = TouchWithType(ET_TOUCH_MOVED, ids[0]); |
361 move0.set_location(gfx::PointF(10, 12)); | |
359 event.OnTouch(move0); | 362 event.OnTouch(move0); |
360 EXPECT_EQ(MotionEvent::ACTION_MOVE, event.GetAction()); | 363 EXPECT_EQ(MotionEvent::ACTION_MOVE, event.GetAction()); |
361 EXPECT_EQ(2U, event.GetPointerCount()); | 364 EXPECT_EQ(2U, event.GetPointerCount()); |
362 | 365 |
363 TouchEvent release0 = TouchWithType(ET_TOUCH_RELEASED, ids[0]); | 366 TouchEvent release0 = TouchWithType(ET_TOUCH_RELEASED, ids[0]); |
364 event.OnTouch(release0); | 367 event.OnTouch(release0); |
365 EXPECT_EQ(MotionEvent::ACTION_POINTER_UP, event.GetAction()); | 368 EXPECT_EQ(MotionEvent::ACTION_POINTER_UP, event.GetAction()); |
366 EXPECT_EQ(2U, event.GetPointerCount()); | 369 EXPECT_EQ(2U, event.GetPointerCount()); |
367 event.CleanupRemovedTouchPoints(release0); | 370 event.CleanupRemovedTouchPoints(release0); |
368 EXPECT_EQ(1U, event.GetPointerCount()); | 371 EXPECT_EQ(1U, event.GetPointerCount()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 event.OnTouch(press0); | 418 event.OnTouch(press0); |
416 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); | 419 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); |
417 | 420 |
418 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 421 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
419 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN); | 422 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN); |
420 event.OnTouch(press1); | 423 event.OnTouch(press1); |
421 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN, event.GetFlags()); | 424 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN, event.GetFlags()); |
422 } | 425 } |
423 | 426 |
424 } // namespace ui | 427 } // namespace ui |
OLD | NEW |