| OLD | NEW |
| 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/host/it2me_host_user_interface.h" |
| 14 #include "remoting/proto/video.pb.h" | 15 #include "remoting/proto/video.pb.h" |
| 15 #include "remoting/protocol/protocol_mock_objects.h" | 16 #include "remoting/protocol/protocol_mock_objects.h" |
| 16 #include "remoting/protocol/session_config.h" | 17 #include "remoting/protocol/session_config.h" |
| 17 #include "testing/gmock_mutant.h" | 18 #include "testing/gmock_mutant.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using ::remoting::protocol::MockClientStub; | 22 using ::remoting::protocol::MockClientStub; |
| 22 using ::remoting::protocol::MockConnectionToClient; | 23 using ::remoting::protocol::MockConnectionToClient; |
| 23 using ::remoting::protocol::MockConnectionToClientEventHandler; | 24 using ::remoting::protocol::MockConnectionToClientEventHandler; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 .Times(AnyNumber()); | 83 .Times(AnyNumber()); |
| 83 EXPECT_CALL(context_, encode_message_loop()) | 84 EXPECT_CALL(context_, encode_message_loop()) |
| 84 .Times(AnyNumber()); | 85 .Times(AnyNumber()); |
| 85 EXPECT_CALL(context_, network_message_loop()) | 86 EXPECT_CALL(context_, network_message_loop()) |
| 86 .Times(AnyNumber()); | 87 .Times(AnyNumber()); |
| 87 EXPECT_CALL(context_, ui_message_loop()) | 88 EXPECT_CALL(context_, ui_message_loop()) |
| 88 .Times(AnyNumber()); | 89 .Times(AnyNumber()); |
| 89 | 90 |
| 90 Capturer* capturer = new CapturerFake(); | 91 Capturer* capturer = new CapturerFake(); |
| 91 event_executor_ = new MockEventExecutor(); | 92 event_executor_ = new MockEventExecutor(); |
| 92 curtain_ = new MockCurtain(); | 93 desktop_environment_.reset( |
| 94 new DesktopEnvironment(&context_, capturer, event_executor_)); |
| 95 |
| 96 host_ = ChromotingHost::Create( |
| 97 &context_, config_,desktop_environment_.get(), false); |
| 98 |
| 93 disconnect_window_ = new MockDisconnectWindow(); | 99 disconnect_window_ = new MockDisconnectWindow(); |
| 94 continue_window_ = new MockContinueWindow(); | 100 continue_window_ = new MockContinueWindow(); |
| 95 local_input_monitor_ = new MockLocalInputMonitor(); | 101 local_input_monitor_ = new MockLocalInputMonitor(); |
| 96 desktop_environment_.reset( | 102 it2me_host_user_interface_.reset(new It2MeHostUserInterface(host_, |
| 97 new DesktopEnvironment(&context_, capturer, event_executor_, curtain_, | 103 &context_)); |
| 98 disconnect_window_, continue_window_, | 104 it2me_host_user_interface_->InitFrom(disconnect_window_, continue_window_, |
| 99 local_input_monitor_)); | 105 local_input_monitor_); |
| 106 host_->AddStatusObserver(it2me_host_user_interface_.get()); |
| 100 | 107 |
| 101 host_ = ChromotingHost::Create( | |
| 102 &context_, config_,desktop_environment_.get(), false); | |
| 103 session_ = new MockSession(); | 108 session_ = new MockSession(); |
| 104 session2_ = new MockSession(); | 109 session2_ = new MockSession(); |
| 105 session_config_ = SessionConfig::GetDefault(); | 110 session_config_ = SessionConfig::GetDefault(); |
| 106 session_jid_ = "user@domain/rest-of-jid"; | 111 session_jid_ = "user@domain/rest-of-jid"; |
| 107 session_config2_ = SessionConfig::GetDefault(); | 112 session_config2_ = SessionConfig::GetDefault(); |
| 108 session2_jid_ = "user2@domain/rest-of-jid"; | 113 session2_jid_ = "user2@domain/rest-of-jid"; |
| 109 EXPECT_CALL(*session_, jid()) | 114 EXPECT_CALL(*session_, jid()) |
| 110 .WillRepeatedly(ReturnRef(session_jid_)); | 115 .WillRepeatedly(ReturnRef(session_jid_)); |
| 111 EXPECT_CALL(*session2_, jid()) | 116 EXPECT_CALL(*session2_, jid()) |
| 112 .WillRepeatedly(ReturnRef(session2_jid_)); | 117 .WillRepeatedly(ReturnRef(session2_jid_)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 message_loop_.PostTask( | 213 message_loop_.PostTask( |
| 209 FROM_HERE, base::Bind(&ChromotingHost::Shutdown, host_, | 214 FROM_HERE, base::Bind(&ChromotingHost::Shutdown, host_, |
| 210 base::Bind(&PostQuitTask, &message_loop_))); | 215 base::Bind(&PostQuitTask, &message_loop_))); |
| 211 } | 216 } |
| 212 | 217 |
| 213 protected: | 218 protected: |
| 214 MessageLoop message_loop_; | 219 MessageLoop message_loop_; |
| 215 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 220 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 216 MockConnectionToClientEventHandler handler_; | 221 MockConnectionToClientEventHandler handler_; |
| 217 scoped_ptr<DesktopEnvironment> desktop_environment_; | 222 scoped_ptr<DesktopEnvironment> desktop_environment_; |
| 223 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; |
| 218 scoped_refptr<ChromotingHost> host_; | 224 scoped_refptr<ChromotingHost> host_; |
| 219 scoped_refptr<InMemoryHostConfig> config_; | 225 scoped_refptr<InMemoryHostConfig> config_; |
| 220 MockChromotingHostContext context_; | 226 MockChromotingHostContext context_; |
| 221 MockConnectionToClient* connection_; | 227 MockConnectionToClient* connection_; |
| 222 scoped_ptr<MockConnectionToClient> owned_connection_; | 228 scoped_ptr<MockConnectionToClient> owned_connection_; |
| 223 ClientSession* client_; | 229 ClientSession* client_; |
| 224 std::string session_jid_; | 230 std::string session_jid_; |
| 225 MockSession* session_; // Owned by |connection_|. | 231 MockSession* session_; // Owned by |connection_|. |
| 226 SessionConfig session_config_; | 232 SessionConfig session_config_; |
| 227 MockVideoStub video_stub_; | 233 MockVideoStub video_stub_; |
| 228 MockClientStub client_stub_; | 234 MockClientStub client_stub_; |
| 229 MockHostStub host_stub_; | 235 MockHostStub host_stub_; |
| 230 MockConnectionToClient* connection2_; | 236 MockConnectionToClient* connection2_; |
| 231 scoped_ptr<MockConnectionToClient> owned_connection2_; | 237 scoped_ptr<MockConnectionToClient> owned_connection2_; |
| 232 ClientSession* client2_; | 238 ClientSession* client2_; |
| 233 std::string session2_jid_; | 239 std::string session2_jid_; |
| 234 MockSession* session2_; // Owned by |connection2_|. | 240 MockSession* session2_; // Owned by |connection2_|. |
| 235 SessionConfig session_config2_; | 241 SessionConfig session_config2_; |
| 236 MockVideoStub video_stub2_; | 242 MockVideoStub video_stub2_; |
| 237 MockClientStub client_stub2_; | 243 MockClientStub client_stub2_; |
| 238 MockHostStub host_stub2_; | 244 MockHostStub host_stub2_; |
| 239 MockEventExecutor event_executor2_; | 245 MockEventExecutor event_executor2_; |
| 240 | 246 |
| 241 // Owned by |host_|. | 247 // Owned by |host_|. |
| 242 MockEventExecutor* event_executor_; | 248 MockEventExecutor* event_executor_; |
| 243 MockCurtain* curtain_; | |
| 244 MockDisconnectWindow* disconnect_window_; | 249 MockDisconnectWindow* disconnect_window_; |
| 245 MockContinueWindow* continue_window_; | 250 MockContinueWindow* continue_window_; |
| 246 MockLocalInputMonitor* local_input_monitor_; | 251 MockLocalInputMonitor* local_input_monitor_; |
| 247 }; | 252 }; |
| 248 | 253 |
| 249 TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) { | 254 TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) { |
| 250 host_->Start(); | 255 host_->Start(); |
| 251 | 256 |
| 252 message_loop_.PostTask( | 257 message_loop_.PostTask( |
| 253 FROM_HERE, base::Bind( | 258 FROM_HERE, base::Bind( |
| 254 &ChromotingHost::Shutdown, host_.get(), | 259 &ChromotingHost::Shutdown, host_.get(), |
| 255 base::Bind(&PostQuitTask, &message_loop_))); | 260 base::Bind(&PostQuitTask, &message_loop_))); |
| 256 message_loop_.Run(); | 261 message_loop_.Run(); |
| 257 } | 262 } |
| 258 | 263 |
| 259 TEST_F(ChromotingHostTest, DISABLED_Connect) { | 264 TEST_F(ChromotingHostTest, DISABLED_Connect) { |
| 260 host_->Start(); | 265 host_->Start(); |
| 261 | 266 |
| 262 // When the video packet is received we first shutdown ChromotingHost | 267 // When the video packet is received we first shutdown ChromotingHost |
| 263 // then execute the done task. | 268 // then execute the done task. |
| 264 { | 269 { |
| 265 InSequence s; | 270 InSequence s; |
| 266 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) | |
| 267 .Times(1); | |
| 268 EXPECT_CALL(*disconnect_window_, Show(_, _)) | 271 EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| 269 .Times(0); | 272 .Times(0); |
| 270 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 273 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 271 .WillOnce(DoAll( | 274 .WillOnce(DoAll( |
| 272 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), | 275 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), |
| 273 RunDoneTask())) | 276 RunDoneTask())) |
| 274 .RetiresOnSaturation(); | 277 .RetiresOnSaturation(); |
| 275 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 278 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 276 .Times(AnyNumber()); | 279 .Times(AnyNumber()); |
| 277 EXPECT_CALL(*connection_, Disconnect()) | 280 EXPECT_CALL(*connection_, Disconnect()) |
| 278 .RetiresOnSaturation(); | 281 .RetiresOnSaturation(); |
| 279 } | 282 } |
| 280 SimulateClientConnection(0, true); | 283 SimulateClientConnection(0, true); |
| 281 message_loop_.Run(); | 284 message_loop_.Run(); |
| 282 } | 285 } |
| 283 | 286 |
| 284 TEST_F(ChromotingHostTest, DISABLED_Reconnect) { | 287 TEST_F(ChromotingHostTest, DISABLED_Reconnect) { |
| 285 host_->Start(); | 288 host_->Start(); |
| 286 | 289 |
| 287 // When the video packet is received we first disconnect the mock | 290 // When the video packet is received we first disconnect the mock |
| 288 // connection. | 291 // connection. |
| 289 { | 292 { |
| 290 InSequence s; | 293 InSequence s; |
| 291 // Ensure that curtain mode is activated before the first video packet. | |
| 292 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) | |
| 293 .Times(1); | |
| 294 EXPECT_CALL(*disconnect_window_, Show(_, _)) | 294 EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| 295 .Times(0); | 295 .Times(0); |
| 296 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 296 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 297 .WillOnce(DoAll( | 297 .WillOnce(DoAll( |
| 298 InvokeWithoutArgs(this, &ChromotingHostTest::RemoveClientSession), | 298 InvokeWithoutArgs(this, &ChromotingHostTest::RemoveClientSession), |
| 299 RunDoneTask())) | 299 RunDoneTask())) |
| 300 .RetiresOnSaturation(); | 300 .RetiresOnSaturation(); |
| 301 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 301 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 302 .Times(AnyNumber()); | 302 .Times(AnyNumber()); |
| 303 EXPECT_CALL(*curtain_, EnableCurtainMode(false)) | |
| 304 .Times(1); | |
| 305 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 303 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 306 .Times(AnyNumber()); | 304 .Times(AnyNumber()); |
| 307 } | 305 } |
| 308 | 306 |
| 309 // If Disconnect() is called we can break the main message loop. | 307 // If Disconnect() is called we can break the main message loop. |
| 310 EXPECT_CALL(*connection_, Disconnect()) | 308 EXPECT_CALL(*connection_, Disconnect()) |
| 311 .WillOnce(QuitMainMessageLoop(&message_loop_)) | 309 .WillOnce(QuitMainMessageLoop(&message_loop_)) |
| 312 .RetiresOnSaturation(); | 310 .RetiresOnSaturation(); |
| 313 | 311 |
| 314 SimulateClientConnection(0, true); | 312 SimulateClientConnection(0, true); |
| 315 message_loop_.Run(); | 313 message_loop_.Run(); |
| 316 | 314 |
| 317 // Connect the client again. | 315 // Connect the client again. |
| 318 { | 316 { |
| 319 InSequence s; | 317 InSequence s; |
| 320 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) | |
| 321 .Times(1); | |
| 322 EXPECT_CALL(*disconnect_window_, Show(_, _)) | 318 EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| 323 .Times(0); | 319 .Times(0); |
| 324 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 320 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 325 .WillOnce(DoAll( | 321 .WillOnce(DoAll( |
| 326 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), | 322 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), |
| 327 RunDoneTask())) | 323 RunDoneTask())) |
| 328 .RetiresOnSaturation(); | 324 .RetiresOnSaturation(); |
| 329 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 325 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 330 .Times(AnyNumber()); | 326 .Times(AnyNumber()); |
| 331 } | 327 } |
| 332 | 328 |
| 333 EXPECT_CALL(*connection_, Disconnect()) | 329 EXPECT_CALL(*connection_, Disconnect()) |
| 334 .RetiresOnSaturation(); | 330 .RetiresOnSaturation(); |
| 335 | 331 |
| 336 SimulateClientConnection(0, true); | 332 SimulateClientConnection(0, true); |
| 337 message_loop_.Run(); | 333 message_loop_.Run(); |
| 338 } | 334 } |
| 339 | 335 |
| 340 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { | 336 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { |
| 341 host_->Start(); | 337 host_->Start(); |
| 342 | 338 |
| 343 // When a video packet is received we connect the second mock | 339 // When a video packet is received we connect the second mock |
| 344 // connection. | 340 // connection. |
| 345 { | 341 { |
| 346 InSequence s; | 342 InSequence s; |
| 347 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) | |
| 348 .Times(1) | |
| 349 .WillOnce(QuitMainMessageLoop(&message_loop_)); | |
| 350 EXPECT_CALL(*disconnect_window_, Show(_, _)) | 343 EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| 351 .Times(0); | 344 .Times(0); |
| 352 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 345 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 353 .WillOnce(DoAll( | 346 .WillOnce(DoAll( |
| 354 InvokeWithoutArgs( | 347 InvokeWithoutArgs( |
| 355 CreateFunctor( | 348 CreateFunctor( |
| 356 this, | 349 this, |
| 357 &ChromotingHostTest::SimulateClientConnection, 1, true)), | 350 &ChromotingHostTest::SimulateClientConnection, 1, true)), |
| 358 RunDoneTask())) | 351 RunDoneTask())) |
| 359 .RetiresOnSaturation(); | 352 .RetiresOnSaturation(); |
| 360 // Check that the second connection does not affect curtain mode. | |
| 361 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) | |
| 362 .Times(0); | |
| 363 EXPECT_CALL(*disconnect_window_, Show(_, _)) | 353 EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| 364 .Times(0); | 354 .Times(0); |
| 365 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | 355 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| 366 .Times(AnyNumber()); | 356 .Times(AnyNumber()); |
| 367 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) | 357 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) |
| 368 .WillOnce(DoAll( | 358 .WillOnce(DoAll( |
| 369 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), | 359 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), |
| 370 RunDoneTask())) | 360 RunDoneTask())) |
| 371 .RetiresOnSaturation(); | 361 .RetiresOnSaturation(); |
| 372 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) | 362 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) |
| 373 .Times(AnyNumber()); | 363 .Times(AnyNumber()); |
| 374 } | 364 } |
| 375 | 365 |
| 376 EXPECT_CALL(*connection_, Disconnect()) | 366 EXPECT_CALL(*connection_, Disconnect()) |
| 377 .RetiresOnSaturation(); | 367 .RetiresOnSaturation(); |
| 378 EXPECT_CALL(*connection2_, Disconnect()) | 368 EXPECT_CALL(*connection2_, Disconnect()) |
| 379 .RetiresOnSaturation(); | 369 .RetiresOnSaturation(); |
| 380 | 370 |
| 381 SimulateClientConnection(0, true); | 371 SimulateClientConnection(0, true); |
| 382 message_loop_.Run(); | 372 message_loop_.Run(); |
| 383 } | 373 } |
| 384 | 374 |
| 385 TEST_F(ChromotingHostTest, CurtainModeFail) { | |
| 386 host_->Start(); | |
| 387 | |
| 388 // Ensure that curtain mode is not activated if a connection does not | |
| 389 // authenticate. | |
| 390 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) | |
| 391 .Times(0); | |
| 392 EXPECT_CALL(*disconnect_window_, Show(_, _)) | |
| 393 .Times(0); | |
| 394 EXPECT_CALL(*continue_window_, Hide()) | |
| 395 .Times(AnyNumber()); | |
| 396 EXPECT_CALL(*disconnect_window_, Hide()) | |
| 397 .Times(AnyNumber()); | |
| 398 SimulateClientConnection(0, false); | |
| 399 context_.network_message_loop()->PostTask( | |
| 400 FROM_HERE, base::Bind(&ChromotingHostTest::RemoveClientSession, | |
| 401 base::Unretained(this))); | |
| 402 PostQuitTask(&message_loop_); | |
| 403 message_loop_.Run(); | |
| 404 } | |
| 405 | |
| 406 TEST_F(ChromotingHostTest, CurtainModeFailSecond) { | |
| 407 host_->Start(); | |
| 408 | |
| 409 // When a video packet is received we connect the second mock | |
| 410 // connection. | |
| 411 { | |
| 412 InSequence s; | |
| 413 EXPECT_CALL(*curtain_, EnableCurtainMode(true)) | |
| 414 .WillOnce(QuitMainMessageLoop(&message_loop_)); | |
| 415 EXPECT_CALL(*local_input_monitor_, Start(_)) | |
| 416 .Times(1); | |
| 417 EXPECT_CALL(*disconnect_window_, Show(_, "user@domain")) | |
| 418 .Times(1); | |
| 419 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | |
| 420 .WillOnce(DoAll( | |
| 421 InvokeWithoutArgs( | |
| 422 CreateFunctor( | |
| 423 this, | |
| 424 &ChromotingHostTest::SimulateClientConnection, 1, false)), | |
| 425 RunDoneTask())) | |
| 426 .RetiresOnSaturation(); | |
| 427 // Check that the second connection does not affect curtain mode. | |
| 428 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) | |
| 429 .Times(0); | |
| 430 EXPECT_CALL(*disconnect_window_, Show(_, _)) | |
| 431 .Times(0); | |
| 432 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | |
| 433 .Times(AnyNumber()); | |
| 434 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) | |
| 435 .Times(0); | |
| 436 } | |
| 437 | |
| 438 SimulateClientConnection(0, true); | |
| 439 message_loop_.Run(); | |
| 440 | |
| 441 // Curtain is removed when there are no clients connected. | |
| 442 EXPECT_CALL(*curtain_, EnableCurtainMode(false)) | |
| 443 .Times(AtLeast(1)); | |
| 444 EXPECT_CALL(*continue_window_, Hide()) | |
| 445 .Times(AtLeast(1)); | |
| 446 EXPECT_CALL(*disconnect_window_, Hide()) | |
| 447 .Times(AtLeast(1)); | |
| 448 EXPECT_CALL(*local_input_monitor_, Stop()) | |
| 449 .Times(AtLeast(1)); | |
| 450 | |
| 451 // Close connections before destroying the host. | |
| 452 client_->OnConnectionClosed(connection_); | |
| 453 client2_->OnConnectionClosed(connection2_); | |
| 454 } | |
| 455 | |
| 456 ACTION_P(SetBool, var) { *var = true; } | |
| 457 | |
| 458 TEST_F(ChromotingHostTest, CurtainModeIT2Me) { | |
| 459 host_->Start(); | |
| 460 host_->set_it2me(true); | |
| 461 | |
| 462 // When the video packet is received we first shutdown ChromotingHost | |
| 463 // then execute the done task. | |
| 464 bool curtain_activated = false; | |
| 465 { | |
| 466 Sequence s1, s2; | |
| 467 // Can't just expect Times(0) because if it fails then the host will | |
| 468 // not be shut down and the message loop will never exit. | |
| 469 EXPECT_CALL(*curtain_, EnableCurtainMode(_)) | |
| 470 .Times(AnyNumber()) | |
| 471 .WillRepeatedly(SetBool(&curtain_activated)); | |
| 472 EXPECT_CALL(*disconnect_window_, Show(_, "user@domain")) | |
| 473 .Times(1) | |
| 474 .InSequence(s1); | |
| 475 EXPECT_CALL(*local_input_monitor_, Start(_)) | |
| 476 .Times(1) | |
| 477 .InSequence(s2); | |
| 478 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) | |
| 479 .InSequence(s1, s2) | |
| 480 .WillOnce(DoAll( | |
| 481 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), | |
| 482 RunDoneTask())) | |
| 483 .RetiresOnSaturation(); | |
| 484 EXPECT_CALL(*connection_, Disconnect()) | |
| 485 .InSequence(s1, s2) | |
| 486 .WillOnce(InvokeWithoutArgs( | |
| 487 this, &ChromotingHostTest::RemoveClientSession)) | |
| 488 .RetiresOnSaturation(); | |
| 489 EXPECT_CALL(*local_input_monitor_, Stop()) | |
| 490 .Times(1) | |
| 491 .InSequence(s1, s2); | |
| 492 EXPECT_CALL(*continue_window_, Hide()) | |
| 493 .Times(1) | |
| 494 .InSequence(s1); | |
| 495 EXPECT_CALL(*disconnect_window_, Hide()) | |
| 496 .Times(1) | |
| 497 .InSequence(s2); | |
| 498 } | |
| 499 SimulateClientConnection(0, true); | |
| 500 message_loop_.Run(); | |
| 501 host_->set_it2me(false); | |
| 502 EXPECT_THAT(curtain_activated, false); | |
| 503 } | |
| 504 | |
| 505 } // namespace remoting | 375 } // namespace remoting |
| OLD | NEW |