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

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

Issue 873563002: [Ozone] Constrain the cursor when overscan insets are set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 int read_pipe_; 70 int read_pipe_;
71 int write_pipe_; 71 int write_pipe_;
72 72
73 ScopedVector<Event> dispatched_events_; 73 ScopedVector<Event> dispatched_events_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(MockTabletEventConverterEvdev); 75 DISALLOW_COPY_AND_ASSIGN(MockTabletEventConverterEvdev);
76 }; 76 };
77 77
78 class MockTabletCursorEvdev : public CursorDelegateEvdev { 78 class MockTabletCursorEvdev : public CursorDelegateEvdev {
79 public: 79 public:
80 MockTabletCursorEvdev() { cursor_display_bounds_ = gfx::Rect(1024, 768); } 80 MockTabletCursorEvdev() { cursor_confined_bounds_ = gfx::Rect(1024, 768); }
81 ~MockTabletCursorEvdev() override {} 81 ~MockTabletCursorEvdev() override {}
82 82
83 // CursorDelegateEvdev: 83 // CursorDelegateEvdev:
84 void MoveCursorTo(gfx::AcceleratedWidget widget, 84 void MoveCursorTo(gfx::AcceleratedWidget widget,
85 const gfx::PointF& location) override { 85 const gfx::PointF& location) override {
86 NOTREACHED(); 86 NOTREACHED();
87 } 87 }
88 void MoveCursorTo(const gfx::PointF& location) override { 88 void MoveCursorTo(const gfx::PointF& location) override {
89 cursor_location_ = location; 89 cursor_location_ = location;
90 } 90 }
91 void MoveCursor(const gfx::Vector2dF& delta) override { NOTREACHED(); } 91 void MoveCursor(const gfx::Vector2dF& delta) override { NOTREACHED(); }
92 bool IsCursorVisible() override { return 1; } 92 bool IsCursorVisible() override { return 1; }
93 gfx::PointF GetLocation() override { return cursor_location_; } 93 gfx::PointF GetLocation() override { return cursor_location_; }
94 gfx::Rect GetCursorDisplayBounds() override { return cursor_display_bounds_; } 94 gfx::Rect GetCursorConfinedBounds() override {
95 return cursor_confined_bounds_;
96 }
95 97
96 private: 98 private:
97 gfx::PointF cursor_location_; 99 gfx::PointF cursor_location_;
98 gfx::Rect cursor_display_bounds_; 100 gfx::Rect cursor_confined_bounds_;
99 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev); 101 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev);
100 }; 102 };
101 103
102 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev( 104 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev(
103 int fd, 105 int fd,
104 base::FilePath path, 106 base::FilePath path,
105 EventModifiersEvdev* modifiers, 107 EventModifiersEvdev* modifiers,
106 CursorDelegateEvdev* cursor) 108 CursorDelegateEvdev* cursor)
107 : TabletEventConverterEvdev( 109 : TabletEventConverterEvdev(
108 fd, 110 fd,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 246 {{0, 0}, EV_SYN, SYN_REPORT, 0},
245 }; 247 };
246 248
247 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 249 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
248 EXPECT_EQ(1u, dev->size()); 250 EXPECT_EQ(1u, dev->size());
249 251
250 ui::MouseEvent* event = dev->event(0); 252 ui::MouseEvent* event = dev->event(0);
251 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 253 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
252 254
253 EXPECT_GT(cursor()->GetLocation().x(), 255 EXPECT_GT(cursor()->GetLocation().x(),
254 cursor()->GetCursorDisplayBounds().width() - EPSILON); 256 cursor()->GetCursorConfinedBounds().width() - EPSILON);
255 EXPECT_LT(cursor()->GetLocation().y(), EPSILON); 257 EXPECT_LT(cursor()->GetLocation().y(), EPSILON);
256 } 258 }
257 259
258 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) { 260 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) {
259 ui::MockTabletEventConverterEvdev* dev = device(); 261 ui::MockTabletEventConverterEvdev* dev = device();
260 262
261 struct input_event mock_kernel_queue[] = { 263 struct input_event mock_kernel_queue[] = {
262 {{0, 0}, EV_ABS, ABS_Y, 40640}, 264 {{0, 0}, EV_ABS, ABS_Y, 40640},
263 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 265 {{0, 0}, EV_ABS, ABS_DISTANCE, 62},
264 {{0, 0}, EV_ABS, ABS_TILT_X, 95}, 266 {{0, 0}, EV_ABS, ABS_TILT_X, 95},
(...skipping 13 matching lines...) Expand all
278 }; 280 };
279 281
280 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 282 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
281 EXPECT_EQ(1u, dev->size()); 283 EXPECT_EQ(1u, dev->size());
282 284
283 ui::MouseEvent* event = dev->event(0); 285 ui::MouseEvent* event = dev->event(0);
284 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 286 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
285 287
286 EXPECT_LT(cursor()->GetLocation().x(), EPSILON); 288 EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
287 EXPECT_GT(cursor()->GetLocation().y(), 289 EXPECT_GT(cursor()->GetLocation().y(),
288 cursor()->GetCursorDisplayBounds().height() - EPSILON); 290 cursor()->GetCursorConfinedBounds().height() - EPSILON);
289 } 291 }
290 292
291 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) { 293 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) {
292 ui::MockTabletEventConverterEvdev* dev = device(); 294 ui::MockTabletEventConverterEvdev* dev = device();
293 295
294 struct input_event mock_kernel_queue[] = { 296 struct input_event mock_kernel_queue[] = {
295 {{0, 0}, EV_ABS, ABS_X, 65024}, 297 {{0, 0}, EV_ABS, ABS_X, 65024},
296 {{0, 0}, EV_ABS, ABS_Y, 40640}, 298 {{0, 0}, EV_ABS, ABS_Y, 40640},
297 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 299 {{0, 0}, EV_ABS, ABS_DISTANCE, 62},
298 {{0, 0}, EV_ABS, ABS_TILT_X, 127}, 300 {{0, 0}, EV_ABS, ABS_TILT_X, 127},
(...skipping 13 matching lines...) Expand all
312 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 314 {{0, 0}, EV_SYN, SYN_REPORT, 0},
313 }; 315 };
314 316
315 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 317 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
316 EXPECT_EQ(1u, dev->size()); 318 EXPECT_EQ(1u, dev->size());
317 319
318 ui::MouseEvent* event = dev->event(0); 320 ui::MouseEvent* event = dev->event(0);
319 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); 321 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
320 322
321 EXPECT_GT(cursor()->GetLocation().x(), 323 EXPECT_GT(cursor()->GetLocation().x(),
322 cursor()->GetCursorDisplayBounds().height() - EPSILON); 324 cursor()->GetCursorConfinedBounds().height() - EPSILON);
323 EXPECT_GT(cursor()->GetLocation().y(), 325 EXPECT_GT(cursor()->GetLocation().y(),
324 cursor()->GetCursorDisplayBounds().height() - EPSILON); 326 cursor()->GetCursorConfinedBounds().height() - EPSILON);
325 } 327 }
326 328
327 TEST_F(TabletEventConverterEvdevTest, Tap) { 329 TEST_F(TabletEventConverterEvdevTest, Tap) {
328 ui::MockTabletEventConverterEvdev* dev = device(); 330 ui::MockTabletEventConverterEvdev* dev = device();
329 331
330 struct input_event mock_kernel_queue[] = { 332 struct input_event mock_kernel_queue[] = {
331 {{0, 0}, EV_ABS, ABS_X, 31628}, 333 {{0, 0}, EV_ABS, ABS_X, 31628},
332 {{0, 0}, EV_ABS, ABS_Y, 21670}, 334 {{0, 0}, EV_ABS, ABS_Y, 21670},
333 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, 335 {{0, 0}, EV_ABS, ABS_DISTANCE, 62},
334 {{0, 0}, EV_ABS, ABS_TILT_X, 114}, 336 {{0, 0}, EV_ABS, ABS_TILT_X, 114},
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 430
429 struct input_event mock_kernel_queue[] = { 431 struct input_event mock_kernel_queue[] = {
430 {{0, 0}, EV_ABS, ABS_X, 0}, 432 {{0, 0}, EV_ABS, ABS_X, 0},
431 {{0, 0}, EV_ABS, ABS_Y, 0}, 433 {{0, 0}, EV_ABS, ABS_Y, 0},
432 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 434 {{0, 0}, EV_SYN, SYN_REPORT, 0},
433 }; 435 };
434 436
435 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 437 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
436 EXPECT_EQ(0u, dev->size()); 438 EXPECT_EQ(0u, dev->size());
437 } 439 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/tablet_event_converter_evdev.cc ('k') | ui/ozone/platform/caca/caca_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698