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

Side by Side Diff: components/html_viewer/input_events_unittest.cc

Issue 1344223002: Revert of Overhaul Mandoline event transport code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « components/html_viewer/html_frame.cc ('k') | components/html_viewer/touch_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/memory/scoped_ptr.h"
6 #include "components/html_viewer/blink_input_events_type_converters.h"
7 #include "mojo/converters/input_events/input_events_type_converters.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/public/web/WebInputEvent.h"
10 #include "ui/events/event.h"
11 #include "ui/events/event_utils.h"
12 #include "ui/events/test/events_test_utils.h"
13
14 using ui::EventTimeForNow;
15 using blink::WebInputEvent;
16 using blink::WebMouseEvent;
17 using blink::WebMouseWheelEvent;
18
19 namespace mojo {
20 namespace {
21
22 TEST(InputEventLibTest, MouseEventConversion) {
23 scoped_ptr<ui::Event> mouseev(
24 new ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(1, 2),
25 gfx::Point(3, 4), EventTimeForNow(), 0, 0));
26
27 mojo::EventPtr mojo_event(Event::From(*mouseev));
28
29 EXPECT_EQ(EVENT_TYPE_POINTER_DOWN, mojo_event->action);
30 EXPECT_EQ(POINTER_KIND_MOUSE, mojo_event->pointer_data->kind);
31
32 scoped_ptr<blink::WebInputEvent> webevent =
33 mojo_event.To<scoped_ptr<blink::WebInputEvent>>();
34
35 ASSERT_TRUE(webevent);
36 EXPECT_EQ(WebInputEvent::MouseDown, webevent->type);
37
38 scoped_ptr<WebMouseEvent> web_mouse_event(
39 static_cast<WebMouseEvent*>(webevent.release()));
40
41 EXPECT_EQ(1, web_mouse_event->x);
42 EXPECT_EQ(2, web_mouse_event->y);
43 EXPECT_EQ(3, web_mouse_event->globalX);
44 EXPECT_EQ(4, web_mouse_event->globalY);
45 }
46
47 TEST(InputEventLibTest, MouseWheelEventConversionNonPrecise) {
48 scoped_ptr<ui::Event> original_wheel(new ui::MouseWheelEvent(
49 gfx::Vector2d(-1.0 * 53, -2.0 * 53), gfx::PointF(1.0, 2.0),
50 gfx::PointF(3.0, 4.0), EventTimeForNow(), 0, 0));
51
52 mojo::EventPtr mojo_event(mojo::Event::From(*original_wheel));
53
54 EXPECT_EQ(EVENT_TYPE_WHEEL, mojo_event->action);
55
56 // Exercise the blink converter.
57 scoped_ptr<blink::WebInputEvent> webevent =
58 mojo_event.To<scoped_ptr<blink::WebInputEvent>>();
59
60 ASSERT_TRUE(webevent);
61 EXPECT_EQ(WebInputEvent::MouseWheel, webevent->type);
62
63 scoped_ptr<WebMouseWheelEvent> web_wheel(
64 static_cast<WebMouseWheelEvent*>(webevent.release()));
65
66 EXPECT_EQ(1, web_wheel->x);
67 EXPECT_EQ(2, web_wheel->y);
68 EXPECT_EQ(3, web_wheel->globalX);
69 EXPECT_EQ(4, web_wheel->globalY);
70
71 EXPECT_EQ(-1.0 * ui::MouseWheelEvent::kWheelDelta, web_wheel->deltaX);
72 EXPECT_EQ(-2.0 * ui::MouseWheelEvent::kWheelDelta, web_wheel->deltaY);
73
74 EXPECT_EQ(-1.0, web_wheel->wheelTicksX);
75 EXPECT_EQ(-2.0, web_wheel->wheelTicksY);
76
77 EXPECT_FALSE(web_wheel->scrollByPage);
78 EXPECT_FALSE(web_wheel->hasPreciseScrollingDeltas);
79 EXPECT_TRUE(web_wheel->canScroll);
80
81 // Exercise the round-trip converter.
82 mojo::EventPtr mojo_other_event(mojo::Event::From(*original_wheel));
83 scoped_ptr<ui::Event> new_event =
84 mojo_other_event.To<scoped_ptr<ui::Event>>();
85 EXPECT_EQ(ui::ET_MOUSEWHEEL, new_event->type());
86
87 scoped_ptr<ui::MouseWheelEvent> ui_wheel(
88 static_cast<ui::MouseWheelEvent*>(new_event.release()));
89
90 EXPECT_EQ(-1 * ui::MouseWheelEvent::kWheelDelta, ui_wheel->x_offset());
91 EXPECT_EQ(-2 * ui::MouseWheelEvent::kWheelDelta, ui_wheel->y_offset());
92 }
93
94 } // namespace
95 } // namespace mojo
OLDNEW
« no previous file with comments | « components/html_viewer/html_frame.cc ('k') | components/html_viewer/touch_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698