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/base/constants.h" | 5 #include "remoting/base/constants.h" |
6 #include "remoting/host/client_session.h" | 6 #include "remoting/host/client_session.h" |
7 #include "remoting/host/host_mock_objects.h" | 7 #include "remoting/host/host_mock_objects.h" |
8 #include "remoting/protocol/protocol_mock_objects.h" | 8 #include "remoting/protocol/protocol_mock_objects.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 108 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
109 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 109 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
110 // This event should get through to the clipboard stub. | 110 // This event should get through to the clipboard stub. |
111 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event2); | 111 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event2); |
112 DisconnectClientSession(); | 112 DisconnectClientSession(); |
113 // This event should not get through to the clipboard stub, | 113 // This event should not get through to the clipboard stub, |
114 // because the client has disconnected. | 114 // because the client has disconnected. |
115 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event3); | 115 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event3); |
116 } | 116 } |
117 | 117 |
118 MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") { | 118 MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") { |
119 return arg.keycode() == keycode && arg.pressed() == pressed; | 119 return arg.usb_keycode() == (unsigned int)usb_keycode && |
| 120 arg.pressed() == pressed; |
120 } | 121 } |
121 | 122 |
122 MATCHER_P2(EqualsMouseEvent, x, y, "") { | 123 MATCHER_P2(EqualsMouseEvent, x, y, "") { |
123 return arg.x() == x && arg.y() == y; | 124 return arg.x() == x && arg.y() == y; |
124 } | 125 } |
125 | 126 |
126 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") { | 127 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") { |
127 return arg.button() == button && arg.button_down() == down; | 128 return arg.button() == button && arg.button_down() == down; |
128 } | 129 } |
129 | 130 |
130 TEST_F(ClientSessionTest, InputStubFilter) { | 131 TEST_F(ClientSessionTest, InputStubFilter) { |
131 protocol::KeyEvent key_event1; | 132 protocol::KeyEvent key_event1; |
132 key_event1.set_pressed(true); | 133 key_event1.set_pressed(true); |
133 key_event1.set_keycode(1); | 134 key_event1.set_usb_keycode(1); |
134 | 135 |
135 protocol::KeyEvent key_event2_down; | 136 protocol::KeyEvent key_event2_down; |
136 key_event2_down.set_pressed(true); | 137 key_event2_down.set_pressed(true); |
137 key_event2_down.set_keycode(2); | 138 key_event2_down.set_usb_keycode(2); |
138 | 139 |
139 protocol::KeyEvent key_event2_up; | 140 protocol::KeyEvent key_event2_up; |
140 key_event2_up.set_pressed(false); | 141 key_event2_up.set_pressed(false); |
141 key_event2_up.set_keycode(2); | 142 key_event2_up.set_usb_keycode(2); |
142 | 143 |
143 protocol::KeyEvent key_event3; | 144 protocol::KeyEvent key_event3; |
144 key_event3.set_pressed(true); | 145 key_event3.set_pressed(true); |
145 key_event3.set_keycode(3); | 146 key_event3.set_usb_keycode(3); |
146 | 147 |
147 protocol::MouseEvent mouse_event1; | 148 protocol::MouseEvent mouse_event1; |
148 mouse_event1.set_x(100); | 149 mouse_event1.set_x(100); |
149 mouse_event1.set_y(101); | 150 mouse_event1.set_y(101); |
150 | 151 |
151 protocol::MouseEvent mouse_event2; | 152 protocol::MouseEvent mouse_event2; |
152 mouse_event2.set_x(200); | 153 mouse_event2.set_x(200); |
153 mouse_event2.set_y(201); | 154 mouse_event2.set_y(201); |
154 | 155 |
155 protocol::MouseEvent mouse_event3; | 156 protocol::MouseEvent mouse_event3; |
156 mouse_event3.set_x(300); | 157 mouse_event3.set_x(300); |
157 mouse_event3.set_y(301); | 158 mouse_event3.set_y(301); |
158 | 159 |
159 InSequence s; | 160 InSequence s; |
160 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 161 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); |
161 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); | 162 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); |
162 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true))); | 163 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, true))); |
163 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); | 164 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, false))); |
164 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); | 165 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); |
165 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); | 166 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); |
166 | 167 |
167 // These events should not get through to the input stub, | 168 // These events should not get through to the input stub, |
168 // because the client isn't authenticated yet. | 169 // because the client isn't authenticated yet. |
169 connection_->input_stub()->InjectKeyEvent(key_event1); | 170 connection_->input_stub()->InjectKeyEvent(key_event1); |
170 connection_->input_stub()->InjectMouseEvent(mouse_event1); | 171 connection_->input_stub()->InjectMouseEvent(mouse_event1); |
171 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 172 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
172 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 173 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
173 // These events should get through to the input stub. | 174 // These events should get through to the input stub. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 mouse_event1.y())); | 213 mouse_event1.y())); |
213 connection_->input_stub()->InjectMouseEvent(mouse_event3); | 214 connection_->input_stub()->InjectMouseEvent(mouse_event3); |
214 // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually | 215 // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually |
215 // (via dependency injection, not sleep!) | 216 // (via dependency injection, not sleep!) |
216 DisconnectClientSession(); | 217 DisconnectClientSession(); |
217 } | 218 } |
218 | 219 |
219 TEST_F(ClientSessionTest, RestoreEventState) { | 220 TEST_F(ClientSessionTest, RestoreEventState) { |
220 protocol::KeyEvent key1; | 221 protocol::KeyEvent key1; |
221 key1.set_pressed(true); | 222 key1.set_pressed(true); |
222 key1.set_keycode(1); | 223 key1.set_usb_keycode(1); |
223 | 224 |
224 protocol::KeyEvent key2; | 225 protocol::KeyEvent key2; |
225 key2.set_pressed(true); | 226 key2.set_pressed(true); |
226 key2.set_keycode(2); | 227 key2.set_usb_keycode(2); |
227 | 228 |
228 protocol::MouseEvent mousedown; | 229 protocol::MouseEvent mousedown; |
229 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); | 230 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); |
230 mousedown.set_button_down(true); | 231 mousedown.set_button_down(true); |
231 | 232 |
232 InSequence s; | 233 InSequence s; |
233 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 234 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); |
234 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); | 235 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); |
235 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(1, true))); | 236 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(1, true))); |
236 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true))); | 237 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, true))); |
237 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent( | 238 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent( |
238 protocol::MouseEvent::BUTTON_LEFT, true))); | 239 protocol::MouseEvent::BUTTON_LEFT, true))); |
239 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(1, false))); | 240 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(1, false))); |
240 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); | 241 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, false))); |
241 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent( | 242 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent( |
242 protocol::MouseEvent::BUTTON_LEFT, false))); | 243 protocol::MouseEvent::BUTTON_LEFT, false))); |
243 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); | 244 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); |
244 | 245 |
245 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 246 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
246 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 247 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
247 | 248 |
248 connection_->input_stub()->InjectKeyEvent(key1); | 249 connection_->input_stub()->InjectKeyEvent(key1); |
249 connection_->input_stub()->InjectKeyEvent(key2); | 250 connection_->input_stub()->InjectKeyEvent(key2); |
250 connection_->input_stub()->InjectMouseEvent(mousedown); | 251 connection_->input_stub()->InjectMouseEvent(mousedown); |
(...skipping 26 matching lines...) Expand all Loading... |
277 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent( | 278 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent( |
278 expected_x[i], expected_y[j]))); | 279 expected_x[i], expected_y[j]))); |
279 connection_->input_stub()->InjectMouseEvent(event); | 280 connection_->input_stub()->InjectMouseEvent(event); |
280 } | 281 } |
281 } | 282 } |
282 | 283 |
283 DisconnectClientSession(); | 284 DisconnectClientSession(); |
284 } | 285 } |
285 | 286 |
286 } // namespace remoting | 287 } // namespace remoting |
OLD | NEW |