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

Side by Side Diff: webrtc/p2p/base/turnport_unittest.cc

Issue 1247573002: Fix a Turn TCP port issue. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Slight change in asynctcpsocket.cc Created 5 years, 4 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
« webrtc/p2p/base/turnport.cc ('K') | « webrtc/p2p/base/turnport.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #if defined(WEBRTC_POSIX) 10 #if defined(WEBRTC_POSIX)
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); 483 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
484 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024)); 484 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024));
485 turn_port_->PrepareAddress(); 485 turn_port_->PrepareAddress();
486 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); 486 EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
487 ASSERT_EQ(1U, turn_port_->Candidates().size()); 487 ASSERT_EQ(1U, turn_port_->Candidates().size());
488 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), 488 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(),
489 turn_port_->Candidates()[0].address().ipaddr()); 489 turn_port_->Candidates()[0].address().ipaddr());
490 EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); 490 EXPECT_NE(0, turn_port_->Candidates()[0].address().port());
491 } 491 }
492 492
493 // Test that sending a TurnAllocate will fail if the TCP connection is closed.
494 TEST_F(TurnPortTest, TestSendingAllocateWhenSocketClosed) {
495 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
496 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
497 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10 * 1024));
498 turn_port_->PrepareAddress();
499 turn_ready_ = false;
500 turn_port_->SendAllocateRequest(0);
501 EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
502
503 // Close the socket and send the request again.
504 turn_ready_ = false;
505 turn_port_->OnSocketClose(turn_port_->socket(), 1);
506 turn_port_->SendAllocateRequest(0);
507 // Wait for half a second and check.
508 WAIT(false, kTimeout / 2);
509 EXPECT_FALSE(turn_ready_);
510 }
511
493 // Test case for WebRTC issue 3927 where a proxy binds to the local host address 512 // Test case for WebRTC issue 3927 where a proxy binds to the local host address
494 // instead the address that TurnPort originally bound to. The candidate pair 513 // instead the address that TurnPort originally bound to. The candidate pair
495 // impacted by this behavior should still be used. 514 // impacted by this behavior should still be used.
496 TEST_F(TurnPortTest, TestTurnTcpAllocationWhenProxyChangesAddressToLocalHost) { 515 TEST_F(TurnPortTest, TestTurnTcpAllocationWhenProxyChangesAddressToLocalHost) {
497 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 516 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
498 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); 517 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
499 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10 * 1024)); 518 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10 * 1024));
500 turn_port_->PrepareAddress(); 519 turn_port_->PrepareAddress();
501 ConnectSignalAddressReadyToSetLocalhostAsAltenertativeLocalAddress(); 520 ConnectSignalAddressReadyToSetLocalhostAsAltenertativeLocalAddress();
502 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); 521 EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 turn_port_->PrepareAddress(); 814 turn_port_->PrepareAddress();
796 ASSERT_TRUE_WAIT(turn_error_, kTimeout); 815 ASSERT_TRUE_WAIT(turn_error_, kTimeout);
797 EXPECT_TRUE(turn_port_->Candidates().empty()); 816 EXPECT_TRUE(turn_port_->Candidates().empty());
798 turn_port_.reset(); 817 turn_port_.reset();
799 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); 818 rtc::Thread::Current()->Post(this, MSG_TESTFINISH);
800 // Waiting for above message to be processed. 819 // Waiting for above message to be processed.
801 ASSERT_TRUE_WAIT(test_finish_, kTimeout); 820 ASSERT_TRUE_WAIT(test_finish_, kTimeout);
802 EXPECT_EQ(last_fd_count, GetFDCount()); 821 EXPECT_EQ(last_fd_count, GetFDCount());
803 } 822 }
804 #endif 823 #endif
OLDNEW
« webrtc/p2p/base/turnport.cc ('K') | « webrtc/p2p/base/turnport.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698