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

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

Issue 2052663004: Remove canScroll from WebMouseWheelEvent as it is unused now. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really fix android unit test Created 4 years, 6 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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 static WebGestureEvent CreateGesture(WebInputEvent::Type type, 45 static WebGestureEvent CreateGesture(WebInputEvent::Type type,
46 float x, 46 float x,
47 float y) { 47 float y) {
48 WebGestureEvent event; 48 WebGestureEvent event;
49 event.type = type; 49 event.type = type;
50 event.x = x; 50 event.x = x;
51 event.y = y; 51 event.y = y;
52 return event; 52 return event;
53 } 53 }
54 54
55 static WebMouseWheelEvent CreateMouseWheel(float deltaX, 55 static WebMouseWheelEvent CreateMouseWheel(float deltaX, float deltaY) {
56 float deltaY,
57 bool canScroll) {
58 WebMouseWheelEvent event; 56 WebMouseWheelEvent event;
59 event.type = WebInputEvent::MouseWheel; 57 event.type = WebInputEvent::MouseWheel;
60 event.deltaX = deltaX; 58 event.deltaX = deltaX;
61 event.deltaY = deltaY; 59 event.deltaY = deltaY;
62 event.canScroll = canScroll;
63 return event; 60 return event;
64 } 61 }
65 }; 62 };
66 63
67 TEST_F(WebInputEventTraitsTest, TouchEventCoalescing) { 64 TEST_F(WebInputEventTraitsTest, TouchEventCoalescing) {
68 WebTouchEvent touch0 = CreateTouch(WebInputEvent::TouchStart); 65 WebTouchEvent touch0 = CreateTouch(WebInputEvent::TouchStart);
69 WebTouchEvent touch1 = CreateTouch(WebInputEvent::TouchMove); 66 WebTouchEvent touch1 = CreateTouch(WebInputEvent::TouchMove);
70 67
71 // Non touch-moves won't coalesce. 68 // Non touch-moves won't coalesce.
72 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch0)); 69 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(touch0, touch0));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 192 pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
196 pinch0.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f; 193 pinch0.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f;
197 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 194 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
198 pinch1.data.pinchUpdate.scale = 10.0f; 195 pinch1.data.pinchUpdate.scale = 10.0f;
199 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1)); 196 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(pinch0, pinch1));
200 WebInputEventTraits::Coalesce(pinch0, &pinch1); 197 WebInputEventTraits::Coalesce(pinch0, &pinch1);
201 EXPECT_EQ(numeric_limits<float>::max(), pinch1.data.pinchUpdate.scale); 198 EXPECT_EQ(numeric_limits<float>::max(), pinch1.data.pinchUpdate.scale);
202 } 199 }
203 200
204 TEST_F(WebInputEventTraitsTest, WebMouseWheelEventCoalescing) { 201 TEST_F(WebInputEventTraitsTest, WebMouseWheelEventCoalescing) {
205 WebMouseWheelEvent mouse_wheel_0 = 202 WebMouseWheelEvent mouse_wheel_0 = CreateMouseWheel(1, 1);
206 CreateMouseWheel(1, 1, true); 203 WebMouseWheelEvent mouse_wheel_1 = CreateMouseWheel(2, 2);
207 WebMouseWheelEvent mouse_wheel_1 =
208 CreateMouseWheel(2, 2, true);
209 204
210 // WebMouseWheelEvent objects with same values except different deltaX and 205 // WebMouseWheelEvent objects with same values except different deltaX and
211 // deltaY should coalesce. 206 // deltaY should coalesce.
212 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 207 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1));
213 208
214 mouse_wheel_0 = CreateMouseWheel(1, 1, true);
215 mouse_wheel_1 = CreateMouseWheel(1, 1, false);
216
217 // WebMouseWheelEvent objects with different canScroll values should not
218 // coalesce.
219 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1));
220
221 // WebMouseWheelEvent objects with different modifiers should not coalesce. 209 // WebMouseWheelEvent objects with different modifiers should not coalesce.
222 mouse_wheel_0 = CreateMouseWheel(1, 1, true); 210 mouse_wheel_0 = CreateMouseWheel(1, 1);
223 mouse_wheel_1 = CreateMouseWheel(1, 1, true); 211 mouse_wheel_1 = CreateMouseWheel(1, 1);
224 mouse_wheel_0.modifiers = blink::WebInputEvent::ControlKey; 212 mouse_wheel_0.modifiers = blink::WebInputEvent::ControlKey;
225 mouse_wheel_1.modifiers = blink::WebInputEvent::ShiftKey; 213 mouse_wheel_1.modifiers = blink::WebInputEvent::ShiftKey;
226 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 214 EXPECT_FALSE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1));
227 } 215 }
228 216
229 // Coalescing preserves the newer timestamp. 217 // Coalescing preserves the newer timestamp.
230 TEST_F(WebInputEventTraitsTest, TimestampCoalescing) { 218 TEST_F(WebInputEventTraitsTest, TimestampCoalescing) {
231 WebMouseWheelEvent mouse_wheel_0 = CreateMouseWheel(1, 1, true); 219 WebMouseWheelEvent mouse_wheel_0 = CreateMouseWheel(1, 1);
232 mouse_wheel_0.timeStampSeconds = 5.0; 220 mouse_wheel_0.timeStampSeconds = 5.0;
233 WebMouseWheelEvent mouse_wheel_1 = CreateMouseWheel(2, 2, true); 221 WebMouseWheelEvent mouse_wheel_1 = CreateMouseWheel(2, 2);
234 mouse_wheel_1.timeStampSeconds = 10.0; 222 mouse_wheel_1.timeStampSeconds = 10.0;
235 223
236 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 224 EXPECT_TRUE(WebInputEventTraits::CanCoalesce(mouse_wheel_0, mouse_wheel_1));
237 WebInputEventTraits::Coalesce(mouse_wheel_1, &mouse_wheel_0); 225 WebInputEventTraits::Coalesce(mouse_wheel_1, &mouse_wheel_0);
238 EXPECT_EQ(10.0, mouse_wheel_0.timeStampSeconds); 226 EXPECT_EQ(10.0, mouse_wheel_0.timeStampSeconds);
239 } 227 }
240 228
241 // Very basic smoke test to ensure stringification doesn't explode. 229 // Very basic smoke test to ensure stringification doesn't explode.
242 TEST_F(WebInputEventTraitsTest, ToString) { 230 TEST_F(WebInputEventTraitsTest, ToString) {
243 WebKeyboardEvent key; 231 WebKeyboardEvent key;
(...skipping 11 matching lines...) Expand all
255 WebGestureEvent gesture = 243 WebGestureEvent gesture =
256 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1); 244 CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1);
257 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty()); 245 EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty());
258 246
259 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart); 247 WebTouchEvent touch = CreateTouch(WebInputEvent::TouchStart);
260 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty()); 248 EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty());
261 } 249 }
262 250
263 } // namespace 251 } // namespace
264 } // namespace content 252 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/web_input_event_traits.cc ('k') | content/renderer/input/render_widget_input_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698