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

Side by Side Diff: content/common/input/web_input_event_traits_unittest.cc

Issue 1218663006: Use new WebTouchPoint field names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 "content/common/input/web_input_event_traits.h" 5 #include "content/common/input/web_input_event_traits.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/web/WebInputEvent.h" 10 #include "third_party/WebKit/public/web/WebInputEvent.h"
11 11
12 using blink::WebGestureEvent; 12 using blink::WebGestureEvent;
13 using blink::WebInputEvent; 13 using blink::WebInputEvent;
14 using blink::WebKeyboardEvent; 14 using blink::WebKeyboardEvent;
15 using blink::WebMouseEvent; 15 using blink::WebMouseEvent;
16 using blink::WebMouseWheelEvent; 16 using blink::WebMouseWheelEvent;
17 using blink::WebTouchEvent; 17 using blink::WebTouchEvent;
18 using blink::WebTouchPoint; 18 using blink::WebTouchPoint;
19 using std::numeric_limits; 19 using std::numeric_limits;
20 20
21 namespace content { 21 namespace content {
22 namespace { 22 namespace {
23 23
24 class WebInputEventTraitsTest : public testing::Test { 24 class WebInputEventTraitsTest : public testing::Test {
25 protected: 25 protected:
26 static WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) { 26 static WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) {
27 WebTouchPoint touch; 27 WebTouchPoint touch;
28 touch.state = state; 28 touch.state = state;
29 touch.id = id; 29 touch.pointerId = id;
30 return touch; 30 return touch;
31 } 31 }
32 32
33 static WebTouchEvent CreateTouch(WebInputEvent::Type type) { 33 static WebTouchEvent CreateTouch(WebInputEvent::Type type) {
34 return CreateTouch(type, 1); 34 return CreateTouch(type, 1);
35 } 35 }
36 36
37 static WebTouchEvent CreateTouch(WebInputEvent::Type type, 37 static WebTouchEvent CreateTouch(WebInputEvent::Type type,
38 unsigned touch_count) { 38 unsigned touch_count) {
39 WebTouchEvent event; 39 WebTouchEvent event;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 // Touches of different types won't coalesce. 74 // Touches of different types won't coalesce.
75 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 75 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1));
76 76
77 // Touch moves with idential touch lengths and touch ids should coalesce. 77 // Touch moves with idential touch lengths and touch ids should coalesce.
78 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch1, touch1)); 78 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch1, touch1));
79 79
80 // Touch moves with different touch ids should not coalesce. 80 // Touch moves with different touch ids should not coalesce.
81 touch0 = CreateTouch(WebInputEvent::TouchMove); 81 touch0 = CreateTouch(WebInputEvent::TouchMove);
82 touch1 = CreateTouch(WebInputEvent::TouchMove); 82 touch1 = CreateTouch(WebInputEvent::TouchMove);
83 touch0.touches[0].id = 7; 83 touch0.touches[0].pointerId = 7;
84 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 84 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1));
85 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 85 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
86 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 86 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
87 touch0.touches[0].id = 1; 87 touch0.touches[0].pointerId = 1;
88 touch1.touches[0].id = 0; 88 touch1.touches[0].pointerId = 0;
89 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 89 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1));
90 90
91 // Touch moves with different touch lengths should not coalesce. 91 // Touch moves with different touch lengths should not coalesce.
92 touch0 = CreateTouch(WebInputEvent::TouchMove, 1); 92 touch0 = CreateTouch(WebInputEvent::TouchMove, 1);
93 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 93 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
94 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 94 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1));
95 95
96 // Touch moves with identical touch ids in different orders should coalesce. 96 // Touch moves with identical touch ids in different orders should coalesce.
97 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 97 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
98 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 98 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
99 touch0.touches[0] = touch1.touches[1] = 99 touch0.touches[0] = touch1.touches[1] =
100 CreateTouchPoint(WebTouchPoint::StateMoved, 1); 100 CreateTouchPoint(WebTouchPoint::StateMoved, 1);
101 touch0.touches[1] = touch1.touches[0] = 101 touch0.touches[1] = touch1.touches[0] =
102 CreateTouchPoint(WebTouchPoint::StateMoved, 0); 102 CreateTouchPoint(WebTouchPoint::StateMoved, 0);
103 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 103 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1));
104 104
105 // Pointers with the same ID's should coalesce. 105 // Pointers with the same ID's should coalesce.
106 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 106 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
107 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 107 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
108 touch0.touches[0] = touch1.touches[1] = 108 touch0.touches[0] = touch1.touches[1] =
109 CreateTouchPoint(WebTouchPoint::StateMoved, 1); 109 CreateTouchPoint(WebTouchPoint::StateMoved, 1);
110 WebInputEventTraits::Coalesce(touch0, &touch1); 110 WebInputEventTraits::Coalesce(touch0, &touch1);
111 ASSERT_EQ(1, touch1.touches[0].id); 111 ASSERT_EQ(1, touch1.touches[0].pointerId);
112 ASSERT_EQ(0, touch1.touches[1].id); 112 ASSERT_EQ(0, touch1.touches[1].pointerId);
113 EXPECT_EQ(WebTouchPoint::StateUndefined, touch1.touches[1].state); 113 EXPECT_EQ(WebTouchPoint::StateUndefined, touch1.touches[1].state);
114 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state); 114 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state);
115 115
116 // Movement from now-stationary pointers should be preserved. 116 // Movement from now-stationary pointers should be preserved.
117 touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 117 touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
118 touch0.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1); 118 touch0.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1);
119 touch1.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1); 119 touch1.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1);
120 touch0.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0); 120 touch0.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0);
121 touch1.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0); 121 touch1.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0);
122 WebInputEventTraits::Coalesce(touch0, &touch1); 122 WebInputEventTraits::Coalesce(touch0, &touch1);
123 ASSERT_EQ(1, touch1.touches[0].id); 123 ASSERT_EQ(1, touch1.touches[0].pointerId);
124 ASSERT_EQ(0, touch1.touches[1].id); 124 ASSERT_EQ(0, touch1.touches[1].pointerId);
125 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state); 125 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state);
126 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[1].state); 126 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[1].state);
127 } 127 }
128 128
129 TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) { 129 TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) {
130 WebGestureEvent pinch0 = 130 WebGestureEvent pinch0 =
131 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); 131 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1);
132 WebGestureEvent pinch1 = 132 WebGestureEvent pinch1 =
133 CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2); 133 CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2);
134 134
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 WebGestureEvent gesture = 215 WebGestureEvent gesture =
216 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); 216 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1);
217 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty()); 217 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty());
218 218
219 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart); 219 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart);
220 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty()); 220 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty());
221 } 221 }
222 222
223 } // namespace 223 } // namespace
224 } // namespace content 224 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | content/renderer/pepper/event_conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698