Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: remoting/host/client_session_unittest.cc

Issue 10894050: Remove support for Windows-style keycodes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux EventExecutor typo. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/client/plugin/pepper_input_handler.cc ('k') | remoting/host/event_executor_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "remoting/base/constants.h" 6 #include "remoting/base/constants.h"
7 #include "remoting/host/client_session.h" 7 #include "remoting/host/client_session.h"
8 #include "remoting/host/host_mock_objects.h" 8 #include "remoting/host/host_mock_objects.h"
9 #include "remoting/protocol/protocol_mock_objects.h" 9 #include "remoting/protocol/protocol_mock_objects.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 client_session_->OnConnectionAuthenticated(client_session_->connection()); 109 client_session_->OnConnectionAuthenticated(client_session_->connection());
110 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 110 client_session_->OnConnectionChannelsConnected(client_session_->connection());
111 // This event should get through to the clipboard stub. 111 // This event should get through to the clipboard stub.
112 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event2); 112 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event2);
113 DisconnectClientSession(); 113 DisconnectClientSession();
114 // This event should not get through to the clipboard stub, 114 // This event should not get through to the clipboard stub,
115 // because the client has disconnected. 115 // because the client has disconnected.
116 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event3); 116 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event3);
117 } 117 }
118 118
119 MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") { 119 MATCHER_P2(EqualsUsbEvent, usb_keycode, pressed, "") {
120 return arg.keycode() == keycode && arg.pressed() == pressed; 120 return arg.usb_keycode() == (unsigned int)usb_keycode &&
121 arg.pressed() == pressed;
121 } 122 }
122 123
123 MATCHER_P2(EqualsMouseEvent, x, y, "") { 124 MATCHER_P2(EqualsMouseEvent, x, y, "") {
124 return arg.x() == x && arg.y() == y; 125 return arg.x() == x && arg.y() == y;
125 } 126 }
126 127
127 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") { 128 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") {
128 return arg.button() == button && arg.button_down() == down; 129 return arg.button() == button && arg.button_down() == down;
129 } 130 }
130 131
131 TEST_F(ClientSessionTest, InputStubFilter) { 132 TEST_F(ClientSessionTest, InputStubFilter) {
132 protocol::KeyEvent key_event1; 133 protocol::KeyEvent key_event1;
133 key_event1.set_pressed(true); 134 key_event1.set_pressed(true);
134 key_event1.set_keycode(1); 135 key_event1.set_usb_keycode(1);
135 136
136 protocol::KeyEvent key_event2_down; 137 protocol::KeyEvent key_event2_down;
137 key_event2_down.set_pressed(true); 138 key_event2_down.set_pressed(true);
138 key_event2_down.set_keycode(2); 139 key_event2_down.set_usb_keycode(2);
139 140
140 protocol::KeyEvent key_event2_up; 141 protocol::KeyEvent key_event2_up;
141 key_event2_up.set_pressed(false); 142 key_event2_up.set_pressed(false);
142 key_event2_up.set_keycode(2); 143 key_event2_up.set_usb_keycode(2);
143 144
144 protocol::KeyEvent key_event3; 145 protocol::KeyEvent key_event3;
145 key_event3.set_pressed(true); 146 key_event3.set_pressed(true);
146 key_event3.set_keycode(3); 147 key_event3.set_usb_keycode(3);
147 148
148 protocol::MouseEvent mouse_event1; 149 protocol::MouseEvent mouse_event1;
149 mouse_event1.set_x(100); 150 mouse_event1.set_x(100);
150 mouse_event1.set_y(101); 151 mouse_event1.set_y(101);
151 152
152 protocol::MouseEvent mouse_event2; 153 protocol::MouseEvent mouse_event2;
153 mouse_event2.set_x(200); 154 mouse_event2.set_x(200);
154 mouse_event2.set_y(201); 155 mouse_event2.set_y(201);
155 156
156 protocol::MouseEvent mouse_event3; 157 protocol::MouseEvent mouse_event3;
157 mouse_event3.set_x(300); 158 mouse_event3.set_x(300);
158 mouse_event3.set_y(301); 159 mouse_event3.set_y(301);
159 160
160 InSequence s; 161 InSequence s;
161 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 162 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
162 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 163 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
163 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true))); 164 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, true)));
164 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); 165 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, false)));
165 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); 166 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201)));
166 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 167 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
167 168
168 // These events should not get through to the input stub, 169 // These events should not get through to the input stub,
169 // because the client isn't authenticated yet. 170 // because the client isn't authenticated yet.
170 connection_->input_stub()->InjectKeyEvent(key_event1); 171 connection_->input_stub()->InjectKeyEvent(key_event1);
171 connection_->input_stub()->InjectMouseEvent(mouse_event1); 172 connection_->input_stub()->InjectMouseEvent(mouse_event1);
172 client_session_->OnConnectionAuthenticated(client_session_->connection()); 173 client_session_->OnConnectionAuthenticated(client_session_->connection());
173 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 174 client_session_->OnConnectionChannelsConnected(client_session_->connection());
174 // These events should get through to the input stub. 175 // These events should get through to the input stub.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 mouse_event1.y())); 214 mouse_event1.y()));
214 connection_->input_stub()->InjectMouseEvent(mouse_event3); 215 connection_->input_stub()->InjectMouseEvent(mouse_event3);
215 // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually 216 // TODO(jamiewalch): Verify that remote inputs are re-enabled eventually
216 // (via dependency injection, not sleep!) 217 // (via dependency injection, not sleep!)
217 DisconnectClientSession(); 218 DisconnectClientSession();
218 } 219 }
219 220
220 TEST_F(ClientSessionTest, RestoreEventState) { 221 TEST_F(ClientSessionTest, RestoreEventState) {
221 protocol::KeyEvent key1; 222 protocol::KeyEvent key1;
222 key1.set_pressed(true); 223 key1.set_pressed(true);
223 key1.set_keycode(1); 224 key1.set_usb_keycode(1);
224 225
225 protocol::KeyEvent key2; 226 protocol::KeyEvent key2;
226 key2.set_pressed(true); 227 key2.set_pressed(true);
227 key2.set_keycode(2); 228 key2.set_usb_keycode(2);
228 229
229 protocol::MouseEvent mousedown; 230 protocol::MouseEvent mousedown;
230 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); 231 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT);
231 mousedown.set_button_down(true); 232 mousedown.set_button_down(true);
232 233
233 InSequence s; 234 InSequence s;
234 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 235 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
235 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 236 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
236 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(1, true))); 237 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(1, true)));
237 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, true))); 238 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, true)));
238 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent( 239 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent(
239 protocol::MouseEvent::BUTTON_LEFT, true))); 240 protocol::MouseEvent::BUTTON_LEFT, true)));
240 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(1, false))); 241 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(1, false)));
241 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); 242 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsUsbEvent(2, false)));
242 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent( 243 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseButtonEvent(
243 protocol::MouseEvent::BUTTON_LEFT, false))); 244 protocol::MouseEvent::BUTTON_LEFT, false)));
244 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 245 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
245 246
246 client_session_->OnConnectionAuthenticated(client_session_->connection()); 247 client_session_->OnConnectionAuthenticated(client_session_->connection());
247 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 248 client_session_->OnConnectionChannelsConnected(client_session_->connection());
248 249
249 connection_->input_stub()->InjectKeyEvent(key1); 250 connection_->input_stub()->InjectKeyEvent(key1);
250 connection_->input_stub()->InjectKeyEvent(key2); 251 connection_->input_stub()->InjectKeyEvent(key2);
251 connection_->input_stub()->InjectMouseEvent(mousedown); 252 connection_->input_stub()->InjectMouseEvent(mousedown);
(...skipping 26 matching lines...) Expand all
278 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent( 279 EXPECT_CALL(host_input_stub_, InjectMouseEvent(EqualsMouseEvent(
279 expected_x[i], expected_y[j]))); 280 expected_x[i], expected_y[j])));
280 connection_->input_stub()->InjectMouseEvent(event); 281 connection_->input_stub()->InjectMouseEvent(event);
281 } 282 }
282 } 283 }
283 284
284 DisconnectClientSession(); 285 DisconnectClientSession();
285 } 286 }
286 287
287 } // namespace remoting 288 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_input_handler.cc ('k') | remoting/host/event_executor_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698