OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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. | |
4 | |
5 #include "ui/events/ipc/event_param_traits.h" | |
6 | |
7 #include <limits> | |
8 | |
9 #include "ipc/ipc_message.h" | |
10 #include "ipc/ipc_param_traits.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 #include "ui/events/event.h" | |
13 #include "ui/events/event_constants.h" | |
14 #include "ui/gfx/geometry/point.h" | |
15 #include "ui/gfx/geometry/rect_f.h" | |
16 #include "ui/gfx/geometry/vector2d.h" | |
17 | |
18 namespace ui { | |
19 namespace { | |
20 | |
21 #define CAST_EVENT(T, e) (*static_cast<const T*>(e.get())) | |
Tom Sepez
2016/02/18 18:46:10
nit: just write it out rather than defining these
Mark Dittmer
2016/02/18 19:12:57
In the case of all these macros, or CAST_EVENT in
| |
22 #define FEQ(a, b) (a == b || (std::isnan(a) && std::isnan(b))) | |
23 #define ASSERT_FEQ(a, b) ASSERT_TRUE(FEQ(a, b)) | |
24 #define LIMIT(T) std::numeric_limits<T> | |
25 #define MIN(T) LIMIT(T)::min() | |
26 #define MAX(T) LIMIT(T)::max() | |
27 #define IMIN MIN(int) | |
28 #define IMAX MAX(int) | |
29 #define FMIN MIN(float) | |
30 #define FMAX MAX(float) | |
31 #define FNAN LIMIT(float)::quiet_NaN() | |
32 | |
33 class EventParamTraitsTest : public testing::Test { | |
34 protected: | |
35 // Implements event downcasting as performed by param traits. This enables | |
36 // testing the interface that client code actually uses: (de)serialization of | |
37 // scoped Event pointers that contain a concrete type. | |
38 static void CompareEvents(const ScopedEvent& a, const ScopedEvent& b) { | |
39 ASSERT_EQ(!!a, !!b); | |
40 ASSERT_EQ(a->type(), b->type()); | |
41 switch (a->type()) { | |
42 case EventType::ET_MOUSE_PRESSED: | |
43 case EventType::ET_MOUSE_DRAGGED: | |
44 case EventType::ET_MOUSE_RELEASED: | |
45 case EventType::ET_MOUSE_MOVED: | |
46 case EventType::ET_MOUSE_ENTERED: | |
47 case EventType::ET_MOUSE_EXITED: | |
48 case EventType::ET_MOUSE_CAPTURE_CHANGED: | |
49 Compare(CAST_EVENT(MouseEvent, a), CAST_EVENT(MouseEvent, b)); | |
50 break; | |
51 case EventType::ET_KEY_PRESSED: | |
52 case EventType::ET_KEY_RELEASED: | |
53 Compare(CAST_EVENT(KeyEvent, a), CAST_EVENT(KeyEvent, b)); | |
54 break; | |
55 case EventType::ET_MOUSEWHEEL: | |
56 Compare(CAST_EVENT(MouseWheelEvent, a), CAST_EVENT(MouseWheelEvent, b)); | |
57 break; | |
58 case EventType::ET_TOUCH_RELEASED: | |
59 case EventType::ET_TOUCH_PRESSED: | |
60 case EventType::ET_TOUCH_MOVED: | |
61 case EventType::ET_TOUCH_CANCELLED: | |
62 case EventType::ET_DROP_TARGET_EVENT: | |
63 Compare(CAST_EVENT(TouchEvent, a), CAST_EVENT(TouchEvent, b)); | |
64 break; | |
65 case EventType::ET_GESTURE_SCROLL_BEGIN: | |
66 case EventType::ET_GESTURE_SCROLL_END: | |
67 case EventType::ET_GESTURE_SCROLL_UPDATE: | |
68 case EventType::ET_GESTURE_SHOW_PRESS: | |
69 case EventType::ET_GESTURE_WIN8_EDGE_SWIPE: | |
70 case EventType::ET_GESTURE_TAP: | |
71 case EventType::ET_GESTURE_TAP_DOWN: | |
72 case EventType::ET_GESTURE_TAP_CANCEL: | |
73 case EventType::ET_GESTURE_BEGIN: | |
74 case EventType::ET_GESTURE_END: | |
75 case EventType::ET_GESTURE_TWO_FINGER_TAP: | |
76 case EventType::ET_GESTURE_PINCH_BEGIN: | |
77 case EventType::ET_GESTURE_PINCH_END: | |
78 case EventType::ET_GESTURE_PINCH_UPDATE: | |
79 case EventType::ET_GESTURE_LONG_PRESS: | |
80 case EventType::ET_GESTURE_LONG_TAP: | |
81 case EventType::ET_GESTURE_SWIPE: | |
82 case EventType::ET_GESTURE_TAP_UNCONFIRMED: | |
83 case EventType::ET_GESTURE_DOUBLE_TAP: | |
84 Compare(CAST_EVENT(GestureEvent, a), CAST_EVENT(GestureEvent, b)); | |
85 break; | |
86 case EventType::ET_SCROLL: | |
87 Compare(CAST_EVENT(ScrollEvent, a), CAST_EVENT(ScrollEvent, b)); | |
88 break; | |
89 case EventType::ET_SCROLL_FLING_START: | |
90 case EventType::ET_SCROLL_FLING_CANCEL: | |
91 ASSERT_EQ(!!a->flags() & MouseEventFlags::EF_FROM_TOUCH, | |
92 !!b->flags() & MouseEventFlags::EF_FROM_TOUCH); | |
93 if (a->flags() & MouseEventFlags::EF_FROM_TOUCH) { | |
94 Compare(CAST_EVENT(GestureEvent, a), CAST_EVENT(GestureEvent, b)); | |
95 } else { | |
96 Compare(CAST_EVENT(MouseEvent, a), CAST_EVENT(MouseEvent, b)); | |
97 } | |
98 break; | |
99 case EventType::ET_CANCEL_MODE: | |
100 Compare(CAST_EVENT(CancelModeEvent, a), CAST_EVENT(CancelModeEvent, b)); | |
101 break; | |
102 default: | |
103 NOTREACHED(); | |
104 } | |
105 } | |
106 | |
107 #undef CAST_EVENT | |
108 | |
109 #define CAST_EVENT(T, e) static_cast<const T&>(e) | |
110 #define COMPARE_BASE(T, a, b) Compare(CAST_EVENT(T, a), CAST_EVENT(T, b)) | |
111 | |
112 static void Compare(const Event& a, const Event& b) { | |
113 ASSERT_EQ(a.type(), b.type()); | |
114 ASSERT_EQ(a.name(), b.name()); | |
115 ASSERT_EQ(a.time_stamp(), b.time_stamp()); | |
116 ASSERT_EQ(a.flags(), b.flags()); | |
117 ASSERT_EQ(a.phase(), b.phase()); | |
118 ASSERT_EQ(a.result(), b.result()); | |
119 ASSERT_EQ(a.cancelable(), b.cancelable()); | |
120 ASSERT_EQ(a.IsShiftDown(), b.IsShiftDown()); | |
121 ASSERT_EQ(a.IsControlDown(), b.IsControlDown()); | |
122 ASSERT_EQ(a.IsAltDown(), b.IsAltDown()); | |
123 ASSERT_EQ(a.IsCommandDown(), b.IsCommandDown()); | |
124 ASSERT_EQ(a.IsAltGrDown(), b.IsAltGrDown()); | |
125 ASSERT_EQ(a.IsCapsLockOn(), b.IsCapsLockOn()); | |
126 ASSERT_EQ(a.IsKeyEvent(), b.IsKeyEvent()); | |
127 ASSERT_EQ(a.IsMouseEvent(), b.IsMouseEvent()); | |
128 ASSERT_EQ(a.IsTouchEvent(), b.IsTouchEvent()); | |
129 ASSERT_EQ(a.IsGestureEvent(), b.IsGestureEvent()); | |
130 ASSERT_EQ(a.IsEndingEvent(), b.IsEndingEvent()); | |
131 ASSERT_EQ(a.IsScrollEvent(), b.IsScrollEvent()); | |
132 ASSERT_EQ(a.IsScrollGestureEvent(), b.IsScrollGestureEvent()); | |
133 ASSERT_EQ(a.IsFlingScrollEvent(), b.IsFlingScrollEvent()); | |
134 ASSERT_EQ(a.IsMouseWheelEvent(), b.IsMouseWheelEvent()); | |
135 ASSERT_EQ(a.IsLocatedEvent(), b.IsLocatedEvent()); | |
136 ASSERT_EQ(a.handled(), b.handled()); | |
137 } | |
138 | |
139 static void Compare(const CancelModeEvent& a, const CancelModeEvent& b) { | |
140 COMPARE_BASE(Event, a, b); | |
141 } | |
142 | |
143 static void Compare(const LocatedEvent& a, const LocatedEvent& b) { | |
144 COMPARE_BASE(Event, a, b); | |
145 | |
146 ASSERT_EQ(a.x(), b.x()); | |
147 ASSERT_EQ(a.y(), b.y()); | |
148 ASSERT_EQ(a.location(), b.location()); | |
149 ASSERT_EQ(a.location_f(), b.location_f()); | |
150 ASSERT_EQ(a.root_location(), b.root_location()); | |
151 ASSERT_EQ(a.root_location_f(), b.root_location_f()); | |
152 } | |
153 | |
154 static void Compare(const MouseEvent& a, const MouseEvent& b) { | |
155 COMPARE_BASE(LocatedEvent, a, b); | |
156 | |
157 ASSERT_EQ(a.IsOnlyLeftMouseButton(), b.IsOnlyLeftMouseButton()); | |
158 ASSERT_EQ(a.IsLeftMouseButton(), b.IsLeftMouseButton()); | |
159 ASSERT_EQ(a.IsOnlyMiddleMouseButton(), b.IsOnlyMiddleMouseButton()); | |
160 ASSERT_EQ(a.IsMiddleMouseButton(), b.IsMiddleMouseButton()); | |
161 ASSERT_EQ(a.IsOnlyRightMouseButton(), b.IsOnlyRightMouseButton()); | |
162 ASSERT_EQ(a.IsRightMouseButton(), b.IsRightMouseButton()); | |
163 ASSERT_EQ(a.IsAnyButton(), b.IsAnyButton()); | |
164 ASSERT_EQ(a.button_flags(), b.button_flags()); | |
165 ASSERT_EQ(a.GetClickCount(), b.GetClickCount()); | |
166 ASSERT_EQ(a.changed_button_flags(), b.changed_button_flags()); | |
167 | |
168 Compare(a.pointer_details(), b.pointer_details()); | |
169 } | |
170 | |
171 static void Compare(const MouseWheelEvent& a, const MouseWheelEvent& b) { | |
172 COMPARE_BASE(MouseEvent, a, b); | |
173 | |
174 ASSERT_EQ(a.x_offset(), b.x_offset()); | |
175 ASSERT_EQ(a.y_offset(), b.y_offset()); | |
176 ASSERT_EQ(a.offset(), b.offset()); | |
177 } | |
178 | |
179 static void Compare(const TouchEvent& a, const TouchEvent& b) { | |
180 COMPARE_BASE(LocatedEvent, a, b); | |
181 | |
182 ASSERT_EQ(a.touch_id(), b.touch_id()); | |
183 ASSERT_EQ(a.unique_event_id(), b.unique_event_id()); | |
184 ASSERT_FEQ(a.rotation_angle(), b.rotation_angle()); | |
185 ASSERT_EQ(a.may_cause_scrolling(), b.may_cause_scrolling()); | |
186 ASSERT_EQ(a.synchronous_handling_disabled(), | |
187 b.synchronous_handling_disabled()); | |
188 | |
189 Compare(a.pointer_details(), b.pointer_details()); | |
190 } | |
191 | |
192 static void Compare(const KeyEvent& a, const KeyEvent& b) { | |
193 COMPARE_BASE(Event, a, b); | |
194 | |
195 ASSERT_EQ(a.GetCharacter(), b.GetCharacter()); | |
196 ASSERT_EQ(a.GetUnmodifiedText(), b.GetUnmodifiedText()); | |
197 ASSERT_EQ(a.GetText(), b.GetText()); | |
198 ASSERT_EQ(a.is_char(), b.is_char()); | |
199 ASSERT_EQ(a.is_repeat(), b.is_repeat()); | |
200 ASSERT_EQ(a.key_code(), b.key_code()); | |
201 ASSERT_EQ(a.GetLocatedWindowsKeyboardCode(), | |
202 b.GetLocatedWindowsKeyboardCode()); | |
203 ASSERT_EQ(a.GetConflatedWindowsKeyCode(), b.GetConflatedWindowsKeyCode()); | |
204 ASSERT_EQ(a.IsUnicodeKeyCode(), b.IsUnicodeKeyCode()); | |
205 ASSERT_EQ(a.code(), b.code()); | |
206 ASSERT_EQ(a.GetCodeString(), b.GetCodeString()); | |
207 ASSERT_EQ(a.GetDomKey(), b.GetDomKey()); | |
208 } | |
209 | |
210 static void Compare(const ScrollEvent& a, const ScrollEvent& b) { | |
211 COMPARE_BASE(MouseEvent, a, b); | |
212 | |
213 ASSERT_FEQ(a.x_offset(), b.x_offset()); | |
214 ASSERT_FEQ(a.y_offset(), b.y_offset()); | |
215 ASSERT_FEQ(a.x_offset_ordinal(), b.x_offset_ordinal()); | |
216 ASSERT_FEQ(a.y_offset_ordinal(), b.y_offset_ordinal()); | |
217 ASSERT_EQ(a.finger_count(), b.finger_count()); | |
218 } | |
219 | |
220 static void Compare(const GestureEvent& a, const GestureEvent& b) { | |
221 COMPARE_BASE(LocatedEvent, a, b); | |
222 | |
223 ASSERT_EQ(a.details(), b.details()); | |
224 } | |
225 | |
226 static void Compare(const PointerDetails& a, const PointerDetails& b) { | |
227 ASSERT_EQ(a.pointer_type, b.pointer_type); | |
228 ASSERT_FEQ(a.radius_x, b.radius_x); | |
229 ASSERT_FEQ(a.radius_y, b.radius_y); | |
230 ASSERT_FEQ(a.force, b.force); | |
231 ASSERT_FEQ(a.tilt_x, b.tilt_x); | |
232 ASSERT_FEQ(a.tilt_y, b.tilt_y); | |
233 } | |
234 | |
235 static void Verify(const ScopedEvent& event_in) { | |
236 IPC::Message msg; | |
237 IPC::ParamTraits<ScopedEvent>::Write(&msg, event_in); | |
238 | |
239 ScopedEvent event_out; | |
240 base::PickleIterator iter(msg); | |
241 EXPECT_TRUE(IPC::ParamTraits<ScopedEvent>::Read(&msg, &iter, &event_out)); | |
242 | |
243 CompareEvents(event_in, event_out); | |
244 | |
245 // Perform a sanity check that logging doesn't explode. | |
246 std::string event_in_string; | |
247 IPC::ParamTraits<ScopedEvent>::Log(event_in, &event_in_string); | |
248 std::string event_out_string; | |
249 IPC::ParamTraits<ScopedEvent>::Log(event_out, &event_out_string); | |
250 ASSERT_FALSE(event_in_string.empty()); | |
251 EXPECT_EQ(event_in_string, event_out_string); | |
252 } | |
253 | |
254 static GestureEventDetails CreateCornerCaseGestureEventDetails( | |
255 EventType type) { | |
256 GestureEventDetails details; | |
257 | |
258 // Only some types support |delta_x| and |delta_y| parameters. | |
259 if (type == EventType::ET_GESTURE_SCROLL_BEGIN || | |
260 type == EventType::ET_GESTURE_SCROLL_UPDATE || | |
261 type == EventType::ET_SCROLL_FLING_START || | |
262 type == EventType::ET_GESTURE_TWO_FINGER_TAP || | |
263 type == EventType::ET_GESTURE_SWIPE) { | |
264 details = GestureEventDetails(type, FMIN, FMAX); | |
265 } else { | |
266 details = GestureEventDetails(type); | |
267 } | |
268 | |
269 details.set_bounding_box(gfx::RectF(FMIN, FMAX, FNAN, FNAN)); | |
270 | |
271 // Note: Positive values and |type| check dodges DCHECKs that are not being | |
272 // tested here. | |
273 details.set_touch_points(IMAX); | |
274 if (type == EventType::ET_GESTURE_TAP || | |
275 type == EventType::ET_GESTURE_TAP_UNCONFIRMED || | |
276 type == EventType::ET_GESTURE_DOUBLE_TAP) { | |
277 details.set_tap_count(IMAX); | |
278 } | |
279 if (type == EventType::ET_GESTURE_PINCH_UPDATE) { | |
280 details.set_scale(FMAX); | |
281 } | |
282 | |
283 return details; | |
284 } | |
285 }; | |
286 | |
287 TEST_F(EventParamTraitsTest, GoodCancelModeEvent) { | |
288 ScopedEvent event(new CancelModeEvent()); | |
289 Verify(event); | |
290 } | |
291 | |
292 TEST_F(EventParamTraitsTest, GoodSimpleMouseEvent) { | |
293 EventType event_types[7] = { | |
294 EventType::ET_MOUSE_PRESSED, EventType::ET_MOUSE_DRAGGED, | |
295 EventType::ET_MOUSE_RELEASED, EventType::ET_MOUSE_MOVED, | |
296 EventType::ET_MOUSE_ENTERED, EventType::ET_MOUSE_EXITED, | |
297 EventType::ET_MOUSE_CAPTURE_CHANGED, | |
298 }; | |
299 for (int i = 0; i < 7; i++) { | |
300 ScopedEvent event(new MouseEvent(event_types[i], gfx::Point(), gfx::Point(), | |
301 base::TimeDelta(), 0, 0)); | |
302 Verify(event); | |
303 } | |
304 } | |
305 | |
306 TEST_F(EventParamTraitsTest, GoodCornerCaseMouseEvent) { | |
307 EventType event_types[7] = { | |
308 EventType::ET_MOUSE_PRESSED, EventType::ET_MOUSE_DRAGGED, | |
309 EventType::ET_MOUSE_RELEASED, EventType::ET_MOUSE_MOVED, | |
310 EventType::ET_MOUSE_ENTERED, EventType::ET_MOUSE_EXITED, | |
311 EventType::ET_MOUSE_CAPTURE_CHANGED, | |
312 }; | |
313 for (int i = 0; i < 7; i++) { | |
314 ScopedEvent event(new MouseEvent(event_types[i], gfx::Point(IMIN, IMIN), | |
315 gfx::Point(IMAX, IMAX), | |
316 base::TimeDelta::Max(), IMIN, IMAX)); | |
317 Verify(event); | |
318 } | |
319 } | |
320 | |
321 TEST_F(EventParamTraitsTest, GoodSimpleMouseWheelEvent) { | |
322 ScopedEvent event(new MouseWheelEvent(gfx::Vector2d(), gfx::Point(), | |
323 gfx::Point(), base::TimeDelta(), 0, 0)); | |
324 Verify(event); | |
325 } | |
326 | |
327 TEST_F(EventParamTraitsTest, GoodCornerCaseMouseWheelEvent) { | |
328 ScopedEvent event(new MouseWheelEvent( | |
329 gfx::Vector2d(IMIN, IMAX), gfx::Point(IMIN, IMIN), gfx::Point(IMAX, IMAX), | |
330 base::TimeDelta::Max(), IMIN, IMAX)); | |
331 Verify(event); | |
332 } | |
333 | |
334 TEST_F(EventParamTraitsTest, GoodSimpleTouchEvent) { | |
335 EventType event_types[5] = { | |
336 EventType::ET_TOUCH_RELEASED, EventType::ET_TOUCH_PRESSED, | |
337 EventType::ET_TOUCH_MOVED, EventType::ET_TOUCH_CANCELLED, | |
338 EventType::ET_DROP_TARGET_EVENT, | |
339 }; | |
340 for (int i = 0; i < 5; i++) { | |
341 ScopedEvent event(new TouchEvent(event_types[i], gfx::Point(), 0, 0, | |
342 base::TimeDelta(), 0.0, 0.0, 0.0, 0.0)); | |
343 Verify(event); | |
344 } | |
345 } | |
346 | |
347 TEST_F(EventParamTraitsTest, GoodCornerCaseTouchEvent) { | |
348 EventType event_types[5] = { | |
349 EventType::ET_TOUCH_RELEASED, EventType::ET_TOUCH_PRESSED, | |
350 EventType::ET_TOUCH_MOVED, EventType::ET_TOUCH_CANCELLED, | |
351 EventType::ET_DROP_TARGET_EVENT, | |
352 }; | |
353 for (int i = 0; i < 5; i++) { | |
354 ScopedEvent event(new TouchEvent(event_types[i], gfx::Point(IMIN, IMAX), | |
355 IMIN, IMAX, base::TimeDelta::Max(), FMIN, | |
356 FMAX, FNAN, FNAN)); | |
357 Verify(event); | |
358 } | |
359 } | |
360 | |
361 TEST_F(EventParamTraitsTest, GoodSimpleKeyEvent) { | |
362 EventType event_types[2] = { | |
363 EventType::ET_KEY_PRESSED, EventType::ET_KEY_RELEASED, | |
364 }; | |
365 for (int i = 0; i < 2; i++) { | |
366 ScopedEvent event(new KeyEvent(event_types[i], KeyboardCode::VKEY_UNKNOWN, | |
367 static_cast<DomCode>(0), 0, DomKey(0), | |
368 base::TimeDelta())); | |
369 Verify(event); | |
370 } | |
371 } | |
372 | |
373 TEST_F(EventParamTraitsTest, GoodCornerCaseKeyEvent) { | |
374 EventType event_types[2] = { | |
375 EventType::ET_KEY_PRESSED, EventType::ET_KEY_RELEASED, | |
376 }; | |
377 for (int i = 0; i < 2; i++) { | |
378 ScopedEvent event(new KeyEvent(event_types[i], KeyboardCode::VKEY_OEM_CLEAR, | |
379 static_cast<DomCode>(0x0c028c), IMIN, | |
380 MIN(DomKey), base::TimeDelta::Max())); | |
381 Verify(event); | |
382 } | |
383 } | |
384 | |
385 TEST_F(EventParamTraitsTest, GoodSimpleScrollEvent) { | |
386 ScopedEvent event(new ScrollEvent(EventType::ET_SCROLL, gfx::Point(), | |
387 base::TimeDelta(), 0, 0.0, 0.0, 0.0, 0.0, | |
388 0)); | |
389 Verify(event); | |
390 } | |
391 | |
392 TEST_F(EventParamTraitsTest, GoodCornerCaseScrollEvent) { | |
393 ScopedEvent event(new ScrollEvent(EventType::ET_SCROLL, gfx::Point(), | |
394 base::TimeDelta(), IMIN, FMIN, FMAX, FNAN, | |
395 FMIN, IMAX)); | |
396 Verify(event); | |
397 } | |
398 | |
399 TEST_F(EventParamTraitsTest, GoodSimpleGestureEvent) { | |
400 EventType event_types[19] = { | |
401 EventType::ET_GESTURE_SCROLL_BEGIN, | |
402 EventType::ET_GESTURE_SCROLL_END, | |
403 EventType::ET_GESTURE_SCROLL_UPDATE, | |
404 EventType::ET_GESTURE_SHOW_PRESS, | |
405 EventType::ET_GESTURE_WIN8_EDGE_SWIPE, | |
406 EventType::ET_GESTURE_TAP, | |
407 EventType::ET_GESTURE_TAP_DOWN, | |
408 EventType::ET_GESTURE_TAP_CANCEL, | |
409 EventType::ET_GESTURE_BEGIN, | |
410 EventType::ET_GESTURE_END, | |
411 EventType::ET_GESTURE_TWO_FINGER_TAP, | |
412 EventType::ET_GESTURE_PINCH_BEGIN, | |
413 EventType::ET_GESTURE_PINCH_END, | |
414 EventType::ET_GESTURE_PINCH_UPDATE, | |
415 EventType::ET_GESTURE_LONG_PRESS, | |
416 EventType::ET_GESTURE_LONG_TAP, | |
417 EventType::ET_GESTURE_SWIPE, | |
418 EventType::ET_GESTURE_TAP_UNCONFIRMED, | |
419 EventType::ET_GESTURE_DOUBLE_TAP, | |
420 }; | |
421 for (int i = 0; i < 19; i++) { | |
422 ScopedEvent event(new GestureEvent(0.0, 0.0, 0, base::TimeDelta(), | |
423 GestureEventDetails(event_types[i]))); | |
424 Verify(event); | |
425 } | |
426 } | |
427 | |
428 TEST_F(EventParamTraitsTest, GoodCornerCaseGestureEvent) { | |
429 EventType event_types[17] = { | |
430 EventType::ET_GESTURE_SCROLL_UPDATE, | |
431 EventType::ET_GESTURE_SHOW_PRESS, | |
432 EventType::ET_GESTURE_WIN8_EDGE_SWIPE, | |
433 EventType::ET_GESTURE_TAP, | |
434 EventType::ET_GESTURE_TAP_DOWN, | |
435 EventType::ET_GESTURE_TAP_CANCEL, | |
436 EventType::ET_GESTURE_BEGIN, | |
437 EventType::ET_GESTURE_END, | |
438 EventType::ET_GESTURE_TWO_FINGER_TAP, | |
439 EventType::ET_GESTURE_PINCH_BEGIN, | |
440 EventType::ET_GESTURE_PINCH_END, | |
441 EventType::ET_GESTURE_PINCH_UPDATE, | |
442 EventType::ET_GESTURE_LONG_PRESS, | |
443 EventType::ET_GESTURE_LONG_TAP, | |
444 EventType::ET_GESTURE_SWIPE, | |
445 EventType::ET_GESTURE_TAP_UNCONFIRMED, | |
446 EventType::ET_GESTURE_DOUBLE_TAP, | |
447 }; | |
448 for (int i = 0; i < 17; i++) { | |
449 ScopedEvent event( | |
450 new GestureEvent(0.0, 0.0, 0, base::TimeDelta(), | |
451 CreateCornerCaseGestureEventDetails(event_types[i]))); | |
452 Verify(event); | |
453 } | |
454 } | |
455 | |
456 #undef FEQ | |
457 #undef ASSERT_FEQ | |
458 #undef CAST_EVENT | |
459 #undef COMPARE_BASE | |
460 #undef LIMIT | |
461 #undef MIN | |
462 #undef MAX | |
463 #undef IMIN | |
464 #undef IMAX | |
465 #undef FMIN | |
466 #undef FMAX | |
467 #undef FNAN | |
468 | |
469 } // namespace | |
470 } // namespace ui | |
OLD | NEW |