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

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

Issue 2257023004: Coalesced mouse wheel event has the position of the most recent event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a more verbose unittest. Created 4 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
« no previous file with comments | « content/common/input/event_with_latency_info.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/event_with_latency_info.h" 5 #include "content/common/input/event_with_latency_info.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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1); 295 pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
296 pinch1.event.data.pinchUpdate.scale = 10.0f; 296 pinch1.event.data.pinchUpdate.scale = 10.0f;
297 EXPECT_TRUE(CanCoalesce(pinch0, pinch1)); 297 EXPECT_TRUE(CanCoalesce(pinch0, pinch1));
298 Coalesce(pinch0, &pinch1); 298 Coalesce(pinch0, &pinch1);
299 EXPECT_EQ(numeric_limits<float>::max(), pinch1.event.data.pinchUpdate.scale); 299 EXPECT_EQ(numeric_limits<float>::max(), pinch1.event.data.pinchUpdate.scale);
300 } 300 }
301 301
302 TEST_F(EventWithLatencyInfoTest, WebMouseWheelEventCoalescing) { 302 TEST_F(EventWithLatencyInfoTest, WebMouseWheelEventCoalescing) {
303 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1); 303 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1);
304 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2); 304 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2);
305
306 // WebMouseWheelEvent objects with same values except different deltaX and 305 // WebMouseWheelEvent objects with same values except different deltaX and
307 // deltaY should coalesce. 306 // deltaY should coalesce.
308 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 307 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
309 308
310 // WebMouseWheelEvent objects with different modifiers should not coalesce. 309 // WebMouseWheelEvent objects with different modifiers should not coalesce.
311 mouse_wheel_0 = CreateMouseWheel(1, 1); 310 mouse_wheel_0 = CreateMouseWheel(1, 1);
312 mouse_wheel_1 = CreateMouseWheel(1, 1); 311 mouse_wheel_1 = CreateMouseWheel(1, 1);
313 mouse_wheel_0.event.modifiers = WebInputEvent::ControlKey; 312 mouse_wheel_0.event.modifiers = WebInputEvent::ControlKey;
314 mouse_wheel_1.event.modifiers = WebInputEvent::ShiftKey; 313 mouse_wheel_1.event.modifiers = WebInputEvent::ShiftKey;
315 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 314 EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
315
316 // Coalesce old and new events.
317 mouse_wheel_0 = CreateMouseWheel(1, 1);
318 mouse_wheel_0.event.x = 1;
319 mouse_wheel_0.event.y = 1;
320 mouse_wheel_1 = CreateMouseWheel(2, 2);
321 mouse_wheel_1.event.x = 2;
322 mouse_wheel_1.event.y = 2;
323 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1;
324 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
325 EXPECT_EQ(mouse_wheel_0.event.modifiers, mouse_wheel_1.event.modifiers);
326 EXPECT_EQ(mouse_wheel_0.event.scrollByPage, mouse_wheel_1.event.scrollByPage);
327 EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase);
328 EXPECT_EQ(mouse_wheel_0.event.momentumPhase,
329 mouse_wheel_1.event.momentumPhase);
330 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas,
331 mouse_wheel_1.event.hasPreciseScrollingDeltas);
332 Coalesce(mouse_wheel_0, &mouse_wheel_1);
333
334 // Coalesced event has the position of the most recent event.
335 EXPECT_EQ(1, mouse_wheel_1.event.x);
336 EXPECT_EQ(1, mouse_wheel_1.event.y);
337
338 // deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are
339 // calculated properly.
340 EXPECT_EQ(mouse_wheel_1_copy.event.deltaX + mouse_wheel_0.event.deltaX,
341 mouse_wheel_1.event.deltaX);
342 EXPECT_EQ(mouse_wheel_1_copy.event.deltaY + mouse_wheel_0.event.deltaY,
343 mouse_wheel_1.event.deltaY);
344 EXPECT_EQ(
345 mouse_wheel_1_copy.event.wheelTicksX + mouse_wheel_0.event.wheelTicksX,
346 mouse_wheel_1.event.wheelTicksX);
347 EXPECT_EQ(
348 mouse_wheel_1_copy.event.wheelTicksY + mouse_wheel_0.event.wheelTicksY,
349 mouse_wheel_1.event.wheelTicksY);
350 EXPECT_EQ(mouse_wheel_1_copy.event.movementX + mouse_wheel_0.event.movementX,
351 mouse_wheel_1.event.movementX);
352 EXPECT_EQ(mouse_wheel_1_copy.event.movementY + mouse_wheel_0.event.movementY,
353 mouse_wheel_1.event.movementY);
316 } 354 }
317 355
318 // Coalescing preserves the newer timestamp. 356 // Coalescing preserves the newer timestamp.
319 TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) { 357 TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) {
320 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1); 358 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1);
321 mouse_wheel_0.event.timeStampSeconds = 5.0; 359 mouse_wheel_0.event.timeStampSeconds = 5.0;
322 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2); 360 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2);
323 mouse_wheel_1.event.timeStampSeconds = 10.0; 361 mouse_wheel_1.event.timeStampSeconds = 10.0;
324 362
325 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 363 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
326 Coalesce(mouse_wheel_1, &mouse_wheel_0); 364 Coalesce(mouse_wheel_1, &mouse_wheel_0);
327 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds); 365 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds);
328 } 366 }
329 367
330 } // namespace 368 } // namespace
331 } // namespace content 369 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/event_with_latency_info.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698