OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/client/key_event_mapper.h" | 5 #include "remoting/client/key_event_mapper.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "remoting/proto/event.pb.h" | 10 #include "remoting/proto/event.pb.h" |
9 #include "remoting/protocol/protocol_mock_objects.h" | 11 #include "remoting/protocol/protocol_mock_objects.h" |
10 #include "remoting/protocol/test_event_matchers.h" | 12 #include "remoting/protocol/test_event_matchers.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 using ::testing::_; | 16 using ::testing::_; |
15 using ::testing::ExpectationSet; | 17 using ::testing::ExpectationSet; |
16 using ::testing::InSequence; | 18 using ::testing::InSequence; |
17 | 19 |
18 namespace remoting { | 20 namespace remoting { |
19 | 21 |
20 using protocol::InputStub; | 22 using protocol::InputStub; |
21 using protocol::KeyEvent; | 23 using protocol::KeyEvent; |
22 using protocol::MockInputStub; | 24 using protocol::MockInputStub; |
23 using protocol::test::EqualsKeyEventWithCapsLock; | 25 using protocol::test::EqualsKeyEventWithCapsLock; |
24 | 26 |
25 static KeyEvent NewUsbEvent(uint32 usb_keycode, | 27 static KeyEvent NewUsbEvent(uint32_t usb_keycode, |
26 bool pressed, | 28 bool pressed, |
27 uint32 lock_states) { | 29 uint32_t lock_states) { |
28 KeyEvent event; | 30 KeyEvent event; |
29 event.set_usb_keycode(usb_keycode); | 31 event.set_usb_keycode(usb_keycode); |
30 event.set_pressed(pressed); | 32 event.set_pressed(pressed); |
31 event.set_lock_states(lock_states); | 33 event.set_lock_states(lock_states); |
32 | 34 |
33 return event; | 35 return event; |
34 } | 36 } |
35 | 37 |
36 static void PressAndReleaseUsb(InputStub* input_stub, uint32 usb_keycode) { | 38 static void PressAndReleaseUsb(InputStub* input_stub, uint32_t usb_keycode) { |
37 input_stub->InjectKeyEvent( | 39 input_stub->InjectKeyEvent( |
38 NewUsbEvent(usb_keycode, true, KeyEvent::LOCK_STATES_CAPSLOCK)); | 40 NewUsbEvent(usb_keycode, true, KeyEvent::LOCK_STATES_CAPSLOCK)); |
39 input_stub->InjectKeyEvent( | 41 input_stub->InjectKeyEvent( |
40 NewUsbEvent(usb_keycode, false, KeyEvent::LOCK_STATES_CAPSLOCK)); | 42 NewUsbEvent(usb_keycode, false, KeyEvent::LOCK_STATES_CAPSLOCK)); |
41 } | 43 } |
42 | 44 |
43 static void InjectTestSequence(InputStub* input_stub) { | 45 static void InjectTestSequence(InputStub* input_stub) { |
44 for (int i = 1; i <= 5; ++i) | 46 for (int i = 1; i <= 5; ++i) |
45 PressAndReleaseUsb(input_stub, i); | 47 PressAndReleaseUsb(input_stub, i); |
46 } | 48 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 InjectKeyEvent(EqualsKeyEventWithCapsLock(4, false))); | 138 InjectKeyEvent(EqualsKeyEventWithCapsLock(4, false))); |
137 EXPECT_CALL(trap_stub, InjectKeyEvent(EqualsKeyEventWithCapsLock(5, true))); | 139 EXPECT_CALL(trap_stub, InjectKeyEvent(EqualsKeyEventWithCapsLock(5, true))); |
138 EXPECT_CALL(trap_stub, | 140 EXPECT_CALL(trap_stub, |
139 InjectKeyEvent(EqualsKeyEventWithCapsLock(5, false))); | 141 InjectKeyEvent(EqualsKeyEventWithCapsLock(5, false))); |
140 } | 142 } |
141 | 143 |
142 InjectTestSequence(&event_mapper); | 144 InjectTestSequence(&event_mapper); |
143 } | 145 } |
144 | 146 |
145 } // namespace remoting | 147 } // namespace remoting |
OLD | NEW |