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

Side by Side Diff: remoting/protocol/jingle_session_unittest.cc

Issue 1530523002: More cleanups in JingleSessionManager interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@transport_context
Patch Set: Created 5 years 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/protocol/jingle_session_manager.cc ('k') | remoting/protocol/protocol_mock_objects.h » ('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 "remoting/protocol/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 30 matching lines...) Expand all
41 using testing::WithArg; 41 using testing::WithArg;
42 42
43 namespace remoting { 43 namespace remoting {
44 namespace protocol { 44 namespace protocol {
45 45
46 namespace { 46 namespace {
47 47
48 const char kHostJid[] = "host1@gmail.com/123"; 48 const char kHostJid[] = "host1@gmail.com/123";
49 const char kClientJid[] = "host2@gmail.com/321"; 49 const char kClientJid[] = "host2@gmail.com/321";
50 50
51 class MockSessionManagerListener : public SessionManager::Listener { 51 class MockSessionManagerListener {
52 public: 52 public:
53 MOCK_METHOD2(OnIncomingSession, 53 MOCK_METHOD2(OnIncomingSession,
54 void(Session*, 54 void(Session*,
55 SessionManager::IncomingSessionResponse*)); 55 SessionManager::IncomingSessionResponse*));
56 }; 56 };
57 57
58 class MockSessionEventHandler : public Session::EventHandler { 58 class MockSessionEventHandler : public Session::EventHandler {
59 public: 59 public:
60 MOCK_METHOD1(OnSessionStateChange, void(Session::State)); 60 MOCK_METHOD1(OnSessionStateChange, void(Session::State));
61 MOCK_METHOD2(OnSessionRouteChange, void(const std::string& channel_name, 61 MOCK_METHOD2(OnSessionRouteChange, void(const std::string& channel_name,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void CreateSessionManagers(int auth_round_trips, int messages_till_start, 99 void CreateSessionManagers(int auth_round_trips, int messages_till_start,
100 FakeAuthenticator::Action auth_action) { 100 FakeAuthenticator::Action auth_action) {
101 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); 101 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid));
102 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); 102 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid));
103 FakeSignalStrategy::Connect(host_signal_strategy_.get(), 103 FakeSignalStrategy::Connect(host_signal_strategy_.get(),
104 client_signal_strategy_.get()); 104 client_signal_strategy_.get());
105 105
106 host_server_.reset(new JingleSessionManager( 106 host_server_.reset(new JingleSessionManager(
107 make_scoped_ptr(new IceTransportFactory(new TransportContext( 107 make_scoped_ptr(new IceTransportFactory(new TransportContext(
108 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)), 108 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)),
109 network_settings_, TransportRole::SERVER))))); 109 network_settings_, TransportRole::SERVER))),
110 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); 110 host_signal_strategy_.get()));
111 host_server_->AcceptIncoming(
112 base::Bind(&MockSessionManagerListener::OnIncomingSession,
113 base::Unretained(&host_server_listener_)));
111 114
112 scoped_ptr<AuthenticatorFactory> factory( 115 scoped_ptr<AuthenticatorFactory> factory(
113 new FakeHostAuthenticatorFactory(auth_round_trips, 116 new FakeHostAuthenticatorFactory(auth_round_trips,
114 messages_till_start, auth_action, true)); 117 messages_till_start, auth_action, true));
115 host_server_->set_authenticator_factory(factory.Pass()); 118 host_server_->set_authenticator_factory(factory.Pass());
116 119
117 client_server_.reset(new JingleSessionManager( 120 client_server_.reset(new JingleSessionManager(
118 make_scoped_ptr(new IceTransportFactory(new TransportContext( 121 make_scoped_ptr(new IceTransportFactory(new TransportContext(
119 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)), 122 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)),
120 network_settings_, TransportRole::CLIENT))))); 123 network_settings_, TransportRole::CLIENT))),
121 client_server_->Init(client_signal_strategy_.get(), 124 client_signal_strategy_.get()));
122 &client_server_listener_);
123 } 125 }
124 126
125 void CreateSessionManagers(int auth_round_trips, 127 void CreateSessionManagers(int auth_round_trips,
126 FakeAuthenticator::Action auth_action) { 128 FakeAuthenticator::Action auth_action) {
127 CreateSessionManagers(auth_round_trips, 0, auth_action); 129 CreateSessionManagers(auth_round_trips, 0, auth_action);
128 } 130 }
129 131
130 void CloseSessionManager() { 132 void CloseSessionManager() {
131 if (host_server_.get()) { 133 host_server_.reset();
132 host_server_->Close(); 134 client_server_.reset();
133 host_server_.reset();
134 }
135 if (client_server_.get()) {
136 client_server_->Close();
137 client_server_.reset();
138 }
139 host_signal_strategy_.reset(); 135 host_signal_strategy_.reset();
140 client_signal_strategy_.reset(); 136 client_signal_strategy_.reset();
141 } 137 }
142 138
143 void InitiateConnection(int auth_round_trips, 139 void InitiateConnection(int auth_round_trips,
144 FakeAuthenticator::Action auth_action, 140 FakeAuthenticator::Action auth_action,
145 bool expect_fail) { 141 bool expect_fail) {
146 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 142 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
147 .WillOnce(DoAll( 143 .WillOnce(DoAll(
148 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)), 144 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 scoped_ptr<base::MessageLoopForIO> message_loop_; 213 scoped_ptr<base::MessageLoopForIO> message_loop_;
218 214
219 NetworkSettings network_settings_; 215 NetworkSettings network_settings_;
220 216
221 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 217 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
222 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 218 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
223 219
224 scoped_ptr<JingleSessionManager> host_server_; 220 scoped_ptr<JingleSessionManager> host_server_;
225 MockSessionManagerListener host_server_listener_; 221 MockSessionManagerListener host_server_listener_;
226 scoped_ptr<JingleSessionManager> client_server_; 222 scoped_ptr<JingleSessionManager> client_server_;
227 MockSessionManagerListener client_server_listener_;
228 223
229 scoped_ptr<Session> host_session_; 224 scoped_ptr<Session> host_session_;
230 MockSessionEventHandler host_session_event_handler_; 225 MockSessionEventHandler host_session_event_handler_;
231 scoped_ptr<Session> client_session_; 226 scoped_ptr<Session> client_session_;
232 MockSessionEventHandler client_session_event_handler_; 227 MockSessionEventHandler client_session_event_handler_;
233 }; 228 };
234 229
235 230
236 // Verify that we can create and destroy session managers without a 231 // Verify that we can create and destroy session managers without a
237 // connection. 232 // connection.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 397
403 // Verify that we can connect with multistep authentication. 398 // Verify that we can connect with multistep authentication.
404 TEST_F(JingleSessionTest, TestMultistepAuth) { 399 TEST_F(JingleSessionTest, TestMultistepAuth) {
405 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); 400 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
406 ASSERT_NO_FATAL_FAILURE( 401 ASSERT_NO_FATAL_FAILURE(
407 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); 402 InitiateConnection(3, FakeAuthenticator::ACCEPT, false));
408 } 403 }
409 404
410 } // namespace protocol 405 } // namespace protocol
411 } // namespace remoting 406 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session_manager.cc ('k') | remoting/protocol/protocol_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698