| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // Actually dispatch the event reader code. | 94 // Actually dispatch the event reader code. |
| 95 void ReadNow() { | 95 void ReadNow() { |
| 96 OnFileCanReadWithoutBlocking(read_pipe_); | 96 OnFileCanReadWithoutBlocking(read_pipe_); |
| 97 base::RunLoop().RunUntilIdle(); | 97 base::RunLoop().RunUntilIdle(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 int read_pipe_; | 101 int read_pipe_; |
| 102 int write_pipe_; | 102 int write_pipe_; |
| 103 | 103 |
| 104 ScopedVector<Event> dispatched_events_; | 104 std::vector<scoped_ptr<Event>> dispatched_events_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(MockTabletEventConverterEvdev); | 106 DISALLOW_COPY_AND_ASSIGN(MockTabletEventConverterEvdev); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 class MockTabletCursorEvdev : public CursorDelegateEvdev { | 109 class MockTabletCursorEvdev : public CursorDelegateEvdev { |
| 110 public: | 110 public: |
| 111 MockTabletCursorEvdev() { cursor_confined_bounds_ = gfx::Rect(1024, 768); } | 111 MockTabletCursorEvdev() { cursor_confined_bounds_ = gfx::Rect(1024, 768); } |
| 112 ~MockTabletCursorEvdev() override {} | 112 ~MockTabletCursorEvdev() override {} |
| 113 | 113 |
| 114 // CursorDelegateEvdev: | 114 // CursorDelegateEvdev: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return new ui::MockTabletEventConverterEvdev( | 204 return new ui::MockTabletEventConverterEvdev( |
| 205 events_in_, base::FilePath(kTestDevicePath), cursor_.get(), devinfo, | 205 events_in_, base::FilePath(kTestDevicePath), cursor_.get(), devinfo, |
| 206 dispatcher_.get()); | 206 dispatcher_.get()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } | 209 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } |
| 210 | 210 |
| 211 unsigned size() { return dispatched_events_.size(); } | 211 unsigned size() { return dispatched_events_.size(); } |
| 212 ui::MouseEvent* dispatched_event(unsigned index) { | 212 ui::MouseEvent* dispatched_event(unsigned index) { |
| 213 DCHECK_GT(dispatched_events_.size(), index); | 213 DCHECK_GT(dispatched_events_.size(), index); |
| 214 ui::Event* ev = dispatched_events_[index]; | 214 ui::Event* ev = dispatched_events_[index].get(); |
| 215 DCHECK(ev->IsMouseEvent()); | 215 DCHECK(ev->IsMouseEvent()); |
| 216 return static_cast<ui::MouseEvent*>(ev); | 216 return static_cast<ui::MouseEvent*>(ev); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void DispatchEventForTest(ui::Event* event) { | 219 void DispatchEventForTest(ui::Event* event) { |
| 220 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); | 220 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); |
| 221 dispatched_events_.push_back(cloned_event.Pass()); | 221 dispatched_events_.push_back(cloned_event.Pass()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 private: | 224 private: |
| 225 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; | 225 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; |
| 226 scoped_ptr<ui::DeviceManager> device_manager_; | 226 scoped_ptr<ui::DeviceManager> device_manager_; |
| 227 scoped_ptr<ui::EventFactoryEvdev> event_factory_; | 227 scoped_ptr<ui::EventFactoryEvdev> event_factory_; |
| 228 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; | 228 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; |
| 229 | 229 |
| 230 ScopedVector<ui::Event> dispatched_events_; | 230 std::vector<scoped_ptr<ui::Event>> dispatched_events_; |
| 231 | 231 |
| 232 int events_out_; | 232 int events_out_; |
| 233 int events_in_; | 233 int events_in_; |
| 234 | 234 |
| 235 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdevTest); | 235 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdevTest); |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 #define EPSILON 20 | 238 #define EPSILON 20 |
| 239 | 239 |
| 240 // Uses real data captured from Wacom Intuos 5 Pen | 240 // Uses real data captured from Wacom Intuos 5 Pen |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 498 |
| 499 struct input_event mock_kernel_queue[] = { | 499 struct input_event mock_kernel_queue[] = { |
| 500 {{0, 0}, EV_ABS, ABS_X, 0}, | 500 {{0, 0}, EV_ABS, ABS_X, 0}, |
| 501 {{0, 0}, EV_ABS, ABS_Y, 0}, | 501 {{0, 0}, EV_ABS, ABS_Y, 0}, |
| 502 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 502 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 503 }; | 503 }; |
| 504 | 504 |
| 505 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 505 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 506 EXPECT_EQ(0u, size()); | 506 EXPECT_EQ(0u, size()); |
| 507 } | 507 } |
| OLD | NEW |