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