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

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

Issue 11761019: Tiny little refactoring of DesktopEnvironment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/host/client_session.cc ('k') | remoting/host/desktop_environment.h » ('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/auto_thread_task_runner.h" 6 #include "remoting/base/auto_thread_task_runner.h"
7 #include "remoting/base/constants.h" 7 #include "remoting/base/constants.h"
8 #include "remoting/capturer/video_capturer_mock_objects.h" 8 #include "remoting/capturer/video_capturer_mock_objects.h"
9 #include "remoting/host/audio_capturer.h" 9 #include "remoting/host/audio_capturer.h"
10 #include "remoting/host/client_session.h" 10 #include "remoting/host/client_session.h"
11 #include "remoting/host/desktop_environment.h"
12 #include "remoting/host/host_mock_objects.h" 11 #include "remoting/host/host_mock_objects.h"
13 #include "remoting/protocol/protocol_mock_objects.h" 12 #include "remoting/protocol/protocol_mock_objects.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 14
16 namespace remoting { 15 namespace remoting {
17 16
18 using protocol::MockConnectionToClient; 17 using protocol::MockConnectionToClient;
19 using protocol::MockClientStub; 18 using protocol::MockClientStub;
20 using protocol::MockHostStub; 19 using protocol::MockHostStub;
21 using protocol::MockInputStub; 20 using protocol::MockInputStub;
22 using protocol::MockSession; 21 using protocol::MockSession;
23 using protocol::MockVideoStub; 22 using protocol::MockVideoStub;
24 using protocol::SessionConfig; 23 using protocol::SessionConfig;
25 24
26 using testing::_; 25 using testing::_;
27 using testing::AnyNumber; 26 using testing::AnyNumber;
28 using testing::DeleteArg; 27 using testing::DeleteArg;
29 using testing::Expectation; 28 using testing::Expectation;
30 using testing::InSequence; 29 using testing::InSequence;
31 using testing::Return; 30 using testing::Return;
32 using testing::ReturnRef; 31 using testing::ReturnRef;
32 using testing::ReturnPointee;
33 33
34 class ClientSessionTest : public testing::Test { 34 class ClientSessionTest : public testing::Test {
35 public: 35 public:
36 ClientSessionTest() : event_executor_(NULL) {} 36 ClientSessionTest() : desktop_environment_(NULL) {}
37 37
38 virtual void SetUp() OVERRIDE { 38 virtual void SetUp() OVERRIDE {
39 ui_task_runner_ = new AutoThreadTaskRunner( 39 ui_task_runner_ = new AutoThreadTaskRunner(
40 message_loop_.message_loop_proxy(), 40 message_loop_.message_loop_proxy(),
41 base::Bind(&ClientSessionTest::QuitMainMessageLoop, 41 base::Bind(&ClientSessionTest::QuitMainMessageLoop,
42 base::Unretained(this))); 42 base::Unretained(this)));
43 43
44 client_jid_ = "user@domain/rest-of-jid"; 44 client_jid_ = "user@domain/rest-of-jid";
45 45
46 desktop_environment_factory_.reset(new MockDesktopEnvironmentFactory()); 46 desktop_environment_factory_.reset(
47 new MockDesktopEnvironmentFactory(ui_task_runner_));
47 EXPECT_CALL(*desktop_environment_factory_, CreatePtr()) 48 EXPECT_CALL(*desktop_environment_factory_, CreatePtr())
48 .Times(AnyNumber()) 49 .Times(AnyNumber())
49 .WillRepeatedly(Invoke(this, 50 .WillRepeatedly(Invoke(this,
50 &ClientSessionTest::CreateDesktopEnvironment)); 51 &ClientSessionTest::CreateDesktopEnvironment));
51 52
52 // Set up a large default screen size that won't affect most tests. 53 // Set up a large default screen size that won't affect most tests.
53 screen_size_.set(1000, 1000); 54 screen_size_.set(1000, 1000);
54 55
55 session_config_ = SessionConfig::ForTest(); 56 session_config_ = SessionConfig::ForTest();
56 57
(...skipping 10 matching lines...) Expand all
67 EXPECT_CALL(*connection, session()).WillRepeatedly(Return(session)); 68 EXPECT_CALL(*connection, session()).WillRepeatedly(Return(session));
68 EXPECT_CALL(*connection, client_stub()) 69 EXPECT_CALL(*connection, client_stub())
69 .WillRepeatedly(Return(&client_stub_)); 70 .WillRepeatedly(Return(&client_stub_));
70 EXPECT_CALL(*connection, video_stub()).WillRepeatedly(Return(&video_stub_)); 71 EXPECT_CALL(*connection, video_stub()).WillRepeatedly(Return(&video_stub_));
71 EXPECT_CALL(*connection, Disconnect()); 72 EXPECT_CALL(*connection, Disconnect());
72 connection_ = connection.get(); 73 connection_ = connection.get();
73 74
74 client_session_ = new ClientSession( 75 client_session_ = new ClientSession(
75 &session_event_handler_, 76 &session_event_handler_,
76 ui_task_runner_, // Audio thread. 77 ui_task_runner_, // Audio thread.
78 ui_task_runner_, // Input thread.
77 ui_task_runner_, // Capture thread. 79 ui_task_runner_, // Capture thread.
78 ui_task_runner_, // Encode thread. 80 ui_task_runner_, // Encode thread.
79 ui_task_runner_, // Network thread. 81 ui_task_runner_, // Network thread.
82 ui_task_runner_, // UI thread.
80 connection.PassAs<protocol::ConnectionToClient>(), 83 connection.PassAs<protocol::ConnectionToClient>(),
81 desktop_environment_factory_.get(), 84 desktop_environment_factory_.get(),
82 base::TimeDelta()); 85 base::TimeDelta());
83 } 86 }
84 87
85 virtual void TearDown() OVERRIDE { 88 virtual void TearDown() OVERRIDE {
86 // MockClientSessionEventHandler won't trigger Stop, so fake it. 89 // MockClientSessionEventHandler won't trigger Stop, so fake it.
87 client_session_->Stop(base::Bind( 90 client_session_->Stop();
88 &ClientSessionTest::OnClientStopped, base::Unretained(this))); 91 client_session_ = NULL;
92
93 desktop_environment_factory_.reset();
89 94
90 // Run message loop before destroying because the session is destroyed 95 // Run message loop before destroying because the session is destroyed
91 // asynchronously. 96 // asynchronously.
92 ui_task_runner_ = NULL; 97 ui_task_runner_ = NULL;
93 message_loop_.Run(); 98 message_loop_.Run();
94 99
95 // Verify that the client session has been stopped. 100 // Verify that the client session has been stopped.
96 EXPECT_TRUE(client_session_.get() == NULL); 101 EXPECT_TRUE(client_session_.get() == NULL);
97 } 102 }
98 103
99 protected: 104 protected:
100 DesktopEnvironment* CreateDesktopEnvironment() { 105 DesktopEnvironment* CreateDesktopEnvironment() {
101 MockVideoFrameCapturer* capturer = new MockVideoFrameCapturer(); 106 EXPECT_TRUE(!desktop_environment_);
102 EXPECT_CALL(*capturer, Start(_));
103 EXPECT_CALL(*capturer, Stop());
104 EXPECT_CALL(*capturer, InvalidateRegion(_)).Times(AnyNumber());
105 EXPECT_CALL(*capturer, CaptureFrame()).Times(AnyNumber());
106 EXPECT_CALL(*capturer, size_most_recent())
107 .WillRepeatedly(ReturnRef(screen_size_));
108 107
109 EXPECT_TRUE(!event_executor_); 108 desktop_environment_ = new MockDesktopEnvironment();
110 event_executor_ = new MockEventExecutor(); 109 EXPECT_CALL(*desktop_environment_, StartVideoPtr(_, _, _, _, _));
111 return new DesktopEnvironment(scoped_ptr<AudioCapturer>(NULL), 110 EXPECT_CALL(*desktop_environment_, GetScreenSize())
112 scoped_ptr<EventExecutor>(event_executor_), 111 .WillRepeatedly(ReturnPointee(&screen_size_));
113 scoped_ptr<VideoFrameCapturer>(capturer)); 112
113 return desktop_environment_;
114 } 114 }
115 115
116 void DisconnectClientSession() { 116 void DisconnectClientSession() {
117 client_session_->Disconnect(); 117 client_session_->Disconnect();
118 // MockSession won't trigger OnConnectionClosed, so fake it. 118 // MockSession won't trigger OnConnectionClosed, so fake it.
119 client_session_->OnConnectionClosed(client_session_->connection(), 119 client_session_->OnConnectionClosed(client_session_->connection(),
120 protocol::OK); 120 protocol::OK);
121 } 121 }
122 122
123 void QuitMainMessageLoop() { 123 void QuitMainMessageLoop() {
124 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); 124 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
125 } 125 }
126 126
127 void OnClientStopped() {
128 client_session_ = NULL;
129 }
130
131 // Message loop passed to |client_session_| to perform all functions on. 127 // Message loop passed to |client_session_| to perform all functions on.
132 MessageLoop message_loop_; 128 MessageLoop message_loop_;
133 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; 129 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
134 130
135 // ClientSession instance under test. 131 // ClientSession instance under test.
136 scoped_refptr<ClientSession> client_session_; 132 scoped_refptr<ClientSession> client_session_;
137 133
138 // ClientSession::EventHandler mock for use in tests. 134 // ClientSession::EventHandler mock for use in tests.
139 MockClientSessionEventHandler session_event_handler_; 135 MockClientSessionEventHandler session_event_handler_;
140 136
141 // Screen size that the fake VideoFrameCapturer should report. 137 // Screen size that the fake VideoFrameCapturer should report.
142 SkISize screen_size_; 138 SkISize screen_size_;
143 139
144 // Storage for values to be returned by the protocol::Session mock. 140 // Storage for values to be returned by the protocol::Session mock.
145 SessionConfig session_config_; 141 SessionConfig session_config_;
146 std::string client_jid_; 142 std::string client_jid_;
147 143
148 // Stubs returned to |client_session_| components by |connection_|. 144 // Stubs returned to |client_session_| components by |connection_|.
149 MockClientStub client_stub_; 145 MockClientStub client_stub_;
150 MockVideoStub video_stub_; 146 MockVideoStub video_stub_;
151 147
152 // DesktopEnvironment owns |event_executor_|, but input injection tests need 148 MockDesktopEnvironment* desktop_environment_;
153 // to express expectations on it.
154 MockEventExecutor* event_executor_;
155 149
156 // ClientSession owns |connection_| but tests need it to inject fake events. 150 // ClientSession owns |connection_| but tests need it to inject fake events.
157 MockConnectionToClient* connection_; 151 MockConnectionToClient* connection_;
158 152
159 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_; 153 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_;
160 }; 154 };
161 155
162 MATCHER_P2(EqualsClipboardEvent, m, d, "") { 156 MATCHER_P2(EqualsClipboardEvent, m, d, "") {
163 return (strcmp(arg.mime_type().c_str(), m) == 0 && 157 return (strcmp(arg.mime_type().c_str(), m) == 0 &&
164 memcmp(arg.data().data(), d, arg.data().size()) == 0); 158 memcmp(arg.data().data(), d, arg.data().size()) == 0);
165 } 159 }
166 160
167 TEST_F(ClientSessionTest, ClipboardStubFilter) { 161 TEST_F(ClientSessionTest, ClipboardStubFilter) {
168 protocol::ClipboardEvent clipboard_event1; 162 protocol::ClipboardEvent clipboard_event1;
169 clipboard_event1.set_mime_type(kMimeTypeTextUtf8); 163 clipboard_event1.set_mime_type(kMimeTypeTextUtf8);
170 clipboard_event1.set_data("a"); 164 clipboard_event1.set_data("a");
171 165
172 protocol::ClipboardEvent clipboard_event2; 166 protocol::ClipboardEvent clipboard_event2;
173 clipboard_event2.set_mime_type(kMimeTypeTextUtf8); 167 clipboard_event2.set_mime_type(kMimeTypeTextUtf8);
174 clipboard_event2.set_data("b"); 168 clipboard_event2.set_data("b");
175 169
176 protocol::ClipboardEvent clipboard_event3; 170 protocol::ClipboardEvent clipboard_event3;
177 clipboard_event3.set_mime_type(kMimeTypeTextUtf8); 171 clipboard_event3.set_mime_type(kMimeTypeTextUtf8);
178 clipboard_event3.set_data("c"); 172 clipboard_event3.set_data("c");
179 173
180 InSequence s; 174 InSequence s;
181 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 175 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
182 EXPECT_CALL(*event_executor_, StartPtr(_)); 176 EXPECT_CALL(*desktop_environment_, StartInput(_, _, _));
183 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 177 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
184 EXPECT_CALL(*event_executor_, InjectClipboardEvent(EqualsClipboardEvent( 178 EXPECT_CALL(*desktop_environment_, InjectClipboardEvent(EqualsClipboardEvent(
185 kMimeTypeTextUtf8, "b"))); 179 kMimeTypeTextUtf8, "b")));
186 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 180 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
187 181
188 // This event should not get through to the clipboard stub, 182 // This event should not get through to the clipboard stub,
189 // because the client isn't authenticated yet. 183 // because the client isn't authenticated yet.
190 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event1); 184 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event1);
191 client_session_->OnConnectionAuthenticated(client_session_->connection()); 185 client_session_->OnConnectionAuthenticated(client_session_->connection());
192 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 186 client_session_->OnConnectionChannelsConnected(client_session_->connection());
193 // This event should get through to the clipboard stub. 187 // This event should get through to the clipboard stub.
194 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event2); 188 connection_->clipboard_stub()->InjectClipboardEvent(clipboard_event2);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 protocol::MouseEvent mouse_event2; 229 protocol::MouseEvent mouse_event2;
236 mouse_event2.set_x(200); 230 mouse_event2.set_x(200);
237 mouse_event2.set_y(201); 231 mouse_event2.set_y(201);
238 232
239 protocol::MouseEvent mouse_event3; 233 protocol::MouseEvent mouse_event3;
240 mouse_event3.set_x(300); 234 mouse_event3.set_x(300);
241 mouse_event3.set_y(301); 235 mouse_event3.set_y(301);
242 236
243 InSequence s; 237 InSequence s;
244 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 238 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
245 EXPECT_CALL(*event_executor_, StartPtr(_)); 239 EXPECT_CALL(*desktop_environment_, StartInput(_, _, _));
246 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 240 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
247 EXPECT_CALL(*event_executor_, InjectKeyEvent(EqualsUsbEvent(2, true))); 241 EXPECT_CALL(*desktop_environment_, InjectKeyEvent(EqualsUsbEvent(2, true)));
248 EXPECT_CALL(*event_executor_, InjectKeyEvent(EqualsUsbEvent(2, false))); 242 EXPECT_CALL(*desktop_environment_, InjectKeyEvent(EqualsUsbEvent(2, false)));
249 EXPECT_CALL(*event_executor_, InjectMouseEvent(EqualsMouseEvent(200, 201))); 243 EXPECT_CALL(*desktop_environment_, InjectMouseEvent(EqualsMouseEvent(
244 200, 201)));
250 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 245 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
251 246
252 // These events should not get through to the input stub, 247 // These events should not get through to the input stub,
253 // because the client isn't authenticated yet. 248 // because the client isn't authenticated yet.
254 connection_->input_stub()->InjectKeyEvent(key_event1); 249 connection_->input_stub()->InjectKeyEvent(key_event1);
255 connection_->input_stub()->InjectMouseEvent(mouse_event1); 250 connection_->input_stub()->InjectMouseEvent(mouse_event1);
256 client_session_->OnConnectionAuthenticated(client_session_->connection()); 251 client_session_->OnConnectionAuthenticated(client_session_->connection());
257 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 252 client_session_->OnConnectionChannelsConnected(client_session_->connection());
258 // These events should get through to the input stub. 253 // These events should get through to the input stub.
259 connection_->input_stub()->InjectKeyEvent(key_event2_down); 254 connection_->input_stub()->InjectKeyEvent(key_event2_down);
(...skipping 12 matching lines...) Expand all
272 mouse_event1.set_y(101); 267 mouse_event1.set_y(101);
273 protocol::MouseEvent mouse_event2; 268 protocol::MouseEvent mouse_event2;
274 mouse_event2.set_x(200); 269 mouse_event2.set_x(200);
275 mouse_event2.set_y(201); 270 mouse_event2.set_y(201);
276 protocol::MouseEvent mouse_event3; 271 protocol::MouseEvent mouse_event3;
277 mouse_event3.set_x(300); 272 mouse_event3.set_x(300);
278 mouse_event3.set_y(301); 273 mouse_event3.set_y(301);
279 274
280 InSequence s; 275 InSequence s;
281 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 276 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
282 EXPECT_CALL(*event_executor_, StartPtr(_)); 277 EXPECT_CALL(*desktop_environment_, StartInput(_, _, _));
283 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 278 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
284 EXPECT_CALL(*event_executor_, InjectMouseEvent(EqualsMouseEvent(100, 101))); 279 EXPECT_CALL(*desktop_environment_, InjectMouseEvent(EqualsMouseEvent(
285 EXPECT_CALL(*event_executor_, InjectMouseEvent(EqualsMouseEvent(200, 201))); 280 100, 101)));
281 EXPECT_CALL(*desktop_environment_, InjectMouseEvent(EqualsMouseEvent(
282 200, 201)));
286 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 283 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
287 284
288 client_session_->OnConnectionAuthenticated(client_session_->connection()); 285 client_session_->OnConnectionAuthenticated(client_session_->connection());
289 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 286 client_session_->OnConnectionChannelsConnected(client_session_->connection());
290 // This event should get through to the input stub. 287 // This event should get through to the input stub.
291 connection_->input_stub()->InjectMouseEvent(mouse_event1); 288 connection_->input_stub()->InjectMouseEvent(mouse_event1);
292 // This one should too because the local event echoes the remote one. 289 // This one should too because the local event echoes the remote one.
293 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(), 290 client_session_->LocalMouseMoved(SkIPoint::Make(mouse_event1.x(),
294 mouse_event1.y())); 291 mouse_event1.y()));
295 connection_->input_stub()->InjectMouseEvent(mouse_event2); 292 connection_->input_stub()->InjectMouseEvent(mouse_event2);
(...skipping 14 matching lines...) Expand all
310 protocol::KeyEvent key2; 307 protocol::KeyEvent key2;
311 key2.set_pressed(true); 308 key2.set_pressed(true);
312 key2.set_usb_keycode(2); 309 key2.set_usb_keycode(2);
313 310
314 protocol::MouseEvent mousedown; 311 protocol::MouseEvent mousedown;
315 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT); 312 mousedown.set_button(protocol::MouseEvent::BUTTON_LEFT);
316 mousedown.set_button_down(true); 313 mousedown.set_button_down(true);
317 314
318 InSequence s; 315 InSequence s;
319 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 316 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
320 EXPECT_CALL(*event_executor_, StartPtr(_)); 317 EXPECT_CALL(*desktop_environment_, StartInput(_, _, _));
321 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 318 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
322 EXPECT_CALL(*event_executor_, InjectKeyEvent(EqualsUsbEvent(1, true))); 319 EXPECT_CALL(*desktop_environment_, InjectKeyEvent(EqualsUsbEvent(1, true)));
323 EXPECT_CALL(*event_executor_, InjectKeyEvent(EqualsUsbEvent(2, true))); 320 EXPECT_CALL(*desktop_environment_, InjectKeyEvent(EqualsUsbEvent(2, true)));
324 EXPECT_CALL(*event_executor_, InjectMouseEvent(EqualsMouseButtonEvent( 321 EXPECT_CALL(*desktop_environment_, InjectMouseEvent(EqualsMouseButtonEvent(
325 protocol::MouseEvent::BUTTON_LEFT, true))); 322 protocol::MouseEvent::BUTTON_LEFT, true)));
326 EXPECT_CALL(*event_executor_, InjectKeyEvent(EqualsUsbEvent(1, false))); 323 EXPECT_CALL(*desktop_environment_, InjectKeyEvent(EqualsUsbEvent(1, false)));
327 EXPECT_CALL(*event_executor_, InjectKeyEvent(EqualsUsbEvent(2, false))); 324 EXPECT_CALL(*desktop_environment_, InjectKeyEvent(EqualsUsbEvent(2, false)));
328 EXPECT_CALL(*event_executor_, InjectMouseEvent(EqualsMouseButtonEvent( 325 EXPECT_CALL(*desktop_environment_, InjectMouseEvent(EqualsMouseButtonEvent(
329 protocol::MouseEvent::BUTTON_LEFT, false))); 326 protocol::MouseEvent::BUTTON_LEFT, false)));
330 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 327 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
331 328
332 client_session_->OnConnectionAuthenticated(client_session_->connection()); 329 client_session_->OnConnectionAuthenticated(client_session_->connection());
333 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 330 client_session_->OnConnectionChannelsConnected(client_session_->connection());
334 331
335 connection_->input_stub()->InjectKeyEvent(key1); 332 connection_->input_stub()->InjectKeyEvent(key1);
336 connection_->input_stub()->InjectKeyEvent(key2); 333 connection_->input_stub()->InjectKeyEvent(key2);
337 connection_->input_stub()->InjectMouseEvent(mousedown); 334 connection_->input_stub()->InjectMouseEvent(mousedown);
338 335
339 DisconnectClientSession(); 336 DisconnectClientSession();
340 } 337 }
341 338
342 TEST_F(ClientSessionTest, ClampMouseEvents) { 339 TEST_F(ClientSessionTest, ClampMouseEvents) {
343 screen_size_.set(200, 100); 340 screen_size_.set(200, 100);
344 341
345 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); 342 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_));
346 EXPECT_CALL(*event_executor_, StartPtr(_)); 343 EXPECT_CALL(*desktop_environment_, StartInput(_, _, _));
347 Expectation connected = 344 Expectation connected =
348 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); 345 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_));
349 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); 346 EXPECT_CALL(session_event_handler_, OnSessionClosed(_));
350 347
351 client_session_->OnConnectionAuthenticated(client_session_->connection()); 348 client_session_->OnConnectionAuthenticated(client_session_->connection());
352 client_session_->OnConnectionChannelsConnected(client_session_->connection()); 349 client_session_->OnConnectionChannelsConnected(client_session_->connection());
353 350
354 int input_x[3] = { -999, 100, 999 }; 351 int input_x[3] = { -999, 100, 999 };
355 int expected_x[3] = { 0, 100, 199 }; 352 int expected_x[3] = { 0, 100, 199 };
356 int input_y[3] = { -999, 50, 999 }; 353 int input_y[3] = { -999, 50, 999 };
357 int expected_y[3] = { 0, 50, 99 }; 354 int expected_y[3] = { 0, 50, 99 };
358 355
359 protocol::MouseEvent event; 356 protocol::MouseEvent event;
360 for (int j = 0; j < 3; j++) { 357 for (int j = 0; j < 3; j++) {
361 for (int i = 0; i < 3; i++) { 358 for (int i = 0; i < 3; i++) {
362 event.set_x(input_x[i]); 359 event.set_x(input_x[i]);
363 event.set_y(input_y[j]); 360 event.set_y(input_y[j]);
364 connected = 361 connected =
365 EXPECT_CALL(*event_executor_, 362 EXPECT_CALL(*desktop_environment_,
366 InjectMouseEvent(EqualsMouseEvent(expected_x[i], 363 InjectMouseEvent(EqualsMouseEvent(expected_x[i],
367 expected_y[j]))) 364 expected_y[j])))
368 .After(connected); 365 .After(connected);
369 connection_->input_stub()->InjectMouseEvent(event); 366 connection_->input_stub()->InjectMouseEvent(event);
370 } 367 }
371 } 368 }
372 369
373 DisconnectClientSession(); 370 DisconnectClientSession();
374 } 371 }
375 372
376 } // namespace remoting 373 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_session.cc ('k') | remoting/host/desktop_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698