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

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

Issue 1085703003: Use standard ICE in Chromoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash on memory bots 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();
112 session_unowned_jid1_ = "user3@doman/rest-of-jid"; 111 session_unowned_jid1_ = "user3@doman/rest-of-jid";
113 session_unowned_config2_ = SessionConfig::ForTest();
114 session_unowned_jid2_ = "user4@doman/rest-of-jid"; 112 session_unowned_jid2_ = "user4@doman/rest-of-jid";
115 113
116 EXPECT_CALL(*session1_, jid()) 114 EXPECT_CALL(*session1_, jid())
117 .WillRepeatedly(ReturnRef(session_jid1_)); 115 .WillRepeatedly(ReturnRef(session_jid1_));
118 EXPECT_CALL(*session2_, jid()) 116 EXPECT_CALL(*session2_, jid())
119 .WillRepeatedly(ReturnRef(session_jid2_)); 117 .WillRepeatedly(ReturnRef(session_jid2_));
120 EXPECT_CALL(*session_unowned1_, jid()) 118 EXPECT_CALL(*session_unowned1_, jid())
121 .WillRepeatedly(ReturnRef(session_unowned_jid1_)); 119 .WillRepeatedly(ReturnRef(session_unowned_jid1_));
122 EXPECT_CALL(*session_unowned2_, jid()) 120 EXPECT_CALL(*session_unowned2_, jid())
123 .WillRepeatedly(ReturnRef(session_unowned_jid2_)); 121 .WillRepeatedly(ReturnRef(session_unowned_jid2_));
124 EXPECT_CALL(*session1_, SetEventHandler(_)) 122 EXPECT_CALL(*session1_, SetEventHandler(_))
125 .Times(AnyNumber()); 123 .Times(AnyNumber());
126 EXPECT_CALL(*session2_, SetEventHandler(_)) 124 EXPECT_CALL(*session2_, SetEventHandler(_))
127 .Times(AnyNumber()); 125 .Times(AnyNumber());
128 EXPECT_CALL(*session_unowned1_, SetEventHandler(_)) 126 EXPECT_CALL(*session_unowned1_, SetEventHandler(_))
129 .Times(AnyNumber()) 127 .Times(AnyNumber())
130 .WillRepeatedly(SaveArg<0>(&session_unowned1_event_handler_)); 128 .WillRepeatedly(SaveArg<0>(&session_unowned1_event_handler_));
131 EXPECT_CALL(*session_unowned2_, SetEventHandler(_)) 129 EXPECT_CALL(*session_unowned2_, SetEventHandler(_))
132 .Times(AnyNumber()) 130 .Times(AnyNumber())
133 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_)); 131 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_));
134 EXPECT_CALL(*session1_, config()) 132 EXPECT_CALL(*session1_, config())
135 .WillRepeatedly(ReturnRef(session_config1_)); 133 .WillRepeatedly(ReturnRef(*session_config1_));
136 EXPECT_CALL(*session2_, config()) 134 EXPECT_CALL(*session2_, config())
137 .WillRepeatedly(ReturnRef(session_config2_)); 135 .WillRepeatedly(ReturnRef(*session_config2_));
138 136
139 owned_connection1_.reset(new MockConnectionToClient(session1_, 137 owned_connection1_.reset(new MockConnectionToClient(session1_,
140 &host_stub1_)); 138 &host_stub1_));
141 connection1_ = owned_connection1_.get(); 139 connection1_ = owned_connection1_.get();
142 owned_connection2_.reset(new MockConnectionToClient(session2_, 140 owned_connection2_.reset(new MockConnectionToClient(session2_,
143 &host_stub2_)); 141 &host_stub2_));
144 connection2_ = owned_connection2_.get(); 142 connection2_ = owned_connection2_.get();
145 143
146 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _)) 144 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _))
147 .WillByDefault(DeleteArg<0>()); 145 .WillByDefault(DeleteArg<0>());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_; 412 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory_;
415 scoped_ptr<ChromotingHost> host_; 413 scoped_ptr<ChromotingHost> host_;
416 MockHostStatusObserver host_status_observer_; 414 MockHostStatusObserver host_status_observer_;
417 protocol::MockSessionManager* session_manager_; 415 protocol::MockSessionManager* session_manager_;
418 std::string xmpp_login_; 416 std::string xmpp_login_;
419 MockConnectionToClient* connection1_; 417 MockConnectionToClient* connection1_;
420 scoped_ptr<MockConnectionToClient> owned_connection1_; 418 scoped_ptr<MockConnectionToClient> owned_connection1_;
421 ClientSession* client1_; 419 ClientSession* client1_;
422 std::string session_jid1_; 420 std::string session_jid1_;
423 MockSession* session1_; // Owned by |connection_|. 421 MockSession* session1_; // Owned by |connection_|.
424 SessionConfig session_config1_; 422 scoped_ptr<SessionConfig> session_config1_;
425 MockVideoStub video_stub1_; 423 MockVideoStub video_stub1_;
426 MockClientStub client_stub1_; 424 MockClientStub client_stub1_;
427 MockHostStub host_stub1_; 425 MockHostStub host_stub1_;
428 MockConnectionToClient* connection2_; 426 MockConnectionToClient* connection2_;
429 scoped_ptr<MockConnectionToClient> owned_connection2_; 427 scoped_ptr<MockConnectionToClient> owned_connection2_;
430 ClientSession* client2_; 428 ClientSession* client2_;
431 std::string session_jid2_; 429 std::string session_jid2_;
432 MockSession* session2_; // Owned by |connection2_|. 430 MockSession* session2_; // Owned by |connection2_|.
433 SessionConfig session_config2_; 431 scoped_ptr<SessionConfig> session_config2_;
434 MockVideoStub video_stub2_; 432 MockVideoStub video_stub2_;
435 MockClientStub client_stub2_; 433 MockClientStub client_stub2_;
436 MockHostStub host_stub2_; 434 MockHostStub host_stub2_;
437 scoped_ptr<MockSession> session_unowned1_; // Not owned by a connection. 435 scoped_ptr<MockSession> session_unowned1_; // Not owned by a connection.
438 SessionConfig session_unowned_config1_;
439 std::string session_unowned_jid1_; 436 std::string session_unowned_jid1_;
440 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection. 437 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection.
441 SessionConfig session_unowned_config2_;
442 std::string session_unowned_jid2_; 438 std::string session_unowned_jid2_;
443 protocol::Session::EventHandler* session_unowned1_event_handler_; 439 protocol::Session::EventHandler* session_unowned1_event_handler_;
444 protocol::Session::EventHandler* session_unowned2_event_handler_; 440 protocol::Session::EventHandler* session_unowned2_event_handler_;
445 scoped_ptr<protocol::CandidateSessionConfig> empty_candidate_config_; 441 scoped_ptr<protocol::CandidateSessionConfig> empty_candidate_config_;
446 scoped_ptr<protocol::CandidateSessionConfig> default_candidate_config_; 442 scoped_ptr<protocol::CandidateSessionConfig> default_candidate_config_;
447 443
448 MockConnectionToClient*& get_connection(int connection_index) { 444 MockConnectionToClient*& get_connection(int connection_index) {
449 return (connection_index == 0) ? connection1_ : connection2_; 445 return (connection_index == 0) ? connection1_ : connection2_;
450 } 446 }
451 447
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response); 588 EXPECT_EQ(protocol::SessionManager::INCOMPATIBLE, response);
593 589
594 ShutdownHost(); 590 ShutdownHost();
595 message_loop_.Run(); 591 message_loop_.Run();
596 } 592 }
597 593
598 TEST_F(ChromotingHostTest, IncomingSessionAccepted) { 594 TEST_F(ChromotingHostTest, IncomingSessionAccepted) {
599 ExpectHostAndSessionManagerStart(); 595 ExpectHostAndSessionManagerStart();
600 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return( 596 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(Return(
601 default_candidate_config_.get())); 597 default_candidate_config_.get()));
602 EXPECT_CALL(*session_unowned1_, set_config(_)); 598 EXPECT_CALL(*session_unowned1_, set_config_ptr(_));
603 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs( 599 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(InvokeWithoutArgs(
604 this, &ChromotingHostTest::NotifyConnectionClosed1)); 600 this, &ChromotingHostTest::NotifyConnectionClosed1));
605 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); 601 EXPECT_CALL(host_status_observer_, OnAccessDenied(_));
606 EXPECT_CALL(host_status_observer_, OnShutdown()); 602 EXPECT_CALL(host_status_observer_, OnShutdown());
607 603
608 host_->Start(xmpp_login_); 604 host_->Start(xmpp_login_);
609 605
610 protocol::SessionManager::IncomingSessionResponse response = 606 protocol::SessionManager::IncomingSessionResponse response =
611 protocol::SessionManager::DECLINE; 607 protocol::SessionManager::DECLINE;
612 host_->OnIncomingSession(session_unowned1_.release(), &response); 608 host_->OnIncomingSession(session_unowned1_.release(), &response);
613 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); 609 EXPECT_EQ(protocol::SessionManager::ACCEPT, response);
614 610
615 ShutdownHost(); 611 ShutdownHost();
616 message_loop_.Run(); 612 message_loop_.Run();
617 } 613 }
618 614
619 TEST_F(ChromotingHostTest, LoginBackOffUponConnection) { 615 TEST_F(ChromotingHostTest, LoginBackOffUponConnection) {
620 ExpectHostAndSessionManagerStart(); 616 ExpectHostAndSessionManagerStart();
621 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce( 617 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(
622 Return(default_candidate_config_.get())); 618 Return(default_candidate_config_.get()));
623 EXPECT_CALL(*session_unowned1_, set_config(_)); 619 EXPECT_CALL(*session_unowned1_, set_config_ptr(_));
624 EXPECT_CALL(*session_unowned1_, Close()).WillOnce( 620 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(
625 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1)); 621 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1));
626 EXPECT_CALL(host_status_observer_, OnAccessDenied(_)); 622 EXPECT_CALL(host_status_observer_, OnAccessDenied(_));
627 EXPECT_CALL(host_status_observer_, OnShutdown()); 623 EXPECT_CALL(host_status_observer_, OnShutdown());
628 624
629 host_->Start(xmpp_login_); 625 host_->Start(xmpp_login_);
630 626
631 protocol::SessionManager::IncomingSessionResponse response = 627 protocol::SessionManager::IncomingSessionResponse response =
632 protocol::SessionManager::DECLINE; 628 protocol::SessionManager::DECLINE;
633 629
634 host_->OnIncomingSession(session_unowned1_.release(), &response); 630 host_->OnIncomingSession(session_unowned1_.release(), &response);
635 EXPECT_EQ(protocol::SessionManager::ACCEPT, response); 631 EXPECT_EQ(protocol::SessionManager::ACCEPT, response);
636 632
637 host_->OnSessionAuthenticating(get_clients_from_host().front()); 633 host_->OnSessionAuthenticating(get_clients_from_host().front());
638 host_->OnIncomingSession(session_unowned2_.get(), &response); 634 host_->OnIncomingSession(session_unowned2_.get(), &response);
639 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response); 635 EXPECT_EQ(protocol::SessionManager::OVERLOAD, response);
640 636
641 ShutdownHost(); 637 ShutdownHost();
642 message_loop_.Run(); 638 message_loop_.Run();
643 } 639 }
644 640
645 TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) { 641 TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) {
646 Expectation start = ExpectHostAndSessionManagerStart(); 642 Expectation start = ExpectHostAndSessionManagerStart();
647 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce( 643 EXPECT_CALL(*session_unowned1_, candidate_config()).WillOnce(
648 Return(default_candidate_config_.get())); 644 Return(default_candidate_config_.get()));
649 EXPECT_CALL(*session_unowned1_, set_config(_)); 645 EXPECT_CALL(*session_unowned1_, set_config_ptr(_));
650 EXPECT_CALL(*session_unowned1_, Close()).WillOnce( 646 EXPECT_CALL(*session_unowned1_, Close()).WillOnce(
651 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1)); 647 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1));
652 648
653 EXPECT_CALL(*session_unowned2_, candidate_config()).WillOnce( 649 EXPECT_CALL(*session_unowned2_, candidate_config()).WillOnce(
654 Return(default_candidate_config_.get())); 650 Return(default_candidate_config_.get()));
655 EXPECT_CALL(*session_unowned2_, set_config(_)); 651 EXPECT_CALL(*session_unowned2_, set_config_ptr(_));
656 EXPECT_CALL(*session_unowned2_, Close()).WillOnce( 652 EXPECT_CALL(*session_unowned2_, Close()).WillOnce(
657 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed2)); 653 InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed2));
658 654
659 EXPECT_CALL(host_status_observer_, OnShutdown()); 655 EXPECT_CALL(host_status_observer_, OnShutdown());
660 656
661 host_->Start(xmpp_login_); 657 host_->Start(xmpp_login_);
662 658
663 protocol::SessionManager::IncomingSessionResponse response = 659 protocol::SessionManager::IncomingSessionResponse response =
664 protocol::SessionManager::DECLINE; 660 protocol::SessionManager::DECLINE;
665 661
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 ExpectClientDisconnected(0, true, video_packet_sent, 707 ExpectClientDisconnected(0, true, video_packet_sent,
712 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 708 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
713 EXPECT_CALL(host_status_observer_, OnShutdown()); 709 EXPECT_CALL(host_status_observer_, OnShutdown());
714 710
715 host_->Start(xmpp_login_); 711 host_->Start(xmpp_login_);
716 SimulateClientConnection(0, true, false); 712 SimulateClientConnection(0, true, false);
717 message_loop_.Run(); 713 message_loop_.Run();
718 } 714 }
719 715
720 } // namespace remoting 716 } // 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