OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input_param_traits.h" | 5 #include "content/common/input/input_param_traits.h" |
6 | 6 |
7 #include "content/common/input/input_event.h" | 7 #include "content/common/input/input_event.h" |
8 #include "content/common/input_messages.h" | 8 #include "content/common/input_messages.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/WebKit/public/web/WebInputEvent.h" | 11 #include "third_party/WebKit/public/web/WebInputEvent.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 namespace { | 14 namespace { |
15 | 15 |
16 typedef ScopedVector<InputEvent> InputEvents; | 16 typedef ScopedVector<InputEvent> InputEvents; |
17 | 17 |
18 void AddTo(InputEvents& events, const WebKit::WebInputEvent& event) { | 18 void AddTo(InputEvents& events, const blink::WebInputEvent& event) { |
19 events.push_back(new InputEvent(event, ui::LatencyInfo(), false)); | 19 events.push_back(new InputEvent(event, ui::LatencyInfo(), false)); |
20 } | 20 } |
21 | 21 |
22 class InputParamTraitsTest : public testing::Test { | 22 class InputParamTraitsTest : public testing::Test { |
23 protected: | 23 protected: |
24 static void Compare(const InputEvent* a, const InputEvent* b) { | 24 static void Compare(const InputEvent* a, const InputEvent* b) { |
25 EXPECT_EQ(!!a->web_event, !!b->web_event); | 25 EXPECT_EQ(!!a->web_event, !!b->web_event); |
26 if (a->web_event && b->web_event) { | 26 if (a->web_event && b->web_event) { |
27 const size_t a_size = a->web_event->size; | 27 const size_t a_size = a->web_event->size; |
28 ASSERT_EQ(a_size, b->web_event->size); | 28 ASSERT_EQ(a_size, b->web_event->size); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 InputEvent event_out; | 112 InputEvent event_out; |
113 PickleIterator iter(msg); | 113 PickleIterator iter(msg); |
114 EXPECT_FALSE(IPC::ReadParam(&msg, &iter, &event_out)); | 114 EXPECT_FALSE(IPC::ReadParam(&msg, &iter, &event_out)); |
115 } | 115 } |
116 | 116 |
117 TEST_F(InputParamTraitsTest, InitializedEvents) { | 117 TEST_F(InputParamTraitsTest, InitializedEvents) { |
118 InputEvents events; | 118 InputEvents events; |
119 | 119 |
120 ui::LatencyInfo latency; | 120 ui::LatencyInfo latency; |
121 | 121 |
122 WebKit::WebKeyboardEvent key_event; | 122 blink::WebKeyboardEvent key_event; |
123 key_event.type = WebKit::WebInputEvent::RawKeyDown; | 123 key_event.type = blink::WebInputEvent::RawKeyDown; |
124 key_event.nativeKeyCode = 5; | 124 key_event.nativeKeyCode = 5; |
125 events.push_back(new InputEvent(key_event, latency, false)); | 125 events.push_back(new InputEvent(key_event, latency, false)); |
126 | 126 |
127 WebKit::WebMouseWheelEvent wheel_event; | 127 blink::WebMouseWheelEvent wheel_event; |
128 wheel_event.type = WebKit::WebInputEvent::MouseWheel; | 128 wheel_event.type = blink::WebInputEvent::MouseWheel; |
129 wheel_event.deltaX = 10; | 129 wheel_event.deltaX = 10; |
130 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, 1); | 130 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, 1); |
131 events.push_back(new InputEvent(wheel_event, latency, false)); | 131 events.push_back(new InputEvent(wheel_event, latency, false)); |
132 | 132 |
133 WebKit::WebMouseEvent mouse_event; | 133 blink::WebMouseEvent mouse_event; |
134 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 134 mouse_event.type = blink::WebInputEvent::MouseDown; |
135 mouse_event.x = 10; | 135 mouse_event.x = 10; |
136 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 2, 2); | 136 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 2, 2); |
137 events.push_back(new InputEvent(mouse_event, latency, false)); | 137 events.push_back(new InputEvent(mouse_event, latency, false)); |
138 | 138 |
139 WebKit::WebGestureEvent gesture_event; | 139 blink::WebGestureEvent gesture_event; |
140 gesture_event.type = WebKit::WebInputEvent::GestureScrollBegin; | 140 gesture_event.type = blink::WebInputEvent::GestureScrollBegin; |
141 gesture_event.x = -1; | 141 gesture_event.x = -1; |
142 events.push_back(new InputEvent(gesture_event, latency, false)); | 142 events.push_back(new InputEvent(gesture_event, latency, false)); |
143 | 143 |
144 WebKit::WebTouchEvent touch_event; | 144 blink::WebTouchEvent touch_event; |
145 touch_event.type = WebKit::WebInputEvent::TouchStart; | 145 touch_event.type = blink::WebInputEvent::TouchStart; |
146 touch_event.touchesLength = 1; | 146 touch_event.touchesLength = 1; |
147 touch_event.touches[0].radiusX = 1; | 147 touch_event.touches[0].radiusX = 1; |
148 events.push_back(new InputEvent(touch_event, latency, false)); | 148 events.push_back(new InputEvent(touch_event, latency, false)); |
149 | 149 |
150 Verify(events); | 150 Verify(events); |
151 } | 151 } |
152 | 152 |
153 TEST_F(InputParamTraitsTest, InvalidSyntheticGestureParams) { | 153 TEST_F(InputParamTraitsTest, InvalidSyntheticGestureParams) { |
154 IPC::Message msg; | 154 IPC::Message msg; |
155 // Write invalid value for SyntheticGestureParams::GestureType. | 155 // Write invalid value for SyntheticGestureParams::GestureType. |
(...skipping 15 matching lines...) Expand all Loading... |
171 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE, | 171 ASSERT_EQ(SyntheticGestureParams::SMOOTH_SCROLL_GESTURE, |
172 gesture_params->GetGestureType()); | 172 gesture_params->GetGestureType()); |
173 SyntheticGesturePacket packet_in; | 173 SyntheticGesturePacket packet_in; |
174 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); | 174 packet_in.set_gesture_params(gesture_params.PassAs<SyntheticGestureParams>()); |
175 | 175 |
176 Verify(packet_in); | 176 Verify(packet_in); |
177 } | 177 } |
178 | 178 |
179 } // namespace | 179 } // namespace |
180 } // namespace content | 180 } // namespace content |
OLD | NEW |