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

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

Issue 1155543002: ozone: Use DeviceCapabilities in TabletEventConverterEvdev unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « ui/events/ozone/evdev/tablet_event_converter_evdev.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/posix/eintr_wrapper.h" 15 #include "base/posix/eintr_wrapper.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/events/ozone/device/device_manager.h" 20 #include "ui/events/ozone/device/device_manager.h"
21 #include "ui/events/ozone/evdev/event_converter_test_util.h" 21 #include "ui/events/ozone/evdev/event_converter_test_util.h"
22 #include "ui/events/ozone/evdev/event_device_test_util.h"
22 #include "ui/events/ozone/evdev/event_factory_evdev.h" 23 #include "ui/events/ozone/evdev/event_factory_evdev.h"
23 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" 24 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
24 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 25 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
25 #include "ui/events/platform/platform_event_dispatcher.h" 26 #include "ui/events/platform/platform_event_dispatcher.h"
26 #include "ui/events/platform/platform_event_source.h" 27 #include "ui/events/platform/platform_event_source.h"
27 28
28 namespace { 29 namespace {
29 30
30 static int SetNonBlocking(int fd) { 31 static int SetNonBlocking(int fd) {
31 int flags = fcntl(fd, F_GETFL, 0); 32 int flags = fcntl(fd, F_GETFL, 0);
32 if (flags == -1) 33 if (flags == -1)
33 flags = 0; 34 flags = 0;
34 return fcntl(fd, F_SETFL, flags | O_NONBLOCK); 35 return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
35 } 36 }
36 37
37 const char kTestDevicePath[] = "/dev/input/test-device"; 38 const char kTestDevicePath[] = "/dev/input/test-device";
38 39
40 const ui::DeviceAbsoluteAxis kWacomIntuos5SPenAbsAxes[] = {
41 {ABS_X, {0, 0, 31496, 4, 0, 200}},
42 {ABS_Y, {0, 0, 19685, 4, 0, 200}},
43 {ABS_Z, {0, -900, 899, 0, 0, 0}},
44 {ABS_RZ, {0, -900, 899, 0, 0, 0}},
45 {ABS_THROTTLE, {0, -1023, 1023, 0, 0, 0}},
46 {ABS_WHEEL, {0, 0, 1023, 0, 0, 0}},
47 {ABS_PRESSURE, {0, 0, 2047, 0, 0, 0}},
48 {ABS_DISTANCE, {0, 0, 63, 0, 0, 0}},
49 {ABS_TILT_X, {0, 0, 127, 0, 0, 0}},
50 {ABS_TILT_Y, {0, 0, 127, 0, 0, 0}},
51 {ABS_MISC, {0, 0, 0, 0, 0, 0}},
52 };
53
54 const ui::DeviceCapabilities kWacomIntuos5SPen = {
55 /* path */ "/sys/devices/pci0000:00/0000:00:14.0/usb1/"
56 "1-1/1-1:1.0/input/input19/event5",
57 /* name */ "Wacom Intuos5 touch S Pen",
58 /* phys */ "",
59 /* uniq */ "",
60 /* bustype */ "0003",
61 /* vendor */ "056a",
62 /* product */ "0026",
63 /* version */ "0107",
64 /* prop */ "1",
65 /* ev */ "1f",
66 /* key */ "1cdf 1f007f 0 0 0 0",
67 /* rel */ "100",
68 /* abs */ "1000f000167",
69 /* msc */ "1",
70 /* sw */ "0",
71 /* led */ "0",
72 /* ff */ "0",
73 kWacomIntuos5SPenAbsAxes,
74 arraysize(kWacomIntuos5SPenAbsAxes),
75 };
76
39 } // namespace 77 } // namespace
40 78
41 namespace ui { 79 namespace ui {
42 80
43 class MockTabletEventConverterEvdev : public TabletEventConverterEvdev { 81 class MockTabletEventConverterEvdev : public TabletEventConverterEvdev {
44 public: 82 public:
45 MockTabletEventConverterEvdev(int fd, 83 MockTabletEventConverterEvdev(int fd,
46 base::FilePath path, 84 base::FilePath path,
47 CursorDelegateEvdev* cursor, 85 CursorDelegateEvdev* cursor,
86 const EventDeviceInfo& devinfo,
48 DeviceEventDispatcherEvdev* dispatcher); 87 DeviceEventDispatcherEvdev* dispatcher);
49 ~MockTabletEventConverterEvdev() override {}; 88 ~MockTabletEventConverterEvdev() override {};
50 89
51 void ConfigureReadMock(struct input_event* queue, 90 void ConfigureReadMock(struct input_event* queue,
52 long read_this_many, 91 long read_this_many,
53 long queue_index); 92 long queue_index);
54 93
55 // Actually dispatch the event reader code. 94 // Actually dispatch the event reader code.
56 void ReadNow() { 95 void ReadNow() {
57 OnFileCanReadWithoutBlocking(read_pipe_); 96 OnFileCanReadWithoutBlocking(read_pipe_);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 private: 129 private:
91 gfx::PointF cursor_location_; 130 gfx::PointF cursor_location_;
92 gfx::Rect cursor_confined_bounds_; 131 gfx::Rect cursor_confined_bounds_;
93 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev); 132 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev);
94 }; 133 };
95 134
96 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev( 135 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev(
97 int fd, 136 int fd,
98 base::FilePath path, 137 base::FilePath path,
99 CursorDelegateEvdev* cursor, 138 CursorDelegateEvdev* cursor,
139 const EventDeviceInfo& devinfo,
100 DeviceEventDispatcherEvdev* dispatcher) 140 DeviceEventDispatcherEvdev* dispatcher)
101 : TabletEventConverterEvdev(fd, 141 : TabletEventConverterEvdev(fd,
102 path, 142 path,
103 1, 143 1,
104 INPUT_DEVICE_UNKNOWN, 144 INPUT_DEVICE_UNKNOWN,
105 cursor, 145 cursor,
106 EventDeviceInfo(), 146 devinfo,
107 dispatcher) { 147 dispatcher) {
108 // Real values taken from Wacom Intuos 4
109 x_abs_min_ = 0;
110 x_abs_range_ = 65024;
111 y_abs_min_ = 0;
112 y_abs_range_ = 40640;
113
114 int fds[2]; 148 int fds[2];
115 149
116 if (pipe(fds)) 150 if (pipe(fds))
117 PLOG(FATAL) << "failed pipe"; 151 PLOG(FATAL) << "failed pipe";
118 152
119 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1])) 153 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1]))
120 << "failed to set non-blocking: " << strerror(errno); 154 << "failed to set non-blocking: " << strerror(errno);
121 155
122 read_pipe_ = fds[0]; 156 read_pipe_ = fds[0];
123 write_pipe_ = fds[1]; 157 write_pipe_ = fds[1];
(...skipping 27 matching lines...) Expand all
151 185
152 cursor_.reset(new ui::MockTabletCursorEvdev()); 186 cursor_.reset(new ui::MockTabletCursorEvdev());
153 device_manager_ = ui::CreateDeviceManagerForTest(); 187 device_manager_ = ui::CreateDeviceManagerForTest();
154 event_factory_ = ui::CreateEventFactoryEvdevForTest( 188 event_factory_ = ui::CreateEventFactoryEvdevForTest(
155 cursor_.get(), device_manager_.get(), 189 cursor_.get(), device_manager_.get(),
156 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), 190 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(),
157 base::Bind(&TabletEventConverterEvdevTest::DispatchEventForTest, 191 base::Bind(&TabletEventConverterEvdevTest::DispatchEventForTest,
158 base::Unretained(this))); 192 base::Unretained(this)));
159 dispatcher_ = 193 dispatcher_ =
160 ui::CreateDeviceEventDispatcherEvdevForTest(event_factory_.get()); 194 ui::CreateDeviceEventDispatcherEvdevForTest(event_factory_.get());
161 device_.reset(new ui::MockTabletEventConverterEvdev(
162 events_in_, base::FilePath(kTestDevicePath), cursor_.get(),
163 dispatcher_.get()));
164 } 195 }
165 196
166 void TearDown() override { 197 void TearDown() override {
167 cursor_.reset(); 198 cursor_.reset();
168 device_.reset();
169 } 199 }
170 200
171 ui::MockTabletEventConverterEvdev* device() { return device_.get(); } 201 ui::MockTabletEventConverterEvdev* CreateDevice(
202 const ui::DeviceCapabilities& caps) {
203 ui::EventDeviceInfo devinfo;
204 CapabilitiesToDeviceInfo(caps, &devinfo);
205 return new ui::MockTabletEventConverterEvdev(
206 events_in_, base::FilePath(kTestDevicePath), cursor_.get(), devinfo,
207 dispatcher_.get());
208 }
209
172 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } 210 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); }
173 211
174 unsigned size() { return dispatched_events_.size(); } 212 unsigned size() { return dispatched_events_.size(); }
175 ui::MouseEvent* dispatched_event(unsigned index) { 213 ui::MouseEvent* dispatched_event(unsigned index) {
176 DCHECK_GT(dispatched_events_.size(), index); 214 DCHECK_GT(dispatched_events_.size(), index);
177 ui::Event* ev = dispatched_events_[index]; 215 ui::Event* ev = dispatched_events_[index];
178 DCHECK(ev->IsMouseEvent()); 216 DCHECK(ev->IsMouseEvent());
179 return static_cast<ui::MouseEvent*>(ev); 217 return static_cast<ui::MouseEvent*>(ev);
180 } 218 }
181 219
182 void DispatchEventForTest(ui::Event* event) { 220 void DispatchEventForTest(ui::Event* event) {
183 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); 221 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event);
184 dispatched_events_.push_back(cloned_event.release()); 222 dispatched_events_.push_back(cloned_event.release());
185 } 223 }
186 224
187 private: 225 private:
188 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; 226 scoped_ptr<ui::MockTabletCursorEvdev> cursor_;
189 scoped_ptr<ui::DeviceManager> device_manager_; 227 scoped_ptr<ui::DeviceManager> device_manager_;
190 scoped_ptr<ui::EventFactoryEvdev> event_factory_; 228 scoped_ptr<ui::EventFactoryEvdev> event_factory_;
191 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; 229 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_;
192 scoped_ptr<ui::MockTabletEventConverterEvdev> device_;
193 230
194 ScopedVector<ui::Event> dispatched_events_; 231 ScopedVector<ui::Event> dispatched_events_;
195 232
196 int events_out_; 233 int events_out_;
197 int events_in_; 234 int events_in_;
198 235
199 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdevTest); 236 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdevTest);
200 }; 237 };
201 238
202 #define EPSILON 20 239 #define EPSILON 20
203 240
204 // Uses real data captured from Wacom Intuos 4 241 // Uses real data captured from Wacom Intuos 5 Pen
205 TEST_F(TabletEventConverterEvdevTest, MoveTopLeft) { 242 TEST_F(TabletEventConverterEvdevTest, MoveTopLeft) {
206 ui::MockTabletEventConverterEvdev* dev = device(); 243 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
244 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
207 245
208 struct input_event mock_kernel_queue[] = { 246 struct input_event mock_kernel_queue[] = {
209 {{0, 0}, EV_ABS, ABS_Y, 616}, 247 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
210 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 248 {{0, 0}, EV_ABS, ABS_X, 477},
211 {{0, 0}, EV_ABS, ABS_TILT_X, 50}, 249 {{0, 0}, EV_ABS, ABS_TILT_X, 66},
212 {{0, 0}, EV_ABS, ABS_TILT_Y, 7}, 250 {{0, 0}, EV_ABS, ABS_TILT_Y, 62},
213 {{0, 0}, EV_ABS, ABS_MISC, 1050626}, 251 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
214 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 252 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
215 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 253 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
216 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 254 {{0, 0}, EV_SYN, SYN_REPORT, 0},
217 {{0, 0}, EV_ABS, ABS_Y, 0},
218 {{0, 0}, EV_ABS, ABS_DISTANCE, 0}, 255 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
219 {{0, 0}, EV_ABS, ABS_TILT_X, 0}, 256 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
257 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
220 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 258 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
221 {{0, 0}, EV_ABS, ABS_MISC, 0}, 259 {{0, 0}, EV_ABS, ABS_MISC, 0},
222 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 260 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
223 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 261 {{0, 0}, EV_SYN, SYN_REPORT, 0},
224 }; 262 };
225 263
226 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 264 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
227 EXPECT_EQ(1u, size()); 265 EXPECT_EQ(1u, size());
228 266
229 ui::MouseEvent* event = dispatched_event(0); 267 ui::MouseEvent* event = dispatched_event(0);
230 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 268 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
231 269
232 EXPECT_LT(cursor()->GetLocation().x(), EPSILON); 270 EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
233 EXPECT_LT(cursor()->GetLocation().y(), EPSILON); 271 EXPECT_LT(cursor()->GetLocation().y(), EPSILON);
234 } 272 }
235 273
236 TEST_F(TabletEventConverterEvdevTest, MoveTopRight) { 274 TEST_F(TabletEventConverterEvdevTest, MoveTopRight) {
237 ui::MockTabletEventConverterEvdev* dev = device(); 275 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
276 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
238 277
239 struct input_event mock_kernel_queue[] = { 278 struct input_event mock_kernel_queue[] = {
240 {{0, 0}, EV_ABS, ABS_X, 65024}, 279 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
241 {{0, 0}, EV_ABS, ABS_Y, 33}, 280 {{0, 0}, EV_ABS, ABS_X, 31496},
242 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 281 {{0, 0}, EV_ABS, ABS_Y, 109},
243 {{0, 0}, EV_ABS, ABS_TILT_X, 109}, 282 {{0, 0}, EV_ABS, ABS_TILT_X, 66},
244 {{0, 0}, EV_ABS, ABS_TILT_Y, 59}, 283 {{0, 0}, EV_ABS, ABS_TILT_Y, 61},
245 {{0, 0}, EV_ABS, ABS_MISC, 1050626}, 284 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
246 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 285 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
247 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 286 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
248 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 287 {{0, 0}, EV_SYN, SYN_REPORT, 0},
249 {{0, 0}, EV_ABS, ABS_X, 0}, 288 {{0, 0}, EV_ABS, ABS_X, 0},
250 {{0, 0}, EV_ABS, ABS_DISTANCE, 0}, 289 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
251 {{0, 0}, EV_ABS, ABS_TILT_X, 0}, 290 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
252 {{0, 0}, EV_ABS, ABS_TILT_Y, 0}, 291 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
253 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 292 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
254 {{0, 0}, EV_ABS, ABS_MISC, 0}, 293 {{0, 0}, EV_ABS, ABS_MISC, 0},
255 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 294 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
256 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 295 {{0, 0}, EV_SYN, SYN_REPORT, 0},
257 }; 296 };
258 297
259 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 298 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
260 EXPECT_EQ(1u, size()); 299 EXPECT_EQ(1u, size());
261 300
262 ui::MouseEvent* event = dispatched_event(0); 301 ui::MouseEvent* event = dispatched_event(0);
263 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 302 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
264 303
265 EXPECT_GT(cursor()->GetLocation().x(), 304 EXPECT_GT(cursor()->GetLocation().x(),
266 cursor()->GetCursorConfinedBounds().width() - EPSILON); 305 cursor()->GetCursorConfinedBounds().width() - EPSILON);
267 EXPECT_LT(cursor()->GetLocation().y(), EPSILON); 306 EXPECT_LT(cursor()->GetLocation().y(), EPSILON);
268 } 307 }
269 308
270 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) { 309 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) {
271 ui::MockTabletEventConverterEvdev* dev = device(); 310 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
311 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
272 312
273 struct input_event mock_kernel_queue[] = { 313 struct input_event mock_kernel_queue[] = {
274 {{0, 0}, EV_ABS, ABS_Y, 40640}, 314 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
275 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 315 {{0, 0}, EV_ABS, ABS_Y, 19685},
276 {{0, 0}, EV_ABS, ABS_TILT_X, 95}, 316 {{0, 0}, EV_ABS, ABS_TILT_X, 64},
277 {{0, 0}, EV_ABS, ABS_TILT_Y, 44}, 317 {{0, 0}, EV_ABS, ABS_TILT_Y, 61},
278 {{0, 0}, EV_ABS, ABS_MISC, 1050626}, 318 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
279 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 319 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
280 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 320 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
281 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 321 {{0, 0}, EV_SYN, SYN_REPORT, 0},
322 {{0, 0}, EV_ABS, ABS_X, 0},
282 {{0, 0}, EV_ABS, ABS_Y, 0}, 323 {{0, 0}, EV_ABS, ABS_Y, 0},
283 {{0, 0}, EV_ABS, ABS_DISTANCE, 0}, 324 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
284 {{0, 0}, EV_ABS, ABS_TILT_X, 0}, 325 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
285 {{0, 0}, EV_ABS, ABS_TILT_Y, 0}, 326 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
286 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 327 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
287 {{0, 0}, EV_ABS, ABS_MISC, 0}, 328 {{0, 0}, EV_ABS, ABS_MISC, 0},
288 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 329 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
289 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 330 {{0, 0}, EV_SYN, SYN_REPORT, 0},
290 }; 331 };
291 332
292 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 333 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
293 EXPECT_EQ(1u, size()); 334 EXPECT_EQ(1u, size());
294 335
295 ui::MouseEvent* event = dispatched_event(0); 336 ui::MouseEvent* event = dispatched_event(0);
296 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 337 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
297 338
298 EXPECT_LT(cursor()->GetLocation().x(), EPSILON); 339 EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
299 EXPECT_GT(cursor()->GetLocation().y(), 340 EXPECT_GT(cursor()->GetLocation().y(),
300 cursor()->GetCursorConfinedBounds().height() - EPSILON); 341 cursor()->GetCursorConfinedBounds().height() - EPSILON);
301 } 342 }
302 343
303 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) { 344 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) {
304 ui::MockTabletEventConverterEvdev* dev = device(); 345 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
346 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
305 347
306 struct input_event mock_kernel_queue[] = { 348 struct input_event mock_kernel_queue[] = {
307 {{0, 0}, EV_ABS, ABS_X, 65024}, 349 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
308 {{0, 0}, EV_ABS, ABS_Y, 40640}, 350 {{0, 0}, EV_ABS, ABS_X, 31496},
309 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 351 {{0, 0}, EV_ABS, ABS_Y, 19685},
310 {{0, 0}, EV_ABS, ABS_TILT_X, 127}, 352 {{0, 0}, EV_ABS, ABS_TILT_X, 67},
311 {{0, 0}, EV_ABS, ABS_TILT_Y, 89}, 353 {{0, 0}, EV_ABS, ABS_TILT_Y, 63},
312 {{0, 0}, EV_ABS, ABS_MISC, 1050626}, 354 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
313 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 355 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
314 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 356 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
315 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 357 {{0, 0}, EV_SYN, SYN_REPORT, 0},
316 {{0, 0}, EV_ABS, ABS_X, 0}, 358 {{0, 0}, EV_ABS, ABS_X, 0},
317 {{0, 0}, EV_ABS, ABS_Y, 0}, 359 {{0, 0}, EV_ABS, ABS_Y, 0},
318 {{0, 0}, EV_ABS, ABS_DISTANCE, 0}, 360 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
319 {{0, 0}, EV_ABS, ABS_TILT_X, 0}, 361 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
320 {{0, 0}, EV_ABS, ABS_TILT_Y, 0}, 362 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
321 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 363 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
322 {{0, 0}, EV_ABS, ABS_MISC, 0}, 364 {{0, 0}, EV_ABS, ABS_MISC, 0},
323 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 365 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
324 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 366 {{0, 0}, EV_SYN, SYN_REPORT, 0},
325 }; 367 };
326 368
327 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 369 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
328 EXPECT_EQ(1u, size()); 370 EXPECT_EQ(1u, size());
329 371
330 ui::MouseEvent* event = dispatched_event(0); 372 ui::MouseEvent* event = dispatched_event(0);
331 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 373 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
332 374
333 EXPECT_GT(cursor()->GetLocation().x(), 375 EXPECT_GT(cursor()->GetLocation().x(),
334 cursor()->GetCursorConfinedBounds().height() - EPSILON); 376 cursor()->GetCursorConfinedBounds().height() - EPSILON);
335 EXPECT_GT(cursor()->GetLocation().y(), 377 EXPECT_GT(cursor()->GetLocation().y(),
336 cursor()->GetCursorConfinedBounds().height() - EPSILON); 378 cursor()->GetCursorConfinedBounds().height() - EPSILON);
337 } 379 }
338 380
339 TEST_F(TabletEventConverterEvdevTest, Tap) { 381 TEST_F(TabletEventConverterEvdevTest, Tap) {
340 ui::MockTabletEventConverterEvdev* dev = device(); 382 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
383 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
341 384
342 struct input_event mock_kernel_queue[] = { 385 struct input_event mock_kernel_queue[] = {
343 {{0, 0}, EV_ABS, ABS_X, 31628}, 386 {{0, 0}, EV_ABS, ABS_X, 15456},
344 {{0, 0}, EV_ABS, ABS_Y, 21670}, 387 {{0, 0}, EV_ABS, ABS_Y, 8605},
345 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 388 {{0, 0}, EV_ABS, ABS_DISTANCE, 49},
346 {{0, 0}, EV_ABS, ABS_TILT_X, 114}, 389 {{0, 0}, EV_ABS, ABS_TILT_X, 68},
347 {{0, 0}, EV_ABS, ABS_TILT_Y, 85}, 390 {{0, 0}, EV_ABS, ABS_TILT_Y, 64},
348 {{0, 0}, EV_ABS, ABS_MISC, 1050626}, 391 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
349 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 392 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
350 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 393 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
351 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 394 {{0, 0}, EV_SYN, SYN_REPORT, 0},
352 {{0, 0}, EV_ABS, ABS_X, 32094}, 395 {{0, 0}, EV_ABS, ABS_X, 15725},
353 {{0, 0}, EV_ABS, ABS_DISTANCE, 17}, 396 {{0, 0}, EV_ABS, ABS_Y, 8755},
354 {{0, 0}, EV_ABS, ABS_PRESSURE, 883}, 397 {{0, 0}, EV_ABS, ABS_DISTANCE, 29},
355 {{0, 0}, EV_ABS, ABS_TILT_Y, 68}, 398 {{0, 0}, EV_ABS, ABS_PRESSURE, 992},
356 {{0, 0}, EV_KEY, BTN_TOUCH, 1}, 399 {{0, 0}, EV_KEY, BTN_TOUCH, 1},
357 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 400 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
358 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 401 {{0, 0}, EV_SYN, SYN_REPORT, 0},
359 {{0, 0}, EV_ABS, ABS_X, 32036}, 402 {{0, 0}, EV_ABS, ABS_X, 15922},
360 {{0, 0}, EV_ABS, ABS_Y, 21658}, 403 {{0, 0}, EV_ABS, ABS_Y, 8701},
361 {{0, 0}, EV_ABS, ABS_DISTANCE, 19}, 404 {{0, 0}, EV_ABS, ABS_DISTANCE, 32},
362 {{0, 0}, EV_ABS, ABS_PRESSURE, 0}, 405 {{0, 0}, EV_ABS, ABS_PRESSURE, 0},
363 {{0, 0}, EV_KEY, BTN_TOUCH, 0}, 406 {{0, 0}, EV_KEY, BTN_TOUCH, 0},
364 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 407 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
365 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 408 {{0, 0}, EV_SYN, SYN_REPORT, 0},
366 {{0, 0}, EV_ABS, ABS_X, 0}, 409 {{0, 0}, EV_ABS, ABS_X, 0},
367 {{0, 0}, EV_ABS, ABS_Y, 0}, 410 {{0, 0}, EV_ABS, ABS_Y, 0},
368 {{0, 0}, EV_ABS, ABS_DISTANCE, 0}, 411 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
369 {{0, 0}, EV_ABS, ABS_TILT_X, 0}, 412 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
370 {{0, 0}, EV_ABS, ABS_TILT_Y, 0}, 413 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
371 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 414 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
372 {{0, 0}, EV_ABS, ABS_MISC, 0}, 415 {{0, 0}, EV_ABS, ABS_MISC, 0},
373 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 416 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
374 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 417 {{0, 0}, EV_SYN, SYN_REPORT, 0},
375 }; 418 };
376 419
377 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 420 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
378 EXPECT_EQ(3u, size()); 421 EXPECT_EQ(3u, size());
379 422
380 ui::MouseEvent* event = dispatched_event(0); 423 ui::MouseEvent* event = dispatched_event(0);
381 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 424 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
382 event = dispatched_event(1); 425 event = dispatched_event(1);
383 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type()); 426 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
384 EXPECT_EQ(true, event->IsLeftMouseButton()); 427 EXPECT_EQ(true, event->IsLeftMouseButton());
385 event = dispatched_event(2); 428 event = dispatched_event(2);
386 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type()); 429 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
387 EXPECT_EQ(true, event->IsLeftMouseButton()); 430 EXPECT_EQ(true, event->IsLeftMouseButton());
388 } 431 }
389 432
390 TEST_F(TabletEventConverterEvdevTest, StylusButtonPress) { 433 TEST_F(TabletEventConverterEvdevTest, StylusButtonPress) {
391 ui::MockTabletEventConverterEvdev* dev = device(); 434 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
435 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
392 436
393 struct input_event mock_kernel_queue[] = { 437 struct input_event mock_kernel_queue[] = {
394 {{0, 0}, EV_ABS, ABS_X, 30055}, 438 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
395 {{0, 0}, EV_ABS, ABS_Y, 18094}, 439 {{0, 0}, EV_ABS, ABS_X, 18372},
396 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 440 {{0, 0}, EV_ABS, ABS_Y, 9880},
397 {{0, 0}, EV_ABS, ABS_TILT_X, 99}, 441 {{0, 0}, EV_ABS, ABS_DISTANCE, 61},
398 {{0, 0}, EV_ABS, ABS_TILT_Y, 68}, 442 {{0, 0}, EV_ABS, ABS_TILT_X, 60},
443 {{0, 0}, EV_ABS, ABS_TILT_Y, 63},
399 {{0, 0}, EV_ABS, ABS_MISC, 1050626}, 444 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
400 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1}, 445 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
401 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 446 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
402 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 447 {{0, 0}, EV_SYN, SYN_REPORT, 0},
403 {{0, 0}, EV_ABS, ABS_X, 29380}, 448 {{0, 0}, EV_ABS, ABS_X, 18294},
449 {{0, 0}, EV_ABS, ABS_Y, 9723},
450 {{0, 0}, EV_ABS, ABS_DISTANCE, 20},
451 {{0, 0}, EV_ABS, ABS_PRESSURE, 1015},
404 {{0, 0}, EV_KEY, BTN_STYLUS2, 1}, 452 {{0, 0}, EV_KEY, BTN_STYLUS2, 1},
405 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 453 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
406 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 454 {{0, 0}, EV_SYN, SYN_REPORT, 0},
407 {{0, 0}, EV_ABS, ABS_X, 29355}, 455 {{0, 0}, EV_ABS, ABS_X, 18516},
408 {{0, 0}, EV_ABS, ABS_Y, 20091}, 456 {{0, 0}, EV_ABS, ABS_Y, 9723},
409 {{0, 0}, EV_ABS, ABS_DISTANCE, 34}, 457 {{0, 0}, EV_ABS, ABS_DISTANCE, 23},
410 {{0, 0}, EV_KEY, BTN_STYLUS2, 0}, 458 {{0, 0}, EV_KEY, BTN_STYLUS2, 0},
411 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 459 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
412 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 460 {{0, 0}, EV_SYN, SYN_REPORT, 0},
413 {{0, 0}, EV_ABS, ABS_X, 0}, 461 {{0, 0}, EV_ABS, ABS_X, 0},
414 {{0, 0}, EV_ABS, ABS_Y, 0}, 462 {{0, 0}, EV_ABS, ABS_Y, 0},
415 {{0, 0}, EV_ABS, ABS_DISTANCE, 0}, 463 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
416 {{0, 0}, EV_ABS, ABS_TILT_X, 0}, 464 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
417 {{0, 0}, EV_ABS, ABS_TILT_Y, 0}, 465 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
418 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0}, 466 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
419 {{0, 0}, EV_ABS, ABS_MISC, 0}, 467 {{0, 0}, EV_ABS, ABS_MISC, 0},
420 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, 468 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
421 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 469 {{0, 0}, EV_SYN, SYN_REPORT, 0},
422 }; 470 };
423 471
424 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 472 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
425 EXPECT_EQ(3u, size()); 473 EXPECT_EQ(3u, size());
426 474
427 ui::MouseEvent* event = dispatched_event(0); 475 ui::MouseEvent* event = dispatched_event(0);
428 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 476 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
429 event = dispatched_event(1); 477 event = dispatched_event(1);
430 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type()); 478 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
431 EXPECT_EQ(true, event->IsRightMouseButton()); 479 EXPECT_EQ(true, event->IsRightMouseButton());
432 event = dispatched_event(2); 480 event = dispatched_event(2);
433 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type()); 481 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
434 EXPECT_EQ(true, event->IsRightMouseButton()); 482 EXPECT_EQ(true, event->IsRightMouseButton());
435 } 483 }
436 484
437 // Should only get an event if BTN_TOOL received 485 // Should only get an event if BTN_TOOL received
438 TEST_F(TabletEventConverterEvdevTest, CheckStylusFiltering) { 486 TEST_F(TabletEventConverterEvdevTest, CheckStylusFiltering) {
439 ui::MockTabletEventConverterEvdev* dev = device(); 487 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
488 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
440 489
441 struct input_event mock_kernel_queue[] = { 490 struct input_event mock_kernel_queue[] = {
442 {{0, 0}, EV_ABS, ABS_X, 0}, 491 {{0, 0}, EV_ABS, ABS_X, 0},
443 {{0, 0}, EV_ABS, ABS_Y, 0}, 492 {{0, 0}, EV_ABS, ABS_Y, 0},
444 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 493 {{0, 0}, EV_SYN, SYN_REPORT, 0},
445 }; 494 };
446 495
447 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 496 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
448 EXPECT_EQ(0u, size()); 497 EXPECT_EQ(0u, size());
449 } 498 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/tablet_event_converter_evdev.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698