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

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: 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
« no previous file with comments | « 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 620
621 // Verifies that the new port has the same address. 621 // Verifies that the new port has the same address.
622 EXPECT_EQ(first_addr, turn_port_->socket()->GetLocalAddress()); 622 EXPECT_EQ(first_addr, turn_port_->socket()->GetLocalAddress());
623 623
624 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); 624 EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
625 625
626 // Verifies that the new port has a different address now. 626 // Verifies that the new port has a different address now.
627 EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress()); 627 EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress());
628 } 628 }
629 629
630 // Test that CreateConnection will return null if port becomes disconnected.
631 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) {
632 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
633 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
634 turn_port_->PrepareAddress();
635 ASSERT_TRUE_WAIT(turn_ready_, kTimeout);
636
637 CreateUdpPort();
638 udp_port_->PrepareAddress();
639 ASSERT_TRUE_WAIT(udp_ready_, kTimeout);
640 // Create a connection.
641 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
642 Port::ORIGIN_MESSAGE);
643 ASSERT_TRUE(conn1 != NULL);
644
645 // Close the socket and create a connection again.
646 turn_port_->OnSocketClose(turn_port_->socket(), 1);
647 conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
648 Port::ORIGIN_MESSAGE);
649 ASSERT_TRUE(conn1 == NULL);
650 }
651
630 // Test try-alternate-server feature. 652 // Test try-alternate-server feature.
631 TEST_F(TurnPortTest, TestTurnAlternateServerUDP) { 653 TEST_F(TurnPortTest, TestTurnAlternateServerUDP) {
632 TestTurnAlternateServer(cricket::PROTO_UDP); 654 TestTurnAlternateServer(cricket::PROTO_UDP);
633 } 655 }
634 656
635 TEST_F(TurnPortTest, TestTurnAlternateServerTCP) { 657 TEST_F(TurnPortTest, TestTurnAlternateServerTCP) {
636 TestTurnAlternateServer(cricket::PROTO_TCP); 658 TestTurnAlternateServer(cricket::PROTO_TCP);
637 } 659 }
638 660
639 // Test that we fail when we redirect to an address different from 661 // Test that we fail when we redirect to an address different from
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 turn_port_->PrepareAddress(); 817 turn_port_->PrepareAddress();
796 ASSERT_TRUE_WAIT(turn_error_, kTimeout); 818 ASSERT_TRUE_WAIT(turn_error_, kTimeout);
797 EXPECT_TRUE(turn_port_->Candidates().empty()); 819 EXPECT_TRUE(turn_port_->Candidates().empty());
798 turn_port_.reset(); 820 turn_port_.reset();
799 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); 821 rtc::Thread::Current()->Post(this, MSG_TESTFINISH);
800 // Waiting for above message to be processed. 822 // Waiting for above message to be processed.
801 ASSERT_TRUE_WAIT(test_finish_, kTimeout); 823 ASSERT_TRUE_WAIT(test_finish_, kTimeout);
802 EXPECT_EQ(last_fd_count, GetFDCount()); 824 EXPECT_EQ(last_fd_count, GetFDCount());
803 } 825 }
804 #endif 826 #endif
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698