| 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 "ui/events/ozone/evdev/tablet_event_converter_evdev.h" |
| 6 |
| 5 #include <errno.h> | 7 #include <errno.h> |
| 6 #include <fcntl.h> | 8 #include <fcntl.h> |
| 7 #include <linux/input.h> | 9 #include <linux/input.h> |
| 8 #include <unistd.h> | 10 #include <unistd.h> |
| 9 | 11 #include <utility> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/bind.h" | 14 #include "base/bind.h" |
| 13 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 14 #include "base/macros.h" | 16 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 17 #include "base/posix/eintr_wrapper.h" | 19 #include "base/posix/eintr_wrapper.h" |
| 18 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
| 22 #include "ui/events/ozone/device/device_manager.h" | 24 #include "ui/events/ozone/device/device_manager.h" |
| 23 #include "ui/events/ozone/evdev/event_converter_test_util.h" | 25 #include "ui/events/ozone/evdev/event_converter_test_util.h" |
| 24 #include "ui/events/ozone/evdev/event_device_test_util.h" | 26 #include "ui/events/ozone/evdev/event_device_test_util.h" |
| 25 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 27 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 26 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" | |
| 27 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 28 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 28 #include "ui/events/platform/platform_event_dispatcher.h" | 29 #include "ui/events/platform/platform_event_dispatcher.h" |
| 29 #include "ui/events/platform/platform_event_source.h" | 30 #include "ui/events/platform/platform_event_source.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const char kTestDevicePath[] = "/dev/input/test-device"; | 34 const char kTestDevicePath[] = "/dev/input/test-device"; |
| 34 | 35 |
| 35 const ui::DeviceAbsoluteAxis kWacomIntuos5SPenAbsAxes[] = { | 36 const ui::DeviceAbsoluteAxis kWacomIntuos5SPenAbsAxes[] = { |
| 36 {ABS_X, {0, 0, 31496, 4, 0, 200}}, | 37 {ABS_X, {0, 0, 31496, 4, 0, 200}}, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 unsigned size() { return dispatched_events_.size(); } | 207 unsigned size() { return dispatched_events_.size(); } |
| 207 ui::MouseEvent* dispatched_event(unsigned index) { | 208 ui::MouseEvent* dispatched_event(unsigned index) { |
| 208 DCHECK_GT(dispatched_events_.size(), index); | 209 DCHECK_GT(dispatched_events_.size(), index); |
| 209 ui::Event* ev = dispatched_events_[index].get(); | 210 ui::Event* ev = dispatched_events_[index].get(); |
| 210 DCHECK(ev->IsMouseEvent()); | 211 DCHECK(ev->IsMouseEvent()); |
| 211 return static_cast<ui::MouseEvent*>(ev); | 212 return static_cast<ui::MouseEvent*>(ev); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void DispatchEventForTest(ui::Event* event) { | 215 void DispatchEventForTest(ui::Event* event) { |
| 215 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); | 216 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); |
| 216 dispatched_events_.push_back(cloned_event.Pass()); | 217 dispatched_events_.push_back(std::move(cloned_event)); |
| 217 } | 218 } |
| 218 | 219 |
| 219 private: | 220 private: |
| 220 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; | 221 scoped_ptr<ui::MockTabletCursorEvdev> cursor_; |
| 221 scoped_ptr<ui::DeviceManager> device_manager_; | 222 scoped_ptr<ui::DeviceManager> device_manager_; |
| 222 scoped_ptr<ui::EventFactoryEvdev> event_factory_; | 223 scoped_ptr<ui::EventFactoryEvdev> event_factory_; |
| 223 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; | 224 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; |
| 224 | 225 |
| 225 std::vector<scoped_ptr<ui::Event>> dispatched_events_; | 226 std::vector<scoped_ptr<ui::Event>> dispatched_events_; |
| 226 | 227 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 494 |
| 494 struct input_event mock_kernel_queue[] = { | 495 struct input_event mock_kernel_queue[] = { |
| 495 {{0, 0}, EV_ABS, ABS_X, 0}, | 496 {{0, 0}, EV_ABS, ABS_X, 0}, |
| 496 {{0, 0}, EV_ABS, ABS_Y, 0}, | 497 {{0, 0}, EV_ABS, ABS_Y, 0}, |
| 497 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 498 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 498 }; | 499 }; |
| 499 | 500 |
| 500 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 501 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 501 EXPECT_EQ(0u, size()); | 502 EXPECT_EQ(0u, size()); |
| 502 } | 503 } |
| OLD | NEW |