OLD | NEW |
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 Loading... |
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_server_url = "turn:99.99.99.3:3478?transport=udp"; |
| 658 EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_server_url); |
| 659 |
| 660 // Connect the server with IPV6 using UDP. |
| 661 turn_ready_ = false; |
| 662 turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, PROTO_UDP); |
| 663 CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, |
| 664 kTurnUdpIPv6ProtoAddr); |
| 665 turn_port_->PrepareAddress(); |
| 666 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_); |
| 667 ASSERT_EQ(1U, turn_port_->Candidates().size()); |
| 668 expected_server_url = |
| 669 "turn:2400:4030:1:2c00:be30:abcd:efab:cdef:3478?transport=udp"; |
| 670 EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_server_url); |
| 671 |
| 672 // Connection the server using TCP. |
| 673 turn_ready_ = false; |
| 674 turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP); |
| 675 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); |
| 676 turn_port_->PrepareAddress(); |
| 677 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 3, fake_clock_); |
| 678 ASSERT_EQ(1U, turn_port_->Candidates().size()); |
| 679 expected_server_url = "turn:99.99.99.4:3478?transport=tcp"; |
| 680 EXPECT_EQ(turn_port_->Candidates()[0].url(), expected_server_url); |
| 681 turn_ready_ = false; |
| 682 } |
| 683 |
650 // Do a normal TURN allocation. | 684 // Do a normal TURN allocation. |
651 TEST_F(TurnPortTest, TestTurnAllocate) { | 685 TEST_F(TurnPortTest, TestTurnAllocate) { |
652 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | 686 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
653 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024)); | 687 EXPECT_EQ(0, turn_port_->SetOption(rtc::Socket::OPT_SNDBUF, 10*1024)); |
654 turn_port_->PrepareAddress(); | 688 turn_port_->PrepareAddress(); |
655 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_); | 689 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kSimulatedRtt * 2, fake_clock_); |
656 ASSERT_EQ(1U, turn_port_->Candidates().size()); | 690 ASSERT_EQ(1U, turn_port_->Candidates().size()); |
657 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), | 691 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), |
658 turn_port_->Candidates()[0].address().ipaddr()); | 692 turn_port_->Candidates()[0].address().ipaddr()); |
659 EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); | 693 EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 EXPECT_TRUE(turn_port_->Candidates().empty()); | 1293 EXPECT_TRUE(turn_port_->Candidates().empty()); |
1260 turn_port_.reset(); | 1294 turn_port_.reset(); |
1261 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); | 1295 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); |
1262 // Waiting for above message to be processed. | 1296 // Waiting for above message to be processed. |
1263 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); | 1297 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); |
1264 EXPECT_EQ(last_fd_count, GetFDCount()); | 1298 EXPECT_EQ(last_fd_count, GetFDCount()); |
1265 } | 1299 } |
1266 #endif | 1300 #endif |
1267 | 1301 |
1268 } // namespace cricket | 1302 } // namespace cricket |
OLD | NEW |