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

Side by Side Diff: ui/events/gesture_detection/gesture_event_data_packet_unittest.cc

Issue 468043003: Ignore min/max gesture bounds for mouse or stylus-derived gestures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GestureTextSelectorTest Created 6 years, 4 months 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/events/gesture_detection/gesture_event_data_packet.h" 7 #include "ui/events/gesture_detection/gesture_event_data_packet.h"
8 #include "ui/events/test/mock_motion_event.h" 8 #include "ui/events/test/mock_motion_event.h"
9 9
10 using ui::test::MockMotionEvent; 10 using ui::test::MockMotionEvent;
11 11
12 namespace ui { 12 namespace ui {
13 namespace { 13 namespace {
14 14
15 const float kTouchX = 13.7f; 15 const float kTouchX = 13.7f;
16 const float kTouchY = 14.2f; 16 const float kTouchY = 14.2f;
17 17
18 GestureEventData CreateGesture(EventType type) { 18 GestureEventData CreateGesture(EventType type) {
19 return GestureEventData(GestureEventDetails(type, 0, 0), 19 return GestureEventData(GestureEventDetails(type, 0, 0),
20 0, 20 0,
21 MotionEvent::TOOL_TYPE_FINGER,
21 base::TimeTicks(), 22 base::TimeTicks(),
22 kTouchX, 23 kTouchX,
23 kTouchY, 24 kTouchY,
24 kTouchX + 5.f, 25 kTouchX + 5.f,
25 kTouchY + 10.f, 26 kTouchY + 10.f,
26 1, 27 1,
27 gfx::RectF(kTouchX - 1.f, kTouchY - 1.f, 2.f, 2.f)); 28 gfx::RectF(kTouchX - 1.f, kTouchY - 1.f, 2.f, 2.f));
28 } 29 }
29 30
30 } // namespace 31 } // namespace
31 32
32 bool GestureEquals(const GestureEventData& lhs, const GestureEventData& rhs) { 33 bool GestureEquals(const GestureEventData& lhs, const GestureEventData& rhs) {
33 return lhs.type() == rhs.type() && 34 return lhs.type() == rhs.type() &&
34 lhs.motion_event_id == rhs.motion_event_id && lhs.time == rhs.time && 35 lhs.motion_event_id == rhs.motion_event_id &&
35 lhs.x == rhs.x && lhs.y == rhs.y && lhs.raw_x == rhs.raw_x && 36 lhs.primary_tool_type == rhs.primary_tool_type &&
36 lhs.raw_y == rhs.raw_y; 37 lhs.time == rhs.time && lhs.x == rhs.x && lhs.y == rhs.y &&
38 lhs.raw_x == rhs.raw_x && lhs.raw_y == rhs.raw_y;
37 } 39 }
38 40
39 bool PacketEquals(const GestureEventDataPacket& lhs, 41 bool PacketEquals(const GestureEventDataPacket& lhs,
40 const GestureEventDataPacket& rhs) { 42 const GestureEventDataPacket& rhs) {
41 if (lhs.timestamp() != rhs.timestamp() || 43 if (lhs.timestamp() != rhs.timestamp() ||
42 lhs.gesture_count() != rhs.gesture_count() || 44 lhs.gesture_count() != rhs.gesture_count() ||
43 lhs.timestamp() != rhs.timestamp() || 45 lhs.timestamp() != rhs.timestamp() ||
44 lhs.gesture_source() != rhs.gesture_source() || 46 lhs.gesture_source() != rhs.gesture_source() ||
45 lhs.touch_location() != rhs.touch_location() || 47 lhs.touch_location() != rhs.touch_location() ||
46 lhs.raw_touch_location() != rhs.raw_touch_location()) 48 lhs.raw_touch_location() != rhs.raw_touch_location())
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 124
123 GestureEventData gesture = CreateGesture(ET_GESTURE_TAP); 125 GestureEventData gesture = CreateGesture(ET_GESTURE_TAP);
124 packet = GestureEventDataPacket::FromTouchTimeout(gesture); 126 packet = GestureEventDataPacket::FromTouchTimeout(gesture);
125 EXPECT_EQ(GestureEventDataPacket::TOUCH_TIMEOUT, packet.gesture_source()); 127 EXPECT_EQ(GestureEventDataPacket::TOUCH_TIMEOUT, packet.gesture_source());
126 EXPECT_EQ(1U, packet.gesture_count()); 128 EXPECT_EQ(1U, packet.gesture_count());
127 EXPECT_EQ(base::TimeTicks(), packet.timestamp()); 129 EXPECT_EQ(base::TimeTicks(), packet.timestamp());
128 EXPECT_EQ(gfx::PointF(gesture.x, gesture.y), packet.touch_location()); 130 EXPECT_EQ(gfx::PointF(gesture.x, gesture.y), packet.touch_location());
129 } 131 }
130 132
131 } // namespace ui 133 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gesture_detection/gesture_event_data.cc ('k') | ui/events/gesture_detection/gesture_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698