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

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

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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 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/platform/WebInputEvent.h" 10 #include "third_party/WebKit/public/platform/WebInputEvent.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseEvent) { 63 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseEvent) {
64 MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent( 64 MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(
65 WebInputEvent::MouseMove, 5.0); 65 WebInputEvent::MouseMove, 5.0);
66 MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent( 66 MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(
67 WebInputEvent::MouseMove, 10.0); 67 WebInputEvent::MouseMove, 10.0);
68 68
69 ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1)); 69 ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1));
70 mouse_0.CoalesceWith(mouse_1); 70 mouse_0.CoalesceWith(mouse_1);
71 // Coalescing WebMouseEvent preserves newer timestamp. 71 // Coalescing WebMouseEvent preserves newer timestamp.
72 EXPECT_EQ(10.0, mouse_0.event.timeStampSeconds); 72 EXPECT_EQ(10.0, mouse_0.event.timeStampSeconds());
73 } 73 }
74 74
75 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) { 75 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) {
76 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheelEvent(5.0); 76 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheelEvent(5.0);
77 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheelEvent(10.0); 77 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheelEvent(10.0);
78 78
79 ASSERT_TRUE(mouse_wheel_0.CanCoalesceWith(mouse_wheel_1)); 79 ASSERT_TRUE(mouse_wheel_0.CanCoalesceWith(mouse_wheel_1));
80 mouse_wheel_0.CoalesceWith(mouse_wheel_1); 80 mouse_wheel_0.CoalesceWith(mouse_wheel_1);
81 // Coalescing WebMouseWheelEvent preserves newer timestamp. 81 // Coalescing WebMouseWheelEvent preserves newer timestamp.
82 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds); 82 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds());
83 } 83 }
84 84
85 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) { 85 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) {
86 TouchEventWithLatencyInfo touch_0 = CreateTouchEvent( 86 TouchEventWithLatencyInfo touch_0 = CreateTouchEvent(
87 WebInputEvent::TouchMove, 5.0); 87 WebInputEvent::TouchMove, 5.0);
88 TouchEventWithLatencyInfo touch_1 = CreateTouchEvent( 88 TouchEventWithLatencyInfo touch_1 = CreateTouchEvent(
89 WebInputEvent::TouchMove, 10.0); 89 WebInputEvent::TouchMove, 10.0);
90 90
91 ASSERT_TRUE(touch_0.CanCoalesceWith(touch_1)); 91 ASSERT_TRUE(touch_0.CanCoalesceWith(touch_1));
92 touch_0.CoalesceWith(touch_1); 92 touch_0.CoalesceWith(touch_1);
93 // Coalescing WebTouchEvent preserves newer timestamp. 93 // Coalescing WebTouchEvent preserves newer timestamp.
94 EXPECT_EQ(10.0, touch_0.event.timeStampSeconds); 94 EXPECT_EQ(10.0, touch_0.event.timeStampSeconds());
95 } 95 }
96 96
97 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) { 97 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) {
98 GestureEventWithLatencyInfo scroll_0 = CreateGestureEvent( 98 GestureEventWithLatencyInfo scroll_0 = CreateGestureEvent(
99 WebInputEvent::GestureScrollUpdate, 5.0); 99 WebInputEvent::GestureScrollUpdate, 5.0);
100 GestureEventWithLatencyInfo scroll_1 = CreateGestureEvent( 100 GestureEventWithLatencyInfo scroll_1 = CreateGestureEvent(
101 WebInputEvent::GestureScrollUpdate, 10.0); 101 WebInputEvent::GestureScrollUpdate, 10.0);
102 102
103 ASSERT_TRUE(scroll_0.CanCoalesceWith(scroll_1)); 103 ASSERT_TRUE(scroll_0.CanCoalesceWith(scroll_1));
104 scroll_0.CoalesceWith(scroll_1); 104 scroll_0.CoalesceWith(scroll_1);
105 // Coalescing WebGestureEvent preserves newer timestamp. 105 // Coalescing WebGestureEvent preserves newer timestamp.
106 EXPECT_EQ(10.0, scroll_0.event.timeStampSeconds); 106 EXPECT_EQ(10.0, scroll_0.event.timeStampSeconds());
107 } 107 }
108 108
109 TEST_F(EventWithLatencyInfoTest, LatencyInfoCoalescing) { 109 TEST_F(EventWithLatencyInfoTest, LatencyInfoCoalescing) {
110 MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent( 110 MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(
111 WebInputEvent::MouseMove, 5.0); 111 WebInputEvent::MouseMove, 5.0);
112 mouse_0.latency.AddLatencyNumberWithTimestamp( 112 mouse_0.latency.AddLatencyNumberWithTimestamp(
113 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks(), 1); 113 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks(), 1);
114 MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent( 114 MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(
115 WebInputEvent::MouseMove, 10.0); 115 WebInputEvent::MouseMove, 10.0);
116 116
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 // Coalesce old and new events. 311 // Coalesce old and new events.
312 mouse_wheel_0 = CreateMouseWheel(1, 1); 312 mouse_wheel_0 = CreateMouseWheel(1, 1);
313 mouse_wheel_0.event.x = 1; 313 mouse_wheel_0.event.x = 1;
314 mouse_wheel_0.event.y = 1; 314 mouse_wheel_0.event.y = 1;
315 mouse_wheel_1 = CreateMouseWheel(2, 2); 315 mouse_wheel_1 = CreateMouseWheel(2, 2);
316 mouse_wheel_1.event.x = 2; 316 mouse_wheel_1.event.x = 2;
317 mouse_wheel_1.event.y = 2; 317 mouse_wheel_1.event.y = 2;
318 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1; 318 MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1;
319 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 319 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
320 EXPECT_EQ(mouse_wheel_0.event.modifiers, mouse_wheel_1.event.modifiers); 320 EXPECT_EQ(mouse_wheel_0.event.modifiers(), mouse_wheel_1.event.modifiers());
321 EXPECT_EQ(mouse_wheel_0.event.scrollByPage, mouse_wheel_1.event.scrollByPage); 321 EXPECT_EQ(mouse_wheel_0.event.scrollByPage, mouse_wheel_1.event.scrollByPage);
322 EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase); 322 EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase);
323 EXPECT_EQ(mouse_wheel_0.event.momentumPhase, 323 EXPECT_EQ(mouse_wheel_0.event.momentumPhase,
324 mouse_wheel_1.event.momentumPhase); 324 mouse_wheel_1.event.momentumPhase);
325 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas, 325 EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas,
326 mouse_wheel_1.event.hasPreciseScrollingDeltas); 326 mouse_wheel_1.event.hasPreciseScrollingDeltas);
327 Coalesce(mouse_wheel_0, &mouse_wheel_1); 327 Coalesce(mouse_wheel_0, &mouse_wheel_1);
328 328
329 // Coalesced event has the position of the most recent event. 329 // Coalesced event has the position of the most recent event.
330 EXPECT_EQ(1, mouse_wheel_1.event.x); 330 EXPECT_EQ(1, mouse_wheel_1.event.x);
(...skipping 19 matching lines...) Expand all
350 350
351 // Coalescing preserves the newer timestamp. 351 // Coalescing preserves the newer timestamp.
352 TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) { 352 TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) {
353 MouseWheelEventWithLatencyInfo mouse_wheel_0 = 353 MouseWheelEventWithLatencyInfo mouse_wheel_0 =
354 CreateMouseWheelEvent(5.0, 1, 1); 354 CreateMouseWheelEvent(5.0, 1, 1);
355 MouseWheelEventWithLatencyInfo mouse_wheel_1 = 355 MouseWheelEventWithLatencyInfo mouse_wheel_1 =
356 CreateMouseWheelEvent(10.0, 2, 2); 356 CreateMouseWheelEvent(10.0, 2, 2);
357 357
358 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); 358 EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
359 Coalesce(mouse_wheel_1, &mouse_wheel_0); 359 Coalesce(mouse_wheel_1, &mouse_wheel_0);
360 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds); 360 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds());
361 } 361 }
362 362
363 } // namespace 363 } // namespace
364 } // namespace content 364 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/event_with_latency_info.cc ('k') | content/common/input/gesture_event_stream_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698