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

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

Issue 2685053004: Add the URL attribute to cricket::Candiate. (Closed)
Patch Set: Add the Server URL to the Candiate. Created 3 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
« 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 std::vector<rtc::Buffer> turn_packets_; 640 std::vector<rtc::Buffer> turn_packets_;
641 std::vector<rtc::Buffer> udp_packets_; 641 std::vector<rtc::Buffer> udp_packets_;
642 rtc::PacketOptions options; 642 rtc::PacketOptions options;
643 }; 643 };
644 644
645 TEST_F(TurnPortTest, TestTurnPortType) { 645 TEST_F(TurnPortTest, TestTurnPortType) {
646 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 646 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
647 EXPECT_EQ(cricket::RELAY_PORT_TYPE, turn_port_->Type()); 647 EXPECT_EQ(cricket::RELAY_PORT_TYPE, turn_port_->Type());
648 } 648 }
649 649
650 // Tests that the URL of the servers can be correctly reconstructed when
651 // gathering the candidates.
652 TEST_F(TurnPortTest, TestReconstructedServerUrl) {
653 // Connect the TURN server using UDP.
654 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
655 turn_port_->PrepareAddress();
656 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_);
657 std::string expected_url =
658 "turn:" + kTurnUdpProtoAddr.address.ToString() + "?transport=udp";
Taylor Brandstetter 2017/02/10 01:58:46 See my comment on stunport_unittest.cc
Zhi Huang 2017/02/10 06:45:50 Done.
659 EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_url);
660
661 // Connect the server with IPV6 using UDP.
662 turn_ready_ = false;
663 turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP);
664 CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword,
665 kTurnUdpIPv6ProtoAddr);
666 turn_port_->PrepareAddress();
667 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_);
668 ASSERT_EQ(1U, turn_port_->Candidates().size());
669 expected_url =
670 "turn:" + kTurnUdpIPv6ProtoAddr.address.ToString() + "?transport=udp";
671 EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_url);
672
673 // Connection the server using TCP.
674 turn_ready_ = false;
675 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
676 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
677 turn_port_->PrepareAddress();
678 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 3, fake_clock_);
679 ASSERT_EQ(1U, turn_port_->Candidates().size());
680 expected_url =
681 "turn:" + kTurnTcpProtoAddr.address.ToString() + "?transport=tcp";
682 EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_url);
683 }
684
650 // Do a normal TURN allocation. 685 // Do a normal TURN allocation.
651 TEST_F(TurnPortTest, TestTurnAllocate) { 686 TEST_F(TurnPortTest, TestTurnAllocate) {
652 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 687 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
653 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024)); 688 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024));
654 turn_port_->PrepareAddress(); 689 turn_port_->PrepareAddress();
655 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_); 690 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_);
656 ASSERT_EQ(1U, turn_port_->Candidates().size()); 691 ASSERT_EQ(1U, turn_port_->Candidates().size());
657 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), 692 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(),
658 turn_port_->Candidates()[0].address().ipaddr()); 693 turn_port_->Candidates()[0].address().ipaddr());
659 EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); 694 EXPECT_NE(0, turn_port_->Candidates()[0].address().port());
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 EXPECT_TRUE(turn_port_->Candidates().empty()); 1294 EXPECT_TRUE(turn_port_->Candidates().empty());
1260 turn_port_.reset(); 1295 turn_port_.reset();
1261 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); 1296 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH);
1262 // Waiting for above message to be processed. 1297 // Waiting for above message to be processed.
1263 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); 1298 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_);
1264 EXPECT_EQ(last_fd_count, GetFDCount()); 1299 EXPECT_EQ(last_fd_count, GetFDCount());
1265 } 1300 }
1266 #endif 1301 #endif
1267 1302
1268 } // namespace cricket 1303 } // namespace cricket
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