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

Side by Side Diff: mojo/converters/blink/blink_input_events_type_converters_unittest.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mojo/converters/blink/blink_input_events_type_converters.h" 5 #include "mojo/converters/blink/blink_input_events_type_converters.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 8 #include "third_party/WebKit/public/web/WebInputEvent.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 10
(...skipping 27 matching lines...) Expand all
38 ASSERT_EQ(static_cast<int>(tests[i].event.GetLocatedWindowsKeyboardCode()), 38 ASSERT_EQ(static_cast<int>(tests[i].event.GetLocatedWindowsKeyboardCode()),
39 web_key_event->windowsKeyCode); 39 web_key_event->windowsKeyCode);
40 } 40 }
41 } 41 }
42 42
43 TEST(BlinkInputEventsConvertersTest, WheelEvent) { 43 TEST(BlinkInputEventsConvertersTest, WheelEvent) {
44 const int kDeltaX = 14; 44 const int kDeltaX = 14;
45 const int kDeltaY = -3; 45 const int kDeltaY = -3;
46 ui::MouseWheelEvent ui_event( 46 ui::MouseWheelEvent ui_event(
47 ui::MouseEvent(ui::ET_MOUSEWHEEL, gfx::Point(), gfx::Point(), 47 ui::MouseEvent(ui::ET_MOUSEWHEEL, gfx::Point(), gfx::Point(),
48 base::TimeDelta(), 0, 0), 48 base::TimeTicks(), 0, 0),
49 kDeltaX, kDeltaY); 49 kDeltaX, kDeltaY);
50 const std::unique_ptr<blink::WebInputEvent> web_event( 50 const std::unique_ptr<blink::WebInputEvent> web_event(
51 TypeConverter<std::unique_ptr<blink::WebInputEvent>, ui::Event>::Convert( 51 TypeConverter<std::unique_ptr<blink::WebInputEvent>, ui::Event>::Convert(
52 ui_event)); 52 ui_event));
53 ASSERT_TRUE(web_event); 53 ASSERT_TRUE(web_event);
54 ASSERT_EQ(blink::WebInputEvent::MouseWheel, web_event->type); 54 ASSERT_EQ(blink::WebInputEvent::MouseWheel, web_event->type);
55 ASSERT_EQ(0, web_event->modifiers); 55 ASSERT_EQ(0, web_event->modifiers);
56 56
57 const blink::WebMouseWheelEvent* web_wheel_event = 57 const blink::WebMouseWheelEvent* web_wheel_event =
58 static_cast<const blink::WebMouseWheelEvent*>(web_event.get()); 58 static_cast<const blink::WebMouseWheelEvent*>(web_event.get());
(...skipping 18 matching lines...) Expand all
77 {ui::ET_MOUSE_MOVED, blink::WebInputEvent::MouseMove, 77 {ui::ET_MOUSE_MOVED, blink::WebInputEvent::MouseMove,
78 ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 78 ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
79 blink::WebInputEvent::MiddleButtonDown | 79 blink::WebInputEvent::MiddleButtonDown |
80 blink::WebInputEvent::RightButtonDown, 80 blink::WebInputEvent::RightButtonDown,
81 gfx::Point(13, 3), gfx::Point(53, 3)}, 81 gfx::Point(13, 3), gfx::Point(53, 3)},
82 }; 82 };
83 83
84 for (size_t i = 0; i < arraysize(tests); i++) { 84 for (size_t i = 0; i < arraysize(tests); i++) {
85 ui::PointerEvent ui_event(ui::MouseEvent( 85 ui::PointerEvent ui_event(ui::MouseEvent(
86 tests[i].ui_type, tests[i].location, tests[i].screen_location, 86 tests[i].ui_type, tests[i].location, tests[i].screen_location,
87 base::TimeDelta(), tests[i].ui_modifiers, 0)); 87 base::TimeTicks(), tests[i].ui_modifiers, 0));
88 const std::unique_ptr<blink::WebInputEvent> web_event( 88 const std::unique_ptr<blink::WebInputEvent> web_event(
89 TypeConverter<std::unique_ptr<blink::WebInputEvent>, 89 TypeConverter<std::unique_ptr<blink::WebInputEvent>,
90 ui::Event>::Convert(ui_event)); 90 ui::Event>::Convert(ui_event));
91 ASSERT_TRUE(web_event); 91 ASSERT_TRUE(web_event);
92 ASSERT_TRUE(blink::WebInputEvent::isMouseEventType(web_event->type)); 92 ASSERT_TRUE(blink::WebInputEvent::isMouseEventType(web_event->type));
93 ASSERT_EQ(tests[i].web_type, web_event->type); 93 ASSERT_EQ(tests[i].web_type, web_event->type);
94 ASSERT_EQ(tests[i].web_modifiers, web_event->modifiers); 94 ASSERT_EQ(tests[i].web_modifiers, web_event->modifiers);
95 95
96 const blink::WebMouseEvent* web_mouse_event = 96 const blink::WebMouseEvent* web_mouse_event =
97 static_cast<const blink::WebMouseEvent*>(web_event.get()); 97 static_cast<const blink::WebMouseEvent*>(web_event.get());
(...skipping 15 matching lines...) Expand all
113 } tests[] = { 113 } tests[] = {
114 {ui::ET_TOUCH_PRESSED, blink::WebInputEvent::TouchStart, gfx::Point(3, 5), 114 {ui::ET_TOUCH_PRESSED, blink::WebInputEvent::TouchStart, gfx::Point(3, 5),
115 1, 4.5, 5.5}, 115 1, 4.5, 5.5},
116 {ui::ET_TOUCH_RELEASED, blink::WebInputEvent::TouchEnd, 116 {ui::ET_TOUCH_RELEASED, blink::WebInputEvent::TouchEnd,
117 gfx::Point(100, 1), 2, 3.0, 3.0}, 117 gfx::Point(100, 1), 2, 3.0, 3.0},
118 }; 118 };
119 119
120 for (size_t i = 0; i < arraysize(tests); i++) { 120 for (size_t i = 0; i < arraysize(tests); i++) {
121 ui::PointerEvent ui_event(ui::TouchEvent( 121 ui::PointerEvent ui_event(ui::TouchEvent(
122 tests[i].ui_type, tests[i].location, 0, tests[i].touch_id, 122 tests[i].ui_type, tests[i].location, 0, tests[i].touch_id,
123 base::TimeDelta(), tests[i].radius_x, tests[i].radius_y, 0.0, 0.0)); 123 base::TimeTicks(), tests[i].radius_x, tests[i].radius_y, 0.0, 0.0));
124 const std::unique_ptr<blink::WebInputEvent> web_event( 124 const std::unique_ptr<blink::WebInputEvent> web_event(
125 TypeConverter<std::unique_ptr<blink::WebInputEvent>, 125 TypeConverter<std::unique_ptr<blink::WebInputEvent>,
126 ui::Event>::Convert(ui_event)); 126 ui::Event>::Convert(ui_event));
127 ASSERT_TRUE(web_event); 127 ASSERT_TRUE(web_event);
128 ASSERT_TRUE(blink::WebInputEvent::isTouchEventType(web_event->type)); 128 ASSERT_TRUE(blink::WebInputEvent::isTouchEventType(web_event->type));
129 ASSERT_EQ(tests[i].web_type, web_event->type); 129 ASSERT_EQ(tests[i].web_type, web_event->type);
130 ASSERT_EQ(0, web_event->modifiers); 130 ASSERT_EQ(0, web_event->modifiers);
131 131
132 const blink::WebTouchEvent* web_touch_event = 132 const blink::WebTouchEvent* web_touch_event =
133 static_cast<const blink::WebTouchEvent*>(web_event.get()); 133 static_cast<const blink::WebTouchEvent*>(web_event.get());
134 const blink::WebTouchPoint* web_touch_point = 134 const blink::WebTouchPoint* web_touch_point =
135 &web_touch_event->touches[tests[i].touch_id]; 135 &web_touch_event->touches[tests[i].touch_id];
136 ASSERT_EQ(tests[i].radius_x, web_touch_point->radiusX); 136 ASSERT_EQ(tests[i].radius_x, web_touch_point->radiusX);
137 ASSERT_EQ(tests[i].radius_y, web_touch_point->radiusY); 137 ASSERT_EQ(tests[i].radius_y, web_touch_point->radiusY);
138 } 138 }
139 } 139 }
140 } // namespace mojo 140 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/converters/blink/blink_input_events_type_converters.cc ('k') | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698