| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } | 173 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); } |
| 174 | 174 |
| 175 unsigned size() { return dispatched_events_.size(); } | 175 unsigned size() { return dispatched_events_.size(); } |
| 176 ui::MouseEvent* dispatched_event(unsigned index) { | 176 ui::MouseEvent* dispatched_event(unsigned index) { |
| 177 DCHECK_GT(dispatched_events_.size(), index); | 177 DCHECK_GT(dispatched_events_.size(), index); |
| 178 ui::Event* ev = dispatched_events_[index]; | 178 ui::Event* ev = dispatched_events_[index]; |
| 179 DCHECK(ev->IsMouseEvent()); | 179 DCHECK(ev->IsMouseEvent()); |
| 180 return static_cast<ui::MouseEvent*>(ev); | 180 return static_cast<ui::MouseEvent*>(ev); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void DispatchEventForTest(scoped_ptr<ui::Event> event) { | 183 void DispatchEventForTest(ui::Event* event) { |
| 184 dispatched_events_.push_back(event.release()); | 184 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); |
| 185 dispatched_events_.push_back(cloned_event.release()); |
| 185 } | 186 } |
| 186 | 187 |
| 187 private: | 188 private: |
| 188 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; | 189 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; |
| 189 scoped_ptr<ui::DeviceManager> device_manager_; | 190 scoped_ptr<ui::DeviceManager> device_manager_; |
| 190 scoped_ptr<ui::EventFactoryEvdev> event_factory_; | 191 scoped_ptr<ui::EventFactoryEvdev> event_factory_; |
| 191 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; | 192 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; |
| 192 scoped_ptr<ui::MockTabletEventConverterEvdev> device_; | 193 scoped_ptr<ui::MockTabletEventConverterEvdev> device_; |
| 193 | 194 |
| 194 ScopedVector<ui::Event> dispatched_events_; | 195 ScopedVector<ui::Event> dispatched_events_; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 441 |
| 441 struct input_event mock_kernel_queue[] = { | 442 struct input_event mock_kernel_queue[] = { |
| 442 {{0, 0}, EV_ABS, ABS_X, 0}, | 443 {{0, 0}, EV_ABS, ABS_X, 0}, |
| 443 {{0, 0}, EV_ABS, ABS_Y, 0}, | 444 {{0, 0}, EV_ABS, ABS_Y, 0}, |
| 444 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 445 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 445 }; | 446 }; |
| 446 | 447 |
| 447 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 448 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 448 EXPECT_EQ(0u, size()); | 449 EXPECT_EQ(0u, size()); |
| 449 } | 450 } |
| OLD | NEW |