| 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/gesture_detection/gesture_event_data_packet.h" | 8 #include "ui/events/gesture_detection/gesture_event_data_packet.h" |
| 9 #include "ui/events/test/motion_event_test_utils.h" | 9 #include "ui/events/test/motion_event_test_utils.h" |
| 10 | 10 |
| 11 using ui::test::MockMotionEvent; | 11 using ui::test::MockMotionEvent; |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const float kTouchX = 13.7f; | 16 const float kTouchX = 13.7f; |
| 17 const float kTouchY = 14.2f; | 17 const float kTouchY = 14.2f; |
| 18 const uint32_t uniqueTouchEventId = 1234U; |
| 18 | 19 |
| 19 GestureEventData CreateGesture(EventType type) { | 20 GestureEventData CreateGesture(EventType type) { |
| 20 return GestureEventData(GestureEventDetails(type), | 21 return GestureEventData(GestureEventDetails(type), |
| 21 0, | 22 0, |
| 22 MotionEvent::TOOL_TYPE_FINGER, | 23 MotionEvent::TOOL_TYPE_FINGER, |
| 23 base::TimeTicks(), | 24 base::TimeTicks(), |
| 24 kTouchX, | 25 kTouchX, |
| 25 kTouchY, | 26 kTouchY, |
| 26 kTouchX + 5.f, | 27 kTouchX + 5.f, |
| 27 kTouchY + 10.f, | 28 kTouchY + 10.f, |
| 28 1, | 29 1, |
| 29 gfx::RectF(kTouchX - 1.f, kTouchY - 1.f, 2.f, 2.f), | 30 gfx::RectF(kTouchX - 1.f, kTouchY - 1.f, 2.f, 2.f), |
| 30 EF_NONE); | 31 EF_NONE, |
| 32 uniqueTouchEventId); |
| 31 } | 33 } |
| 32 | 34 |
| 33 } // namespace | 35 } // namespace |
| 34 | 36 |
| 35 bool GestureEquals(const GestureEventData& lhs, const GestureEventData& rhs) { | 37 bool GestureEquals(const GestureEventData& lhs, const GestureEventData& rhs) { |
| 36 return lhs.type() == rhs.type() && | 38 return lhs.type() == rhs.type() && |
| 37 lhs.motion_event_id == rhs.motion_event_id && | 39 lhs.motion_event_id == rhs.motion_event_id && |
| 38 lhs.primary_tool_type == rhs.primary_tool_type && | 40 lhs.primary_tool_type == rhs.primary_tool_type && |
| 39 lhs.time == rhs.time && lhs.x == rhs.x && lhs.y == rhs.y && | 41 lhs.time == rhs.time && lhs.x == rhs.x && lhs.y == rhs.y && |
| 40 lhs.raw_x == rhs.raw_x && lhs.raw_y == rhs.raw_y; | 42 lhs.raw_x == rhs.raw_x && lhs.raw_y == rhs.raw_y && |
| 43 lhs.unique_touch_event_id == rhs.unique_touch_event_id; |
| 41 } | 44 } |
| 42 | 45 |
| 43 bool PacketEquals(const GestureEventDataPacket& lhs, | 46 bool PacketEquals(const GestureEventDataPacket& lhs, |
| 44 const GestureEventDataPacket& rhs) { | 47 const GestureEventDataPacket& rhs) { |
| 45 if (lhs.timestamp() != rhs.timestamp() || | 48 if (lhs.timestamp() != rhs.timestamp() || |
| 46 lhs.gesture_count() != rhs.gesture_count() || | 49 lhs.gesture_count() != rhs.gesture_count() || |
| 47 lhs.timestamp() != rhs.timestamp() || | 50 lhs.timestamp() != rhs.timestamp() || |
| 48 lhs.gesture_source() != rhs.gesture_source() || | 51 lhs.gesture_source() != rhs.gesture_source() || |
| 49 lhs.touch_location() != rhs.touch_location() || | 52 lhs.touch_location() != rhs.touch_location() || |
| 50 lhs.raw_touch_location() != rhs.raw_touch_location()) | 53 lhs.raw_touch_location() != rhs.raw_touch_location()) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 129 |
| 127 GestureEventData gesture = CreateGesture(ET_GESTURE_TAP); | 130 GestureEventData gesture = CreateGesture(ET_GESTURE_TAP); |
| 128 packet = GestureEventDataPacket::FromTouchTimeout(gesture); | 131 packet = GestureEventDataPacket::FromTouchTimeout(gesture); |
| 129 EXPECT_EQ(GestureEventDataPacket::TOUCH_TIMEOUT, packet.gesture_source()); | 132 EXPECT_EQ(GestureEventDataPacket::TOUCH_TIMEOUT, packet.gesture_source()); |
| 130 EXPECT_EQ(1U, packet.gesture_count()); | 133 EXPECT_EQ(1U, packet.gesture_count()); |
| 131 EXPECT_EQ(base::TimeTicks(), packet.timestamp()); | 134 EXPECT_EQ(base::TimeTicks(), packet.timestamp()); |
| 132 EXPECT_EQ(gfx::PointF(gesture.x, gesture.y), packet.touch_location()); | 135 EXPECT_EQ(gfx::PointF(gesture.x, gesture.y), packet.touch_location()); |
| 133 } | 136 } |
| 134 | 137 |
| 135 } // namespace ui | 138 } // namespace ui |
| OLD | NEW |