| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "remoting/protocol/pepper_session.h" | 5 #include "remoting/protocol/pepper_session.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 namespace remoting { | 36 namespace remoting { |
| 37 namespace protocol { | 37 namespace protocol { |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 const char kHostJid[] = "host1@gmail.com/123"; | 41 const char kHostJid[] = "host1@gmail.com/123"; |
| 42 const char kClientJid[] = "host2@gmail.com/321"; | 42 const char kClientJid[] = "host2@gmail.com/321"; |
| 43 | 43 |
| 44 class MockSessionManagerListener : public SessionManager::Listener { | 44 class MockSessionManagerListener : public SessionManager::Listener { |
| 45 public: | 45 public: |
| 46 MOCK_METHOD0(OnSessionManagerInitialized, void()); | 46 MOCK_METHOD0(OnSessionManagerReady, void()); |
| 47 MOCK_METHOD2(OnIncomingSession, | 47 MOCK_METHOD2(OnIncomingSession, |
| 48 void(Session*, | 48 void(Session*, |
| 49 SessionManager::IncomingSessionResponse*)); | 49 SessionManager::IncomingSessionResponse*)); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MockSessionCallback { | 52 class MockSessionCallback { |
| 53 public: | 53 public: |
| 54 MOCK_METHOD1(OnStateChange, void(Session::State)); | 54 MOCK_METHOD1(OnStateChange, void(Session::State)); |
| 55 }; | 55 }; |
| 56 | 56 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 87 client_session_.reset(); | 87 client_session_.reset(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void CreateSessionManagers(int auth_round_trips, | 90 void CreateSessionManagers(int auth_round_trips, |
| 91 FakeAuthenticator::Action auth_action) { | 91 FakeAuthenticator::Action auth_action) { |
| 92 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); | 92 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); |
| 93 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); | 93 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); |
| 94 FakeSignalStrategy::Connect(host_signal_strategy_.get(), | 94 FakeSignalStrategy::Connect(host_signal_strategy_.get(), |
| 95 client_signal_strategy_.get()); | 95 client_signal_strategy_.get()); |
| 96 | 96 |
| 97 EXPECT_CALL(host_server_listener_, OnSessionManagerInitialized()) | 97 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) |
| 98 .Times(1); | 98 .Times(1); |
| 99 host_server_.reset(new JingleSessionManager( | 99 host_server_.reset(new JingleSessionManager( |
| 100 base::MessageLoopProxy::current())); | 100 base::MessageLoopProxy::current())); |
| 101 host_server_->Init( | 101 host_server_->Init( |
| 102 kHostJid, host_signal_strategy_.get(), &host_server_listener_, false); | 102 host_signal_strategy_.get(), &host_server_listener_, false); |
| 103 | 103 |
| 104 host_server_->set_authenticator_factory( | 104 host_server_->set_authenticator_factory( |
| 105 new FakeHostAuthenticatorFactory(auth_round_trips, auth_action, true)); | 105 new FakeHostAuthenticatorFactory(auth_round_trips, auth_action, true)); |
| 106 | 106 |
| 107 EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized()) | 107 EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) |
| 108 .Times(1); | 108 .Times(1); |
| 109 client_server_.reset(new PepperSessionManager(NULL)); | 109 client_server_.reset(new PepperSessionManager(NULL)); |
| 110 client_server_->Init( | 110 client_server_->Init( |
| 111 kClientJid, client_signal_strategy_.get(), | 111 client_signal_strategy_.get(), &client_server_listener_, false); |
| 112 &client_server_listener_, false); | |
| 113 } | 112 } |
| 114 | 113 |
| 115 void CloseSessionManager() { | 114 void CloseSessionManager() { |
| 116 if (host_server_.get()) { | 115 if (host_server_.get()) { |
| 117 host_server_->Close(); | 116 host_server_->Close(); |
| 118 host_server_.reset(); | 117 host_server_.reset(); |
| 119 } | 118 } |
| 120 if (client_server_.get()) { | 119 if (client_server_.get()) { |
| 121 client_server_->Close(); | 120 client_server_->Close(); |
| 122 client_server_.reset(); | 121 client_server_.reset(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 262 } |
| 264 | 263 |
| 265 // Verify that connection is terminated when multi-step auth fails. | 264 // Verify that connection is terminated when multi-step auth fails. |
| 266 TEST_F(PepperSessionTest, ConnectWithBadMultistepAuth) { | 265 TEST_F(PepperSessionTest, ConnectWithBadMultistepAuth) { |
| 267 CreateSessionManagers(3, FakeAuthenticator::REJECT); | 266 CreateSessionManagers(3, FakeAuthenticator::REJECT); |
| 268 InitiateConnection(3, FakeAuthenticator::ACCEPT, true); | 267 InitiateConnection(3, FakeAuthenticator::ACCEPT, true); |
| 269 } | 268 } |
| 270 | 269 |
| 271 } // namespace protocol | 270 } // namespace protocol |
| 272 } // namespace remoting | 271 } // namespace remoting |
| OLD | NEW |