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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
12 #include "ui/events/keycodes/keyboard_codes.h" | 12 #include "ui/events/keycodes/keyboard_codes.h" |
13 #include "ui/events/ozone/evdev/key_event_converter_evdev.h" | 13 #include "ui/events/ozone/evdev/key_event_converter_evdev.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 const char kTestDevicePath[] = "/dev/input/test-device"; | 17 const char kTestDevicePath[] = "/dev/input/test-device"; |
18 | 18 |
19 class MockKeyEventConverterEvdev : public KeyEventConverterEvdev { | 19 class MockKeyEventConverterEvdev : public KeyEventConverterEvdev { |
20 public: | 20 public: |
21 MockKeyEventConverterEvdev(int fd, EventModifiersEvdev* modifiers) | 21 MockKeyEventConverterEvdev(int fd, EventModifiersEvdev* modifiers) |
22 : KeyEventConverterEvdev(fd, base::FilePath(kTestDevicePath), modifiers) { | 22 : KeyEventConverterEvdev(fd, |
| 23 base::FilePath(kTestDevicePath), |
| 24 modifiers, |
| 25 EventDispatchCallback()) { |
23 Start(); | 26 Start(); |
24 } | 27 } |
25 virtual ~MockKeyEventConverterEvdev() {}; | 28 virtual ~MockKeyEventConverterEvdev() {}; |
26 | 29 |
27 unsigned size() { return dispatched_events_.size(); } | 30 unsigned size() { return dispatched_events_.size(); } |
28 KeyEvent* event(unsigned index) { | 31 KeyEvent* event(unsigned index) { |
29 CHECK_GT(dispatched_events_.size(), index); | 32 CHECK_GT(dispatched_events_.size(), index); |
30 return dispatched_events_[index]; | 33 return dispatched_events_[index]; |
31 } | 34 } |
32 | 35 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 event = dev->event(4); | 338 event = dev->event(4); |
336 EXPECT_EQ(ui::ET_KEY_PRESSED, event->type()); | 339 EXPECT_EQ(ui::ET_KEY_PRESSED, event->type()); |
337 EXPECT_EQ(ui::VKEY_CAPITAL, event->key_code()); | 340 EXPECT_EQ(ui::VKEY_CAPITAL, event->key_code()); |
338 EXPECT_EQ(0, event->flags()); | 341 EXPECT_EQ(0, event->flags()); |
339 | 342 |
340 event = dev->event(5); | 343 event = dev->event(5); |
341 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); | 344 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); |
342 EXPECT_EQ(ui::VKEY_CAPITAL, event->key_code()); | 345 EXPECT_EQ(ui::VKEY_CAPITAL, event->key_code()); |
343 EXPECT_EQ(0, event->flags()); | 346 EXPECT_EQ(0, event->flags()); |
344 } | 347 } |
OLD | NEW |