| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> |
| 6 |
| 5 #include "remoting/client/normalizing_input_filter_win.h" | 7 #include "remoting/client/normalizing_input_filter_win.h" |
| 6 #include "remoting/proto/event.pb.h" | 8 #include "remoting/proto/event.pb.h" |
| 7 #include "remoting/protocol/protocol_mock_objects.h" | 9 #include "remoting/protocol/protocol_mock_objects.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 using ::testing::InSequence; | 13 using ::testing::InSequence; |
| 12 using remoting::protocol::InputStub; | 14 using remoting::protocol::InputStub; |
| 13 using remoting::protocol::KeyEvent; | 15 using remoting::protocol::KeyEvent; |
| 14 using remoting::protocol::MockInputStub; | 16 using remoting::protocol::MockInputStub; |
| 15 using remoting::protocol::MouseEvent; | 17 using remoting::protocol::MouseEvent; |
| 16 | 18 |
| 17 namespace remoting { | 19 namespace remoting { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 const unsigned int kUsbKeyA = 0x070004; | 23 const unsigned int kUsbKeyA = 0x070004; |
| 22 const unsigned int kUsbLeftControl = 0x0700e0; | 24 const unsigned int kUsbLeftControl = 0x0700e0; |
| 23 const unsigned int kUsbRightAlt = 0x0700e6; | 25 const unsigned int kUsbRightAlt = 0x0700e6; |
| 24 | 26 |
| 25 // A hardcoded value used to verify |lock_states| is preserved. | 27 // A hardcoded value used to verify |lock_states| is preserved. |
| 26 static const uint32 kTestLockStates = protocol::KeyEvent::LOCK_STATES_NUMLOCK; | 28 static const uint32_t kTestLockStates = protocol::KeyEvent::LOCK_STATES_NUMLOCK; |
| 27 | 29 |
| 28 MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") { | 30 MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") { |
| 29 return arg.usb_keycode() == static_cast<uint32>(usb_keycode) && | 31 return arg.usb_keycode() == static_cast<uint32_t>(usb_keycode) && |
| 30 arg.pressed() == pressed && arg.lock_states() == kTestLockStates; | 32 arg.pressed() == pressed && arg.lock_states() == kTestLockStates; |
| 31 } | 33 } |
| 32 | 34 |
| 33 KeyEvent MakeKeyEvent(uint32 keycode, bool pressed) { | 35 KeyEvent MakeKeyEvent(uint32_t keycode, bool pressed) { |
| 34 KeyEvent event; | 36 KeyEvent event; |
| 35 event.set_usb_keycode(keycode); | 37 event.set_usb_keycode(keycode); |
| 36 event.set_pressed(pressed); | 38 event.set_pressed(pressed); |
| 37 event.set_lock_states(kTestLockStates); | 39 event.set_lock_states(kTestLockStates); |
| 38 return event; | 40 return event; |
| 39 } | 41 } |
| 40 | 42 |
| 41 void PressAndReleaseKey(InputStub* input_stub, uint32 keycode) { | 43 void PressAndReleaseKey(InputStub* input_stub, uint32_t keycode) { |
| 42 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, true)); | 44 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, true)); |
| 43 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, false)); | 45 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, false)); |
| 44 } | 46 } |
| 45 | 47 |
| 46 MATCHER_P2(EqualsMouseMoveEvent, x, y, "") { | 48 MATCHER_P2(EqualsMouseMoveEvent, x, y, "") { |
| 47 return arg.x() == x && arg.y() == y; | 49 return arg.x() == x && arg.y() == y; |
| 48 } | 50 } |
| 49 | 51 |
| 50 static MouseEvent MakeMouseMoveEvent(int x, int y) { | 52 static MouseEvent MakeMouseMoveEvent(int x, int y) { |
| 51 MouseEvent event; | 53 MouseEvent event; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 211 |
| 210 // Hold the left Control while moving the mouse. | 212 // Hold the left Control while moving the mouse. |
| 211 processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true)); | 213 processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true)); |
| 212 processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, true)); | 214 processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, true)); |
| 213 processor.InjectMouseEvent(MakeMouseMoveEvent(0, 0)); | 215 processor.InjectMouseEvent(MakeMouseMoveEvent(0, 0)); |
| 214 processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, false)); | 216 processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, false)); |
| 215 processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false)); | 217 processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false)); |
| 216 } | 218 } |
| 217 | 219 |
| 218 } // namespace remoting | 220 } // namespace remoting |
| OLD | NEW |