cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / browser / renderer_host / event_with_latency_info_unittest.cc
blob42d490f8ad36d5e2cba85afdf81d3e8dbd81cb80
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
3 // found in the LICENSE file.
5 #include "content/browser/renderer_host/event_with_latency_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h"
10 using blink::WebGestureEvent;
11 using blink::WebInputEvent;
12 using blink::WebMouseEvent;
13 using blink::WebMouseWheelEvent;
14 using blink::WebTouchEvent;
16 namespace content {
17 namespace {
19 class EventWithLatencyInfoTest : public testing::Test {
20 protected:
21 TouchEventWithLatencyInfo CreateTouchEvent(WebInputEvent::Type type,
22 double timestamp) {
23 TouchEventWithLatencyInfo touch;
24 touch.event.touchesLength = 1;
25 touch.event.type = type;
26 touch.event.timeStampSeconds = timestamp;
27 return touch;
30 MouseEventWithLatencyInfo CreateMouseEvent(WebInputEvent::Type type,
31 double timestamp) {
32 MouseEventWithLatencyInfo mouse;
33 mouse.event.type = type;
34 mouse.event.timeStampSeconds = timestamp;
35 return mouse;
38 MouseWheelEventWithLatencyInfo CreateMouseWheelEvent(double timestamp) {
39 MouseWheelEventWithLatencyInfo mouse_wheel;
40 mouse_wheel.event.type = WebInputEvent::MouseWheel;
41 mouse_wheel.event.timeStampSeconds = timestamp;
42 return mouse_wheel;
45 GestureEventWithLatencyInfo CreateGestureEvent(WebInputEvent::Type type,
46 double timestamp) {
47 GestureEventWithLatencyInfo gesture;
48 gesture.event.type = type;
49 gesture.event.timeStampSeconds = timestamp;
50 return gesture;
54 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseEvent) {
55 MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(
56 WebInputEvent::MouseMove, 5.0);
57 MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(
58 WebInputEvent::MouseMove, 10.0);
60 ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1));
61 mouse_0.CoalesceWith(mouse_1);
62 // Coalescing WebMouseEvent preserves newer timestamp.
63 EXPECT_EQ(10.0, mouse_0.event.timeStampSeconds);
64 ASSERT_EQ(1u, mouse_0.latency.coalesced_events_size());
65 EXPECT_EQ(5.0, mouse_0.latency.timestamps_of_coalesced_events()[0]);
68 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) {
69 MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheelEvent(5.0);
70 MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheelEvent(10.0);
72 ASSERT_TRUE(mouse_wheel_0.CanCoalesceWith(mouse_wheel_1));
73 mouse_wheel_0.CoalesceWith(mouse_wheel_1);
74 // Coalescing WebMouseWheelEvent preserves newer timestamp.
75 EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds);
76 ASSERT_EQ(1u, mouse_wheel_0.latency.coalesced_events_size());
77 EXPECT_EQ(5.0, mouse_wheel_0.latency.timestamps_of_coalesced_events()[0]);
80 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) {
81 TouchEventWithLatencyInfo touch_0 = CreateTouchEvent(
82 WebInputEvent::TouchMove, 5.0);
83 TouchEventWithLatencyInfo touch_1 = CreateTouchEvent(
84 WebInputEvent::TouchMove, 10.0);
86 ASSERT_TRUE(touch_0.CanCoalesceWith(touch_1));
87 touch_0.CoalesceWith(touch_1);
88 // Coalescing WebTouchEvent preserves newer timestamp.
89 EXPECT_EQ(10.0, touch_0.event.timeStampSeconds);
90 ASSERT_EQ(1u, touch_0.latency.coalesced_events_size());
91 EXPECT_EQ(5.0, touch_0.latency.timestamps_of_coalesced_events()[0]);
94 TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) {
95 GestureEventWithLatencyInfo scroll_0 = CreateGestureEvent(
96 WebInputEvent::GestureScrollUpdate, 5.0);
97 GestureEventWithLatencyInfo scroll_1 = CreateGestureEvent(
98 WebInputEvent::GestureScrollUpdate, 10.0);
100 ASSERT_TRUE(scroll_0.CanCoalesceWith(scroll_1));
101 scroll_0.CoalesceWith(scroll_1);
102 // Coalescing WebGestureEvent preserves newer timestamp.
103 EXPECT_EQ(10.0, scroll_0.event.timeStampSeconds);
104 ASSERT_EQ(1u, scroll_0.latency.coalesced_events_size());
105 EXPECT_EQ(5.0, scroll_0.latency.timestamps_of_coalesced_events()[0]);
108 } // namespace
109 } // namespace content