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

Side by Side Diff: ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc

Issue 869613003: [PATCH 5/11] ozone: evdev: Replace dispatch callbacks with an interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: namespace ui Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <linux/input.h> 7 #include <linux/input.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 const char kTestDevicePath[] = "/dev/input/test-device"; 36 const char kTestDevicePath[] = "/dev/input/test-device";
37 37
38 } // namespace 38 } // namespace
39 39
40 namespace ui { 40 namespace ui {
41 41
42 class MockTabletEventConverterEvdev : public TabletEventConverterEvdev { 42 class MockTabletEventConverterEvdev : public TabletEventConverterEvdev {
43 public: 43 public:
44 MockTabletEventConverterEvdev( 44 MockTabletEventConverterEvdev(int fd,
45 int fd, 45 base::FilePath path,
46 base::FilePath path, 46 CursorDelegateEvdev* cursor,
47 CursorDelegateEvdev* cursor, 47 DeviceEventDispatcherEvdev* dispatcher);
48 const MouseMoveEventDispatchCallback& mouse_move_callback,
49 const MouseButtonEventDispatchCallback& mouse_button_callback);
50 ~MockTabletEventConverterEvdev() override {}; 48 ~MockTabletEventConverterEvdev() override {};
51 49
52 void ConfigureReadMock(struct input_event* queue, 50 void ConfigureReadMock(struct input_event* queue,
53 long read_this_many, 51 long read_this_many,
54 long queue_index); 52 long queue_index);
55 53
56 // Actually dispatch the event reader code. 54 // Actually dispatch the event reader code.
57 void ReadNow() { 55 void ReadNow() {
58 OnFileCanReadWithoutBlocking(read_pipe_); 56 OnFileCanReadWithoutBlocking(read_pipe_);
59 base::RunLoop().RunUntilIdle(); 57 base::RunLoop().RunUntilIdle();
(...skipping 29 matching lines...) Expand all
89 private: 87 private:
90 gfx::PointF cursor_location_; 88 gfx::PointF cursor_location_;
91 gfx::Rect cursor_display_bounds_; 89 gfx::Rect cursor_display_bounds_;
92 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev); 90 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev);
93 }; 91 };
94 92
95 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev( 93 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev(
96 int fd, 94 int fd,
97 base::FilePath path, 95 base::FilePath path,
98 CursorDelegateEvdev* cursor, 96 CursorDelegateEvdev* cursor,
99 const MouseMoveEventDispatchCallback& mouse_move_callback, 97 DeviceEventDispatcherEvdev* dispatcher)
100 const MouseButtonEventDispatchCallback& mouse_button_callback)
101 : TabletEventConverterEvdev(fd, 98 : TabletEventConverterEvdev(fd,
102 path, 99 path,
103 1, 100 1,
104 INPUT_DEVICE_UNKNOWN, 101 INPUT_DEVICE_UNKNOWN,
105 cursor, 102 cursor,
106 EventDeviceInfo(), 103 EventDeviceInfo(),
107 mouse_move_callback, 104 dispatcher) {
108 mouse_button_callback) {
109 // Real values taken from Wacom Intuos 4 105 // Real values taken from Wacom Intuos 4
110 x_abs_min_ = 0; 106 x_abs_min_ = 0;
111 x_abs_range_ = 65024; 107 x_abs_range_ = 65024;
112 y_abs_min_ = 0; 108 y_abs_min_ = 0;
113 y_abs_range_ = 40640; 109 y_abs_range_ = 40640;
114 110
115 int fds[2]; 111 int fds[2];
116 112
117 if (pipe(fds)) 113 if (pipe(fds))
118 PLOG(FATAL) << "failed pipe"; 114 PLOG(FATAL) << "failed pipe";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 178
183 cursor_.reset(new ui::MockTabletCursorEvdev()); 179 cursor_.reset(new ui::MockTabletCursorEvdev());
184 device_manager_.reset(new ui::MockDeviceManager); 180 device_manager_.reset(new ui::MockDeviceManager);
185 event_factory_.reset(new ui::TestEventFactoryEvdev( 181 event_factory_.reset(new ui::TestEventFactoryEvdev(
186 cursor_.get(), device_manager_.get(), 182 cursor_.get(), device_manager_.get(),
187 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), 183 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(),
188 base::Bind(&TabletEventConverterEvdevTest::DispatchEventForTest, 184 base::Bind(&TabletEventConverterEvdevTest::DispatchEventForTest,
189 base::Unretained(this)))); 185 base::Unretained(this))));
190 device_.reset(new ui::MockTabletEventConverterEvdev( 186 device_.reset(new ui::MockTabletEventConverterEvdev(
191 events_in_, base::FilePath(kTestDevicePath), cursor_.get(), 187 events_in_, base::FilePath(kTestDevicePath), cursor_.get(),
192 base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent, 188 event_factory_.get()));
193 base::Unretained(event_factory_.get())),
194 base::Bind(&ui::EventFactoryEvdev::PostMouseButtonEvent,
195 base::Unretained(event_factory_.get()))));
196 } 189 }
197 190
198 void TearDown() override { 191 void TearDown() override {
199 cursor_.reset(); 192 cursor_.reset();
200 device_.reset(); 193 device_.reset();
201 } 194 }
202 195
203 ui::MockTabletEventConverterEvdev* device() { return device_.get(); } 196 ui::MockTabletEventConverterEvdev* device() { return device_.get(); }
204 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } 197 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); }
205 198
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 463
471 struct input_event mock_kernel_queue[] = { 464 struct input_event mock_kernel_queue[] = {
472 {{0, 0}, EV_ABS, ABS_X, 0}, 465 {{0, 0}, EV_ABS, ABS_X, 0},
473 {{0, 0}, EV_ABS, ABS_Y, 0}, 466 {{0, 0}, EV_ABS, ABS_Y, 0},
474 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 467 {{0, 0}, EV_SYN, SYN_REPORT, 0},
475 }; 468 };
476 469
477 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 470 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
478 EXPECT_EQ(0u, size()); 471 EXPECT_EQ(0u, size());
479 } 472 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/tablet_event_converter_evdev.cc ('k') | ui/events/ozone/evdev/touch_event_converter_evdev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698