OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
Jamie
2012/08/30 06:09:33
Can you add a unit test for the new callback?
rmsousa
2012/08/30 16:29:03
Done.
| |
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" |
11 #include "remoting/host/chromoting_host.h" | 11 #include "remoting/host/chromoting_host.h" |
(...skipping 90 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 369 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
369 MockConnectionToClientEventHandler handler_; | 370 MockConnectionToClientEventHandler handler_; |
370 MockSignalStrategy signal_strategy_; | 371 MockSignalStrategy signal_strategy_; |
371 MockEventExecutor* event_executor_; | 372 MockEventExecutor* event_executor_; |
372 scoped_ptr<DesktopEnvironment> desktop_environment_; | 373 scoped_ptr<DesktopEnvironment> desktop_environment_; |
373 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; | 374 scoped_ptr<It2MeHostUserInterface> it2me_host_user_interface_; |
374 scoped_refptr<ChromotingHost> host_; | 375 scoped_refptr<ChromotingHost> host_; |
375 MockHostStatusObserver host_status_observer_; | 376 MockHostStatusObserver host_status_observer_; |
376 MockChromotingHostContext context_; | 377 MockChromotingHostContext context_; |
377 protocol::MockSessionManager* session_manager_; | 378 protocol::MockSessionManager* session_manager_; |
379 std::string xmpp_login_; | |
378 MockConnectionToClient* connection1_; | 380 MockConnectionToClient* connection1_; |
379 scoped_ptr<MockConnectionToClient> owned_connection1_; | 381 scoped_ptr<MockConnectionToClient> owned_connection1_; |
380 ClientSession* client1_; | 382 ClientSession* client1_; |
381 std::string session_jid1_; | 383 std::string session_jid1_; |
382 MockSession* session1_; // Owned by |connection_|. | 384 MockSession* session1_; // Owned by |connection_|. |
383 SessionConfig session_config1_; | 385 SessionConfig session_config1_; |
384 MockVideoStub video_stub1_; | 386 MockVideoStub video_stub1_; |
385 MockClientStub client_stub1_; | 387 MockClientStub client_stub1_; |
386 MockHostStub host_stub1_; | 388 MockHostStub host_stub1_; |
387 MockConnectionToClient* connection2_; | 389 MockConnectionToClient* connection2_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 | 424 |
423 MockVideoStub& get_video_stub(int connection_index) { | 425 MockVideoStub& get_video_stub(int connection_index) { |
424 return (connection_index == 0) ? video_stub1_ : video_stub2_; | 426 return (connection_index == 0) ? video_stub1_ : video_stub2_; |
425 } | 427 } |
426 }; | 428 }; |
427 | 429 |
428 TEST_F(ChromotingHostTest, StartAndShutdown) { | 430 TEST_F(ChromotingHostTest, StartAndShutdown) { |
429 Expectation start = ExpectHostAndSessionManagerStart(); | 431 Expectation start = ExpectHostAndSessionManagerStart(); |
430 EXPECT_CALL(host_status_observer_, OnShutdown()).After(start); | 432 EXPECT_CALL(host_status_observer_, OnShutdown()).After(start); |
431 | 433 |
432 host_->Start(); | 434 host_->Start(xmpp_login_); |
433 message_loop_.PostTask( | 435 message_loop_.PostTask( |
434 FROM_HERE, base::Bind( | 436 FROM_HERE, base::Bind( |
435 &ChromotingHost::Shutdown, host_.get(), | 437 &ChromotingHost::Shutdown, host_.get(), |
436 base::Bind(&PostQuitTask, &message_loop_))); | 438 base::Bind(&PostQuitTask, &message_loop_))); |
437 message_loop_.Run(); | 439 message_loop_.Run(); |
438 } | 440 } |
439 | 441 |
440 TEST_F(ChromotingHostTest, Connect) { | 442 TEST_F(ChromotingHostTest, Connect) { |
441 ExpectHostAndSessionManagerStart(); | 443 ExpectHostAndSessionManagerStart(); |
442 | 444 |
443 // Shut down the host when the first video packet is received. | 445 // Shut down the host when the first video packet is received. |
444 Expectation video_packet_sent = ExpectClientConnected( | 446 Expectation video_packet_sent = ExpectClientConnected( |
445 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 447 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
446 Expectation client_disconnected = ExpectClientDisconnected( | 448 Expectation client_disconnected = ExpectClientDisconnected( |
447 0, true, video_packet_sent, InvokeWithoutArgs(DoNothing)); | 449 0, true, video_packet_sent, InvokeWithoutArgs(DoNothing)); |
448 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected); | 450 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected); |
449 | 451 |
450 host_->Start(); | 452 host_->Start(xmpp_login_); |
451 SimulateClientConnection(0, true, false); | 453 SimulateClientConnection(0, true, false); |
452 message_loop_.Run(); | 454 message_loop_.Run(); |
453 } | 455 } |
454 | 456 |
455 TEST_F(ChromotingHostTest, RejectAuthenticatingClient) { | 457 TEST_F(ChromotingHostTest, RejectAuthenticatingClient) { |
456 Expectation start = ExpectHostAndSessionManagerStart(); | 458 Expectation start = ExpectHostAndSessionManagerStart(); |
457 EXPECT_CALL(host_status_observer_, OnClientAuthenticated(session_jid1_)) | 459 EXPECT_CALL(host_status_observer_, OnClientAuthenticated(session_jid1_)) |
458 .WillOnce(InvokeWithoutArgs( | 460 .WillOnce(InvokeWithoutArgs( |
459 this, &ChromotingHostTest::RejectAuthenticatingClient)); | 461 this, &ChromotingHostTest::RejectAuthenticatingClient)); |
460 ExpectClientDisconnected( | 462 ExpectClientDisconnected( |
461 0, true, start, | 463 0, true, start, |
462 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 464 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
463 EXPECT_CALL(host_status_observer_, OnShutdown()); | 465 EXPECT_CALL(host_status_observer_, OnShutdown()); |
464 | 466 |
465 host_->Start(); | 467 host_->Start(xmpp_login_); |
466 SimulateClientConnection(0, true, true); | 468 SimulateClientConnection(0, true, true); |
467 message_loop_.Run(); | 469 message_loop_.Run(); |
468 } | 470 } |
469 | 471 |
470 TEST_F(ChromotingHostTest, AuthenticationFailed) { | 472 TEST_F(ChromotingHostTest, AuthenticationFailed) { |
471 ExpectHostAndSessionManagerStart(); | 473 ExpectHostAndSessionManagerStart(); |
472 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)) | 474 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)) |
473 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 475 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
474 EXPECT_CALL(host_status_observer_, OnShutdown()); | 476 EXPECT_CALL(host_status_observer_, OnShutdown()); |
475 | 477 |
476 host_->Start(); | 478 host_->Start(xmpp_login_); |
477 SimulateClientConnection(0, false, false); | 479 SimulateClientConnection(0, false, false); |
478 message_loop_.Run(); | 480 message_loop_.Run(); |
479 } | 481 } |
480 | 482 |
481 TEST_F(ChromotingHostTest, Reconnect) { | 483 TEST_F(ChromotingHostTest, Reconnect) { |
482 ExpectHostAndSessionManagerStart(); | 484 ExpectHostAndSessionManagerStart(); |
483 | 485 |
484 // When a video packet is received on the first connection, disconnect it, | 486 // When a video packet is received on the first connection, disconnect it, |
485 // then quit the message loop. | 487 // then quit the message loop. |
486 Expectation video_packet_sent1 = ExpectClientConnected(0, DoAll( | 488 Expectation video_packet_sent1 = ExpectClientConnected(0, DoAll( |
487 InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectClient1), | 489 InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectClient1), |
488 InvokeWithoutArgs(this, &ChromotingHostTest::QuitMainMessageLoop))); | 490 InvokeWithoutArgs(this, &ChromotingHostTest::QuitMainMessageLoop))); |
489 ExpectClientDisconnectEffects( | 491 ExpectClientDisconnectEffects( |
490 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); | 492 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); |
491 | 493 |
492 // When a video packet is received on the second connection, shut down the | 494 // When a video packet is received on the second connection, shut down the |
493 // host. | 495 // host. |
494 Expectation video_packet_sent2 = ExpectClientConnected( | 496 Expectation video_packet_sent2 = ExpectClientConnected( |
495 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 497 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
496 Expectation client_disconnected2 = ExpectClientDisconnected( | 498 Expectation client_disconnected2 = ExpectClientDisconnected( |
497 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); | 499 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); |
498 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); | 500 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); |
499 | 501 |
500 host_->Start(); | 502 host_->Start(xmpp_login_); |
501 SimulateClientConnection(0, true, false); | 503 SimulateClientConnection(0, true, false); |
502 message_loop_.Run(); | 504 message_loop_.Run(); |
503 SimulateClientConnection(1, true, false); | 505 SimulateClientConnection(1, true, false); |
504 message_loop_.Run(); | 506 message_loop_.Run(); |
505 } | 507 } |
506 | 508 |
507 TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) { | 509 TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) { |
508 ExpectHostAndSessionManagerStart(); | 510 ExpectHostAndSessionManagerStart(); |
509 | 511 |
510 // When a video packet is received, connect the second connection. | 512 // When a video packet is received, connect the second connection. |
511 // This should disconnect the first connection. | 513 // This should disconnect the first connection. |
512 Expectation video_packet_sent1 = ExpectClientConnected( | 514 Expectation video_packet_sent1 = ExpectClientConnected( |
513 0, | 515 0, |
514 InvokeWithoutArgs( | 516 InvokeWithoutArgs( |
515 CreateFunctor( | 517 CreateFunctor( |
516 this, | 518 this, |
517 &ChromotingHostTest::SimulateClientConnection, 1, true, false))); | 519 &ChromotingHostTest::SimulateClientConnection, 1, true, false))); |
518 ExpectClientDisconnected( | 520 ExpectClientDisconnected( |
519 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); | 521 0, true, video_packet_sent1, InvokeWithoutArgs(DoNothing)); |
520 Expectation video_packet_sent2 = ExpectClientConnected( | 522 Expectation video_packet_sent2 = ExpectClientConnected( |
521 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 523 1, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
522 Expectation client_disconnected2 = ExpectClientDisconnected( | 524 Expectation client_disconnected2 = ExpectClientDisconnected( |
523 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); | 525 1, true, video_packet_sent2, InvokeWithoutArgs(DoNothing)); |
524 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); | 526 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected2); |
525 | 527 |
526 host_->Start(); | 528 host_->Start(xmpp_login_); |
527 SimulateClientConnection(0, true, false); | 529 SimulateClientConnection(0, true, false); |
528 message_loop_.Run(); | 530 message_loop_.Run(); |
529 } | 531 } |
530 | 532 |
531 TEST_F(ChromotingHostTest, IncomingSessionDeclined) { | 533 TEST_F(ChromotingHostTest, IncomingSessionDeclined) { |
532 ExpectHostStart(); | 534 ExpectHostStart(); |
533 protocol::SessionManager::IncomingSessionResponse response = | 535 protocol::SessionManager::IncomingSessionResponse response = |
534 protocol::SessionManager::ACCEPT; | 536 protocol::SessionManager::ACCEPT; |
535 host_->OnIncomingSession(session1_, &response); | 537 host_->OnIncomingSession(session1_, &response); |
536 EXPECT_EQ(protocol::SessionManager::DECLINE, response); | 538 EXPECT_EQ(protocol::SessionManager::DECLINE, response); |
537 } | 539 } |
538 | 540 |
539 TEST_F(ChromotingHostTest, IncomingSessionIncompatible) { | 541 TEST_F(ChromotingHostTest, IncomingSessionIncompatible) { |
540 ExpectHostAndSessionManagerStart(); | 542 ExpectHostAndSessionManagerStart(); |
541 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( | 543 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( |
542 empty_candidate_config_.get())); | 544 empty_candidate_config_.get())); |
543 EXPECT_CALL(host_status_observer_, OnShutdown()); | 545 EXPECT_CALL(host_status_observer_, OnShutdown()); |
544 | 546 |
545 host_->set_protocol_config( | 547 host_->set_protocol_config( |
546 protocol::CandidateSessionConfig::CreateDefault().release()); | 548 protocol::CandidateSessionConfig::CreateDefault().release()); |
547 host_->Start(); | 549 host_->Start(xmpp_login_); |
548 | 550 |
549 protocol::SessionManager::IncomingSessionResponse response = | 551 protocol::SessionManager::IncomingSessionResponse response = |
550 protocol::SessionManager::ACCEPT; | 552 protocol::SessionManager::ACCEPT; |
551 host_->OnIncomingSession(session_unowned1_.get(), &response); | 553 host_->OnIncomingSession(session_unowned1_.get(), &response); |
552 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response); | 554 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response); |
553 | 555 |
554 host_->Shutdown(base::Bind(&DoNothing)); | 556 host_->Shutdown(base::Bind(&DoNothing)); |
555 } | 557 } |
556 | 558 |
557 TEST_F(ChromotingHostTest, IncomingSessionAccepted) { | 559 TEST_F(ChromotingHostTest, IncomingSessionAccepted) { |
558 ExpectHostAndSessionManagerStart(); | 560 ExpectHostAndSessionManagerStart(); |
559 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( | 561 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( |
560 default_candidate_config_.get())); | 562 default_candidate_config_.get())); |
561 EXPECT_CALL(*session_unowned1_, set_config(_)); | 563 EXPECT_CALL(*session_unowned1_, set_config(_)); |
562 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( | 564 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( |
563 this, &ChromotingHostTest::NotifyConnectionClosed)); | 565 this, &ChromotingHostTest::NotifyConnectionClosed)); |
564 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); | 566 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); |
565 EXPECT_CALL(host_status_observer_, OnShutdown()); | 567 EXPECT_CALL(host_status_observer_, OnShutdown()); |
566 | 568 |
567 host_->set_protocol_config( | 569 host_->set_protocol_config( |
568 protocol::CandidateSessionConfig::CreateDefault().release()); | 570 protocol::CandidateSessionConfig::CreateDefault().release()); |
569 host_->Start(); | 571 host_->Start(xmpp_login_); |
570 | 572 |
571 protocol::SessionManager::IncomingSessionResponse response = | 573 protocol::SessionManager::IncomingSessionResponse response = |
572 protocol::SessionManager::DECLINE; | 574 protocol::SessionManager::DECLINE; |
573 host_->OnIncomingSession(session_unowned1_.release(), &response); | 575 host_->OnIncomingSession(session_unowned1_.release(), &response); |
574 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); | 576 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); |
575 | 577 |
576 host_->Shutdown(base::Bind(&DoNothing)); | 578 host_->Shutdown(base::Bind(&DoNothing)); |
577 } | 579 } |
578 | 580 |
579 TEST_F(ChromotingHostTest, IncomingSessionOverload) { | 581 TEST_F(ChromotingHostTest, IncomingSessionOverload) { |
580 ExpectHostAndSessionManagerStart(); | 582 ExpectHostAndSessionManagerStart(); |
581 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( | 583 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( |
582 default_candidate_config_.get())); | 584 default_candidate_config_.get())); |
583 EXPECT_CALL(*session_unowned1_, set_config(_)); | 585 EXPECT_CALL(*session_unowned1_, set_config(_)); |
584 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( | 586 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( |
585 this, &ChromotingHostTest::NotifyConnectionClosed)); | 587 this, &ChromotingHostTest::NotifyConnectionClosed)); |
586 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); | 588 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); |
587 EXPECT_CALL(host_status_observer_, OnShutdown()); | 589 EXPECT_CALL(host_status_observer_, OnShutdown()); |
588 | 590 |
589 host_->set_protocol_config( | 591 host_->set_protocol_config( |
590 protocol::CandidateSessionConfig::CreateDefault().release()); | 592 protocol::CandidateSessionConfig::CreateDefault().release()); |
591 host_->Start(); | 593 host_->Start(xmpp_login_); |
592 | 594 |
593 protocol::SessionManager::IncomingSessionResponse response = | 595 protocol::SessionManager::IncomingSessionResponse response = |
594 protocol::SessionManager::DECLINE; | 596 protocol::SessionManager::DECLINE; |
595 host_->OnIncomingSession(session_unowned1_.release(), &response); | 597 host_->OnIncomingSession(session_unowned1_.release(), &response); |
596 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); | 598 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); |
597 | 599 |
598 host_->OnIncomingSession(session_unowned2_.get(), &response); | 600 host_->OnIncomingSession(session_unowned2_.get(), &response); |
599 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); | 601 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); |
600 | 602 |
601 host_->Shutdown(base::Bind(&DoNothing)); | 603 host_->Shutdown(base::Bind(&DoNothing)); |
602 } | 604 } |
603 | 605 |
604 TEST_F(ChromotingHostTest, OnSessionRouteChange) { | 606 TEST_F(ChromotingHostTest, OnSessionRouteChange) { |
605 std::string channel_name("ChannelName"); | 607 std::string channel_name("ChannelName"); |
606 protocol::TransportRoute route; | 608 protocol::TransportRoute route; |
607 | 609 |
608 ExpectHostAndSessionManagerStart(); | 610 ExpectHostAndSessionManagerStart(); |
609 Expectation video_packet_sent = ExpectClientConnected( | 611 Expectation video_packet_sent = ExpectClientConnected( |
610 0, InvokeWithoutArgs(CreateFunctor( | 612 0, InvokeWithoutArgs(CreateFunctor( |
611 this, &ChromotingHostTest::ChangeSessionRoute, channel_name, route))); | 613 this, &ChromotingHostTest::ChangeSessionRoute, channel_name, route))); |
612 Expectation route_change = | 614 Expectation route_change = |
613 EXPECT_CALL(host_status_observer_, OnClientRouteChange( | 615 EXPECT_CALL(host_status_observer_, OnClientRouteChange( |
614 session_jid1_, channel_name, _)) | 616 session_jid1_, channel_name, _)) |
615 .After(video_packet_sent) | 617 .After(video_packet_sent) |
616 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 618 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
617 ExpectClientDisconnected(0, true, route_change, InvokeWithoutArgs(DoNothing)); | 619 ExpectClientDisconnected(0, true, route_change, InvokeWithoutArgs(DoNothing)); |
618 EXPECT_CALL(host_status_observer_, OnShutdown()); | 620 EXPECT_CALL(host_status_observer_, OnShutdown()); |
619 | 621 |
620 host_->Start(); | 622 host_->Start(xmpp_login_); |
621 SimulateClientConnection(0, true, false); | 623 SimulateClientConnection(0, true, false); |
622 message_loop_.Run(); | 624 message_loop_.Run(); |
623 } | 625 } |
624 | 626 |
625 TEST_F(ChromotingHostTest, DisconnectAllClients) { | 627 TEST_F(ChromotingHostTest, DisconnectAllClients) { |
626 ExpectHostAndSessionManagerStart(); | 628 ExpectHostAndSessionManagerStart(); |
627 Expectation video_packet_sent = ExpectClientConnected( | 629 Expectation video_packet_sent = ExpectClientConnected( |
628 0, InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectAllClients)); | 630 0, InvokeWithoutArgs(this, &ChromotingHostTest::DisconnectAllClients)); |
629 ExpectClientDisconnected(0, true, video_packet_sent, | 631 ExpectClientDisconnected(0, true, video_packet_sent, |
630 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 632 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
631 EXPECT_CALL(host_status_observer_, OnShutdown()); | 633 EXPECT_CALL(host_status_observer_, OnShutdown()); |
632 | 634 |
633 host_->Start(); | 635 host_->Start(xmpp_login_); |
634 SimulateClientConnection(0, true, false); | 636 SimulateClientConnection(0, true, false); |
635 message_loop_.Run(); | 637 message_loop_.Run(); |
636 } | 638 } |
637 | 639 |
638 } // namespace remoting | 640 } // namespace remoting |
OLD | NEW |