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

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

Issue 1099203005: Revert of Use standard ICE in Chromoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "remoting/base/auto_thread_task_runner.h" 9 #include "remoting/base/auto_thread_task_runner.h"
10 #include "remoting/host/audio_capturer.h" 10 #include "remoting/host/audio_capturer.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 xmpp_login_ = "host@domain"; 102 xmpp_login_ = "host@domain";
103 session1_ = new MockSession(); 103 session1_ = new MockSession();
104 session2_ = new MockSession(); 104 session2_ = new MockSession();
105 session_unowned1_.reset(new MockSession()); 105 session_unowned1_.reset(new MockSession());
106 session_unowned2_.reset(new MockSession()); 106 session_unowned2_.reset(new MockSession());
107 session_config1_ = SessionConfig::ForTest(); 107 session_config1_ = SessionConfig::ForTest();
108 session_jid1_ = "user@domain/rest-of-jid"; 108 session_jid1_ = "user@domain/rest-of-jid";
109 session_config2_ = SessionConfig::ForTest(); 109 session_config2_ = SessionConfig::ForTest();
110 session_jid2_ = "user2@domain/rest-of-jid"; 110 session_jid2_ = "user2@domain/rest-of-jid";
111 session_unowned_config1_ = SessionConfig::ForTest();
111 session_unowned_jid1_ = "user3@doman/rest-of-jid"; 112 session_unowned_jid1_ = "user3@doman/rest-of-jid";
113 session_unowned_config2_ = SessionConfig::ForTest();
112 session_unowned_jid2_ = "user4@doman/rest-of-jid"; 114 session_unowned_jid2_ = "user4@doman/rest-of-jid";
113 115
114 EXPECT_CALL(*session1_, jid()) 116 EXPECT_CALL(*session1_, jid())
115 .WillRepeatedly(ReturnRef(session_jid1_)); 117 .WillRepeatedly(ReturnRef(session_jid1_));
116 EXPECT_CALL(*session2_, jid()) 118 EXPECT_CALL(*session2_, jid())
117 .WillRepeatedly(ReturnRef(session_jid2_)); 119 .WillRepeatedly(ReturnRef(session_jid2_));
118 EXPECT_CALL(*session_unowned1_, jid()) 120 EXPECT_CALL(*session_unowned1_, jid())
119 .WillRepeatedly(ReturnRef(session_unowned_jid1_)); 121 .WillRepeatedly(ReturnRef(session_unowned_jid1_));
120 EXPECT_CALL(*session_unowned2_, jid()) 122 EXPECT_CALL(*session_unowned2_, jid())
121 .WillRepeatedly(ReturnRef(session_unowned_jid2_)); 123 .WillRepeatedly(ReturnRef(session_unowned_jid2_));
122 EXPECT_CALL(*session1_, SetEventHandler(_)) 124 EXPECT_CALL(*session1_, SetEventHandler(_))
123 .Times(AnyNumber()); 125 .Times(AnyNumber());
124 EXPECT_CALL(*session2_, SetEventHandler(_)) 126 EXPECT_CALL(*session2_, SetEventHandler(_))
125 .Times(AnyNumber()); 127 .Times(AnyNumber());
126 EXPECT_CALL(*session_unowned1_, SetEventHandler(_)) 128 EXPECT_CALL(*session_unowned1_, SetEventHandler(_))
127 .Times(AnyNumber()) 129 .Times(AnyNumber())
128 .WillRepeatedly(SaveArg<0>(&session_unowned1_event_handler_)); 130 .WillRepeatedly(SaveArg<0>(&session_unowned1_event_handler_));
129 EXPECT_CALL(*session_unowned2_, SetEventHandler(_)) 131 EXPECT_CALL(*session_unowned2_, SetEventHandler(_))
130 .Times(AnyNumber()) 132 .Times(AnyNumber())
131 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_)); 133 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_));
132 EXPECT_CALL(*session1_, config()) 134 EXPECT_CALL(*session1_, config())
133 .WillRepeatedly(ReturnRef(*session_config1_)); 135 .WillRepeatedly(ReturnRef(session_config1_));
134 EXPECT_CALL(*session2_, config()) 136 EXPECT_CALL(*session2_, config())
135 .WillRepeatedly(ReturnRef(*session_config2_)); 137 .WillRepeatedly(ReturnRef(session_config2_));
136 138
137 owned_connection1_.reset(new MockConnectionToClient(session1_, 139 owned_connection1_.reset(new MockConnectionToClient(session1_,
138 &host_stub1_)); 140 &host_stub1_));
139 connection1_ = owned_connection1_.get(); 141 connection1_ = owned_connection1_.get();
140 owned_connection2_.reset(new MockConnectionToClient(session2_, 142 owned_connection2_.reset(new MockConnectionToClient(session2_,
141 &host_stub2_)); 143 &host_stub2_));
142 connection2_ = owned_connection2_.get(); 144 connection2_ = owned_connection2_.get();
143 145
144 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _)) 146 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _))
145 .WillByDefault(DeleteArg<0>()); 147 .WillByDefault(DeleteArg<0>());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_; 414 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_;
413 scoped_ptr<ChromotingHost> host_; 415 scoped_ptr<ChromotingHost> host_;
414 MockHostStatusObserver host_status_observer_; 416 MockHostStatusObserver host_status_observer_;
415 protocol::MockSessionManager* session_manager_; 417 protocol::MockSessionManager* session_manager_;
416 std::string xmpp_login_; 418 std::string xmpp_login_;
417 MockConnectionToClient* connection1_; 419 MockConnectionToClient* connection1_;
418 scoped_ptr<MockConnectionToClient> owned_connection1_; 420 scoped_ptr<MockConnectionToClient> owned_connection1_;
419 ClientSession* client1_; 421 ClientSession* client1_;
420 std::string session_jid1_; 422 std::string session_jid1_;
421 MockSession* session1_; // Owned by |connection_|. 423 MockSession* session1_; // Owned by |connection_|.
422 scoped_ptr<SessionConfig> session_config1_; 424 SessionConfig session_config1_;
423 MockVideoStub video_stub1_; 425 MockVideoStub video_stub1_;
424 MockClientStub client_stub1_; 426 MockClientStub client_stub1_;
425 MockHostStub host_stub1_; 427 MockHostStub host_stub1_;
426 MockConnectionToClient* connection2_; 428 MockConnectionToClient* connection2_;
427 scoped_ptr<MockConnectionToClient> owned_connection2_; 429 scoped_ptr<MockConnectionToClient> owned_connection2_;
428 ClientSession* client2_; 430 ClientSession* client2_;
429 std::string session_jid2_; 431 std::string session_jid2_;
430 MockSession* session2_; // Owned by |connection2_|. 432 MockSession* session2_; // Owned by |connection2_|.
431 scoped_ptr<SessionConfig> session_config2_; 433 SessionConfig session_config2_;
432 MockVideoStub video_stub2_; 434 MockVideoStub video_stub2_;
433 MockClientStub client_stub2_; 435 MockClientStub client_stub2_;
434 MockHostStub host_stub2_; 436 MockHostStub host_stub2_;
435 scoped_ptr<MockSession> session_unowned1_; // Not owned by a connection. 437 scoped_ptr<MockSession> session_unowned1_; // Not owned by a connection.
438 SessionConfig session_unowned_config1_;
436 std::string session_unowned_jid1_; 439 std::string session_unowned_jid1_;
437 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection. 440 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection.
441 SessionConfig session_unowned_config2_;
438 std::string session_unowned_jid2_; 442 std::string session_unowned_jid2_;
439 protocol::Session::EventHandler* session_unowned1_event_handler_; 443 protocol::Session::EventHandler* session_unowned1_event_handler_;
440 protocol::Session::EventHandler* session_unowned2_event_handler_; 444 protocol::Session::EventHandler* session_unowned2_event_handler_;
441 scoped_ptr<protocol::CandidateSessionConfig> empty_candidate_config_; 445 scoped_ptr<protocol::CandidateSessionConfig> empty_candidate_config_;
442 scoped_ptr<protocol::CandidateSessionConfig> default_candidate_config_; 446 scoped_ptr<protocol::CandidateSessionConfig> default_candidate_config_;
443 447
444 MockConnectionToClient*& get_connection(int connection_index) { 448 MockConnectionToClient*& get_connection(int connection_index) {
445 return (connection_index == 0) ? connection1_ : connection2_; 449 return (connection_index == 0) ? connection1_ : connection2_;
446 } 450 }
447 451
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response); 592 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response);
589 593
590 ShutdownHost(); 594 ShutdownHost();
591 message_loop_.Run(); 595 message_loop_.Run();
592 } 596 }
593 597
594 TEST_F(ChromotingHostTest, IncomingSessionAccepted) { 598 TEST_F(ChromotingHostTest, IncomingSessionAccepted) {
595 ExpectHostAndSessionManagerStart(); 599 ExpectHostAndSessionManagerStart();
596 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( 600 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return(
597 default_candidate_config_.get())); 601 default_candidate_config_.get()));
598 EXPECT_CALL(*session_unowned1_, set_config_ptr(_)); 602 EXPECT_CALL(*session_unowned1_, set_config(_));
599 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( 603 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs(
600 this, &ChromotingHostTest::NotifyConnectionClosed1)); 604 this, &ChromotingHostTest::NotifyConnectionClosed1));
601 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); 605 EXPECT_CALL(host_status_observer_, OnAccessDenied(_));
602 EXPECT_CALL(host_status_observer_, OnShutdown()); 606 EXPECT_CALL(host_status_observer_, OnShutdown());
603 607
604 host_->Start(xmpp_login_); 608 host_->Start(xmpp_login_);
605 609
606 protocol::SessionManager::IncomingSessionResponse response = 610 protocol::SessionManager::IncomingSessionResponse response =
607 protocol::SessionManager::DECLINE; 611 protocol::SessionManager::DECLINE;
608 host_->OnIncomingSession(session_unowned1_.release(), &response); 612 host_->OnIncomingSession(session_unowned1_.release(), &response);
609 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); 613 EXPECT_EQ(protocol::SessionManager::ACCEPT, response);
610 614
611 ShutdownHost(); 615 ShutdownHost();
612 message_loop_.Run(); 616 message_loop_.Run();
613 } 617 }
614 618
615 TEST_F(ChromotingHostTest, LoginBackOffUponConnection) { 619 TEST_F(ChromotingHostTest, LoginBackOffUponConnection) {
616 ExpectHostAndSessionManagerStart(); 620 ExpectHostAndSessionManagerStart();
617 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce( 621 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(
618 Return(default_candidate_config_.get())); 622 Return(default_candidate_config_.get()));
619 EXPECT_CALL(*session_unowned1_, set_config_ptr(_)); 623 EXPECT_CALL(*session_unowned1_, set_config(_));
620 EXPECT_CALL(*session_unowned1_, Close()).WillOnce( 624 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(
621 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1)); 625 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1));
622 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); 626 EXPECT_CALL(host_status_observer_, OnAccessDenied(_));
623 EXPECT_CALL(host_status_observer_, OnShutdown()); 627 EXPECT_CALL(host_status_observer_, OnShutdown());
624 628
625 host_->Start(xmpp_login_); 629 host_->Start(xmpp_login_);
626 630
627 protocol::SessionManager::IncomingSessionResponse response = 631 protocol::SessionManager::IncomingSessionResponse response =
628 protocol::SessionManager::DECLINE; 632 protocol::SessionManager::DECLINE;
629 633
630 host_->OnIncomingSession(session_unowned1_.release(), &response); 634 host_->OnIncomingSession(session_unowned1_.release(), &response);
631 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); 635 EXPECT_EQ(protocol::SessionManager::ACCEPT, response);
632 636
633 host_->OnSessionAuthenticating(get_clients_from_host().front()); 637 host_->OnSessionAuthenticating(get_clients_from_host().front());
634 host_->OnIncomingSession(session_unowned2_.get(), &response); 638 host_->OnIncomingSession(session_unowned2_.get(), &response);
635 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); 639 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response);
636 640
637 ShutdownHost(); 641 ShutdownHost();
638 message_loop_.Run(); 642 message_loop_.Run();
639 } 643 }
640 644
641 TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) { 645 TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) {
642 Expectation start = ExpectHostAndSessionManagerStart(); 646 Expectation start = ExpectHostAndSessionManagerStart();
643 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce( 647 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(
644 Return(default_candidate_config_.get())); 648 Return(default_candidate_config_.get()));
645 EXPECT_CALL(*session_unowned1_, set_config_ptr(_)); 649 EXPECT_CALL(*session_unowned1_, set_config(_));
646 EXPECT_CALL(*session_unowned1_, Close()).WillOnce( 650 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(
647 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1)); 651 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1));
648 652
649 EXPECT_CALL(*session_unowned2_, candidate_config()).WillOnce( 653 EXPECT_CALL(*session_unowned2_, candidate_config()).WillOnce(
650 Return(default_candidate_config_.get())); 654 Return(default_candidate_config_.get()));
651 EXPECT_CALL(*session_unowned2_, set_config_ptr(_)); 655 EXPECT_CALL(*session_unowned2_, set_config(_));
652 EXPECT_CALL(*session_unowned2_, Close()).WillOnce( 656 EXPECT_CALL(*session_unowned2_, Close()).WillOnce(
653 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed2)); 657 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed2));
654 658
655 EXPECT_CALL(host_status_observer_, OnShutdown()); 659 EXPECT_CALL(host_status_observer_, OnShutdown());
656 660
657 host_->Start(xmpp_login_); 661 host_->Start(xmpp_login_);
658 662
659 protocol::SessionManager::IncomingSessionResponse response = 663 protocol::SessionManager::IncomingSessionResponse response =
660 protocol::SessionManager::DECLINE; 664 protocol::SessionManager::DECLINE;
661 665
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 ExpectClientDisconnected(0, true, video_packet_sent, 711 ExpectClientDisconnected(0, true, video_packet_sent,
708 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 712 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
709 EXPECT_CALL(host_status_observer_, OnShutdown()); 713 EXPECT_CALL(host_status_observer_, OnShutdown());
710 714
711 host_->Start(xmpp_login_); 715 host_->Start(xmpp_login_);
712 SimulateClientConnection(0, true, false); 716 SimulateClientConnection(0, true, false);
713 message_loop_.Run(); 717 message_loop_.Run();
714 } 718 }
715 719
716 } // namespace remoting 720 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/host/client_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698