| OLD | NEW |
| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 location() override { return cursor_location_; } | 93 gfx::PointF GetLocation() override { return cursor_location_; } |
| 94 gfx::Rect GetCursorDisplayBounds() override { return cursor_display_bounds_; } | 94 gfx::Rect GetCursorDisplayBounds() override { return cursor_display_bounds_; } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 gfx::PointF cursor_location_; | 97 gfx::PointF cursor_location_; |
| 98 gfx::Rect cursor_display_bounds_; | 98 gfx::Rect cursor_display_bounds_; |
| 99 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev); | 99 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev( | 102 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev( |
| 103 int fd, | 103 int fd, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, | 209 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, |
| 210 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 210 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 213 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 214 EXPECT_EQ(1u, dev->size()); | 214 EXPECT_EQ(1u, dev->size()); |
| 215 | 215 |
| 216 ui::MouseEvent* event = dev->event(0); | 216 ui::MouseEvent* event = dev->event(0); |
| 217 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); | 217 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); |
| 218 | 218 |
| 219 EXPECT_LT(cursor()->location().x(), EPSILON); | 219 EXPECT_LT(cursor()->GetLocation().x(), EPSILON); |
| 220 EXPECT_LT(cursor()->location().y(), EPSILON); | 220 EXPECT_LT(cursor()->GetLocation().y(), EPSILON); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST_F(TabletEventConverterEvdevTest, MoveTopRight) { | 223 TEST_F(TabletEventConverterEvdevTest, MoveTopRight) { |
| 224 ui::MockTabletEventConverterEvdev* dev = device(); | 224 ui::MockTabletEventConverterEvdev* dev = device(); |
| 225 | 225 |
| 226 struct input_event mock_kernel_queue[] = { | 226 struct input_event mock_kernel_queue[] = { |
| 227 {{0, 0}, EV_ABS, ABS_X, 65024}, | 227 {{0, 0}, EV_ABS, ABS_X, 65024}, |
| 228 {{0, 0}, EV_ABS, ABS_Y, 33}, | 228 {{0, 0}, EV_ABS, ABS_Y, 33}, |
| 229 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, | 229 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, |
| 230 {{0, 0}, EV_ABS, ABS_TILT_X, 109}, | 230 {{0, 0}, EV_ABS, ABS_TILT_X, 109}, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 242 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, | 242 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, |
| 243 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 243 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 246 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 247 EXPECT_EQ(1u, dev->size()); | 247 EXPECT_EQ(1u, dev->size()); |
| 248 | 248 |
| 249 ui::MouseEvent* event = dev->event(0); | 249 ui::MouseEvent* event = dev->event(0); |
| 250 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); | 250 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); |
| 251 | 251 |
| 252 EXPECT_GT(cursor()->location().x(), | 252 EXPECT_GT(cursor()->GetLocation().x(), |
| 253 cursor()->GetCursorDisplayBounds().width() - EPSILON); | 253 cursor()->GetCursorDisplayBounds().width() - EPSILON); |
| 254 EXPECT_LT(cursor()->location().y(), EPSILON); | 254 EXPECT_LT(cursor()->GetLocation().y(), EPSILON); |
| 255 } | 255 } |
| 256 | 256 |
| 257 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) { | 257 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) { |
| 258 ui::MockTabletEventConverterEvdev* dev = device(); | 258 ui::MockTabletEventConverterEvdev* dev = device(); |
| 259 | 259 |
| 260 struct input_event mock_kernel_queue[] = { | 260 struct input_event mock_kernel_queue[] = { |
| 261 {{0, 0}, EV_ABS, ABS_Y, 40640}, | 261 {{0, 0}, EV_ABS, ABS_Y, 40640}, |
| 262 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, | 262 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, |
| 263 {{0, 0}, EV_ABS, ABS_TILT_X, 95}, | 263 {{0, 0}, EV_ABS, ABS_TILT_X, 95}, |
| 264 {{0, 0}, EV_ABS, ABS_TILT_Y, 44}, | 264 {{0, 0}, EV_ABS, ABS_TILT_Y, 44}, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 275 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, | 275 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, |
| 276 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 276 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 279 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 280 EXPECT_EQ(1u, dev->size()); | 280 EXPECT_EQ(1u, dev->size()); |
| 281 | 281 |
| 282 ui::MouseEvent* event = dev->event(0); | 282 ui::MouseEvent* event = dev->event(0); |
| 283 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); | 283 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); |
| 284 | 284 |
| 285 EXPECT_LT(cursor()->location().x(), EPSILON); | 285 EXPECT_LT(cursor()->GetLocation().x(), EPSILON); |
| 286 EXPECT_GT(cursor()->location().y(), | 286 EXPECT_GT(cursor()->GetLocation().y(), |
| 287 cursor()->GetCursorDisplayBounds().height() - EPSILON); | 287 cursor()->GetCursorDisplayBounds().height() - EPSILON); |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) { | 290 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) { |
| 291 ui::MockTabletEventConverterEvdev* dev = device(); | 291 ui::MockTabletEventConverterEvdev* dev = device(); |
| 292 | 292 |
| 293 struct input_event mock_kernel_queue[] = { | 293 struct input_event mock_kernel_queue[] = { |
| 294 {{0, 0}, EV_ABS, ABS_X, 65024}, | 294 {{0, 0}, EV_ABS, ABS_X, 65024}, |
| 295 {{0, 0}, EV_ABS, ABS_Y, 40640}, | 295 {{0, 0}, EV_ABS, ABS_Y, 40640}, |
| 296 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, | 296 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 310 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, | 310 {{0, 0}, EV_MSC, MSC_SERIAL, 159403517}, |
| 311 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 311 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 314 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 315 EXPECT_EQ(1u, dev->size()); | 315 EXPECT_EQ(1u, dev->size()); |
| 316 | 316 |
| 317 ui::MouseEvent* event = dev->event(0); | 317 ui::MouseEvent* event = dev->event(0); |
| 318 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); | 318 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type()); |
| 319 | 319 |
| 320 EXPECT_GT(cursor()->location().x(), | 320 EXPECT_GT(cursor()->GetLocation().x(), |
| 321 cursor()->GetCursorDisplayBounds().height() - EPSILON); | 321 cursor()->GetCursorDisplayBounds().height() - EPSILON); |
| 322 EXPECT_GT(cursor()->location().y(), | 322 EXPECT_GT(cursor()->GetLocation().y(), |
| 323 cursor()->GetCursorDisplayBounds().height() - EPSILON); | 323 cursor()->GetCursorDisplayBounds().height() - EPSILON); |
| 324 } | 324 } |
| 325 | 325 |
| 326 TEST_F(TabletEventConverterEvdevTest, Tap) { | 326 TEST_F(TabletEventConverterEvdevTest, Tap) { |
| 327 ui::MockTabletEventConverterEvdev* dev = device(); | 327 ui::MockTabletEventConverterEvdev* dev = device(); |
| 328 | 328 |
| 329 struct input_event mock_kernel_queue[] = { | 329 struct input_event mock_kernel_queue[] = { |
| 330 {{0, 0}, EV_ABS, ABS_X, 31628}, | 330 {{0, 0}, EV_ABS, ABS_X, 31628}, |
| 331 {{0, 0}, EV_ABS, ABS_Y, 21670}, | 331 {{0, 0}, EV_ABS, ABS_Y, 21670}, |
| 332 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, | 332 {{0, 0}, EV_ABS, ABS_DISTANCE, 62}, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 427 |
| 428 struct input_event mock_kernel_queue[] = { | 428 struct input_event mock_kernel_queue[] = { |
| 429 {{0, 0}, EV_ABS, ABS_X, 0}, | 429 {{0, 0}, EV_ABS, ABS_X, 0}, |
| 430 {{0, 0}, EV_ABS, ABS_Y, 0}, | 430 {{0, 0}, EV_ABS, ABS_Y, 0}, |
| 431 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 431 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 432 }; | 432 }; |
| 433 | 433 |
| 434 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 434 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 435 EXPECT_EQ(0u, dev->size()); | 435 EXPECT_EQ(0u, dev->size()); |
| 436 } | 436 } |
| OLD | NEW |