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

Side by Side Diff: remoting/protocol/jingle_session_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/protocol/jingle_session.cc ('k') | remoting/protocol/libjingle_transport_factory.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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 message_loop_.reset(new base::MessageLoopForIO()); 98 message_loop_.reset(new base::MessageLoopForIO());
99 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 99 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
100 } 100 }
101 101
102 // Helper method that handles OnIncomingSession(). 102 // Helper method that handles OnIncomingSession().
103 void SetHostSession(Session* session) { 103 void SetHostSession(Session* session) {
104 DCHECK(session); 104 DCHECK(session);
105 host_session_.reset(session); 105 host_session_.reset(session);
106 host_session_->SetEventHandler(&host_session_event_handler_); 106 host_session_->SetEventHandler(&host_session_event_handler_);
107 107
108 session->set_config(SessionConfig::ForTest()); 108 session->set_config(standard_ice_ ? SessionConfig::ForTest()
109 : SessionConfig::WithLegacyIceForTest());
109 } 110 }
110 111
111 void DeleteSession() { 112 void DeleteSession() {
112 host_session_.reset(); 113 host_session_.reset();
113 } 114 }
114 115
115 void OnClientChannelCreated(scoped_ptr<net::StreamSocket> socket) { 116 void OnClientChannelCreated(scoped_ptr<net::StreamSocket> socket) {
116 client_channel_callback_.OnDone(socket.get()); 117 client_channel_callback_.OnDone(socket.get());
117 client_socket_ = socket.Pass(); 118 client_socket_ = socket.Pass();
118 } 119 }
(...skipping 27 matching lines...) Expand all
146 client_signal_strategy_.get()); 147 client_signal_strategy_.get());
147 148
148 EXPECT_CALL(host_server_listener_, OnSessionManagerReady()) 149 EXPECT_CALL(host_server_listener_, OnSessionManagerReady())
149 .Times(1); 150 .Times(1);
150 151
151 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING); 152 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING);
152 153
153 scoped_ptr<TransportFactory> host_transport(new LibjingleTransportFactory( 154 scoped_ptr<TransportFactory> host_transport(new LibjingleTransportFactory(
154 nullptr, 155 nullptr,
155 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(), 156 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(),
156 network_settings)); 157 network_settings, TransportRole::SERVER));
157 host_server_.reset(new JingleSessionManager(host_transport.Pass())); 158 host_server_.reset(new JingleSessionManager(host_transport.Pass()));
158 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_); 159 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_);
159 160
160 scoped_ptr<AuthenticatorFactory> factory( 161 scoped_ptr<AuthenticatorFactory> factory(
161 new FakeHostAuthenticatorFactory(auth_round_trips, 162 new FakeHostAuthenticatorFactory(auth_round_trips,
162 messages_till_start, auth_action, true)); 163 messages_till_start, auth_action, true));
163 host_server_->set_authenticator_factory(factory.Pass()); 164 host_server_->set_authenticator_factory(factory.Pass());
164 165
165 EXPECT_CALL(client_server_listener_, OnSessionManagerReady()) 166 EXPECT_CALL(client_server_listener_, OnSessionManagerReady())
166 .Times(1); 167 .Times(1);
167 scoped_ptr<TransportFactory> client_transport(new LibjingleTransportFactory( 168 scoped_ptr<TransportFactory> client_transport(new LibjingleTransportFactory(
168 nullptr, 169 nullptr,
169 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(), 170 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(),
170 network_settings)); 171 network_settings, TransportRole::CLIENT));
171 client_server_.reset( 172 client_server_.reset(
172 new JingleSessionManager(client_transport.Pass())); 173 new JingleSessionManager(client_transport.Pass()));
173 client_server_->Init(client_signal_strategy_.get(), 174 client_server_->Init(client_signal_strategy_.get(),
174 &client_server_listener_); 175 &client_server_listener_);
175 } 176 }
176 177
177 void CreateSessionManagers(int auth_round_trips, 178 void CreateSessionManagers(int auth_round_trips,
178 FakeAuthenticator::Action auth_action) { 179 FakeAuthenticator::Action auth_action) {
179 CreateSessionManagers(auth_round_trips, 0, auth_action); 180 CreateSessionManagers(auth_round_trips, 0, auth_action);
180 } 181 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 EXPECT_CALL(host_session_event_handler_, 284 EXPECT_CALL(host_session_event_handler_,
284 OnSessionRouteChange(channel_name, _)) 285 OnSessionRouteChange(channel_name, _))
285 .Times(AtLeast(1)); 286 .Times(AtLeast(1));
286 EXPECT_CALL(client_session_event_handler_, 287 EXPECT_CALL(client_session_event_handler_,
287 OnSessionRouteChange(channel_name, _)) 288 OnSessionRouteChange(channel_name, _))
288 .Times(AtLeast(1)); 289 .Times(AtLeast(1));
289 } 290 }
290 291
291 scoped_ptr<base::MessageLoopForIO> message_loop_; 292 scoped_ptr<base::MessageLoopForIO> message_loop_;
292 293
294 bool standard_ice_ = true;
295
293 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 296 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
294 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 297 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
295 298
296 scoped_ptr<JingleSessionManager> host_server_; 299 scoped_ptr<JingleSessionManager> host_server_;
297 MockSessionManagerListener host_server_listener_; 300 MockSessionManagerListener host_server_listener_;
298 scoped_ptr<JingleSessionManager> client_server_; 301 scoped_ptr<JingleSessionManager> client_server_;
299 MockSessionManagerListener client_server_listener_; 302 MockSessionManagerListener client_server_listener_;
300 303
301 scoped_ptr<Session> host_session_; 304 scoped_ptr<Session> host_session_;
302 MockSessionEventHandler host_session_event_handler_; 305 MockSessionEventHandler host_session_event_handler_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // Verify that we can connect two endpoints with single-step authentication. 348 // Verify that we can connect two endpoints with single-step authentication.
346 TEST_F(JingleSessionTest, Connect) { 349 TEST_F(JingleSessionTest, Connect) {
347 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); 350 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
348 InitiateConnection(1, FakeAuthenticator::ACCEPT, false); 351 InitiateConnection(1, FakeAuthenticator::ACCEPT, false);
349 352
350 // Verify that the client specified correct initiator value. 353 // Verify that the client specified correct initiator value.
351 ASSERT_GT(host_signal_strategy_->received_messages().size(), 0U); 354 ASSERT_GT(host_signal_strategy_->received_messages().size(), 0U);
352 const buzz::XmlElement* initiate_xml = 355 const buzz::XmlElement* initiate_xml =
353 host_signal_strategy_->received_messages().front(); 356 host_signal_strategy_->received_messages().front();
354 const buzz::XmlElement* jingle_element = 357 const buzz::XmlElement* jingle_element =
355 initiate_xml->FirstNamed(buzz::QName(kJingleNamespace, "jingle")); 358 initiate_xml->FirstNamed(buzz::QName("urn:xmpp:jingle:1", "jingle"));
356 ASSERT_TRUE(jingle_element); 359 ASSERT_TRUE(jingle_element);
357 ASSERT_EQ(kClientJid, 360 ASSERT_EQ(kClientJid,
358 jingle_element->Attr(buzz::QName(std::string(), "initiator"))); 361 jingle_element->Attr(buzz::QName(std::string(), "initiator")));
359 } 362 }
360 363
361 // Verify that we can connect two endpoints with multi-step authentication. 364 // Verify that we can connect two endpoints with multi-step authentication.
362 TEST_F(JingleSessionTest, ConnectWithMultistep) { 365 TEST_F(JingleSessionTest, ConnectWithMultistep) {
363 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); 366 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
364 InitiateConnection(3, FakeAuthenticator::ACCEPT, false); 367 InitiateConnection(3, FakeAuthenticator::ACCEPT, false);
365 } 368 }
(...skipping 18 matching lines...) Expand all
384 387
385 ASSERT_NO_FATAL_FAILURE(CreateChannel()); 388 ASSERT_NO_FATAL_FAILURE(CreateChannel());
386 389
387 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 390 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
388 kMessageSize, kMessages); 391 kMessageSize, kMessages);
389 tester.Start(); 392 tester.Start();
390 message_loop_->Run(); 393 message_loop_->Run();
391 tester.CheckResults(); 394 tester.CheckResults();
392 } 395 }
393 396
397 // Verify that we can still connect using legacy GICE transport.
398 TEST_F(JingleSessionTest, TestLegacyIceConnection) {
399 standard_ice_ = false;
400
401 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
402 ASSERT_NO_FATAL_FAILURE(
403 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
404
405 ASSERT_NO_FATAL_FAILURE(CreateChannel());
406
407 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
408 kMessageSize, kMessages);
409 tester.Start();
410 message_loop_->Run();
411 tester.CheckResults();
412 }
413
394 TEST_F(JingleSessionTest, DeleteSessionOnIncomingConnection) { 414 TEST_F(JingleSessionTest, DeleteSessionOnIncomingConnection) {
395 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); 415 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
396 416
397 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 417 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
398 .WillOnce(DoAll( 418 .WillOnce(DoAll(
399 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)), 419 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
400 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); 420 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT)));
401 421
402 EXPECT_CALL(host_session_event_handler_, 422 EXPECT_CALL(host_session_event_handler_,
403 OnSessionStateChange(Session::CONNECTED)) 423 OnSessionStateChange(Session::CONNECTED))
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 566
547 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 567 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
548 kMessageSize, 1); 568 kMessageSize, 1);
549 tester.Start(); 569 tester.Start();
550 message_loop_->Run(); 570 message_loop_->Run();
551 tester.CheckResults(); 571 tester.CheckResults();
552 } 572 }
553 573
554 } // namespace protocol 574 } // namespace protocol
555 } // namespace remoting 575 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | remoting/protocol/libjingle_transport_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698