| 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 <utility> |
| 6 |
| 5 #include "base/bind.h" | 7 #include "base/bind.h" |
| 6 #include "base/macros.h" | 8 #include "base/macros.h" |
| 7 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 12 #include "ui/events/keycodes/dom/dom_code.h" | 14 #include "ui/events/keycodes/dom/dom_code.h" |
| 13 #include "ui/events/keycodes/keyboard_codes.h" | 15 #include "ui/events/keycodes/keyboard_codes.h" |
| 14 #include "ui/events/ozone/device/device_manager.h" | 16 #include "ui/events/ozone/device/device_manager.h" |
| 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 17 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
| 18 // Note: This should normally be the first include in the list, but it |
| 19 // transitively includes <linux/input.h>, which breaks dom_code.h due to macros |
| 20 // that conflict with enumerator names. |
| 16 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" | 21 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" |
| 17 #include "ui/events/ozone/evdev/event_converter_test_util.h" | 22 #include "ui/events/ozone/evdev/event_converter_test_util.h" |
| 18 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 23 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 19 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 24 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
| 20 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 25 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 21 | 26 |
| 27 // This is not ordered with the normal #includes, due to the aforementioned |
| 28 // macro conflict. |
| 22 #include <linux/input.h> | 29 #include <linux/input.h> |
| 23 | 30 |
| 24 namespace ui { | 31 namespace ui { |
| 25 | 32 |
| 26 const char kTestDevicePath[] = "/dev/input/test-device"; | 33 const char kTestDevicePath[] = "/dev/input/test-device"; |
| 27 | 34 |
| 28 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { | 35 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { |
| 29 public: | 36 public: |
| 30 MockEventConverterEvdevImpl(int fd, | 37 MockEventConverterEvdevImpl(int fd, |
| 31 CursorDelegateEvdev* cursor, | 38 CursorDelegateEvdev* cursor, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 141 |
| 135 void ClearDispatchedEvents() { | 142 void ClearDispatchedEvents() { |
| 136 dispatched_events_.clear(); | 143 dispatched_events_.clear(); |
| 137 } | 144 } |
| 138 | 145 |
| 139 void DestroyDevice() { device_.reset(); } | 146 void DestroyDevice() { device_.reset(); } |
| 140 | 147 |
| 141 private: | 148 private: |
| 142 void DispatchEventForTest(ui::Event* event) { | 149 void DispatchEventForTest(ui::Event* event) { |
| 143 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); | 150 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); |
| 144 dispatched_events_.push_back(cloned_event.Pass()); | 151 dispatched_events_.push_back(std::move(cloned_event)); |
| 145 } | 152 } |
| 146 | 153 |
| 147 base::MessageLoopForUI ui_loop_; | 154 base::MessageLoopForUI ui_loop_; |
| 148 | 155 |
| 149 scoped_ptr<ui::MockCursorEvdev> cursor_; | 156 scoped_ptr<ui::MockCursorEvdev> cursor_; |
| 150 scoped_ptr<ui::DeviceManager> device_manager_; | 157 scoped_ptr<ui::DeviceManager> device_manager_; |
| 151 scoped_ptr<ui::EventFactoryEvdev> event_factory_; | 158 scoped_ptr<ui::EventFactoryEvdev> event_factory_; |
| 152 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; | 159 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; |
| 153 scoped_ptr<ui::MockEventConverterEvdevImpl> device_; | 160 scoped_ptr<ui::MockEventConverterEvdevImpl> device_; |
| 154 | 161 |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 dev->SetKeyFilter(true /* enable_filter */, allowed_keys); | 663 dev->SetKeyFilter(true /* enable_filter */, allowed_keys); |
| 657 ASSERT_EQ(1u, size()); | 664 ASSERT_EQ(1u, size()); |
| 658 event = dispatched_event(0); | 665 event = dispatched_event(0); |
| 659 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); | 666 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); |
| 660 | 667 |
| 661 // The real key release should be dropped, whenever it comes. | 668 // The real key release should be dropped, whenever it comes. |
| 662 ClearDispatchedEvents(); | 669 ClearDispatchedEvents(); |
| 663 dev->ProcessEvents(key_release, arraysize(key_release)); | 670 dev->ProcessEvents(key_release, arraysize(key_release)); |
| 664 ASSERT_EQ(0u, size()); | 671 ASSERT_EQ(0u, size()); |
| 665 } | 672 } |
| OLD | NEW |