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

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

Issue 8351084: Remove old Authentication code that we don't use or need. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "remoting/host/capturer_fake.h" 9 #include "remoting/host/capturer_fake.h"
10 #include "remoting/host/chromoting_host.h" 10 #include "remoting/host/chromoting_host.h"
11 #include "remoting/host/chromoting_host_context.h" 11 #include "remoting/host/chromoting_host_context.h"
12 #include "remoting/host/host_mock_objects.h" 12 #include "remoting/host/host_mock_objects.h"
13 #include "remoting/host/in_memory_host_config.h" 13 #include "remoting/host/in_memory_host_config.h"
14 #include "remoting/proto/video.pb.h" 14 #include "remoting/proto/video.pb.h"
15 #include "remoting/protocol/protocol_mock_objects.h" 15 #include "remoting/protocol/protocol_mock_objects.h"
16 #include "remoting/protocol/session_config.h" 16 #include "remoting/protocol/session_config.h"
17 #include "testing/gmock_mutant.h" 17 #include "testing/gmock_mutant.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using ::remoting::protocol::LocalLoginCredentials;
22 using ::remoting::protocol::MockClientStub; 21 using ::remoting::protocol::MockClientStub;
23 using ::remoting::protocol::MockConnectionToClient; 22 using ::remoting::protocol::MockConnectionToClient;
24 using ::remoting::protocol::MockConnectionToClientEventHandler; 23 using ::remoting::protocol::MockConnectionToClientEventHandler;
25 using ::remoting::protocol::MockHostStub; 24 using ::remoting::protocol::MockHostStub;
26 using ::remoting::protocol::MockSession; 25 using ::remoting::protocol::MockSession;
27 using ::remoting::protocol::MockVideoStub; 26 using ::remoting::protocol::MockVideoStub;
28 using ::remoting::protocol::SessionConfig; 27 using ::remoting::protocol::SessionConfig;
29 28
30 using testing::_; 29 using testing::_;
31 using testing::AnyNumber; 30 using testing::AnyNumber;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 local_input_monitor_ = new MockLocalInputMonitor(); 94 local_input_monitor_ = new MockLocalInputMonitor();
96 desktop_environment_.reset( 95 desktop_environment_.reset(
97 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_, 96 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_,
98 disconnect_window_, continue_window_, 97 disconnect_window_, continue_window_,
99 local_input_monitor_)); 98 local_input_monitor_));
100 MockAccessVerifier* access_verifier = new MockAccessVerifier(); 99 MockAccessVerifier* access_verifier = new MockAccessVerifier();
101 100
102 host_ = ChromotingHost::Create(&context_, config_, 101 host_ = ChromotingHost::Create(&context_, config_,
103 desktop_environment_.get(), 102 desktop_environment_.get(),
104 access_verifier, false); 103 access_verifier, false);
105 credentials_.set_type(protocol::PASSWORD);
106 credentials_.set_username("user");
107 credentials_.set_credential("password");
108 connection_ = new MockConnectionToClient( 104 connection_ = new MockConnectionToClient(
109 &handler_, &host_stub_, event_executor_); 105 &handler_, &host_stub_, event_executor_);
110 connection2_ = new MockConnectionToClient( 106 connection2_ = new MockConnectionToClient(
111 &handler_, &host_stub2_, &event_executor2_); 107 &handler_, &host_stub2_, &event_executor2_);
112 session_.reset(new MockSession()); 108 session_.reset(new MockSession());
113 session2_.reset(new MockSession()); 109 session2_.reset(new MockSession());
114 session_config_ = SessionConfig::GetDefault(); 110 session_config_ = SessionConfig::GetDefault();
115 session_jid_ = "user@domain/rest-of-jid"; 111 session_jid_ = "user@domain/rest-of-jid";
116 session2_jid_ = "user2@domain/rest-of-jid"; 112 session2_jid_ = "user2@domain/rest-of-jid";
117 session_config2_ = SessionConfig::GetDefault(); 113 session_config2_ = SessionConfig::GetDefault();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 .Times(AnyNumber()); 152 .Times(AnyNumber());
157 EXPECT_CALL(*session2_.get(), config()) 153 EXPECT_CALL(*session2_.get(), config())
158 .Times(AnyNumber()); 154 .Times(AnyNumber());
159 } 155 }
160 156
161 virtual void TearDown() OVERRIDE { 157 virtual void TearDown() OVERRIDE {
162 message_loop_.RunAllPending(); 158 message_loop_.RunAllPending();
163 } 159 }
164 160
165 // Helper method to pretend a client is connected to ChromotingHost. 161 // Helper method to pretend a client is connected to ChromotingHost.
166 void SimulateClientConnection(int connection_index, bool authenticate) { 162 void SimulateClientConnection(int connection_index) {
167 scoped_refptr<MockConnectionToClient> connection = 163 scoped_refptr<MockConnectionToClient> connection =
168 (connection_index == 0) ? connection_ : connection2_; 164 (connection_index == 0) ? connection_ : connection2_;
169 165
170 MockUserAuthenticator *user_authenticator = new MockUserAuthenticator;
171 EXPECT_CALL(*user_authenticator, Authenticate(_, _))
172 .WillOnce(Return(authenticate));
173
174 scoped_refptr<ClientSession> client = new ClientSession( 166 scoped_refptr<ClientSession> client = new ClientSession(
175 host_.get(), 167 host_.get(),
176 user_authenticator,
177 connection, 168 connection,
178 event_executor_, 169 event_executor_,
179 desktop_environment_->capturer()); 170 desktop_environment_->capturer());
180 connection->set_host_stub(client.get()); 171 connection->set_host_stub(client.get());
181 172
182 context_.network_message_loop()->PostTask( 173 context_.network_message_loop()->PostTask(
183 FROM_HERE, 174 FROM_HERE,
184 NewRunnableFunction(&ChromotingHostTest::AddClientToHost, 175 NewRunnableFunction(&ChromotingHostTest::AddClientToHost,
185 host_, client)); 176 host_, client));
186 context_.network_message_loop()->PostTask( 177 context_.network_message_loop()->PostTask(
187 FROM_HERE, 178 FROM_HERE,
188 NewRunnableMethod(client.get(), 179 NewRunnableMethod(client.get(),
189 &ClientSession::BeginSessionRequest, 180 &ClientSession::OnAuthorizationComplete));
190 &credentials_,
191 base::Bind(&DummyDoneTask)));
192 } 181 }
193 182
194 // Helper method to remove a client connection from ChromotingHost. 183 // Helper method to remove a client connection from ChromotingHost.
195 void RemoveClientConnection() { 184 void RemoveClientConnection() {
196 context_.network_message_loop()->PostTask( 185 context_.network_message_loop()->PostTask(
197 FROM_HERE, 186 FROM_HERE,
198 NewRunnableMethod(host_.get(), 187 NewRunnableMethod(host_.get(),
199 &ChromotingHost::OnClientDisconnected, 188 &ChromotingHost::OnClientDisconnected,
200 connection_)); 189 connection_));
201 } 190 }
202 191
203 static void AddClientToHost(scoped_refptr<ChromotingHost> host, 192 static void AddClientToHost(scoped_refptr<ChromotingHost> host,
204 scoped_refptr<ClientSession> session) { 193 scoped_refptr<ClientSession> session) {
205 host->clients_.push_back(session); 194 host->clients_.push_back(session);
206 } 195 }
207 196
208 void ShutdownHost() { 197 void ShutdownHost() {
209 host_->Shutdown( 198 host_->Shutdown(
210 NewRunnableFunction(&PostQuitTask, &message_loop_)); 199 NewRunnableFunction(&PostQuitTask, &message_loop_));
211 } 200 }
212 201
213 protected: 202 protected:
214 MessageLoop message_loop_; 203 MessageLoop message_loop_;
215 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 204 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
216 MockConnectionToClientEventHandler handler_; 205 MockConnectionToClientEventHandler handler_;
217 scoped_ptr<DesktopEnvironment> desktop_environment_; 206 scoped_ptr<DesktopEnvironment> desktop_environment_;
218 scoped_refptr<ChromotingHost> host_; 207 scoped_refptr<ChromotingHost> host_;
219 scoped_refptr<InMemoryHostConfig> config_; 208 scoped_refptr<InMemoryHostConfig> config_;
220 MockChromotingHostContext context_; 209 MockChromotingHostContext context_;
221 protocol::LocalLoginCredentials credentials_;
222 scoped_refptr<MockConnectionToClient> connection_; 210 scoped_refptr<MockConnectionToClient> connection_;
223 std::string session_jid_; 211 std::string session_jid_;
224 scoped_ptr<MockSession> session_; 212 scoped_ptr<MockSession> session_;
225 SessionConfig session_config_; 213 SessionConfig session_config_;
226 MockVideoStub video_stub_; 214 MockVideoStub video_stub_;
227 MockClientStub client_stub_; 215 MockClientStub client_stub_;
228 MockHostStub host_stub_; 216 MockHostStub host_stub_;
229 scoped_refptr<MockConnectionToClient> connection2_; 217 scoped_refptr<MockConnectionToClient> connection2_;
230 std::string session2_jid_; 218 std::string session2_jid_;
231 scoped_ptr<MockSession> session2_; 219 scoped_ptr<MockSession> session2_;
(...skipping 17 matching lines...) Expand all
249 message_loop_.PostTask( 237 message_loop_.PostTask(
250 FROM_HERE,NewRunnableMethod( 238 FROM_HERE,NewRunnableMethod(
251 host_.get(), &ChromotingHost::Shutdown, 239 host_.get(), &ChromotingHost::Shutdown,
252 NewRunnableFunction(&PostQuitTask, &message_loop_))); 240 NewRunnableFunction(&PostQuitTask, &message_loop_)));
253 message_loop_.Run(); 241 message_loop_.Run();
254 } 242 }
255 243
256 TEST_F(ChromotingHostTest, DISABLED_Connect) { 244 TEST_F(ChromotingHostTest, DISABLED_Connect) {
257 host_->Start(); 245 host_->Start();
258 246
259 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
260 .WillOnce(RunDoneTask());
261
262 // When the video packet is received we first shutdown ChromotingHost 247 // When the video packet is received we first shutdown ChromotingHost
263 // then execute the done task. 248 // then execute the done task.
264 { 249 {
265 InSequence s; 250 InSequence s;
266 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) 251 EXPECT_CALL(*curtain_, EnableCurtainMode(true))
267 .Times(1); 252 .Times(1);
268 EXPECT_CALL(*disconnect_window_, Show(_, _)) 253 EXPECT_CALL(*disconnect_window_, Show(_, _))
269 .Times(0); 254 .Times(0);
270 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 255 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
271 .WillOnce(DoAll( 256 .WillOnce(DoAll(
272 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 257 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
273 RunDoneTask())) 258 RunDoneTask()))
274 .RetiresOnSaturation(); 259 .RetiresOnSaturation();
275 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 260 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
276 .Times(AnyNumber()); 261 .Times(AnyNumber());
277 EXPECT_CALL(*connection_.get(), Disconnect()) 262 EXPECT_CALL(*connection_.get(), Disconnect())
278 .RetiresOnSaturation(); 263 .RetiresOnSaturation();
279 } 264 }
280 SimulateClientConnection(0, true); 265 SimulateClientConnection(0);
281 message_loop_.Run(); 266 message_loop_.Run();
282 } 267 }
283 268
284 TEST_F(ChromotingHostTest, DISABLED_Reconnect) { 269 TEST_F(ChromotingHostTest, DISABLED_Reconnect) {
285 host_->Start(); 270 host_->Start();
286 271
287 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
288 .Times(2)
289 .WillRepeatedly(RunDoneTask());
290
291 // When the video packet is received we first disconnect the mock 272 // When the video packet is received we first disconnect the mock
292 // connection. 273 // connection.
293 { 274 {
294 InSequence s; 275 InSequence s;
295 // Ensure that curtain mode is activated before the first video packet. 276 // Ensure that curtain mode is activated before the first video packet.
296 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) 277 EXPECT_CALL(*curtain_, EnableCurtainMode(true))
297 .Times(1); 278 .Times(1);
298 EXPECT_CALL(*disconnect_window_, Show(_, _)) 279 EXPECT_CALL(*disconnect_window_, Show(_, _))
299 .Times(0); 280 .Times(0);
300 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 281 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
301 .WillOnce(DoAll( 282 .WillOnce(DoAll(
302 InvokeWithoutArgs(this, 283 InvokeWithoutArgs(this,
303 &ChromotingHostTest::RemoveClientConnection), 284 &ChromotingHostTest::RemoveClientConnection),
304 RunDoneTask())) 285 RunDoneTask()))
305 .RetiresOnSaturation(); 286 .RetiresOnSaturation();
306 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 287 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
307 .Times(AnyNumber()); 288 .Times(AnyNumber());
308 EXPECT_CALL(*curtain_, EnableCurtainMode(false)) 289 EXPECT_CALL(*curtain_, EnableCurtainMode(false))
309 .Times(1); 290 .Times(1);
310 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 291 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
311 .Times(AnyNumber()); 292 .Times(AnyNumber());
312 } 293 }
313 294
314 // If Disconnect() is called we can break the main message loop. 295 // If Disconnect() is called we can break the main message loop.
315 EXPECT_CALL(*connection_.get(), Disconnect()) 296 EXPECT_CALL(*connection_.get(), Disconnect())
316 .WillOnce(QuitMainMessageLoop(&message_loop_)) 297 .WillOnce(QuitMainMessageLoop(&message_loop_))
317 .RetiresOnSaturation(); 298 .RetiresOnSaturation();
318 299
319 SimulateClientConnection(0, true); 300 SimulateClientConnection(0);
320 message_loop_.Run(); 301 message_loop_.Run();
321 302
322 // Connect the client again. 303 // Connect the client again.
323 { 304 {
324 InSequence s; 305 InSequence s;
325 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) 306 EXPECT_CALL(*curtain_, EnableCurtainMode(true))
326 .Times(1); 307 .Times(1);
327 EXPECT_CALL(*disconnect_window_, Show(_, _)) 308 EXPECT_CALL(*disconnect_window_, Show(_, _))
328 .Times(0); 309 .Times(0);
329 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 310 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
330 .WillOnce(DoAll( 311 .WillOnce(DoAll(
331 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 312 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
332 RunDoneTask())) 313 RunDoneTask()))
333 .RetiresOnSaturation(); 314 .RetiresOnSaturation();
334 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 315 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
335 .Times(AnyNumber()); 316 .Times(AnyNumber());
336 } 317 }
337 318
338 EXPECT_CALL(*connection_.get(), Disconnect()) 319 EXPECT_CALL(*connection_.get(), Disconnect())
339 .RetiresOnSaturation(); 320 .RetiresOnSaturation();
340 321
341 SimulateClientConnection(0, true); 322 SimulateClientConnection(0);
342 message_loop_.Run(); 323 message_loop_.Run();
343 } 324 }
344 325
345 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { 326 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) {
346 host_->Start(); 327 host_->Start();
347 328
348 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
349 .Times(1)
350 .WillRepeatedly(RunDoneTask());
351
352 EXPECT_CALL(client_stub2_, BeginSessionResponse(_, _))
353 .Times(1)
354 .WillRepeatedly(RunDoneTask());
355
356 // When a video packet is received we connect the second mock 329 // When a video packet is received we connect the second mock
357 // connection. 330 // connection.
358 { 331 {
359 InSequence s; 332 InSequence s;
360 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) 333 EXPECT_CALL(*curtain_, EnableCurtainMode(true))
361 .Times(1) 334 .Times(1)
362 .WillOnce(QuitMainMessageLoop(&message_loop_)); 335 .WillOnce(QuitMainMessageLoop(&message_loop_));
363 EXPECT_CALL(*disconnect_window_, Show(_, _)) 336 EXPECT_CALL(*disconnect_window_, Show(_, _))
364 .Times(0); 337 .Times(0);
365 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 338 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
366 .WillOnce(DoAll( 339 .WillOnce(DoAll(
367 InvokeWithoutArgs( 340 InvokeWithoutArgs(
368 CreateFunctor( 341 CreateFunctor(
369 this, 342 this,
370 &ChromotingHostTest::SimulateClientConnection, 1, true)), 343 &ChromotingHostTest::SimulateClientConnection, 1)),
371 RunDoneTask())) 344 RunDoneTask()))
372 .RetiresOnSaturation(); 345 .RetiresOnSaturation();
373 // Check that the second connection does not affect curtain mode. 346 // Check that the second connection does not affect curtain mode.
374 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) 347 EXPECT_CALL(*curtain_, EnableCurtainMode(_))
375 .Times(0); 348 .Times(0);
376 EXPECT_CALL(*disconnect_window_, Show(_, _)) 349 EXPECT_CALL(*disconnect_window_, Show(_, _))
377 .Times(0); 350 .Times(0);
378 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 351 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
379 .Times(AnyNumber()); 352 .Times(AnyNumber());
380 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) 353 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _))
381 .WillOnce(DoAll( 354 .WillOnce(DoAll(
382 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 355 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
383 RunDoneTask())) 356 RunDoneTask()))
384 .RetiresOnSaturation(); 357 .RetiresOnSaturation();
385 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) 358 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _))
386 .Times(AnyNumber()); 359 .Times(AnyNumber());
387 } 360 }
388 361
389 EXPECT_CALL(*connection_.get(), Disconnect()) 362 EXPECT_CALL(*connection_.get(), Disconnect())
390 .RetiresOnSaturation(); 363 .RetiresOnSaturation();
391 EXPECT_CALL(*connection2_.get(), Disconnect()) 364 EXPECT_CALL(*connection2_.get(), Disconnect())
392 .RetiresOnSaturation(); 365 .RetiresOnSaturation();
393 366
394 SimulateClientConnection(0, true); 367 SimulateClientConnection(0);
395 message_loop_.Run(); 368 message_loop_.Run();
396 } 369 }
397 370
398 TEST_F(ChromotingHostTest, CurtainModeFail) {
Wez 2011/11/03 00:25:02 Assuming that we retain the idea of curtain mode,
Sergey Ulanov 2011/11/03 01:21:12 Done.
399 host_->Start();
400
401 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
402 .WillOnce(RunDoneTask());
403
404 // Ensure that curtain mode is not activated if a connection does not
405 // authenticate.
406 EXPECT_CALL(*curtain_, EnableCurtainMode(_))
407 .Times(0);
408 EXPECT_CALL(*disconnect_window_, Show(_, _))
409 .Times(0);
410 EXPECT_CALL(*connection_.get(), Disconnect())
411 .WillOnce(QuitMainMessageLoop(&message_loop_));
412 SimulateClientConnection(0, false);
413 RemoveClientConnection();
414 message_loop_.Run();
415 }
416
417 TEST_F(ChromotingHostTest, CurtainModeFailSecond) {
418 host_->Start();
419
420 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
421 .WillOnce(RunDoneTask());
422
423 EXPECT_CALL(client_stub2_, BeginSessionResponse(_, _))
424 .WillOnce(RunDoneTask());
425
426
427 // When a video packet is received we connect the second mock
428 // connection.
429 {
430 InSequence s;
431 EXPECT_CALL(*curtain_, EnableCurtainMode(true))
432 .WillOnce(QuitMainMessageLoop(&message_loop_));
433 EXPECT_CALL(*disconnect_window_, Show(_, _))
434 .Times(0);
435 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
436 .WillOnce(DoAll(
437 InvokeWithoutArgs(
438 CreateFunctor(
439 this,
440 &ChromotingHostTest::SimulateClientConnection, 1, false)),
441 RunDoneTask()))
442 .RetiresOnSaturation();
443 // Check that the second connection does not affect curtain mode.
444 EXPECT_CALL(*curtain_, EnableCurtainMode(_))
445 .Times(0);
446 EXPECT_CALL(*disconnect_window_, Show(_, _))
447 .Times(0);
448 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
449 .Times(AnyNumber());
450 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _))
451 .Times(0);
452 }
453
454 SimulateClientConnection(0, true);
455 message_loop_.Run();
456 }
457
458 ACTION_P(SetBool, var) { *var = true; } 371 ACTION_P(SetBool, var) { *var = true; }
459 372
460 TEST_F(ChromotingHostTest, CurtainModeIT2Me) { 373 TEST_F(ChromotingHostTest, CurtainModeIT2Me) {
461 host_->Start(); 374 host_->Start();
462 host_->set_it2me(true); 375 host_->set_it2me(true);
463 376
464 EXPECT_CALL(client_stub_, BeginSessionResponse(_, _))
465 .WillOnce(RunDoneTask());
466
467 // When the video packet is received we first shutdown ChromotingHost 377 // When the video packet is received we first shutdown ChromotingHost
468 // then execute the done task. 378 // then execute the done task.
469 bool curtain_activated = false; 379 bool curtain_activated = false;
470 { 380 {
471 Sequence s1, s2; 381 Sequence s1, s2;
472 // Can't just expect Times(0) because if it fails then the host will 382 // Can't just expect Times(0) because if it fails then the host will
473 // not be shut down and the message loop will never exit. 383 // not be shut down and the message loop will never exit.
474 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) 384 EXPECT_CALL(*curtain_, EnableCurtainMode(_))
475 .Times(AnyNumber()) 385 .Times(AnyNumber())
476 .WillRepeatedly(SetBool(&curtain_activated)); 386 .WillRepeatedly(SetBool(&curtain_activated));
477 EXPECT_CALL(*disconnect_window_, Show(_, "user@domain")) 387 EXPECT_CALL(*disconnect_window_, Show(_, "user@domain"))
478 .Times(1) 388 .Times(1)
479 .InSequence(s1); 389 .InSequence(s1);
480 EXPECT_CALL(*local_input_monitor_, Start(_)) 390 EXPECT_CALL(*local_input_monitor_, Start(_))
481 .Times(1) 391 .Times(1)
482 .InSequence(s2); 392 .InSequence(s2);
483 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 393 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
484 .InSequence(s1, s2) 394 .InSequence(s1, s2)
485 .WillOnce(DoAll( 395 .WillOnce(DoAll(
486 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 396 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
487 RunDoneTask())) 397 RunDoneTask()))
488 .RetiresOnSaturation(); 398 .RetiresOnSaturation();
489 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 399 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _))
490 .Times(AnyNumber()) 400 .Times(AnyNumber())
491 .InSequence(s1, s2); 401 .InSequence(s1, s2);
492 EXPECT_CALL(*connection_.get(), Disconnect()) 402 EXPECT_CALL(*connection_.get(), Disconnect())
493 .InSequence(s1, s2) 403 .InSequence(s1, s2)
494 .RetiresOnSaturation(); 404 .RetiresOnSaturation();
405 EXPECT_CALL(*local_input_monitor_, Stop())
406 .Times(1)
407 .InSequence(s1, s2);
408 EXPECT_CALL(*continue_window_, Hide())
409 .Times(1)
410 .InSequence(s1);
411 EXPECT_CALL(*disconnect_window_, Hide())
412 .Times(1)
413 .InSequence(s2);
Wez 2011/11/03 00:25:02 How come these have changed?
Sergey Ulanov 2011/11/03 01:21:12 They haven't changed. I just added them to fix gun
495 } 414 }
496 SimulateClientConnection(0, true); 415 SimulateClientConnection(0);
497 message_loop_.Run(); 416 message_loop_.Run();
498 host_->set_it2me(false); 417 host_->set_it2me(false);
499 EXPECT_THAT(curtain_activated, false); 418 EXPECT_THAT(curtain_activated, false);
500 } 419 }
501 420
502 } // namespace remoting 421 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698