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_aura.h" |
13 #include "ui/events/test/motion_event_test_utils.h" | 13 #include "ui/events/test/motion_event_test_utils.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 ui::TouchEvent TouchWithType(ui::EventType type, int id) { | 17 ui::TouchEvent TouchWithType(ui::EventType type, int id) { |
18 return ui::TouchEvent( | 18 return ui::TouchEvent( |
19 type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(0)); | 19 type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(0)); |
20 } | 20 } |
21 | 21 |
22 ui::TouchEvent TouchWithPosition(ui::EventType type, | 22 ui::TouchEvent TouchWithPosition(ui::EventType type, |
23 int id, | 23 int id, |
24 float x, | 24 float x, |
25 float y, | 25 float y, |
26 float raw_x, | 26 float raw_x, |
27 float raw_y) { | 27 float raw_y) { |
28 ui::TouchEvent event(type, | 28 ui::TouchEvent event( |
29 gfx::PointF(x, y), | 29 type, gfx::PointF(x, y), 0, id, base::TimeDelta::FromMilliseconds(0), 0, |
30 0, | 30 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_TOUCH)); |
31 id, | |
32 base::TimeDelta::FromMilliseconds(0), | |
33 0, | |
34 0, | |
35 0, | |
36 0); | |
37 event.set_root_location(gfx::PointF(raw_x, raw_y)); | 31 event.set_root_location(gfx::PointF(raw_x, raw_y)); |
38 return event; | 32 return event; |
39 } | 33 } |
40 | 34 |
41 ui::TouchEvent TouchWithTapParams(ui::EventType type, | 35 ui::TouchEvent TouchWithTapParams(ui::EventType type, |
42 int id, | 36 int id, |
43 float radius_x, | 37 float radius_x, |
44 float radius_y, | 38 float radius_y, |
45 float rotation_angle, | 39 float rotation_angle, |
46 float pressure) { | 40 float pressure) { |
47 ui::TouchEvent event(type, | 41 ui::TouchEvent event( |
48 gfx::PointF(1, 1), | 42 type, gfx::PointF(1, 1), 0, id, base::TimeDelta::FromMilliseconds(0), |
49 0, | 43 rotation_angle, |
50 id, | 44 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, |
51 base::TimeDelta::FromMilliseconds(0), | 45 radius_x, radius_y, pressure, |
52 radius_x, | 46 /* tilt_x */ 0.0f, |
53 radius_y, | 47 /* tilt_y */ 0.0f)); |
54 rotation_angle, | |
55 pressure); | |
56 event.set_root_location(gfx::PointF(1, 1)); | 48 event.set_root_location(gfx::PointF(1, 1)); |
57 return event; | 49 return event; |
58 } | 50 } |
59 | 51 |
60 ui::TouchEvent TouchWithTime(ui::EventType type, int id, int ms) { | 52 ui::TouchEvent TouchWithTime(ui::EventType type, int id, int ms) { |
61 return ui::TouchEvent( | 53 return ui::TouchEvent( |
62 type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(ms)); | 54 type, gfx::PointF(0, 0), id, base::TimeDelta::FromMilliseconds(ms)); |
63 } | 55 } |
64 | 56 |
65 base::TimeTicks MsToTicks(int ms) { | 57 base::TimeTicks MsToTicks(int ms) { |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 EXPECT_EQ(event.GetUniqueEventId(), press0.unique_event_id()); | 497 EXPECT_EQ(event.GetUniqueEventId(), press0.unique_event_id()); |
506 | 498 |
507 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, 6); | 499 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, 6); |
508 EXPECT_TRUE(event.OnTouch(press1)); | 500 EXPECT_TRUE(event.OnTouch(press1)); |
509 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); | 501 EXPECT_EQ(MotionEvent::ACTION_POINTER_DOWN, event.GetAction()); |
510 EXPECT_EQ(2U, event.GetPointerCount()); | 502 EXPECT_EQ(2U, event.GetPointerCount()); |
511 EXPECT_EQ(event.GetUniqueEventId(), press1.unique_event_id()); | 503 EXPECT_EQ(event.GetUniqueEventId(), press1.unique_event_id()); |
512 } | 504 } |
513 | 505 |
514 } // namespace ui | 506 } // namespace ui |
OLD | NEW |