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

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

Issue 9465035: Move ClientSession's input logic into separate components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace |authenticated_| with an InputFilter. Created 8 years, 8 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
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 "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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") { 102 MATCHER_P2(EqualsKeyEvent, keycode, pressed, "") {
103 return arg.keycode() == keycode && arg.pressed() == pressed; 103 return arg.keycode() == keycode && arg.pressed() == pressed;
104 } 104 }
105 105
106 MATCHER_P2(EqualsMouseEvent, x, y, "") { 106 MATCHER_P2(EqualsMouseEvent, x, y, "") {
107 return arg.x() == x && arg.y() == y; 107 return arg.x() == x && arg.y() == y;
108 } 108 }
109 109
110 MATCHER_P(EqualsMouseUpEvent, button, "") { 110 MATCHER_P2(EqualsMouseButtonEvent, button, down, "") {
111 return arg.button() == button && !arg.button_down(); 111 return arg.button() == button && arg.button_down() == down;
112 } 112 }
113 113
114 TEST_F(ClientSessionTest, InputStubFilter) { 114 TEST_F(ClientSessionTest, InputStubFilter) {
115 protocol::KeyEvent key_event1; 115 protocol::KeyEvent key_event1;
116 key_event1.set_pressed(true); 116 key_event1.set_pressed(true);
117 key_event1.set_keycode(1); 117 key_event1.set_keycode(1);
118 118
119 protocol::KeyEvent key_event2_down; 119 protocol::KeyEvent key_event2_down;
120 key_event2_down.set_pressed(true); 120 key_event2_down.set_pressed(true);
121 key_event2_down.set_keycode(2); 121 key_event2_down.set_keycode(2);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 key1.set_keycode(1); 206 key1.set_keycode(1);
207 207
208 protocol::KeyEvent key2; 208 protocol::KeyEvent key2;
209 key2.set_pressed(true); 209 key2.set_pressed(true);
210 key2.set_keycode(2); 210 key2.set_keycode(2);
211 211
212 protocol::MouseEvent mousedown; 212 protocol::MouseEvent mousedown;
213 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); 213 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT);
214 mousedown.set_button_down(true); 214 mousedown.set_button_down(true);
215 215
216 client_session_->RecordKeyEvent(key1); 216 InSequence s;
217 client_session_->RecordKeyEvent(key2); 217 EXPECT_CALL(host_event_stub_, InjectKeyEvent(EqualsKeyEvent(1, true)));
218 client_session_->RecordMouseButtonState(mousedown); 218 EXPECT_CALL(host_event_stub_, InjectKeyEvent(EqualsKeyEvent(2, true)));
219 219 EXPECT_CALL(host_event_stub_, InjectMouseEvent(EqualsMouseButtonEvent(
220 protocol::MouseEvent::BUTTON_LEFT, true)));
220 EXPECT_CALL(host_event_stub_, InjectKeyEvent(EqualsKeyEvent(1, false))); 221 EXPECT_CALL(host_event_stub_, InjectKeyEvent(EqualsKeyEvent(1, false)));
221 EXPECT_CALL(host_event_stub_, InjectKeyEvent(EqualsKeyEvent(2, false))); 222 EXPECT_CALL(host_event_stub_, InjectKeyEvent(EqualsKeyEvent(2, false)));
222 EXPECT_CALL(host_event_stub_, InjectMouseEvent(EqualsMouseUpEvent( 223 EXPECT_CALL(host_event_stub_, InjectMouseEvent(EqualsMouseButtonEvent(
223 protocol::MouseEvent::BUTTON_LEFT))); 224 protocol::MouseEvent::BUTTON_LEFT, false)));
224 225
225 client_session_->RestoreEventState(); 226 client_session_->OnConnectionOpened(client_session_->connection());
227
228 client_session_->InjectKeyEvent(key1);
229 client_session_->InjectKeyEvent(key2);
230 client_session_->InjectMouseEvent(mousedown);
231
232 client_session_->Disconnect();
226 } 233 }
227 234
228 TEST_F(ClientSessionTest, ClampMouseEvents) { 235 TEST_F(ClientSessionTest, ClampMouseEvents) {
229 SkISize screen(SkISize::Make(200, 100)); 236 SkISize screen(SkISize::Make(200, 100));
230 EXPECT_CALL(capturer_, size_most_recent()) 237 EXPECT_CALL(capturer_, size_most_recent())
231 .WillRepeatedly(ReturnRef(screen)); 238 .WillRepeatedly(ReturnRef(screen));
232 239
233 EXPECT_CALL(session_event_handler_, 240 EXPECT_CALL(session_event_handler_,
234 OnSessionAuthenticated(client_session_.get())); 241 OnSessionAuthenticated(client_session_.get()));
235 EXPECT_CALL(session_event_handler_, 242 EXPECT_CALL(session_event_handler_,
(...skipping 12 matching lines...) Expand all
248 event.set_x(input_x[i]); 255 event.set_x(input_x[i]);
249 event.set_y(input_y[j]); 256 event.set_y(input_y[j]);
250 EXPECT_CALL(host_event_stub_, InjectMouseEvent(EqualsMouseEvent( 257 EXPECT_CALL(host_event_stub_, InjectMouseEvent(EqualsMouseEvent(
251 expected_x[i], expected_y[j]))); 258 expected_x[i], expected_y[j])));
252 client_session_->InjectMouseEvent(event); 259 client_session_->InjectMouseEvent(event);
253 } 260 }
254 } 261 }
255 } 262 }
256 263
257 } // namespace remoting 264 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698