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/synthetic_gesture_params.h" | 8 #include "content/common/input/synthetic_gesture_params.h" |
9 #include "content/common/input/synthetic_pinch_gesture_params.h" | 9 #include "content/common/input/synthetic_pinch_gesture_params.h" |
10 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" | 10 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" |
(...skipping 12 matching lines...) Expand all Loading... |
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); |
29 EXPECT_EQ(0, memcmp(a->web_event.get(), b->web_event.get(), a_size)); | 29 EXPECT_EQ(0, memcmp(a->web_event.get(), b->web_event.get(), a_size)); |
30 } | 30 } |
31 EXPECT_EQ(a->latency_info.latency_components().size(), | 31 EXPECT_EQ(a->latency_info.latency_components().size(), |
32 b->latency_info.latency_components().size()); | 32 b->latency_info.latency_components().size()); |
33 EXPECT_EQ(a->is_keyboard_shortcut, b->is_keyboard_shortcut); | |
34 } | 33 } |
35 | 34 |
36 static void Compare(const InputEvents* a, const InputEvents* b) { | 35 static void Compare(const InputEvents* a, const InputEvents* b) { |
37 for (size_t i = 0; i < a->size(); ++i) | 36 for (size_t i = 0; i < a->size(); ++i) |
38 Compare((*a)[i], (*b)[i]); | 37 Compare((*a)[i], (*b)[i]); |
39 } | 38 } |
40 | 39 |
41 static void Compare(const SyntheticSmoothScrollGestureParams* a, | 40 static void Compare(const SyntheticSmoothScrollGestureParams* a, |
42 const SyntheticSmoothScrollGestureParams* b) { | 41 const SyntheticSmoothScrollGestureParams* b) { |
43 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); | 42 EXPECT_EQ(a->gesture_source_type, b->gesture_source_type); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 155 } |
157 | 156 |
158 TEST_F(InputParamTraitsTest, InitializedEvents) { | 157 TEST_F(InputParamTraitsTest, InitializedEvents) { |
159 InputEvents events; | 158 InputEvents events; |
160 | 159 |
161 ui::LatencyInfo latency; | 160 ui::LatencyInfo latency; |
162 | 161 |
163 blink::WebKeyboardEvent key_event; | 162 blink::WebKeyboardEvent key_event; |
164 key_event.type = blink::WebInputEvent::RawKeyDown; | 163 key_event.type = blink::WebInputEvent::RawKeyDown; |
165 key_event.nativeKeyCode = 5; | 164 key_event.nativeKeyCode = 5; |
166 events.push_back(new InputEvent(key_event, latency, false)); | 165 events.push_back(new InputEvent(key_event, latency)); |
167 | 166 |
168 blink::WebMouseWheelEvent wheel_event; | 167 blink::WebMouseWheelEvent wheel_event; |
169 wheel_event.type = blink::WebInputEvent::MouseWheel; | 168 wheel_event.type = blink::WebInputEvent::MouseWheel; |
170 wheel_event.deltaX = 10; | 169 wheel_event.deltaX = 10; |
171 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, 1); | 170 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, 1); |
172 events.push_back(new InputEvent(wheel_event, latency, false)); | 171 events.push_back(new InputEvent(wheel_event, latency)); |
173 | 172 |
174 blink::WebMouseEvent mouse_event; | 173 blink::WebMouseEvent mouse_event; |
175 mouse_event.type = blink::WebInputEvent::MouseDown; | 174 mouse_event.type = blink::WebInputEvent::MouseDown; |
176 mouse_event.x = 10; | 175 mouse_event.x = 10; |
177 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 2, 2); | 176 latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 2, 2); |
178 events.push_back(new InputEvent(mouse_event, latency, false)); | 177 events.push_back(new InputEvent(mouse_event, latency)); |
179 | 178 |
180 blink::WebGestureEvent gesture_event; | 179 blink::WebGestureEvent gesture_event; |
181 gesture_event.type = blink::WebInputEvent::GestureScrollBegin; | 180 gesture_event.type = blink::WebInputEvent::GestureScrollBegin; |
182 gesture_event.x = -1; | 181 gesture_event.x = -1; |
183 events.push_back(new InputEvent(gesture_event, latency, false)); | 182 events.push_back(new InputEvent(gesture_event, latency)); |
184 | 183 |
185 blink::WebTouchEvent touch_event; | 184 blink::WebTouchEvent touch_event; |
186 touch_event.type = blink::WebInputEvent::TouchStart; | 185 touch_event.type = blink::WebInputEvent::TouchStart; |
187 touch_event.touchesLength = 1; | 186 touch_event.touchesLength = 1; |
188 touch_event.touches[0].radiusX = 1; | 187 touch_event.touches[0].radiusX = 1; |
189 events.push_back(new InputEvent(touch_event, latency, false)); | 188 events.push_back(new InputEvent(touch_event, latency)); |
190 | 189 |
191 Verify(events); | 190 Verify(events); |
192 } | 191 } |
193 | 192 |
194 TEST_F(InputParamTraitsTest, InvalidSyntheticGestureParams) { | 193 TEST_F(InputParamTraitsTest, InvalidSyntheticGestureParams) { |
195 IPC::Message msg; | 194 IPC::Message msg; |
196 // Write invalid value for SyntheticGestureParams::GestureType. | 195 // Write invalid value for SyntheticGestureParams::GestureType. |
197 WriteParam(&msg, -3); | 196 WriteParam(&msg, -3); |
198 | 197 |
199 SyntheticGesturePacket packet_out; | 198 SyntheticGesturePacket packet_out; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, | 242 ASSERT_EQ(SyntheticGestureParams::TAP_GESTURE, |
244 gesture_params->GetGestureType()); | 243 gesture_params->GetGestureType()); |
245 SyntheticGesturePacket packet_in; | 244 SyntheticGesturePacket packet_in; |
246 packet_in.set_gesture_params(gesture_params.Pass()); | 245 packet_in.set_gesture_params(gesture_params.Pass()); |
247 | 246 |
248 Verify(packet_in); | 247 Verify(packet_in); |
249 } | 248 } |
250 | 249 |
251 } // namespace | 250 } // namespace |
252 } // namespace content | 251 } // namespace content |
OLD | NEW |