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

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

Issue 1687543002: Fix IceTransportTest.TestBrokenTransport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/ice_transport_channel.cc ('k') | remoting/protocol/network_settings.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ice_transport.h" 5 #include "remoting/protocol/ice_transport.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 void DeliverTransportInfo(scoped_ptr<IceTransport>* target_transport, 108 void DeliverTransportInfo(scoped_ptr<IceTransport>* target_transport,
109 scoped_ptr<buzz::XmlElement> transport_info) { 109 scoped_ptr<buzz::XmlElement> transport_info) {
110 ASSERT_TRUE(target_transport); 110 ASSERT_TRUE(target_transport);
111 EXPECT_TRUE( 111 EXPECT_TRUE(
112 (*target_transport)->ProcessTransportInfo(transport_info.get())); 112 (*target_transport)->ProcessTransportInfo(transport_info.get()));
113 } 113 }
114 114
115 void InitializeConnection() { 115 void InitializeConnection() {
116 host_transport_.reset( 116 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
117 new IceTransport(TransportContext::ForTests(TransportRole::SERVER), 117
118 &host_event_handler_)); 118 host_transport_.reset(new IceTransport(
119 new TransportContext(
120 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)),
121 network_settings_, TransportRole::SERVER),
122 &host_event_handler_));
119 if (!host_authenticator_) { 123 if (!host_authenticator_) {
120 host_authenticator_.reset(new FakeAuthenticator( 124 host_authenticator_.reset(new FakeAuthenticator(
121 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, true)); 125 FakeAuthenticator::HOST, 0, FakeAuthenticator::ACCEPT, true));
122 } 126 }
123 127
124 client_transport_.reset( 128 client_transport_.reset(new IceTransport(
125 new IceTransport(TransportContext::ForTests(TransportRole::CLIENT), 129 new TransportContext(
126 &client_event_handler_)); 130 nullptr, make_scoped_ptr(new ChromiumPortAllocatorFactory(nullptr)),
131 network_settings_, TransportRole::CLIENT),
132 &client_event_handler_));
127 if (!client_authenticator_) { 133 if (!client_authenticator_) {
128 client_authenticator_.reset(new FakeAuthenticator( 134 client_authenticator_.reset(new FakeAuthenticator(
129 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, true)); 135 FakeAuthenticator::CLIENT, 0, FakeAuthenticator::ACCEPT, true));
130 } 136 }
131 137
132 host_event_handler_.set_error_callback(base::Bind( 138 host_event_handler_.set_error_callback(base::Bind(
133 &IceTransportTest::OnTransportError, base::Unretained(this))); 139 &IceTransportTest::OnTransportError, base::Unretained(this)));
134 client_event_handler_.set_error_callback(base::Bind( 140 client_event_handler_.set_error_callback(base::Bind(
135 &IceTransportTest::OnTransportError, base::Unretained(this))); 141 &IceTransportTest::OnTransportError, base::Unretained(this)));
136 142
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 EXPECT_EQ(CHANNEL_CONNECTION_ERROR, error_); 268 EXPECT_EQ(CHANNEL_CONNECTION_ERROR, error_);
263 269
264 client_transport_->GetChannelFactory()->CancelChannelCreation( 270 client_transport_->GetChannelFactory()->CancelChannelCreation(
265 kChannelName); 271 kChannelName);
266 } 272 }
267 273
268 // Verify that channels are never marked connected if connection cannot be 274 // Verify that channels are never marked connected if connection cannot be
269 // established. 275 // established.
270 TEST_F(IceTransportTest, TestBrokenTransport) { 276 TEST_F(IceTransportTest, TestBrokenTransport) {
271 // Allow only incoming connections on both ends, which effectively renders 277 // Allow only incoming connections on both ends, which effectively renders
272 // transport unusable. 278 // transport unusable. Also reduce connection timeout so the test finishes
279 // quickly.
273 network_settings_ = NetworkSettings(NetworkSettings::NAT_TRAVERSAL_DISABLED); 280 network_settings_ = NetworkSettings(NetworkSettings::NAT_TRAVERSAL_DISABLED);
281 network_settings_.ice_timeout = base::TimeDelta::FromSeconds(1);
282 network_settings_.ice_reconnect_attempts = 1;
274 283
275 InitializeConnection(); 284 InitializeConnection();
276 285
277 client_transport_->GetChannelFactory()->CreateChannel( 286 client_transport_->GetChannelFactory()->CreateChannel(
278 kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated, 287 kChannelName, base::Bind(&IceTransportTest::OnClientChannelCreated,
279 base::Unretained(this))); 288 base::Unretained(this)));
280 host_transport_->GetChannelFactory()->CreateChannel( 289 host_transport_->GetChannelFactory()->CreateChannel(
281 kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated, 290 kChannelName, base::Bind(&IceTransportTest::OnHostChannelCreated,
282 base::Unretained(this))); 291 base::Unretained(this)));
283 292
284 message_loop_.RunUntilIdle(); 293 // The RunLoop should quit in OnTransportError().
294 run_loop_.reset(new base::RunLoop());
295 run_loop_->Run();
285 296
286 // Verify that neither of the two ends of the channel is connected. 297 // Verify that neither of the two ends of the channel is connected.
287 EXPECT_FALSE(client_message_pipe_); 298 EXPECT_FALSE(client_message_pipe_);
288 EXPECT_FALSE(host_message_pipe_); 299 EXPECT_FALSE(host_message_pipe_);
300 EXPECT_EQ(CHANNEL_CONNECTION_ERROR, error_);
289 301
290 client_transport_->GetChannelFactory()->CancelChannelCreation( 302 client_transport_->GetChannelFactory()->CancelChannelCreation(
291 kChannelName); 303 kChannelName);
292 host_transport_->GetChannelFactory()->CancelChannelCreation( 304 host_transport_->GetChannelFactory()->CancelChannelCreation(
293 kChannelName); 305 kChannelName);
294 } 306 }
295 307
296 TEST_F(IceTransportTest, TestCancelChannelCreation) { 308 TEST_F(IceTransportTest, TestCancelChannelCreation) {
297 InitializeConnection(); 309 InitializeConnection();
298 310
(...skipping 24 matching lines...) Expand all
323 335
324 MessagePipeConnectionTester tester(host_message_pipe_.get(), 336 MessagePipeConnectionTester tester(host_message_pipe_.get(),
325 client_message_pipe_.get(), kMessageSize, 337 client_message_pipe_.get(), kMessageSize,
326 kMessages); 338 kMessages);
327 tester.RunAndCheckResults(); 339 tester.RunAndCheckResults();
328 } 340 }
329 341
330 342
331 } // namespace protocol 343 } // namespace protocol
332 } // namespace remoting 344 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_transport_channel.cc ('k') | remoting/protocol/network_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698