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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST); | 706 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST); |
707 EXPECT_TRUE_WAIT(turn_refresh_success_, kTimeout); | 707 EXPECT_TRUE_WAIT(turn_refresh_success_, kTimeout); |
708 // Flush it again, it will receive a bad response. | 708 // Flush it again, it will receive a bad response. |
709 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST); | 709 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST); |
710 EXPECT_TRUE_WAIT(!turn_refresh_success_, kTimeout); | 710 EXPECT_TRUE_WAIT(!turn_refresh_success_, kTimeout); |
711 EXPECT_TRUE_WAIT(!turn_port_->connected(), kTimeout); | 711 EXPECT_TRUE_WAIT(!turn_port_->connected(), kTimeout); |
712 EXPECT_TRUE_WAIT(turn_port_->connections().empty(), kTimeout); | 712 EXPECT_TRUE_WAIT(turn_port_->connections().empty(), kTimeout); |
713 EXPECT_FALSE(turn_port_->HasRequests()); | 713 EXPECT_FALSE(turn_port_->HasRequests()); |
714 } | 714 } |
715 | 715 |
| 716 // Test that TurnPort will not handle any incoming packets once it has been |
| 717 // closed. |
| 718 TEST_F(TurnPortTest, TestStopProcessingPacketsAfterClosed) { |
| 719 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
| 720 PrepareTurnAndUdpPorts(); |
| 721 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], |
| 722 Port::ORIGIN_MESSAGE); |
| 723 Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], |
| 724 Port::ORIGIN_MESSAGE); |
| 725 ASSERT_TRUE(conn1 != NULL); |
| 726 ASSERT_TRUE(conn2 != NULL); |
| 727 // Make sure conn2 is writable. |
| 728 conn2->Ping(0); |
| 729 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout); |
| 730 |
| 731 turn_port_->Close(); |
| 732 rtc::Thread::Current()->ProcessMessages(0); |
| 733 turn_unknown_address_ = false; |
| 734 conn2->Ping(0); |
| 735 rtc::Thread::Current()->ProcessMessages(500); |
| 736 // Since the turn port does not handle packets any more, it should not |
| 737 // SignalUnknownAddress. |
| 738 EXPECT_FALSE(turn_unknown_address_); |
| 739 } |
| 740 |
716 // Test that CreateConnection will return null if port becomes disconnected. | 741 // Test that CreateConnection will return null if port becomes disconnected. |
717 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) { | 742 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) { |
718 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); | 743 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |
719 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); | 744 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); |
720 PrepareTurnAndUdpPorts(); | 745 PrepareTurnAndUdpPorts(); |
721 // Create a connection. | 746 // Create a connection. |
722 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], | 747 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], |
723 Port::ORIGIN_MESSAGE); | 748 Port::ORIGIN_MESSAGE); |
724 ASSERT_TRUE(conn1 != NULL); | 749 ASSERT_TRUE(conn1 != NULL); |
725 | 750 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 turn_port_->PrepareAddress(); | 1016 turn_port_->PrepareAddress(); |
992 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); | 1017 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); |
993 EXPECT_TRUE(turn_port_->Candidates().empty()); | 1018 EXPECT_TRUE(turn_port_->Candidates().empty()); |
994 turn_port_.reset(); | 1019 turn_port_.reset(); |
995 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); | 1020 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); |
996 // Waiting for above message to be processed. | 1021 // Waiting for above message to be processed. |
997 ASSERT_TRUE_WAIT(test_finish_, kTimeout); | 1022 ASSERT_TRUE_WAIT(test_finish_, kTimeout); |
998 EXPECT_EQ(last_fd_count, GetFDCount()); | 1023 EXPECT_EQ(last_fd_count, GetFDCount()); |
999 } | 1024 } |
1000 #endif | 1025 #endif |
OLD | NEW |