| OLD | NEW |
| 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/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 "remoting/jingle_glue/mock_objects.h" | 8 #include "remoting/jingle_glue/mock_objects.h" |
| 9 #include "remoting/host/audio_capturer.h" | 9 #include "remoting/host/audio_capturer.h" |
| 10 #include "remoting/host/chromoting_host_context.h" | 10 #include "remoting/host/chromoting_host_context.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 continue_window_ = new MockContinueWindow(); | 102 continue_window_ = new MockContinueWindow(); |
| 103 local_input_monitor_ = new MockLocalInputMonitor(); | 103 local_input_monitor_ = new MockLocalInputMonitor(); |
| 104 it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_)); | 104 it2me_host_user_interface_.reset(new It2MeHostUserInterface(&context_)); |
| 105 it2me_host_user_interface_->StartForTest( | 105 it2me_host_user_interface_->StartForTest( |
| 106 host_, | 106 host_, |
| 107 base::Bind(&ChromotingHost::Shutdown, host_, base::Closure()), | 107 base::Bind(&ChromotingHost::Shutdown, host_, base::Closure()), |
| 108 scoped_ptr<DisconnectWindow>(disconnect_window_), | 108 scoped_ptr<DisconnectWindow>(disconnect_window_), |
| 109 scoped_ptr<ContinueWindow>(continue_window_), | 109 scoped_ptr<ContinueWindow>(continue_window_), |
| 110 scoped_ptr<LocalInputMonitor>(local_input_monitor_)); | 110 scoped_ptr<LocalInputMonitor>(local_input_monitor_)); |
| 111 | 111 |
| 112 xmpp_login_ = "host@domain"; |
| 112 session1_ = new MockSession(); | 113 session1_ = new MockSession(); |
| 113 session2_ = new MockSession(); | 114 session2_ = new MockSession(); |
| 114 session_unowned1_.reset(new MockSession()); | 115 session_unowned1_.reset(new MockSession()); |
| 115 session_unowned2_.reset(new MockSession()); | 116 session_unowned2_.reset(new MockSession()); |
| 116 session_config1_ = SessionConfig::GetDefault(); | 117 session_config1_ = SessionConfig::GetDefault(); |
| 117 session_jid1_ = "user@domain/rest-of-jid"; | 118 session_jid1_ = "user@domain/rest-of-jid"; |
| 118 session_config2_ = SessionConfig::GetDefault(); | 119 session_config2_ = SessionConfig::GetDefault(); |
| 119 session_jid2_ = "user2@domain/rest-of-jid"; | 120 session_jid2_ = "user2@domain/rest-of-jid"; |
| 120 session_unowned_config1_ = SessionConfig::GetDefault(); | 121 session_unowned_config1_ = SessionConfig::GetDefault(); |
| 121 session_unowned_jid1_ = "user3@doman/rest-of-jid"; | 122 session_unowned_jid1_ = "user3@doman/rest-of-jid"; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // Expect the host to start. | 280 // Expect the host to start. |
| 280 void ExpectHostStart() { | 281 void ExpectHostStart() { |
| 281 EXPECT_CALL(*disconnect_window_, Hide()); | 282 EXPECT_CALL(*disconnect_window_, Hide()); |
| 282 EXPECT_CALL(*continue_window_, Hide()); | 283 EXPECT_CALL(*continue_window_, Hide()); |
| 283 } | 284 } |
| 284 | 285 |
| 285 // Expect the host and session manager to start, and return the expectation | 286 // Expect the host and session manager to start, and return the expectation |
| 286 // that the session manager has started. | 287 // that the session manager has started. |
| 287 Expectation ExpectHostAndSessionManagerStart() { | 288 Expectation ExpectHostAndSessionManagerStart() { |
| 288 ExpectHostStart(); | 289 ExpectHostStart(); |
| 290 EXPECT_CALL(host_status_observer_, OnStart(xmpp_login_)); |
| 289 return EXPECT_CALL(*session_manager_, Init(_, host_.get())); | 291 return EXPECT_CALL(*session_manager_, Init(_, host_.get())); |
| 290 } | 292 } |
| 291 | 293 |
| 292 // Expect a client to connect. | 294 // Expect a client to connect. |
| 293 // Return an expectation that a session has started, and that the first | 295 // Return an expectation that a session has started, and that the first |
| 294 // video packet has been sent to the client. | 296 // video packet has been sent to the client. |
| 295 // Do |action| when that happens. | 297 // Do |action| when that happens. |
| 296 template <class A> | 298 template <class A> |
| 297 Expectation ExpectClientConnected(int connection_index, A action) { | 299 Expectation ExpectClientConnected(int connection_index, A action) { |
| 298 const std::string& session_jid = get_session_jid(connection_index); | 300 const std::string& session_jid = get_session_jid(connection_index); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 370 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
| 369 MockConnectionToClientEventHandler handler_; | 371 MockConnectionToClientEventHandler handler_; |
| 370 MockSignalStrategy signal_strategy_; | 372 MockSignalStrategy signal_strategy_; |
| 371 MockEventExecutor* event_executor_; | 373 MockEventExecutor* event_executor_; |
| 372 scoped_ptr<DesktopEnvironment> desktop_environment_; | 374 scoped_ptr<DesktopEnvironment> desktop_environment_; |
| 373 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; | 375 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; |
| 374 scoped_refptr<ChromotingHost> host_; | 376 scoped_refptr<ChromotingHost> host_; |
| 375 MockHostStatusObserver host_status_observer_; | 377 MockHostStatusObserver host_status_observer_; |
| 376 MockChromotingHostContext context_; | 378 MockChromotingHostContext context_; |
| 377 protocol::MockSessionManager* session_manager_; | 379 protocol::MockSessionManager* session_manager_; |
| 380 std::string xmpp_login_; |
| 378 MockConnectionToClient* connection1_; | 381 MockConnectionToClient* connection1_; |
| 379 scoped_ptr<MockConnectionToClient> owned_connection1_; | 382 scoped_ptr<MockConnectionToClient> owned_connection1_; |
| 380 ClientSession* client1_; | 383 ClientSession* client1_; |
| 381 std::string session_jid1_; | 384 std::string session_jid1_; |
| 382 MockSession* session1_; // Owned by |connection_|. | 385 MockSession* session1_; // Owned by |connection_|. |
| 383 SessionConfig session_config1_; | 386 SessionConfig session_config1_; |
| 384 MockVideoStub video_stub1_; | 387 MockVideoStub video_stub1_; |
| 385 MockClientStub client_stub1_; | 388 MockClientStub client_stub1_; |
| 386 MockHostStub host_stub1_; | 389 MockHostStub host_stub1_; |
| 387 MockConnectionToClient* connection2_; | 390 MockConnectionToClient* connection2_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 425 |
| 423 MockVideoStub& get_video_stub(int connection_index) { | 426 MockVideoStub& get_video_stub(int connection_index) { |
| 424 return (connection_index == 0) ? video_stub1_ : video_stub2_; | 427 return (connection_index == 0) ? video_stub1_ : video_stub2_; |
| 425 } | 428 } |
| 426 }; | 429 }; |
| 427 | 430 |
| 428 TEST_F(ChromotingHostTest, StartAndShutdown) { | 431 TEST_F(ChromotingHostTest, StartAndShutdown) { |
| 429 Expectation start = ExpectHostAndSessionManagerStart(); | 432 Expectation start = ExpectHostAndSessionManagerStart(); |
| 430 EXPECT_CALL(host_status_observer_, OnShutdown()).After(start); | 433 EXPECT_CALL(host_status_observer_, OnShutdown()).After(start); |
| 431 | 434 |
| 432 host_->Start(); | 435 host_->Start(xmpp_login_); |
| 433 message_loop_.PostTask( | 436 message_loop_.PostTask( |
| 434 FROM_HERE, base::Bind( | 437 FROM_HERE, base::Bind( |
| 435 &ChromotingHost::Shutdown, host_.get(), | 438 &ChromotingHost::Shutdown, host_.get(), |
| 436 base::Bind(&PostQuitTask, &message_loop_))); | 439 base::Bind(&PostQuitTask, &message_loop_))); |
| 437 message_loop_.Run(); | 440 message_loop_.Run(); |
| 438 } | 441 } |
| 439 | 442 |
| 440 TEST_F(ChromotingHostTest, Connect) { | 443 TEST_F(ChromotingHostTest, Connect) { |
| 441 ExpectHostAndSessionManagerStart(); | 444 ExpectHostAndSessionManagerStart(); |
| 442 | 445 |
| 443 // Shut down the host when the first video packet is received. | 446 // Shut down the host when the first video packet is received. |
| 444 Expectation video_packet_sent = ExpectClientConnected( | 447 Expectation video_packet_sent = ExpectClientConnected( |
| 445 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 448 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 446 Expectation client_disconnected = ExpectClientDisconnected( | 449 Expectation client_disconnected = ExpectClientDisconnected( |
| 447 0, true, video_packet_sent, InvokeWithoutArgs(DoNothing)); | 450 0, true, video_packet_sent, InvokeWithoutArgs(DoNothing)); |
| 448 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected); | 451 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected); |
| 449 | 452 |
| 450 host_->Start(); | 453 host_->Start(xmpp_login_); |
| 451 SimulateClientConnection(0, true, false); | 454 SimulateClientConnection(0, true, false); |
| 452 message_loop_.Run(); | 455 message_loop_.Run(); |
| 453 } | 456 } |
| 454 | 457 |
| 455 TEST_F(ChromotingHostTest, RejectAuthenticatingClient) { | 458 TEST_F(ChromotingHostTest, RejectAuthenticatingClient) { |
| 456 Expectation start = ExpectHostAndSessionManagerStart(); | 459 Expectation start = ExpectHostAndSessionManagerStart(); |
| 457 EXPECT_CALL(host_status_observer_, OnClientAuthenticated(session_jid1_)) | 460 EXPECT_CALL(host_status_observer_, OnClientAuthenticated(session_jid1_)) |
| 458 .WillOnce(InvokeWithoutArgs( | 461 .WillOnce(InvokeWithoutArgs( |
| 459 this, &ChromotingHostTest::RejectAuthenticatingClient)); | 462 this, &ChromotingHostTest::RejectAuthenticatingClient)); |
| 460 ExpectClientDisconnected( | 463 ExpectClientDisconnected( |
| 461 0, true, start, | 464 0, true, start, |
| 462 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 465 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 463 EXPECT_CALL(host_status_observer_, OnShutdown()); | 466 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 464 | 467 |
| 465 host_->Start(); | 468 host_->Start(xmpp_login_); |
| 466 SimulateClientConnection(0, true, true); | 469 SimulateClientConnection(0, true, true); |
| 467 message_loop_.Run(); | 470 message_loop_.Run(); |
| 468 } | 471 } |
| 469 | 472 |
| 470 TEST_F(ChromotingHostTest, AuthenticationFailed) { | 473 TEST_F(ChromotingHostTest, AuthenticationFailed) { |
| 471 ExpectHostAndSessionManagerStart(); | 474 ExpectHostAndSessionManagerStart(); |
| 472 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)) | 475 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)) |
| 473 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 476 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 474 EXPECT_CALL(host_status_observer_, OnShutdown()); | 477 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 475 | 478 |
| 476 host_->Start(); | 479 host_->Start(xmpp_login_); |
| 477 SimulateClientConnection(0, false, false); | 480 SimulateClientConnection(0, false, false); |
| 478 message_loop_.Run(); | 481 message_loop_.Run(); |
| 479 } | 482 } |
| 480 | 483 |
| 481 TEST_F(ChromotingHostTest, Reconnect) { | 484 TEST_F(ChromotingHostTest, Reconnect) { |
| 482 ExpectHostAndSessionManagerStart(); | 485 ExpectHostAndSessionManagerStart(); |
| 483 | 486 |
| 484 // When a video packet is received on the first connection, disconnect it, | 487 // When a video packet is received on the first connection, disconnect it, |
| 485 // then quit the message loop. | 488 // then quit the message loop. |
| 486 Expectation video_packet_sent1 = ExpectClientConnected(0, DoAll( | 489 Expectation video_packet_sent1 = ExpectClientConnected(0, DoAll( |
| 487 InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectClient1), | 490 InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectClient1), |
| 488 InvokeWithoutArgs(this, &ChromotingHostTest::QuitMainMessageLoop))); | 491 InvokeWithoutArgs(this, &ChromotingHostTest::QuitMainMessageLoop))); |
| 489 ExpectClientDisconnectEffects( | 492 ExpectClientDisconnectEffects( |
| 490 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); | 493 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); |
| 491 | 494 |
| 492 // When a video packet is received on the second connection, shut down the | 495 // When a video packet is received on the second connection, shut down the |
| 493 // host. | 496 // host. |
| 494 Expectation video_packet_sent2 = ExpectClientConnected( | 497 Expectation video_packet_sent2 = ExpectClientConnected( |
| 495 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 498 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 496 Expectation client_disconnected2 = ExpectClientDisconnected( | 499 Expectation client_disconnected2 = ExpectClientDisconnected( |
| 497 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); | 500 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); |
| 498 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); | 501 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); |
| 499 | 502 |
| 500 host_->Start(); | 503 host_->Start(xmpp_login_); |
| 501 SimulateClientConnection(0, true, false); | 504 SimulateClientConnection(0, true, false); |
| 502 message_loop_.Run(); | 505 message_loop_.Run(); |
| 503 SimulateClientConnection(1, true, false); | 506 SimulateClientConnection(1, true, false); |
| 504 message_loop_.Run(); | 507 message_loop_.Run(); |
| 505 } | 508 } |
| 506 | 509 |
| 507 TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) { | 510 TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) { |
| 508 ExpectHostAndSessionManagerStart(); | 511 ExpectHostAndSessionManagerStart(); |
| 509 | 512 |
| 510 // When a video packet is received, connect the second connection. | 513 // When a video packet is received, connect the second connection. |
| 511 // This should disconnect the first connection. | 514 // This should disconnect the first connection. |
| 512 Expectation video_packet_sent1 = ExpectClientConnected( | 515 Expectation video_packet_sent1 = ExpectClientConnected( |
| 513 0, | 516 0, |
| 514 InvokeWithoutArgs( | 517 InvokeWithoutArgs( |
| 515 CreateFunctor( | 518 CreateFunctor( |
| 516 this, | 519 this, |
| 517 &ChromotingHostTest::SimulateClientConnection, 1, true, false))); | 520 &ChromotingHostTest::SimulateClientConnection, 1, true, false))); |
| 518 ExpectClientDisconnected( | 521 ExpectClientDisconnected( |
| 519 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); | 522 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); |
| 520 Expectation video_packet_sent2 = ExpectClientConnected( | 523 Expectation video_packet_sent2 = ExpectClientConnected( |
| 521 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 524 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 522 Expectation client_disconnected2 = ExpectClientDisconnected( | 525 Expectation client_disconnected2 = ExpectClientDisconnected( |
| 523 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); | 526 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); |
| 524 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); | 527 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); |
| 525 | 528 |
| 526 host_->Start(); | 529 host_->Start(xmpp_login_); |
| 527 SimulateClientConnection(0, true, false); | 530 SimulateClientConnection(0, true, false); |
| 528 message_loop_.Run(); | 531 message_loop_.Run(); |
| 529 } | 532 } |
| 530 | 533 |
| 531 TEST_F(ChromotingHostTest, IncomingSessionDeclined) { | 534 TEST_F(ChromotingHostTest, IncomingSessionDeclined) { |
| 532 ExpectHostStart(); | 535 ExpectHostStart(); |
| 533 protocol::SessionManager::IncomingSessionResponse response = | 536 protocol::SessionManager::IncomingSessionResponse response = |
| 534 protocol::SessionManager::ACCEPT; | 537 protocol::SessionManager::ACCEPT; |
| 535 host_->OnIncomingSession(session1_, &response); | 538 host_->OnIncomingSession(session1_, &response); |
| 536 EXPECT_EQ(protocol::SessionManager::DECLINE, response); | 539 EXPECT_EQ(protocol::SessionManager::DECLINE, response); |
| 537 } | 540 } |
| 538 | 541 |
| 539 TEST_F(ChromotingHostTest, IncomingSessionIncompatible) { | 542 TEST_F(ChromotingHostTest, IncomingSessionIncompatible) { |
| 540 ExpectHostAndSessionManagerStart(); | 543 ExpectHostAndSessionManagerStart(); |
| 541 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( | 544 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( |
| 542 empty_candidate_config_.get())); | 545 empty_candidate_config_.get())); |
| 543 EXPECT_CALL(host_status_observer_, OnShutdown()); | 546 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 544 | 547 |
| 545 host_->set_protocol_config( | 548 host_->set_protocol_config( |
| 546 protocol::CandidateSessionConfig::CreateDefault().release()); | 549 protocol::CandidateSessionConfig::CreateDefault().release()); |
| 547 host_->Start(); | 550 host_->Start(xmpp_login_); |
| 548 | 551 |
| 549 protocol::SessionManager::IncomingSessionResponse response = | 552 protocol::SessionManager::IncomingSessionResponse response = |
| 550 protocol::SessionManager::ACCEPT; | 553 protocol::SessionManager::ACCEPT; |
| 551 host_->OnIncomingSession(session_unowned1_.get(), &response); | 554 host_->OnIncomingSession(session_unowned1_.get(), &response); |
| 552 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response); | 555 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response); |
| 553 | 556 |
| 554 host_->Shutdown(base::Bind(&DoNothing)); | 557 host_->Shutdown(base::Bind(&DoNothing)); |
| 555 } | 558 } |
| 556 | 559 |
| 557 TEST_F(ChromotingHostTest, IncomingSessionAccepted) { | 560 TEST_F(ChromotingHostTest, IncomingSessionAccepted) { |
| 558 ExpectHostAndSessionManagerStart(); | 561 ExpectHostAndSessionManagerStart(); |
| 559 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( | 562 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( |
| 560 default_candidate_config_.get())); | 563 default_candidate_config_.get())); |
| 561 EXPECT_CALL(*session_unowned1_, set_config(_)); | 564 EXPECT_CALL(*session_unowned1_, set_config(_)); |
| 562 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( | 565 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( |
| 563 this, &ChromotingHostTest::NotifyConnectionClosed)); | 566 this, &ChromotingHostTest::NotifyConnectionClosed)); |
| 564 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); | 567 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); |
| 565 EXPECT_CALL(host_status_observer_, OnShutdown()); | 568 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 566 | 569 |
| 567 host_->set_protocol_config( | 570 host_->set_protocol_config( |
| 568 protocol::CandidateSessionConfig::CreateDefault().release()); | 571 protocol::CandidateSessionConfig::CreateDefault().release()); |
| 569 host_->Start(); | 572 host_->Start(xmpp_login_); |
| 570 | 573 |
| 571 protocol::SessionManager::IncomingSessionResponse response = | 574 protocol::SessionManager::IncomingSessionResponse response = |
| 572 protocol::SessionManager::DECLINE; | 575 protocol::SessionManager::DECLINE; |
| 573 host_->OnIncomingSession(session_unowned1_.release(), &response); | 576 host_->OnIncomingSession(session_unowned1_.release(), &response); |
| 574 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); | 577 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); |
| 575 | 578 |
| 576 host_->Shutdown(base::Bind(&DoNothing)); | 579 host_->Shutdown(base::Bind(&DoNothing)); |
| 577 } | 580 } |
| 578 | 581 |
| 579 TEST_F(ChromotingHostTest, IncomingSessionOverload) { | 582 TEST_F(ChromotingHostTest, IncomingSessionOverload) { |
| 580 ExpectHostAndSessionManagerStart(); | 583 ExpectHostAndSessionManagerStart(); |
| 581 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( | 584 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( |
| 582 default_candidate_config_.get())); | 585 default_candidate_config_.get())); |
| 583 EXPECT_CALL(*session_unowned1_, set_config(_)); | 586 EXPECT_CALL(*session_unowned1_, set_config(_)); |
| 584 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( | 587 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( |
| 585 this, &ChromotingHostTest::NotifyConnectionClosed)); | 588 this, &ChromotingHostTest::NotifyConnectionClosed)); |
| 586 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); | 589 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); |
| 587 EXPECT_CALL(host_status_observer_, OnShutdown()); | 590 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 588 | 591 |
| 589 host_->set_protocol_config( | 592 host_->set_protocol_config( |
| 590 protocol::CandidateSessionConfig::CreateDefault().release()); | 593 protocol::CandidateSessionConfig::CreateDefault().release()); |
| 591 host_->Start(); | 594 host_->Start(xmpp_login_); |
| 592 | 595 |
| 593 protocol::SessionManager::IncomingSessionResponse response = | 596 protocol::SessionManager::IncomingSessionResponse response = |
| 594 protocol::SessionManager::DECLINE; | 597 protocol::SessionManager::DECLINE; |
| 595 host_->OnIncomingSession(session_unowned1_.release(), &response); | 598 host_->OnIncomingSession(session_unowned1_.release(), &response); |
| 596 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); | 599 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); |
| 597 | 600 |
| 598 host_->OnIncomingSession(session_unowned2_.get(), &response); | 601 host_->OnIncomingSession(session_unowned2_.get(), &response); |
| 599 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); | 602 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); |
| 600 | 603 |
| 601 host_->Shutdown(base::Bind(&DoNothing)); | 604 host_->Shutdown(base::Bind(&DoNothing)); |
| 602 } | 605 } |
| 603 | 606 |
| 604 TEST_F(ChromotingHostTest, OnSessionRouteChange) { | 607 TEST_F(ChromotingHostTest, OnSessionRouteChange) { |
| 605 std::string channel_name("ChannelName"); | 608 std::string channel_name("ChannelName"); |
| 606 protocol::TransportRoute route; | 609 protocol::TransportRoute route; |
| 607 | 610 |
| 608 ExpectHostAndSessionManagerStart(); | 611 ExpectHostAndSessionManagerStart(); |
| 609 Expectation video_packet_sent = ExpectClientConnected( | 612 Expectation video_packet_sent = ExpectClientConnected( |
| 610 0, InvokeWithoutArgs(CreateFunctor( | 613 0, InvokeWithoutArgs(CreateFunctor( |
| 611 this, &ChromotingHostTest::ChangeSessionRoute, channel_name, route))); | 614 this, &ChromotingHostTest::ChangeSessionRoute, channel_name, route))); |
| 612 Expectation route_change = | 615 Expectation route_change = |
| 613 EXPECT_CALL(host_status_observer_, OnClientRouteChange( | 616 EXPECT_CALL(host_status_observer_, OnClientRouteChange( |
| 614 session_jid1_, channel_name, _)) | 617 session_jid1_, channel_name, _)) |
| 615 .After(video_packet_sent) | 618 .After(video_packet_sent) |
| 616 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 619 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 617 ExpectClientDisconnected(0, true, route_change, InvokeWithoutArgs(DoNothing)); | 620 ExpectClientDisconnected(0, true, route_change, InvokeWithoutArgs(DoNothing)); |
| 618 EXPECT_CALL(host_status_observer_, OnShutdown()); | 621 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 619 | 622 |
| 620 host_->Start(); | 623 host_->Start(xmpp_login_); |
| 621 SimulateClientConnection(0, true, false); | 624 SimulateClientConnection(0, true, false); |
| 622 message_loop_.Run(); | 625 message_loop_.Run(); |
| 623 } | 626 } |
| 624 | 627 |
| 625 TEST_F(ChromotingHostTest, DisconnectAllClients) { | 628 TEST_F(ChromotingHostTest, DisconnectAllClients) { |
| 626 ExpectHostAndSessionManagerStart(); | 629 ExpectHostAndSessionManagerStart(); |
| 627 Expectation video_packet_sent = ExpectClientConnected( | 630 Expectation video_packet_sent = ExpectClientConnected( |
| 628 0, InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectAllClients)); | 631 0, InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectAllClients)); |
| 629 ExpectClientDisconnected(0, true, video_packet_sent, | 632 ExpectClientDisconnected(0, true, video_packet_sent, |
| 630 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 633 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
| 631 EXPECT_CALL(host_status_observer_, OnShutdown()); | 634 EXPECT_CALL(host_status_observer_, OnShutdown()); |
| 632 | 635 |
| 633 host_->Start(); | 636 host_->Start(xmpp_login_); |
| 634 SimulateClientConnection(0, true, false); | 637 SimulateClientConnection(0, true, false); |
| 635 message_loop_.Run(); | 638 message_loop_.Run(); |
| 636 } | 639 } |
| 637 | 640 |
| 638 } // namespace remoting | 641 } // namespace remoting |
| OLD | NEW |