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/event_converter_evdev_impl.h" |
| 6 |
5 #include <linux/input.h> | 7 #include <linux/input.h> |
| 8 |
| 9 #include <memory> |
6 #include <utility> | 10 #include <utility> |
7 | 11 |
8 #include "base/bind.h" | 12 #include "base/bind.h" |
9 #include "base/macros.h" | 13 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
12 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
15 #include "ui/events/keycodes/dom/dom_code.h" | 18 #include "ui/events/keycodes/dom/dom_code.h" |
16 #include "ui/events/keycodes/keyboard_codes.h" | 19 #include "ui/events/keycodes/keyboard_codes.h" |
17 #include "ui/events/ozone/device/device_manager.h" | 20 #include "ui/events/ozone/device/device_manager.h" |
18 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 21 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
19 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" | |
20 #include "ui/events/ozone/evdev/event_converter_test_util.h" | 22 #include "ui/events/ozone/evdev/event_converter_test_util.h" |
21 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 23 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
22 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 24 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
23 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 25 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
24 | 26 |
25 namespace ui { | 27 namespace ui { |
26 | 28 |
27 const char kTestDevicePath[] = "/dev/input/test-device"; | 29 const char kTestDevicePath[] = "/dev/input/test-device"; |
28 | 30 |
29 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { | 31 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 136 } |
135 | 137 |
136 void ClearDispatchedEvents() { | 138 void ClearDispatchedEvents() { |
137 dispatched_events_.clear(); | 139 dispatched_events_.clear(); |
138 } | 140 } |
139 | 141 |
140 void DestroyDevice() { device_.reset(); } | 142 void DestroyDevice() { device_.reset(); } |
141 | 143 |
142 private: | 144 private: |
143 void DispatchEventForTest(ui::Event* event) { | 145 void DispatchEventForTest(ui::Event* event) { |
144 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); | 146 std::unique_ptr<ui::Event> cloned_event = ui::Event::Clone(*event); |
145 dispatched_events_.push_back(std::move(cloned_event)); | 147 dispatched_events_.push_back(std::move(cloned_event)); |
146 } | 148 } |
147 | 149 |
148 base::MessageLoopForUI ui_loop_; | 150 base::MessageLoopForUI ui_loop_; |
149 | 151 |
150 scoped_ptr<ui::MockCursorEvdev> cursor_; | 152 std::unique_ptr<ui::MockCursorEvdev> cursor_; |
151 scoped_ptr<ui::DeviceManager> device_manager_; | 153 std::unique_ptr<ui::DeviceManager> device_manager_; |
152 scoped_ptr<ui::EventFactoryEvdev> event_factory_; | 154 std::unique_ptr<ui::EventFactoryEvdev> event_factory_; |
153 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; | 155 std::unique_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_; |
154 scoped_ptr<ui::MockEventConverterEvdevImpl> device_; | 156 std::unique_ptr<ui::MockEventConverterEvdevImpl> device_; |
155 | 157 |
156 std::vector<scoped_ptr<ui::Event>> dispatched_events_; | 158 std::vector<std::unique_ptr<ui::Event>> dispatched_events_; |
157 | 159 |
158 int events_out_; | 160 int events_out_; |
159 int events_in_; | 161 int events_in_; |
160 | 162 |
161 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImplTest); | 163 DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImplTest); |
162 }; | 164 }; |
163 | 165 |
164 TEST_F(EventConverterEvdevImplTest, KeyPress) { | 166 TEST_F(EventConverterEvdevImplTest, KeyPress) { |
165 ui::MockEventConverterEvdevImpl* dev = device(); | 167 ui::MockEventConverterEvdevImpl* dev = device(); |
166 | 168 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 dev->SetKeyFilter(true /* enable_filter */, allowed_keys); | 659 dev->SetKeyFilter(true /* enable_filter */, allowed_keys); |
658 ASSERT_EQ(1u, size()); | 660 ASSERT_EQ(1u, size()); |
659 event = dispatched_event(0); | 661 event = dispatched_event(0); |
660 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); | 662 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); |
661 | 663 |
662 // The real key release should be dropped, whenever it comes. | 664 // The real key release should be dropped, whenever it comes. |
663 ClearDispatchedEvents(); | 665 ClearDispatchedEvents(); |
664 dev->ProcessEvents(key_release, arraysize(key_release)); | 666 dev->ProcessEvents(key_release, arraysize(key_release)); |
665 ASSERT_EQ(0u, size()); | 667 ASSERT_EQ(0u, size()); |
666 } | 668 } |
OLD | NEW |