| 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 <linux/input.h> | 5 #include <linux/input.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
| 13 #include "ui/events/keycodes/keyboard_codes.h" | 13 #include "ui/events/keycodes/keyboard_codes.h" |
| 14 #include "ui/events/ozone/device/device_manager.h" | 14 #include "ui/events/ozone/device/device_manager.h" |
| 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
| 16 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" | 16 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" |
| 17 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 17 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 18 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 18 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
| 19 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 19 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 | 22 |
| 23 const char kTestDevicePath[] = "/dev/input/test-device"; | 23 const char kTestDevicePath[] = "/dev/input/test-device"; |
| 24 | 24 |
| 25 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { | 25 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { |
| 26 public: | 26 public: |
| 27 MockEventConverterEvdevImpl( | 27 MockEventConverterEvdevImpl( |
| 28 int fd, | 28 int fd, |
| 29 EventModifiersEvdev* modifiers, | |
| 30 CursorDelegateEvdev* cursor, | 29 CursorDelegateEvdev* cursor, |
| 31 const KeyEventDispatchCallback& key_callback, | 30 const KeyEventDispatchCallback& key_callback, |
| 32 const MouseMoveEventDispatchCallback& mouse_move_callback, | 31 const MouseMoveEventDispatchCallback& mouse_move_callback, |
| 33 const MouseButtonEventDispatchCallback& mouse_button_callback) | 32 const MouseButtonEventDispatchCallback& mouse_button_callback) |
| 34 : EventConverterEvdevImpl(fd, | 33 : EventConverterEvdevImpl(fd, |
| 35 base::FilePath(kTestDevicePath), | 34 base::FilePath(kTestDevicePath), |
| 36 1, | 35 1, |
| 37 INPUT_DEVICE_UNKNOWN, | 36 INPUT_DEVICE_UNKNOWN, |
| 38 EventDeviceInfo(), | 37 EventDeviceInfo(), |
| 39 modifiers, | |
| 40 cursor, | 38 cursor, |
| 41 key_callback, | 39 key_callback, |
| 42 mouse_move_callback, | 40 mouse_move_callback, |
| 43 mouse_button_callback) { | 41 mouse_button_callback) { |
| 44 Start(); | 42 Start(); |
| 45 } | 43 } |
| 46 ~MockEventConverterEvdevImpl() override {} | 44 ~MockEventConverterEvdevImpl() override {} |
| 47 | 45 |
| 48 private: | 46 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(MockEventConverterEvdevImpl); | 47 DISALLOW_COPY_AND_ASSIGN(MockEventConverterEvdevImpl); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 124 |
| 127 cursor_.reset(new ui::MockCursorEvdev()); | 125 cursor_.reset(new ui::MockCursorEvdev()); |
| 128 device_manager_.reset(new ui::MockDeviceManager()); | 126 device_manager_.reset(new ui::MockDeviceManager()); |
| 129 event_factory_.reset(new ui::TestEventFactoryEvdev( | 127 event_factory_.reset(new ui::TestEventFactoryEvdev( |
| 130 cursor_.get(), device_manager_.get(), | 128 cursor_.get(), device_manager_.get(), |
| 131 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), | 129 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), |
| 132 base::Bind(&EventConverterEvdevImplTest::DispatchEventForTest, | 130 base::Bind(&EventConverterEvdevImplTest::DispatchEventForTest, |
| 133 base::Unretained(this)))); | 131 base::Unretained(this)))); |
| 134 | 132 |
| 135 device_.reset(new ui::MockEventConverterEvdevImpl( | 133 device_.reset(new ui::MockEventConverterEvdevImpl( |
| 136 events_in_, event_factory_->modifiers(), cursor_.get(), | 134 events_in_, cursor_.get(), |
| 137 base::Bind(&ui::EventFactoryEvdev::PostKeyEvent, | 135 base::Bind(&ui::EventFactoryEvdev::PostKeyEvent, |
| 138 base::Unretained(event_factory_.get())), | 136 base::Unretained(event_factory_.get())), |
| 139 base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent, | 137 base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent, |
| 140 base::Unretained(event_factory_.get())), | 138 base::Unretained(event_factory_.get())), |
| 141 base::Bind(&ui::EventFactoryEvdev::PostMouseButtonEvent, | 139 base::Bind(&ui::EventFactoryEvdev::PostMouseButtonEvent, |
| 142 base::Unretained(event_factory_.get())))); | 140 base::Unretained(event_factory_.get())))); |
| 143 } | 141 } |
| 144 void TearDown() override { | 142 void TearDown() override { |
| 145 device_.reset(); | 143 device_.reset(); |
| 146 cursor_.reset(); | 144 cursor_.reset(); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 {{0, 0}, EV_KEY, BTN_TOUCH, 1}, | 483 {{0, 0}, EV_KEY, BTN_TOUCH, 1}, |
| 486 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 484 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 487 | 485 |
| 488 {{0, 0}, EV_KEY, BTN_TOUCH, 0}, | 486 {{0, 0}, EV_KEY, BTN_TOUCH, 0}, |
| 489 {{0, 0}, EV_SYN, SYN_REPORT, 0}, | 487 {{0, 0}, EV_SYN, SYN_REPORT, 0}, |
| 490 }; | 488 }; |
| 491 | 489 |
| 492 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); | 490 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); |
| 493 EXPECT_EQ(0u, size()); | 491 EXPECT_EQ(0u, size()); |
| 494 } | 492 } |
| OLD | NEW |