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

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

Issue 2063823008: Adding IceConfig option to assume TURN/TURN candidate pairs will work. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename IceConfig option and fix transition to STATE_WRITE_UNRELIABLE. Created 4 years, 6 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
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 17 matching lines...) Expand all
28 #include "webrtc/base/helpers.h" 28 #include "webrtc/base/helpers.h"
29 #include "webrtc/base/logging.h" 29 #include "webrtc/base/logging.h"
30 #include "webrtc/base/physicalsocketserver.h" 30 #include "webrtc/base/physicalsocketserver.h"
31 #include "webrtc/base/socketaddress.h" 31 #include "webrtc/base/socketaddress.h"
32 #include "webrtc/base/ssladapter.h" 32 #include "webrtc/base/ssladapter.h"
33 #include "webrtc/base/thread.h" 33 #include "webrtc/base/thread.h"
34 #include "webrtc/base/virtualsocketserver.h" 34 #include "webrtc/base/virtualsocketserver.h"
35 35
36 using rtc::SocketAddress; 36 using rtc::SocketAddress;
37 using cricket::Connection; 37 using cricket::Connection;
38 using cricket::IceConfig;
38 using cricket::Port; 39 using cricket::Port;
39 using cricket::PortInterface; 40 using cricket::PortInterface;
40 using cricket::TurnPort; 41 using cricket::TurnPort;
41 using cricket::UDPPort; 42 using cricket::UDPPort;
42 43
43 static const SocketAddress kLocalAddr1("11.11.11.11", 0); 44 static const SocketAddress kLocalAddr1("11.11.11.11", 0);
44 static const SocketAddress kLocalAddr2("22.22.22.22", 0); 45 static const SocketAddress kLocalAddr2("22.22.22.22", 0);
45 static const SocketAddress kLocalIPv6Addr( 46 static const SocketAddress kLocalIPv6Addr(
46 "2401:fa00:4:1000:be30:5bff:fee5:c3", 0); 47 "2401:fa00:4:1000:be30:5bff:fee5:c3", 0);
47 static const SocketAddress kTurnUdpIntAddr("99.99.99.3", 48 static const SocketAddress kTurnUdpIntAddr("99.99.99.3",
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 EXPECT_TRUE_WAIT(turn_error_, kTimeout); 396 EXPECT_TRUE_WAIT(turn_error_, kTimeout);
396 ASSERT_EQ(0U, turn_port_->Candidates().size()); 397 ASSERT_EQ(0U, turn_port_->Candidates().size());
397 } 398 }
398 399
399 void TestTurnConnection() { 400 void TestTurnConnection() {
400 // Create ports and prepare addresses. 401 // Create ports and prepare addresses.
401 PrepareTurnAndUdpPorts(); 402 PrepareTurnAndUdpPorts();
402 403
403 // Send ping from UDP to TURN. 404 // Send ping from UDP to TURN.
404 Connection* conn1 = udp_port_->CreateConnection( 405 Connection* conn1 = udp_port_->CreateConnection(
405 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); 406 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
406 ASSERT_TRUE(conn1 != NULL); 407 ASSERT_TRUE(conn1 != NULL);
407 conn1->Ping(0); 408 conn1->Ping(0);
408 WAIT(!turn_unknown_address_, kTimeout); 409 WAIT(!turn_unknown_address_, kTimeout);
409 EXPECT_FALSE(turn_unknown_address_); 410 EXPECT_FALSE(turn_unknown_address_);
410 EXPECT_FALSE(conn1->receiving()); 411 EXPECT_FALSE(conn1->receiving());
411 EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state()); 412 EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state());
412 413
413 // Send ping from TURN to UDP. 414 // Send ping from TURN to UDP.
414 Connection* conn2 = turn_port_->CreateConnection( 415 Connection* conn2 = turn_port_->CreateConnection(
415 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); 416 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
416 ASSERT_TRUE(conn2 != NULL); 417 ASSERT_TRUE(conn2 != NULL);
417 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); 418 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout);
418 conn2->Ping(0); 419 conn2->Ping(0);
419 420
420 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout); 421 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout);
421 EXPECT_TRUE(conn1->receiving()); 422 EXPECT_TRUE(conn1->receiving());
422 EXPECT_TRUE(conn2->receiving()); 423 EXPECT_TRUE(conn2->receiving());
423 EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state()); 424 EXPECT_EQ(Connection::STATE_WRITE_INIT, conn1->write_state());
424 425
425 // Send another ping from UDP to TURN. 426 // Send another ping from UDP to TURN.
426 conn1->Ping(0); 427 conn1->Ping(0);
427 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout); 428 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout);
428 EXPECT_TRUE(conn2->receiving()); 429 EXPECT_TRUE(conn2->receiving());
429 } 430 }
430 431
431 void TestDestroyTurnConnection() { 432 void TestDestroyTurnConnection() {
432 PrepareTurnAndUdpPorts(); 433 PrepareTurnAndUdpPorts();
433 434
434 // Create connections on both ends. 435 // Create connections on both ends.
435 Connection* conn1 = udp_port_->CreateConnection(turn_port_->Candidates()[0], 436 Connection* conn1 = udp_port_->CreateConnection(
436 Port::ORIGIN_MESSAGE); 437 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
437 Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 438 Connection* conn2 = turn_port_->CreateConnection(
438 Port::ORIGIN_MESSAGE); 439 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
439 ASSERT_TRUE(conn2 != NULL); 440 ASSERT_TRUE(conn2 != NULL);
440 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); 441 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout);
441 // Make sure turn connection can receive. 442 // Make sure turn connection can receive.
442 conn1->Ping(0); 443 conn1->Ping(0);
443 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout); 444 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout);
444 EXPECT_FALSE(turn_unknown_address_); 445 EXPECT_FALSE(turn_unknown_address_);
445 446
446 // Destroy the connection on the turn port. The TurnEntry is still 447 // Destroy the connection on the turn port. The TurnEntry is still
447 // there. So the turn port gets ping from unknown address if it is pinged. 448 // there. So the turn port gets ping from unknown address if it is pinged.
448 conn2->Destroy(); 449 conn2->Destroy();
449 conn1->Ping(0); 450 conn1->Ping(0);
450 EXPECT_TRUE_WAIT(turn_unknown_address_, kTimeout); 451 EXPECT_TRUE_WAIT(turn_unknown_address_, kTimeout);
451 452
452 // Flush all requests in the invoker to destroy the TurnEntry. 453 // Flush all requests in the invoker to destroy the TurnEntry.
453 // Now the turn port cannot receive the ping. 454 // Now the turn port cannot receive the ping.
454 turn_unknown_address_ = false; 455 turn_unknown_address_ = false;
455 turn_port_->invoker()->Flush(rtc::Thread::Current()); 456 turn_port_->invoker()->Flush(rtc::Thread::Current());
456 conn1->Ping(0); 457 conn1->Ping(0);
457 rtc::Thread::Current()->ProcessMessages(500); 458 rtc::Thread::Current()->ProcessMessages(500);
458 EXPECT_FALSE(turn_unknown_address_); 459 EXPECT_FALSE(turn_unknown_address_);
459 460
460 // If the connection is created again, it will start to receive pings. 461 // If the connection is created again, it will start to receive pings.
461 conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 462 conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
462 Port::ORIGIN_MESSAGE); 463 Port::ORIGIN_MESSAGE, IceConfig());
463 conn1->Ping(0); 464 conn1->Ping(0);
464 EXPECT_TRUE_WAIT(conn2->receiving(), kTimeout); 465 EXPECT_TRUE_WAIT(conn2->receiving(), kTimeout);
465 EXPECT_FALSE(turn_unknown_address_); 466 EXPECT_FALSE(turn_unknown_address_);
466 } 467 }
467 468
468 void TestTurnSendData() { 469 void TestTurnSendData() {
469 PrepareTurnAndUdpPorts(); 470 PrepareTurnAndUdpPorts();
470 471
471 // Create connections and send pings. 472 // Create connections and send pings.
472 Connection* conn1 = turn_port_->CreateConnection( 473 Connection* conn1 = turn_port_->CreateConnection(
473 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE); 474 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
474 Connection* conn2 = udp_port_->CreateConnection( 475 Connection* conn2 = udp_port_->CreateConnection(
475 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE); 476 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
476 ASSERT_TRUE(conn1 != NULL); 477 ASSERT_TRUE(conn1 != NULL);
477 ASSERT_TRUE(conn2 != NULL); 478 ASSERT_TRUE(conn2 != NULL);
478 conn1->SignalReadPacket.connect(static_cast<TurnPortTest*>(this), 479 conn1->SignalReadPacket.connect(static_cast<TurnPortTest*>(this),
479 &TurnPortTest::OnTurnReadPacket); 480 &TurnPortTest::OnTurnReadPacket);
480 conn2->SignalReadPacket.connect(static_cast<TurnPortTest*>(this), 481 conn2->SignalReadPacket.connect(static_cast<TurnPortTest*>(this),
481 &TurnPortTest::OnUdpReadPacket); 482 &TurnPortTest::OnUdpReadPacket);
482 conn1->Ping(0); 483 conn1->Ping(0);
483 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout); 484 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn1->write_state(), kTimeout);
484 conn2->Ping(0); 485 conn2->Ping(0);
485 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout); 486 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 729
729 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); 730 EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
730 731
731 // Verifies that the new port has a different address now. 732 // Verifies that the new port has a different address now.
732 EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress()); 733 EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress());
733 } 734 }
734 735
735 TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) { 736 TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) {
736 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 737 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
737 PrepareTurnAndUdpPorts(); 738 PrepareTurnAndUdpPorts();
738 turn_port_->CreateConnection(udp_port_->Candidates()[0], 739 turn_port_->CreateConnection(udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE,
739 Port::ORIGIN_MESSAGE); 740 IceConfig());
740 // Set bad credentials. 741 // Set bad credentials.
741 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd"); 742 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd");
742 turn_port_->set_credentials(bad_credentials); 743 turn_port_->set_credentials(bad_credentials);
743 turn_refresh_success_ = false; 744 turn_refresh_success_ = false;
744 // This sends out the first RefreshRequest with correct credentials. 745 // This sends out the first RefreshRequest with correct credentials.
745 // When this succeeds, it will schedule a new RefreshRequest with the bad 746 // When this succeeds, it will schedule a new RefreshRequest with the bad
746 // credential. 747 // credential.
747 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST); 748 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST);
748 EXPECT_TRUE_WAIT(turn_refresh_success_, kTimeout); 749 EXPECT_TRUE_WAIT(turn_refresh_success_, kTimeout);
749 // Flush it again, it will receive a bad response. 750 // Flush it again, it will receive a bad response.
750 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST); 751 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST);
751 EXPECT_TRUE_WAIT(!turn_refresh_success_, kTimeout); 752 EXPECT_TRUE_WAIT(!turn_refresh_success_, kTimeout);
752 EXPECT_TRUE_WAIT(!turn_port_->connected(), kTimeout); 753 EXPECT_TRUE_WAIT(!turn_port_->connected(), kTimeout);
753 EXPECT_TRUE_WAIT(turn_port_->connections().empty(), kTimeout); 754 EXPECT_TRUE_WAIT(turn_port_->connections().empty(), kTimeout);
754 EXPECT_FALSE(turn_port_->HasRequests()); 755 EXPECT_FALSE(turn_port_->HasRequests());
755 } 756 }
756 757
757 // Test that TurnPort will not handle any incoming packets once it has been 758 // Test that TurnPort will not handle any incoming packets once it has been
758 // closed. 759 // closed.
759 TEST_F(TurnPortTest, TestStopProcessingPacketsAfterClosed) { 760 TEST_F(TurnPortTest, TestStopProcessingPacketsAfterClosed) {
760 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 761 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
761 PrepareTurnAndUdpPorts(); 762 PrepareTurnAndUdpPorts();
762 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 763 Connection* conn1 = turn_port_->CreateConnection(
763 Port::ORIGIN_MESSAGE); 764 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
764 Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], 765 Connection* conn2 = udp_port_->CreateConnection(
765 Port::ORIGIN_MESSAGE); 766 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
766 ASSERT_TRUE(conn1 != NULL); 767 ASSERT_TRUE(conn1 != NULL);
767 ASSERT_TRUE(conn2 != NULL); 768 ASSERT_TRUE(conn2 != NULL);
768 // Make sure conn2 is writable. 769 // Make sure conn2 is writable.
769 conn2->Ping(0); 770 conn2->Ping(0);
770 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout); 771 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, conn2->write_state(), kTimeout);
771 772
772 turn_port_->Close(); 773 turn_port_->Close();
773 rtc::Thread::Current()->ProcessMessages(0); 774 rtc::Thread::Current()->ProcessMessages(0);
774 turn_unknown_address_ = false; 775 turn_unknown_address_ = false;
775 conn2->Ping(0); 776 conn2->Ping(0);
776 rtc::Thread::Current()->ProcessMessages(500); 777 rtc::Thread::Current()->ProcessMessages(500);
777 // Since the turn port does not handle packets any more, it should not 778 // Since the turn port does not handle packets any more, it should not
778 // SignalUnknownAddress. 779 // SignalUnknownAddress.
779 EXPECT_FALSE(turn_unknown_address_); 780 EXPECT_FALSE(turn_unknown_address_);
780 } 781 }
781 782
782 // Test that CreateConnection will return null if port becomes disconnected. 783 // Test that CreateConnection will return null if port becomes disconnected.
783 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) { 784 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) {
784 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 785 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
785 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); 786 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
786 PrepareTurnAndUdpPorts(); 787 PrepareTurnAndUdpPorts();
787 // Create a connection. 788 // Create a connection.
788 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 789 Connection* conn1 = turn_port_->CreateConnection(
789 Port::ORIGIN_MESSAGE); 790 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
790 ASSERT_TRUE(conn1 != NULL); 791 ASSERT_TRUE(conn1 != NULL);
791 792
792 // Close the socket and create a connection again. 793 // Close the socket and create a connection again.
793 turn_port_->OnSocketClose(turn_port_->socket(), 1); 794 turn_port_->OnSocketClose(turn_port_->socket(), 1);
794 conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 795 conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
795 Port::ORIGIN_MESSAGE); 796 Port::ORIGIN_MESSAGE, IceConfig());
796 ASSERT_TRUE(conn1 == NULL); 797 ASSERT_TRUE(conn1 == NULL);
797 } 798 }
798 799
799 // Test try-alternate-server feature. 800 // Test try-alternate-server feature.
800 TEST_F(TurnPortTest, TestTurnAlternateServerUDP) { 801 TEST_F(TurnPortTest, TestTurnAlternateServerUDP) {
801 TestTurnAlternateServer(cricket::PROTO_UDP); 802 TestTurnAlternateServer(cricket::PROTO_UDP);
802 } 803 }
803 804
804 TEST_F(TurnPortTest, TestTurnAlternateServerTCP) { 805 TEST_F(TurnPortTest, TestTurnAlternateServerTCP) {
805 TestTurnAlternateServer(cricket::PROTO_TCP); 806 TestTurnAlternateServer(cricket::PROTO_TCP);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 TestTurnConnection(); 891 TestTurnConnection();
891 } 892 }
892 893
893 // Test that CreatePermissionRequest will be scheduled after the success 894 // Test that CreatePermissionRequest will be scheduled after the success
894 // of the first create permission request and the request will get an 895 // of the first create permission request and the request will get an
895 // ErrorResponse if the ufrag and pwd are incorrect. 896 // ErrorResponse if the ufrag and pwd are incorrect.
896 TEST_F(TurnPortTest, TestRefreshCreatePermissionRequest) { 897 TEST_F(TurnPortTest, TestRefreshCreatePermissionRequest) {
897 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 898 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
898 PrepareTurnAndUdpPorts(); 899 PrepareTurnAndUdpPorts();
899 900
900 Connection* conn = turn_port_->CreateConnection(udp_port_->Candidates()[0], 901 Connection* conn = turn_port_->CreateConnection(
901 Port::ORIGIN_MESSAGE); 902 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
902 ConnectConnectionDestroyedSignal(conn); 903 ConnectConnectionDestroyedSignal(conn);
903 ASSERT_TRUE(conn != NULL); 904 ASSERT_TRUE(conn != NULL);
904 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); 905 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout);
905 turn_create_permission_success_ = false; 906 turn_create_permission_success_ = false;
906 // A create-permission-request should be pending. 907 // A create-permission-request should be pending.
907 // After the next create-permission-response is received, it will schedule 908 // After the next create-permission-response is received, it will schedule
908 // another request with bad_ufrag and bad_pwd. 909 // another request with bad_ufrag and bad_pwd.
909 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd"); 910 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd");
910 turn_port_->set_credentials(bad_credentials); 911 turn_port_->set_credentials(bad_credentials);
911 turn_port_->FlushRequests(cricket::kAllRequests); 912 turn_port_->FlushRequests(cricket::kAllRequests);
912 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); 913 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout);
913 // Flush the requests again; the create-permission-request will fail. 914 // Flush the requests again; the create-permission-request will fail.
914 turn_port_->FlushRequests(cricket::kAllRequests); 915 turn_port_->FlushRequests(cricket::kAllRequests);
915 EXPECT_TRUE_WAIT(!turn_create_permission_success_, kTimeout); 916 EXPECT_TRUE_WAIT(!turn_create_permission_success_, kTimeout);
916 EXPECT_TRUE_WAIT(connection_destroyed_, kTimeout); 917 EXPECT_TRUE_WAIT(connection_destroyed_, kTimeout);
917 } 918 }
918 919
919 TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { 920 TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) {
920 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 921 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
921 PrepareTurnAndUdpPorts(); 922 PrepareTurnAndUdpPorts();
922 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 923 Connection* conn1 = turn_port_->CreateConnection(
923 Port::ORIGIN_MESSAGE); 924 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
924 ASSERT_TRUE(conn1 != nullptr); 925 ASSERT_TRUE(conn1 != nullptr);
925 Connection* conn2 = udp_port_->CreateConnection(turn_port_->Candidates()[0], 926 Connection* conn2 = udp_port_->CreateConnection(
926 Port::ORIGIN_MESSAGE); 927 turn_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig());
927 ASSERT_TRUE(conn2 != nullptr); 928 ASSERT_TRUE(conn2 != nullptr);
928 ConnectConnectionDestroyedSignal(conn1); 929 ConnectConnectionDestroyedSignal(conn1);
929 conn1->Ping(0); 930 conn1->Ping(0);
930 ASSERT_TRUE_WAIT(conn1->writable(), kTimeout); 931 ASSERT_TRUE_WAIT(conn1->writable(), kTimeout);
931 932
932 std::string data = "ABC"; 933 std::string data = "ABC";
933 conn1->Send(data.data(), data.length(), options); 934 conn1->Send(data.data(), data.length(), options);
934 bool success = 935 bool success =
935 turn_port_->SetEntryChannelId(udp_port_->Candidates()[0].address(), -1); 936 turn_port_->SetEntryChannelId(udp_port_->Candidates()[0].address(), -1);
936 ASSERT_TRUE(success); 937 ASSERT_TRUE(success);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 turn_server_.server()->set_reject_private_addresses(true); 1002 turn_server_.server()->set_reject_private_addresses(true);
1002 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); 1003 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
1003 turn_port_->PrepareAddress(); 1004 turn_port_->PrepareAddress();
1004 ASSERT_TRUE_WAIT(turn_ready_, kTimeout); 1005 ASSERT_TRUE_WAIT(turn_ready_, kTimeout);
1005 1006
1006 CreateUdpPort(SocketAddress("10.0.0.10", 0)); 1007 CreateUdpPort(SocketAddress("10.0.0.10", 0));
1007 udp_port_->PrepareAddress(); 1008 udp_port_->PrepareAddress();
1008 ASSERT_TRUE_WAIT(udp_ready_, kTimeout); 1009 ASSERT_TRUE_WAIT(udp_ready_, kTimeout);
1009 // Create a connection. 1010 // Create a connection.
1010 TestConnectionWrapper conn(turn_port_->CreateConnection( 1011 TestConnectionWrapper conn(turn_port_->CreateConnection(
1011 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE)); 1012 udp_port_->Candidates()[0], Port::ORIGIN_MESSAGE, IceConfig()));
1012 ASSERT_TRUE(conn.connection() != nullptr); 1013 ASSERT_TRUE(conn.connection() != nullptr);
1013 1014
1014 // Asynchronously, CreatePermission request should be sent and fail, closing 1015 // Asynchronously, CreatePermission request should be sent and fail, closing
1015 // the connection. 1016 // the connection.
1016 EXPECT_TRUE_WAIT(conn.connection() == nullptr, kTimeout); 1017 EXPECT_TRUE_WAIT(conn.connection() == nullptr, kTimeout);
1017 EXPECT_FALSE(turn_create_permission_success_); 1018 EXPECT_FALSE(turn_create_permission_success_);
1018 } 1019 }
1019 1020
1020 // Test that a TURN allocation is released when the port is closed. 1021 // Test that a TURN allocation is released when the port is closed.
1021 TEST_F(TurnPortTest, TestTurnReleaseAllocation) { 1022 TEST_F(TurnPortTest, TestTurnReleaseAllocation) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 turn_port_->PrepareAddress(); 1058 turn_port_->PrepareAddress();
1058 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); 1059 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout);
1059 EXPECT_TRUE(turn_port_->Candidates().empty()); 1060 EXPECT_TRUE(turn_port_->Candidates().empty());
1060 turn_port_.reset(); 1061 turn_port_.reset();
1061 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); 1062 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH);
1062 // Waiting for above message to be processed. 1063 // Waiting for above message to be processed.
1063 ASSERT_TRUE_WAIT(test_finish_, kTimeout); 1064 ASSERT_TRUE_WAIT(test_finish_, kTimeout);
1064 EXPECT_EQ(last_fd_count, GetFDCount()); 1065 EXPECT_EQ(last_fd_count, GetFDCount());
1065 } 1066 }
1066 #endif 1067 #endif
OLDNEW
« webrtc/p2p/base/p2ptransportchannel.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