Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/plugin/normalizing_input_filter_cros.h" | 5 #include "remoting/client/plugin/normalizing_input_filter_cros.h" |
| 6 | 6 |
| 7 #include "remoting/proto/event.pb.h" | 7 #include "remoting/proto/event.pb.h" |
| 8 #include "remoting/protocol/protocol_mock_objects.h" | 8 #include "remoting/protocol/protocol_mock_objects.h" |
| 9 #include "remoting/protocol/test_event_matchers.h" | |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 using ::testing::InSequence; | 13 using ::testing::InSequence; |
| 13 using remoting::protocol::InputStub; | 14 using remoting::protocol::InputStub; |
| 14 using remoting::protocol::KeyEvent; | 15 using remoting::protocol::KeyEvent; |
| 15 using remoting::protocol::MockInputStub; | 16 using remoting::protocol::MockInputStub; |
| 16 using remoting::protocol::MouseEvent; | 17 using remoting::protocol::MouseEvent; |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 | 20 |
| 21 using protocol::EqualsMouseButtonEvent; | |
| 22 using protocol::EqualsMouseMoveEvent; | |
| 23 using protocol::EqualsUsbEventWithNumLock; | |
| 24 | |
| 20 namespace { | 25 namespace { |
| 21 | 26 |
| 22 const unsigned int kUsbLeftOsKey = 0x0700e3; | 27 const unsigned int kUsbLeftOsKey = 0x0700e3; |
| 23 const unsigned int kUsbRightOsKey = 0x0700e7; | 28 const unsigned int kUsbRightOsKey = 0x0700e7; |
| 24 const unsigned int kUsbLeftAltKey = 0x0700e2; | 29 const unsigned int kUsbLeftAltKey = 0x0700e2; |
| 25 const unsigned int kUsbRightAltKey = 0x0700e6; | 30 const unsigned int kUsbRightAltKey = 0x0700e6; |
| 26 | 31 |
| 27 const unsigned int kUsbFunctionKey = 0x07003a; // F1 | 32 const unsigned int kUsbFunctionKey = 0x07003a; // F1 |
| 28 const unsigned int kUsbExtendedKey = 0x070049; // Insert | 33 const unsigned int kUsbExtendedKey = 0x070049; // Insert |
| 29 const unsigned int kUsbOtherKey = 0x07002b; // Tab | 34 const unsigned int kUsbOtherKey = 0x07002b; // Tab |
| 30 | 35 |
| 31 // A hardcoded value used to verify |lock_states| is preserved. | |
| 32 static const uint32 kTestLockStates = protocol::KeyEvent::LOCK_STATES_NUMLOCK; | |
|
Wez
2015/03/12 00:13:58
Why remove this?
Rintaro Kuroiwa
2015/03/12 18:51:27
This was used only in the matcher below and MakeKe
| |
| 33 | |
| 34 MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") { | |
| 35 return arg.usb_keycode() == static_cast<uint32>(usb_keycode) && | |
| 36 arg.pressed() == pressed && | |
| 37 arg.lock_states() == kTestLockStates; | |
| 38 } | |
| 39 | |
| 40 KeyEvent MakeKeyEvent(uint32 keycode, bool pressed) { | 36 KeyEvent MakeKeyEvent(uint32 keycode, bool pressed) { |
| 41 KeyEvent event; | 37 KeyEvent event; |
| 42 event.set_usb_keycode(keycode); | 38 event.set_usb_keycode(keycode); |
| 43 event.set_pressed(pressed); | 39 event.set_pressed(pressed); |
| 44 event.set_lock_states(kTestLockStates); | 40 event.set_lock_states(protocol::KeyEvent::LOCK_STATES_NUMLOCK); |
| 45 return event; | 41 return event; |
| 46 } | 42 } |
| 47 | 43 |
| 48 void PressAndReleaseKey(InputStub* input_stub, uint32 keycode) { | 44 void PressAndReleaseKey(InputStub* input_stub, uint32 keycode) { |
| 49 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, true)); | 45 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, true)); |
| 50 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, false)); | 46 input_stub->InjectKeyEvent(MakeKeyEvent(keycode, false)); |
| 51 } | 47 } |
| 52 | 48 |
| 53 MATCHER_P2(EqualsMouseMoveEvent, x, y, "") { | |
| 54 return arg.x() == x && arg.y() == y; | |
| 55 } | |
| 56 | |
| 57 MATCHER_P2(EqualsMouseButtonEvent, button, button_down, "") { | |
| 58 return arg.button() == button && arg.button_down() == button_down; | |
| 59 } | |
| 60 | |
| 61 static MouseEvent MakeMouseMoveEvent(int x, int y) { | 49 static MouseEvent MakeMouseMoveEvent(int x, int y) { |
| 62 MouseEvent event; | 50 MouseEvent event; |
| 63 event.set_x(x); | 51 event.set_x(x); |
| 64 event.set_y(y); | 52 event.set_y(y); |
| 65 return event; | 53 return event; |
| 66 } | 54 } |
| 67 | 55 |
| 68 static MouseEvent MakeMouseButtonEvent(MouseEvent::MouseButton button, | 56 static MouseEvent MakeMouseButtonEvent(MouseEvent::MouseButton button, |
| 69 bool button_down) { | 57 bool button_down) { |
| 70 MouseEvent event; | 58 MouseEvent event; |
| 71 event.set_button(button); | 59 event.set_button(button); |
| 72 event.set_button_down(button_down); | 60 event.set_button_down(button_down); |
| 73 return event; | 61 return event; |
| 74 } | 62 } |
| 75 | 63 |
| 76 } // namespace | 64 } // namespace |
| 77 | 65 |
| 78 // Test OSKey press/release. | 66 // Test OSKey press/release. |
| 79 TEST(NormalizingInputFilterCrosTest, PressReleaseOsKey) { | 67 TEST(NormalizingInputFilterCrosTest, PressReleaseOsKey) { |
| 80 MockInputStub stub; | 68 MockInputStub stub; |
| 81 scoped_ptr<protocol::InputFilter> processor( | 69 scoped_ptr<protocol::InputFilter> processor( |
| 82 new NormalizingInputFilterCros(&stub)); | 70 new NormalizingInputFilterCros(&stub)); |
| 83 | 71 |
| 84 { | 72 { |
| 85 InSequence s; | 73 InSequence s; |
| 86 | 74 |
| 87 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 75 EXPECT_CALL(stub, |
| 88 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); | 76 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); |
| 77 EXPECT_CALL( | |
| 78 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, false))); | |
| 89 | 79 |
| 90 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightOsKey, true))); | 80 EXPECT_CALL( |
| 91 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightOsKey, false))); | 81 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbRightOsKey, true))); |
| 82 EXPECT_CALL( | |
| 83 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbRightOsKey, false))); | |
| 92 } | 84 } |
| 93 | 85 |
| 94 // Inject press & release events for left & right OSKeys. | 86 // Inject press & release events for left & right OSKeys. |
| 95 PressAndReleaseKey(processor.get(), kUsbLeftOsKey); | 87 PressAndReleaseKey(processor.get(), kUsbLeftOsKey); |
| 96 PressAndReleaseKey(processor.get(), kUsbRightOsKey); | 88 PressAndReleaseKey(processor.get(), kUsbRightOsKey); |
| 97 } | 89 } |
| 98 | 90 |
| 99 // Test OSKey key repeat switches it to "modifying" mode. | 91 // Test OSKey key repeat switches it to "modifying" mode. |
| 100 TEST(NormalizingInputFilterCrosTest, OSKeyRepeats) { | 92 TEST(NormalizingInputFilterCrosTest, OSKeyRepeats) { |
| 101 MockInputStub stub; | 93 MockInputStub stub; |
| 102 scoped_ptr<protocol::InputFilter> processor( | 94 scoped_ptr<protocol::InputFilter> processor( |
| 103 new NormalizingInputFilterCros(&stub)); | 95 new NormalizingInputFilterCros(&stub)); |
| 104 | 96 |
| 105 { | 97 { |
| 106 InSequence s; | 98 InSequence s; |
| 107 | 99 |
| 108 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 100 EXPECT_CALL(stub, |
| 109 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 101 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); |
| 110 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 102 EXPECT_CALL(stub, |
| 103 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); | |
| 104 EXPECT_CALL(stub, | |
| 105 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); | |
| 111 } | 106 } |
| 112 | 107 |
| 113 // Inject a press and repeats for the left OSKey, but don't release it, and | 108 // Inject a press and repeats for the left OSKey, but don't release it, and |
| 114 // verify that the repeats result in press events. | 109 // verify that the repeats result in press events. |
| 115 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 110 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 116 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 111 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 117 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 112 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 118 } | 113 } |
| 119 | 114 |
| 120 // Test OSKey press followed by function key press and release results in | 115 // Test OSKey press followed by function key press and release results in |
| 121 // just the function key events. | 116 // just the function key events. |
| 122 TEST(NormalizingInputFilterCrosTest, FunctionKey) { | 117 TEST(NormalizingInputFilterCrosTest, FunctionKey) { |
| 123 MockInputStub stub; | 118 MockInputStub stub; |
| 124 scoped_ptr<protocol::InputFilter> processor( | 119 scoped_ptr<protocol::InputFilter> processor( |
| 125 new NormalizingInputFilterCros(&stub)); | 120 new NormalizingInputFilterCros(&stub)); |
| 126 | 121 |
| 127 { | 122 { |
| 128 InSequence s; | 123 InSequence s; |
| 129 | 124 |
| 130 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbFunctionKey, true))); | 125 EXPECT_CALL( |
| 131 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbFunctionKey, false))); | 126 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbFunctionKey, true))); |
| 127 EXPECT_CALL(stub, InjectKeyEvent( | |
| 128 EqualsUsbEventWithNumLock(kUsbFunctionKey, false))); | |
| 132 } | 129 } |
| 133 | 130 |
| 134 // Hold the left OSKey while pressing & releasing the function key. | 131 // Hold the left OSKey while pressing & releasing the function key. |
| 135 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 132 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 136 PressAndReleaseKey(processor.get(), kUsbFunctionKey); | 133 PressAndReleaseKey(processor.get(), kUsbFunctionKey); |
| 137 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); | 134 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); |
| 138 } | 135 } |
| 139 | 136 |
| 140 // Test OSKey press followed by extended key press and release results in | 137 // Test OSKey press followed by extended key press and release results in |
| 141 // just the function key events. | 138 // just the function key events. |
| 142 TEST(NormalizingInputFilterCrosTest, ExtendedKey) { | 139 TEST(NormalizingInputFilterCrosTest, ExtendedKey) { |
| 143 MockInputStub stub; | 140 MockInputStub stub; |
| 144 scoped_ptr<protocol::InputFilter> processor( | 141 scoped_ptr<protocol::InputFilter> processor( |
| 145 new NormalizingInputFilterCros(&stub)); | 142 new NormalizingInputFilterCros(&stub)); |
| 146 | 143 |
| 147 { | 144 { |
| 148 InSequence s; | 145 InSequence s; |
| 149 | 146 |
| 150 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, true))); | 147 EXPECT_CALL( |
| 151 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, false))); | 148 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbExtendedKey, true))); |
| 149 EXPECT_CALL(stub, InjectKeyEvent( | |
| 150 EqualsUsbEventWithNumLock(kUsbExtendedKey, false))); | |
| 152 } | 151 } |
| 153 | 152 |
| 154 // Hold the left OSKey while pressing & releasing the function key. | 153 // Hold the left OSKey while pressing & releasing the function key. |
| 155 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 154 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 156 PressAndReleaseKey(processor.get(), kUsbExtendedKey); | 155 PressAndReleaseKey(processor.get(), kUsbExtendedKey); |
| 157 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); | 156 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); |
| 158 } | 157 } |
| 159 | 158 |
| 160 // Test OSKey press followed by non-function, non-extended key press and release | 159 // Test OSKey press followed by non-function, non-extended key press and release |
| 161 // results in normal-looking sequence. | 160 // results in normal-looking sequence. |
| 162 TEST(NormalizingInputFilterCrosTest, OtherKey) { | 161 TEST(NormalizingInputFilterCrosTest, OtherKey) { |
| 163 MockInputStub stub; | 162 MockInputStub stub; |
| 164 scoped_ptr<protocol::InputFilter> processor( | 163 scoped_ptr<protocol::InputFilter> processor( |
| 165 new NormalizingInputFilterCros(&stub)); | 164 new NormalizingInputFilterCros(&stub)); |
| 166 | 165 |
| 167 { | 166 { |
| 168 InSequence s; | 167 InSequence s; |
| 169 | 168 |
| 170 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 169 EXPECT_CALL(stub, |
| 171 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, true))); | 170 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); |
| 172 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, false))); | 171 EXPECT_CALL(stub, |
| 173 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); | 172 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbOtherKey, true))); |
| 173 EXPECT_CALL(stub, | |
| 174 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbOtherKey, false))); | |
| 175 EXPECT_CALL( | |
| 176 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, false))); | |
| 174 } | 177 } |
| 175 | 178 |
| 176 // Hold the left OSKey while pressing & releasing the function key. | 179 // Hold the left OSKey while pressing & releasing the function key. |
| 177 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 180 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 178 PressAndReleaseKey(processor.get(), kUsbOtherKey); | 181 PressAndReleaseKey(processor.get(), kUsbOtherKey); |
| 179 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); | 182 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); |
| 180 } | 183 } |
| 181 | 184 |
| 182 // Test OSKey press followed by extended key press, then normal key press | 185 // Test OSKey press followed by extended key press, then normal key press |
| 183 // results in OSKey switching to modifying mode for the normal key. | 186 // results in OSKey switching to modifying mode for the normal key. |
| 184 TEST(NormalizingInputFilterCrosTest, ExtendedThenOtherKey) { | 187 TEST(NormalizingInputFilterCrosTest, ExtendedThenOtherKey) { |
| 185 MockInputStub stub; | 188 MockInputStub stub; |
| 186 scoped_ptr<protocol::InputFilter> processor( | 189 scoped_ptr<protocol::InputFilter> processor( |
| 187 new NormalizingInputFilterCros(&stub)); | 190 new NormalizingInputFilterCros(&stub)); |
| 188 | 191 |
| 189 { | 192 { |
| 190 InSequence s; | 193 InSequence s; |
| 191 | 194 |
| 192 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, true))); | 195 EXPECT_CALL( |
| 193 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbExtendedKey, false))); | 196 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbExtendedKey, true))); |
| 194 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 197 EXPECT_CALL(stub, InjectKeyEvent( |
| 195 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, true))); | 198 EqualsUsbEventWithNumLock(kUsbExtendedKey, false))); |
| 196 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbOtherKey, false))); | 199 EXPECT_CALL(stub, |
| 197 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); | 200 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); |
| 201 EXPECT_CALL(stub, | |
| 202 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbOtherKey, true))); | |
| 203 EXPECT_CALL(stub, | |
| 204 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbOtherKey, false))); | |
| 205 EXPECT_CALL( | |
| 206 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, false))); | |
| 198 } | 207 } |
| 199 | 208 |
| 200 // Hold the left OSKey while pressing & releasing the function key. | 209 // Hold the left OSKey while pressing & releasing the function key. |
| 201 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 210 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 202 PressAndReleaseKey(processor.get(), kUsbExtendedKey); | 211 PressAndReleaseKey(processor.get(), kUsbExtendedKey); |
| 203 PressAndReleaseKey(processor.get(), kUsbOtherKey); | 212 PressAndReleaseKey(processor.get(), kUsbOtherKey); |
| 204 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); | 213 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); |
| 205 } | 214 } |
| 206 | 215 |
| 207 // Test OSKey press followed by mouse event puts the OSKey into modifying mode. | 216 // Test OSKey press followed by mouse event puts the OSKey into modifying mode. |
| 208 TEST(NormalizingInputFilterCrosTest, MouseEvent) { | 217 TEST(NormalizingInputFilterCrosTest, MouseEvent) { |
| 209 MockInputStub stub; | 218 MockInputStub stub; |
| 210 scoped_ptr<protocol::InputFilter> processor( | 219 scoped_ptr<protocol::InputFilter> processor( |
| 211 new NormalizingInputFilterCros(&stub)); | 220 new NormalizingInputFilterCros(&stub)); |
| 212 | 221 |
| 213 { | 222 { |
| 214 InSequence s; | 223 InSequence s; |
| 215 | 224 |
| 216 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, true))); | 225 EXPECT_CALL(stub, |
| 226 InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, true))); | |
| 217 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseMoveEvent(0, 0))); | 227 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseMoveEvent(0, 0))); |
| 218 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftOsKey, false))); | 228 EXPECT_CALL( |
| 229 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftOsKey, false))); | |
| 219 } | 230 } |
| 220 | 231 |
| 221 // Hold the left OSKey while pressing & releasing the function key. | 232 // Hold the left OSKey while pressing & releasing the function key. |
| 222 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); | 233 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, true)); |
| 223 processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0)); | 234 processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0)); |
| 224 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); | 235 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftOsKey, false)); |
| 225 } | 236 } |
| 226 | 237 |
| 227 // Test left alt + right click is remapped to left alt + left click. | 238 // Test left alt + right click is remapped to left alt + left click. |
| 228 TEST(NormalizingInputFilterCrosTest, LeftAltClick) { | 239 TEST(NormalizingInputFilterCrosTest, LeftAltClick) { |
| 229 MockInputStub stub; | 240 MockInputStub stub; |
| 230 scoped_ptr<protocol::InputFilter> processor( | 241 scoped_ptr<protocol::InputFilter> processor( |
| 231 new NormalizingInputFilterCros(&stub)); | 242 new NormalizingInputFilterCros(&stub)); |
| 232 | 243 |
| 233 { | 244 { |
| 234 InSequence s; | 245 InSequence s; |
| 235 | 246 |
| 236 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftAltKey, true))); | 247 EXPECT_CALL( |
| 237 EXPECT_CALL(stub, InjectMouseEvent( | 248 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftAltKey, true))); |
| 238 EqualsMouseButtonEvent(MouseEvent::BUTTON_LEFT, true))); | 249 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent( |
| 239 EXPECT_CALL(stub, InjectMouseEvent( | 250 MouseEvent::BUTTON_LEFT, true))); |
| 240 EqualsMouseButtonEvent(MouseEvent::BUTTON_LEFT, false))); | 251 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent( |
| 241 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbLeftAltKey, false))); | 252 MouseEvent::BUTTON_LEFT, false))); |
| 253 EXPECT_CALL( | |
| 254 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbLeftAltKey, false))); | |
| 242 } | 255 } |
| 243 | 256 |
| 244 // Hold the left alt key while left-clicking. ChromeOS will rewrite this as | 257 // Hold the left alt key while left-clicking. ChromeOS will rewrite this as |
| 245 // Alt+RightClick | 258 // Alt+RightClick |
| 246 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, true)); | 259 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, true)); |
| 247 processor->InjectMouseEvent( | 260 processor->InjectMouseEvent( |
| 248 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true)); | 261 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true)); |
| 249 processor->InjectMouseEvent( | 262 processor->InjectMouseEvent( |
| 250 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false)); | 263 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false)); |
| 251 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, false)); | 264 processor->InjectKeyEvent(MakeKeyEvent(kUsbLeftAltKey, false)); |
| 252 } | 265 } |
| 253 | 266 |
| 254 // Test that right alt + right click is unchanged. | 267 // Test that right alt + right click is unchanged. |
| 255 TEST(NormalizingInputFilterCrosTest, RightAltClick) { | 268 TEST(NormalizingInputFilterCrosTest, RightAltClick) { |
| 256 MockInputStub stub; | 269 MockInputStub stub; |
| 257 scoped_ptr<protocol::InputFilter> processor( | 270 scoped_ptr<protocol::InputFilter> processor( |
| 258 new NormalizingInputFilterCros(&stub)); | 271 new NormalizingInputFilterCros(&stub)); |
| 259 | 272 |
| 260 { | 273 { |
| 261 InSequence s; | 274 InSequence s; |
| 262 | 275 |
| 263 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightAltKey, true))); | 276 EXPECT_CALL( |
| 264 EXPECT_CALL(stub, InjectMouseEvent( | 277 stub, InjectKeyEvent(EqualsUsbEventWithNumLock(kUsbRightAltKey, true))); |
| 265 EqualsMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true))); | 278 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent( |
| 266 EXPECT_CALL(stub, InjectMouseEvent( | 279 MouseEvent::BUTTON_RIGHT, true))); |
| 267 EqualsMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false))); | 280 EXPECT_CALL(stub, InjectMouseEvent(EqualsMouseButtonEvent( |
| 268 EXPECT_CALL(stub, InjectKeyEvent(EqualsKeyEvent(kUsbRightAltKey, false))); | 281 MouseEvent::BUTTON_RIGHT, false))); |
| 282 EXPECT_CALL(stub, InjectKeyEvent( | |
| 283 EqualsUsbEventWithNumLock(kUsbRightAltKey, false))); | |
| 269 } | 284 } |
| 270 | 285 |
| 271 // Hold the right alt key while left-clicking. ChromeOS will rewrite this as | 286 // Hold the right alt key while left-clicking. ChromeOS will rewrite this as |
| 272 // Alt+RightClick | 287 // Alt+RightClick |
| 273 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, true)); | 288 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, true)); |
| 274 processor->InjectMouseEvent( | 289 processor->InjectMouseEvent( |
| 275 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true)); | 290 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true)); |
| 276 processor->InjectMouseEvent( | 291 processor->InjectMouseEvent( |
| 277 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false)); | 292 MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false)); |
| 278 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, false)); | 293 processor->InjectKeyEvent(MakeKeyEvent(kUsbRightAltKey, false)); |
| 279 } | 294 } |
| 280 | 295 |
| 281 } // namespace remoting | 296 } // namespace remoting |
| OLD | NEW |