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

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

Issue 2091213002: Decouple EventWithLatencyInfo and WebInputEventTraits [extern templates] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reference a better bug Created 4 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
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/common/input/event_with_latency_info.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/web/WebInputEvent.h" 11 #include "third_party/WebKit/public/web/WebInputEvent.h"
11 12
12 using blink::WebGestureEvent; 13 using blink::WebGestureEvent;
13 using blink::WebInputEvent; 14 using blink::WebInputEvent;
14 using blink::WebKeyboardEvent; 15 using blink::WebKeyboardEvent;
15 using blink::WebMouseEvent; 16 using blink::WebMouseEvent;
16 using blink::WebMouseWheelEvent; 17 using blink::WebMouseWheelEvent;
17 using blink::WebTouchEvent; 18 using blink::WebTouchEvent;
18 using blink::WebTouchPoint; 19 using blink::WebTouchPoint;
19 using std::numeric_limits; 20 using std::numeric_limits;
20 21
21 namespace content { 22 namespace content {
22 namespace { 23 namespace {
23 24
25 // TODO(tapted): Move the Coalesce tests to event_with_latency_info_unittest.cc.
26 // Merge this test harness into EventWithLatencyInfoTest.
24 class WebInputEventTraitsTest : public testing::Test { 27 class WebInputEventTraitsTest : public testing::Test {
25 protected: 28 protected:
26 static WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) { 29 static WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) {
27 WebTouchPoint touch; 30 WebTouchPoint touch;
28 touch.state = state; 31 touch.state = state;
29 touch.id = id; 32 touch.id = id;
30 return touch; 33 return touch;
31 } 34 }
32 35
33 static WebTouchEvent CreateTouch(WebInputEvent::Type type) { 36 static TouchEventWithLatencyInfo CreateTouch(WebInputEvent::Type type) {
34 return CreateTouch(type, 1); 37 return CreateTouch(type, 1);
35 } 38 }
36 39
37 static WebTouchEvent CreateTouch(WebInputEvent::Type type, 40 static TouchEventWithLatencyInfo CreateTouch(WebInputEvent::Type type,
38 unsigned touch_count) { 41 unsigned touch_count) {
39 WebTouchEvent event; 42 WebTouchEvent event;
40 event.touchesLength = touch_count; 43 event.touchesLength = touch_count;
41 event.type = type; 44 event.type = type;
42 return event; 45 return TouchEventWithLatencyInfo(event);
43 } 46 }
44 47
45 static WebGestureEvent CreateGesture(WebInputEvent::Type type, 48 static GestureEventWithLatencyInfo CreateGesture(WebInputEvent::Type type,
46 float x, 49 float x,
47 float y) { 50 float y) {
48 WebGestureEvent event; 51 WebGestureEvent event;
49 event.type = type; 52 event.type = type;
50 event.x = x; 53 event.x = x;
51 event.y = y; 54 event.y = y;
52 return event; 55 return GestureEventWithLatencyInfo(event);
53 } 56 }
54 57
55 static WebMouseWheelEvent CreateMouseWheel(float deltaX, float deltaY) { 58 static MouseWheelEventWithLatencyInfo CreateMouseWheel(float deltaX,
59 float deltaY) {
56 WebMouseWheelEvent event; 60 WebMouseWheelEvent event;
57 event.type = WebInputEvent::MouseWheel; 61 event.type = WebInputEvent::MouseWheel;
58 event.deltaX = deltaX; 62 event.deltaX = deltaX;
59 event.deltaY = deltaY; 63 event.deltaY = deltaY;
60 return event; 64 return MouseWheelEventWithLatencyInfo(event);
61 } 65 }
62 }; 66 };
63 67
68 template <class T>
69 bool CanCoalesce(const T& event_to_coalesce, const T& event) {
70 return event.CanCoalesceWith(event_to_coalesce);
71 }
72
73 template <class T>
74 void Coalesce(const T& event_to_coalesce, T* event) {
75 return event->CoalesceWith(event_to_coalesce);
76 }
77
64 TEST_F(WebInputEventTraitsTest, TouchEventCoalescing) { 78 TEST_F(WebInputEventTraitsTest, TouchEventCoalescing) {
65 WebTouchEvent touch0 = CreateTouch(WebInputEvent::TouchStart); 79 TouchEventWithLatencyInfo touch0 = CreateTouch(WebInputEvent::TouchStart);
66 WebTouchEvent touch1 = CreateTouch(WebInputEvent::TouchMove); 80 TouchEventWithLatencyInfo touch1 = CreateTouch(WebInputEvent::TouchMove);
67 81
68 // Non touch-moves won't coalesce. 82 // Non touch-moves won't coalesce.
69 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch0)); 83 EXPECT_FALSE(CanCoalesce(touch0, touch0));
70 84
71 // Touches of different types won't coalesce. 85 // Touches of different types won't coalesce.
72 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 86 EXPECT_FALSE(CanCoalesce(touch0, touch1));
73 87
74 // Touch moves with idential touch lengths and touch ids should coalesce. 88 // Touch moves with idential touch lengths and touch ids should coalesce.
75 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch1, touch1)); 89 EXPECT_TRUE(CanCoalesce(touch1, touch1));
76 90
77 // Touch moves with different touch ids should not coalesce. 91 // Touch moves with different touch ids should not coalesce.
78 touch0 = CreateTouch(WebInputEvent::TouchMove); 92 touch0 = CreateTouch(WebInputEvent::TouchMove);
79 touch1 = CreateTouch(WebInputEvent::TouchMove); 93 touch1 = CreateTouch(WebInputEvent::TouchMove);
80 touch0.touches[0].id = 7; 94 touch0.event.touches[0].id = 7;
81 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 95 EXPECT_FALSE(CanCoalesce(touch0, touch1));
82 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 96 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
83 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 97 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
84 touch0.touches[0].id = 1; 98 touch0.event.touches[0].id = 1;
85 touch1.touches[0].id = 0; 99 touch1.event.touches[0].id = 0;
86 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 100 EXPECT_FALSE(CanCoalesce(touch0, touch1));
87 101
88 // Touch moves with different touch lengths should not coalesce. 102 // Touch moves with different touch lengths should not coalesce.
89 touch0 = CreateTouch(WebInputEvent::TouchMove, 1); 103 touch0 = CreateTouch(WebInputEvent::TouchMove, 1);
90 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 104 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
91 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 105 EXPECT_FALSE(CanCoalesce(touch0, touch1));
92 106
93 // Touch moves with identical touch ids in different orders should coalesce. 107 // Touch moves with identical touch ids in different orders should coalesce.
94 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 108 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
95 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 109 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
96 touch0.touches[0] = touch1.touches[1] = 110 touch0.event.touches[0] = touch1.event.touches[1] =
97 CreateTouchPoint(WebTouchPoint::StateMoved, 1); 111 CreateTouchPoint(WebTouchPoint::StateMoved, 1);
98 touch0.touches[1] = touch1.touches[0] = 112 touch0.event.touches[1] = touch1.event.touches[0] =
99 CreateTouchPoint(WebTouchPoint::StateMoved, 0); 113 CreateTouchPoint(WebTouchPoint::StateMoved, 0);
100 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 114 EXPECT_TRUE(CanCoalesce(touch0, touch1));
101 115
102 // Pointers with the same ID's should coalesce. 116 // Pointers with the same ID's should coalesce.
103 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 117 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
104 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 118 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
105 touch0.touches[0] = touch1.touches[1] = 119 touch0.event.touches[0] = touch1.event.touches[1] =
106 CreateTouchPoint(WebTouchPoint::StateMoved, 1); 120 CreateTouchPoint(WebTouchPoint::StateMoved, 1);
107 WebInputEventTraits::Coalesce(touch0, &touch1); 121 Coalesce(touch0, &touch1);
108 ASSERT_EQ(1, touch1.touches[0].id); 122 ASSERT_EQ(1, touch1.event.touches[0].id);
109 ASSERT_EQ(0, touch1.touches[1].id); 123 ASSERT_EQ(0, touch1.event.touches[1].id);
110 EXPECT_EQ(WebTouchPoint::StateUndefined, touch1.touches[1].state); 124 EXPECT_EQ(WebTouchPoint::StateUndefined, touch1.event.touches[1].state);
111 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state); 125 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.event.touches[0].state);
112 126
113 // Movement from now-stationary pointers should be preserved. 127 // Movement from now-stationary pointers should be preserved.
114 touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 128 touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
115 touch0.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1); 129 touch0.event.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1);
116 touch1.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1); 130 touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1);
117 touch0.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0); 131 touch0.event.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0);
118 touch1.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0); 132 touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0);
119 WebInputEventTraits::Coalesce(touch0, &touch1); 133 Coalesce(touch0, &touch1);
120 ASSERT_EQ(1, touch1.touches[0].id); 134 ASSERT_EQ(1, touch1.event.touches[0].id);
121 ASSERT_EQ(0, touch1.touches[1].id); 135 ASSERT_EQ(0, touch1.event.touches[1].id);
122 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[0].state); 136 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.event.touches[0].state);
123 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.touches[1].state); 137 EXPECT_EQ(WebTouchPoint::StateMoved, touch1.event.touches[1].state);
124 138
125 // Touch moves with different dispatchTypes coalesce. 139 // Touch moves with different dispatchTypes coalesce.
126 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 140 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
127 touch0.dispatchType = WebInputEvent::DispatchType::Blocking; 141 touch0.event.dispatchType = WebInputEvent::DispatchType::Blocking;
128 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 142 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
129 touch1.dispatchType = WebInputEvent::DispatchType::EventNonBlocking; 143 touch1.event.dispatchType = WebInputEvent::DispatchType::EventNonBlocking;
130 touch0.touches[0] = touch1.touches[1] = 144 touch0.event.touches[0] = touch1.event.touches[1] =
131 CreateTouchPoint(WebTouchPoint::StateMoved, 1); 145 CreateTouchPoint(WebTouchPoint::StateMoved, 1);
132 touch0.touches[1] = touch1.touches[0] = 146 touch0.event.touches[1] = touch1.event.touches[0] =
133 CreateTouchPoint(WebTouchPoint::StateMoved, 0); 147 CreateTouchPoint(WebTouchPoint::StateMoved, 0);
134 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 148 EXPECT_TRUE(CanCoalesce(touch0, touch1));
135 WebInputEventTraits::Coalesce(touch0, &touch1); 149 Coalesce(touch0, &touch1);
136 ASSERT_EQ(WebInputEvent::DispatchType::Blocking, touch1.dispatchType); 150 ASSERT_EQ(WebInputEvent::DispatchType::Blocking, touch1.event.dispatchType);
137 151
138 touch0 = CreateTouch(WebInputEvent::TouchMove, 2); 152 touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
139 touch0.dispatchType = 153 touch0.event.dispatchType =
140 WebInputEvent::DispatchType::ListenersForcedNonBlockingPassive; 154 WebInputEvent::DispatchType::ListenersForcedNonBlockingPassive;
141 touch1 = CreateTouch(WebInputEvent::TouchMove, 2); 155 touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
142 touch1.dispatchType = 156 touch1.event.dispatchType =
143 WebInputEvent::DispatchType::ListenersNonBlockingPassive; 157 WebInputEvent::DispatchType::ListenersNonBlockingPassive;
144 touch0.touches[0] = touch1.touches[1] = 158 touch0.event.touches[0] = touch1.event.touches[1] =
145 CreateTouchPoint(WebTouchPoint::StateMoved, 1); 159 CreateTouchPoint(WebTouchPoint::StateMoved, 1);
146 touch0.touches[1] = touch1.touches[0] = 160 touch0.event.touches[1] = touch1.event.touches[0] =
147 CreateTouchPoint(WebTouchPoint::StateMoved, 0); 161 CreateTouchPoint(WebTouchPoint::StateMoved, 0);
148 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(touch0, touch1)); 162 EXPECT_TRUE(CanCoalesce(touch0, touch1));
149 WebInputEventTraits::Coalesce(touch0, &touch1); 163 Coalesce(touch0, &touch1);
150 ASSERT_EQ(WebInputEvent::DispatchType::ListenersNonBlockingPassive, 164 ASSERT_EQ(WebInputEvent::DispatchType::ListenersNonBlockingPassive,
151 touch1.dispatchType); 165 touch1.event.dispatchType);
152 } 166 }
153 167
154 TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) { 168 TEST_F(WebInputEventTraitsTest, PinchEventCoalescing) {
155 WebGestureEvent pinch0 = 169 GestureEventWithLatencyInfo pinch0 =
156 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); 170 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1);
157 WebGestureEvent pinch1 = 171 GestureEventWithLatencyInfo pinch1 =
158 CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2); 172 CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2);
159 173
160 // Only GesturePinchUpdate's coalesce. 174 // Only GesturePinchUpdate's coalesce.
161 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); 175 EXPECT_FALSE(CanCoalesce(pinch0, pinch0));
162 176
163 // Pinch gestures of different types should not coalesce. 177 // Pinch gestures of different types should not coalesce.
164 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(pinch0, pinch1)); 178 EXPECT_FALSE(CanCoalesce(pinch0, pinch1));
165 179
166 // Pinches with different focal points should not coalesce. 180 // Pinches with different focal points should not coalesce.
167 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 181 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
168 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2); 182 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2);
169 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(pinch0, pinch1)); 183 EXPECT_FALSE(CanCoalesce(pinch0, pinch1));
170 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); 184 EXPECT_TRUE(CanCoalesce(pinch0, pinch0));
171 185
172 // Coalesced scales are multiplicative. 186 // Coalesced scales are multiplicative.
173 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 187 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
174 pinch0.data.pinchUpdate.scale = 2.f; 188 pinch0.event.data.pinchUpdate.scale = 2.f;
175 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 189 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
176 pinch1.data.pinchUpdate.scale = 3.f; 190 pinch1.event.data.pinchUpdate.scale = 3.f;
177 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch0)); 191 EXPECT_TRUE(CanCoalesce(pinch0, pinch0));
178 WebInputEventTraits::Coalesce(pinch0, &pinch1); 192 Coalesce(pinch0, &pinch1);
179 EXPECT_EQ(2.f * 3.f, pinch1.data.pinchUpdate.scale); 193 EXPECT_EQ(2.f * 3.f, pinch1.event.data.pinchUpdate.scale);
180 194
181 // Scales have a minimum value and can never reach 0. 195 // Scales have a minimum value and can never reach 0.
182 ASSERT_GT(numeric_limits<float>::min(), 0); 196 ASSERT_GT(numeric_limits<float>::min(), 0);
183 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 197 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
184 pinch0.data.pinchUpdate.scale = numeric_limits<float>::min() * 2.0f; 198 pinch0.event.data.pinchUpdate.scale = numeric_limits<float>::min() * 2.0f;
185 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 199 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
186 pinch1.data.pinchUpdate.scale = numeric_limits<float>::min() * 5.0f; 200 pinch1.event.data.pinchUpdate.scale = numeric_limits<float>::min() * 5.0f;
187 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1)); 201 EXPECT_TRUE(CanCoalesce(pinch0, pinch1));
188 WebInputEventTraits::Coalesce(pinch0, &pinch1); 202 Coalesce(pinch0, &pinch1);
189 EXPECT_EQ(numeric_limits<float>::min(), pinch1.data.pinchUpdate.scale); 203 EXPECT_EQ(numeric_limits<float>::min(), pinch1.event.data.pinchUpdate.scale);
190 204
191 // Scales have a maximum value and can never reach Infinity. 205 // Scales have a maximum value and can never reach Infinity.
192 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 206 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
193 pinch0.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f; 207 pinch0.event.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f;
194 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 208 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
195 pinch1.data.pinchUpdate.scale = 10.0f; 209 pinch1.event.data.pinchUpdate.scale = 10.0f;
196 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1)); 210 EXPECT_TRUE(CanCoalesce(pinch0, pinch1));
197 WebInputEventTraits::Coalesce(pinch0, &pinch1); 211 Coalesce(pinch0, &pinch1);
198 EXPECT_EQ(numeric_limits<float>::max(), pinch1.data.pinchUpdate.scale); 212 EXPECT_EQ(numeric_limits<float>::max(), pinch1.event.data.pinchUpdate.scale);
199 } 213 }
200 214
201 TEST_F(WebInputEventTraitsTest, WebMouseWheelEventCoalescing) { 215 TEST_F(WebInputEventTraitsTest, WebMouseWheelEventCoalescing) {
202 WebMouseWheelEvent mouse_wheel_0 = CreateMouseWheel(1, 1); 216 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1);
203 WebMouseWheelEvent mouse_wheel_1 = CreateMouseWheel(2, 2); 217 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2);
204 218
205 // WebMouseWheelEvent objects with same values except different deltaX and 219 // WebMouseWheelEvent objects with same values except different deltaX and
206 // deltaY should coalesce. 220 // deltaY should coalesce.
207 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 221 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
208 222
209 // WebMouseWheelEvent objects with different modifiers should not coalesce. 223 // WebMouseWheelEvent objects with different modifiers should not coalesce.
210 mouse_wheel_0 = CreateMouseWheel(1, 1); 224 mouse_wheel_0 = CreateMouseWheel(1, 1);
211 mouse_wheel_1 = CreateMouseWheel(1, 1); 225 mouse_wheel_1 = CreateMouseWheel(1, 1);
212 mouse_wheel_0.modifiers = blink::WebInputEvent::ControlKey; 226 mouse_wheel_0.event.modifiers = blink::WebInputEvent::ControlKey;
213 mouse_wheel_1.modifiers = blink::WebInputEvent::ShiftKey; 227 mouse_wheel_1.event.modifiers = blink::WebInputEvent::ShiftKey;
214 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 228 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
215 } 229 }
216 230
217 // Coalescing preserves the newer timestamp. 231 // Coalescing preserves the newer timestamp.
218 TEST_F(WebInputEventTraitsTest, TimestampCoalescing) { 232 TEST_F(WebInputEventTraitsTest, TimestampCoalescing) {
219 WebMouseWheelEvent mouse_wheel_0 = CreateMouseWheel(1, 1); 233 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1);
220 mouse_wheel_0.timeStampSeconds = 5.0; 234 mouse_wheel_0.event.timeStampSeconds = 5.0;
221 WebMouseWheelEvent mouse_wheel_1 = CreateMouseWheel(2, 2); 235 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2);
222 mouse_wheel_1.timeStampSeconds = 10.0; 236 mouse_wheel_1.event.timeStampSeconds = 10.0;
223 237
224 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 238 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
225 WebInputEventTraits::Coalesce(mouse_wheel_1, &mouse_wheel_0); 239 Coalesce(mouse_wheel_1, &mouse_wheel_0);
226 EXPECT_EQ(10.0, mouse_wheel_0.timeStampSeconds); 240 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds);
227 } 241 }
228 242
229 // Very basic smoke test to ensure stringification doesn't explode. 243 // Very basic smoke test to ensure stringification doesn't explode.
230 TEST_F(WebInputEventTraitsTest, ToString) { 244 TEST_F(WebInputEventTraitsTest, ToString) {
231 WebKeyboardEvent key; 245 WebKeyboardEvent key;
232 key.type = WebInputEvent::RawKeyDown; 246 key.type = WebInputEvent::RawKeyDown;
233 EXPECT_FALSE(WebInputEventTraits::ToString(key).empty()); 247 EXPECT_FALSE(WebInputEventTraits::ToString(key).empty());
234 248
235 WebMouseEvent mouse; 249 WebMouseEvent mouse;
236 mouse.type = WebInputEvent::MouseMove; 250 mouse.type = WebInputEvent::MouseMove;
237 EXPECT_FALSE(WebInputEventTraits::ToString(mouse).empty()); 251 EXPECT_FALSE(WebInputEventTraits::ToString(mouse).empty());
238 252
239 WebMouseWheelEvent mouse_wheel; 253 WebMouseWheelEvent mouse_wheel;
240 mouse_wheel.type = WebInputEvent::MouseWheel; 254 mouse_wheel.type = WebInputEvent::MouseWheel;
241 EXPECT_FALSE(WebInputEventTraits::ToString(mouse_wheel).empty()); 255 EXPECT_FALSE(WebInputEventTraits::ToString(mouse_wheel).empty());
242 256
243 WebGestureEvent gesture = 257 WebGestureEvent gesture;
244 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); 258 gesture.type = WebInputEvent::GesturePinchBegin;
259 gesture.x = 1;
260 gesture.y = 1;
245 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty()); 261 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty());
246 262
247 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart); 263 WebTouchEvent touch;
264 touch.type = WebInputEvent::TouchStart;
265 touch.touchesLength = 1;
248 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty()); 266 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty());
249 } 267 }
250 268
251 } // namespace 269 } // namespace
252 } // namespace content 270 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698