diff options
author | sergeyu <sergeyu@chromium.org> | 2015-12-16 19:17:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-17 03:18:35 +0000 |
commit | 1b03268d85cb1563eeec00bc44cb612f418b2839 (patch) | |
tree | d2e5b909c9055a9cdf228c77c1946da9c33821e1 /remoting/host/chromoting_host_unittest.cc | |
parent | 6a120341ccc1679d06a0f16fe7a68a0e23ba6f12 (diff) | |
download | chromium_src-1b03268d85cb1563eeec00bc44cb612f418b2839.zip chromium_src-1b03268d85cb1563eeec00bc44cb612f418b2839.tar.gz chromium_src-1b03268d85cb1563eeec00bc44cb612f418b2839.tar.bz2 |
More cleanups in JingleSessionManager interface.
1. Removed Close() method.
2. Replaced Init() method with AcceptIncoming() that's called only
on the host.
Review URL: https://codereview.chromium.org/1530523002
Cr-Commit-Position: refs/heads/master@{#365702}
Diffstat (limited to 'remoting/host/chromoting_host_unittest.cc')
-rw-r--r-- | remoting/host/chromoting_host_unittest.cc | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index 66cf95b..de03e60 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -18,7 +18,6 @@ #include "remoting/protocol/fake_desktop_capturer.h" #include "remoting/protocol/protocol_mock_objects.h" #include "remoting/protocol/session_config.h" -#include "remoting/signaling/mock_signal_strategy.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock_mutant.h" #include "testing/gtest/include/gtest/gtest.h" @@ -61,16 +60,14 @@ class ChromotingHostTest : public testing::Test { desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory()); session_manager_ = new protocol::MockSessionManager(); - host_.reset(new ChromotingHost( - &signal_strategy_, - desktop_environment_factory_.get(), - make_scoped_ptr(session_manager_), - task_runner_, // Audio - task_runner_, // Input - task_runner_, // Video capture - task_runner_, // Video encode - task_runner_, // Network - task_runner_)); // UI + host_.reset(new ChromotingHost(desktop_environment_factory_.get(), + make_scoped_ptr(session_manager_), + task_runner_, // Audio + task_runner_, // Input + task_runner_, // Video capture + task_runner_, // Video encode + task_runner_, // Network + task_runner_)); // UI host_->AddStatusObserver(&host_status_observer_); xmpp_login_ = "host@domain"; @@ -189,11 +186,11 @@ class ChromotingHostTest : public testing::Test { desktop_environment_factory_.reset(); } - // Expect the host and session manager to start, and return the expectation - // that the session manager has started. - Expectation ExpectHostAndSessionManagerStart() { + // Starts the host. + void StartHost() { EXPECT_CALL(host_status_observer_, OnStart(xmpp_login_)); - return EXPECT_CALL(*session_manager_, Init(_, host_.get())); + EXPECT_CALL(*session_manager_, AcceptIncoming(_)); + host_->Start(xmpp_login_); } // Expect a client to connect. @@ -219,7 +216,6 @@ class ChromotingHostTest : public testing::Test { base::MessageLoop message_loop_; scoped_refptr<AutoThreadTaskRunner> task_runner_; MockConnectionToClientEventHandler handler_; - MockSignalStrategy signal_strategy_; scoped_ptr<FakeDesktopEnvironmentFactory> desktop_environment_factory_; MockHostStatusObserver host_status_observer_; scoped_ptr<ChromotingHost> host_; @@ -268,13 +264,11 @@ class ChromotingHostTest : public testing::Test { }; TEST_F(ChromotingHostTest, StartAndShutdown) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); } TEST_F(ChromotingHostTest, Connect) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); // Shut down the host when the first video packet is received. ExpectClientConnected(0); @@ -282,16 +276,14 @@ TEST_F(ChromotingHostTest, Connect) { } TEST_F(ChromotingHostTest, AuthenticationFailed) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)); SimulateClientConnection(0, false, false); } TEST_F(ChromotingHostTest, Reconnect) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); // Connect first client. ExpectClientConnected(0); @@ -311,8 +303,7 @@ TEST_F(ChromotingHostTest, Reconnect) { } TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); // Connect first client. ExpectClientConnected(0); @@ -332,8 +323,7 @@ TEST_F(ChromotingHostTest, ConnectWhenAnotherClientIsConnected) { } TEST_F(ChromotingHostTest, IncomingSessionAccepted) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); MockSession* session = session_unowned1_.get(); protocol::SessionManager::IncomingSessionResponse response = @@ -347,8 +337,7 @@ TEST_F(ChromotingHostTest, IncomingSessionAccepted) { } TEST_F(ChromotingHostTest, LoginBackOffUponConnection) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); protocol::SessionManager::IncomingSessionResponse response = protocol::SessionManager::DECLINE; @@ -364,7 +353,7 @@ TEST_F(ChromotingHostTest, LoginBackOffUponConnection) { } TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) { - ExpectHostAndSessionManagerStart(); + StartHost(); EXPECT_CALL(*session_unowned1_, Close(_)).WillOnce( InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed1)); @@ -372,8 +361,6 @@ TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) { EXPECT_CALL(*session_unowned2_, Close(_)).WillOnce( InvokeWithoutArgs(this, &ChromotingHostTest::NotifyConnectionClosed2)); - host_->Start(xmpp_login_); - protocol::SessionManager::IncomingSessionResponse response = protocol::SessionManager::DECLINE; @@ -394,8 +381,7 @@ TEST_F(ChromotingHostTest, LoginBackOffUponAuthenticating) { } TEST_F(ChromotingHostTest, OnSessionRouteChange) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); ExpectClientConnected(0); @@ -409,8 +395,7 @@ TEST_F(ChromotingHostTest, OnSessionRouteChange) { } TEST_F(ChromotingHostTest, DisconnectAllClients) { - ExpectHostAndSessionManagerStart(); - host_->Start(xmpp_login_); + StartHost(); ExpectClientConnected(0); SimulateClientConnection(0, true, false); |