| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 | 10 |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); | 533 const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); |
| 534 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); | 534 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); |
| 535 const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); | 535 const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); |
| 536 EXPECT_EQ(expected.controlled_type, local_type); | 536 EXPECT_EQ(expected.controlled_type, local_type); |
| 537 EXPECT_EQ(expected.controlling_type, remote_type); | 537 EXPECT_EQ(expected.controlling_type, remote_type); |
| 538 EXPECT_EQ(expected.controlled_protocol, local_protocol); | 538 EXPECT_EQ(expected.controlled_protocol, local_protocol); |
| 539 EXPECT_EQ(expected.controlling_protocol, remote_protocol); | 539 EXPECT_EQ(expected.controlling_protocol, remote_protocol); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void Test(const Result& expected) { | 542 void Test(const Result& expected) { |
| 543 rtc::ScopedFakeClock clock; |
| 543 int64_t connect_start = rtc::TimeMillis(); | 544 int64_t connect_start = rtc::TimeMillis(); |
| 544 int64_t connect_time; | 545 int64_t connect_time; |
| 545 | 546 |
| 546 // Create the channels and wait for them to connect. | 547 // Create the channels and wait for them to connect. |
| 547 CreateChannels(); | 548 CreateChannels(); |
| 548 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 549 EXPECT_TRUE_SIMULATED_WAIT( |
| 549 ep1_ch1()->receiving() && | 550 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && |
| 550 ep1_ch1()->writable() && | 551 ep1_ch1()->writable() && ep2_ch1()->receiving() && |
| 551 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 552 ep2_ch1()->writable(), |
| 552 expected.connect_wait, kShortTimeout); | 553 expected.connect_wait + kShortTimeout, clock); |
| 553 connect_time = rtc::TimeMillis() - connect_start; | 554 connect_time = rtc::TimeMillis() - connect_start; |
| 554 if (connect_time < expected.connect_wait) { | 555 if (connect_time < expected.connect_wait) { |
| 555 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; | 556 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; |
| 556 } else { | 557 } else { |
| 557 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" | 558 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" |
| 558 << expected.connect_wait << " ms)"; | 559 << expected.connect_wait << " ms)"; |
| 559 } | 560 } |
| 560 | 561 |
| 561 // Allow a few turns of the crank for the selected connections to emerge. | 562 // Allow a few turns of the crank for the selected connections to emerge. |
| 562 // This may take up to 2 seconds. | 563 // This may take up to 2 seconds. |
| 563 if (ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection()) { | 564 if (ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection()) { |
| 564 int64_t converge_start = rtc::TimeMillis(); | 565 int64_t converge_start = rtc::TimeMillis(); |
| 565 int64_t converge_time; | 566 int64_t converge_time; |
| 566 int64_t converge_wait = 2000; | |
| 567 // Verifying local and remote channel selected connection information. | 567 // Verifying local and remote channel selected connection information. |
| 568 // This is done only for the RFC 5245 as controlled agent will use | 568 // This is done only for the RFC 5245 as controlled agent will use |
| 569 // USE-CANDIDATE from controlling (ep1) agent. We can easily predict from | 569 // USE-CANDIDATE from controlling (ep1) agent. We can easily predict from |
| 570 // EP1 result matrix. | 570 // EP1 result matrix. |
| 571 EXPECT_TRUE_WAIT_MARGIN( | 571 EXPECT_TRUE_SIMULATED_WAIT( |
| 572 CheckCandidate1(expected) && CheckCandidate2(expected), converge_wait, | 572 CheckCandidate1(expected) && CheckCandidate2(expected), |
| 573 converge_wait); | 573 kMediumTimeout, clock); |
| 574 // Also do EXPECT_EQ on each part so that failures are more verbose. | 574 // Also do EXPECT_EQ on each part so that failures are more verbose. |
| 575 ExpectCandidate1(expected); | 575 ExpectCandidate1(expected); |
| 576 ExpectCandidate2(expected); | 576 ExpectCandidate2(expected); |
| 577 | 577 |
| 578 converge_time = rtc::TimeMillis() - converge_start; | 578 converge_time = rtc::TimeMillis() - converge_start; |
| 579 int64_t converge_wait = 2000; |
| 579 if (converge_time < converge_wait) { | 580 if (converge_time < converge_wait) { |
| 580 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; | 581 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; |
| 581 } else { | 582 } else { |
| 582 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" | 583 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" |
| 583 << converge_wait << " ms)"; | 584 << converge_wait << " ms)"; |
| 584 } | 585 } |
| 585 } | 586 } |
| 586 // Try sending some data to other end. | 587 // Try sending some data to other end. |
| 587 TestSendRecv(); | 588 TestSendRecv(clock); |
| 588 | 589 |
| 589 // Destroy the channels, and wait for them to be fully cleaned up. | 590 // Destroy the channels, and wait for them to be fully cleaned up. |
| 590 DestroyChannels(); | 591 DestroyChannels(); |
| 591 } | 592 } |
| 592 | 593 |
| 593 void TestSendRecv() { | 594 void TestSendRecv(rtc::FakeClock& clock) { |
| 594 for (int i = 0; i < 10; ++i) { | 595 for (int i = 0; i < 10; ++i) { |
| 595 const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | 596 const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
| 596 int len = static_cast<int>(strlen(data)); | 597 int len = static_cast<int>(strlen(data)); |
| 597 // local_channel1 <==> remote_channel1 | 598 // local_channel1 <==> remote_channel1 |
| 598 EXPECT_EQ_WAIT(len, SendData(ep1_ch1(), data, len), kMediumTimeout); | 599 EXPECT_EQ_SIMULATED_WAIT(len, SendData(ep1_ch1(), data, len), |
| 599 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch1(), data, len), | 600 kMediumTimeout, clock); |
| 600 kMediumTimeout); | 601 EXPECT_TRUE_SIMULATED_WAIT(CheckDataOnChannel(ep2_ch1(), data, len), |
| 601 EXPECT_EQ_WAIT(len, SendData(ep2_ch1(), data, len), kMediumTimeout); | 602 kMediumTimeout, clock); |
| 602 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch1(), data, len), | 603 EXPECT_EQ_SIMULATED_WAIT(len, SendData(ep2_ch1(), data, len), |
| 603 kMediumTimeout); | 604 kMediumTimeout, clock); |
| 605 EXPECT_TRUE_SIMULATED_WAIT(CheckDataOnChannel(ep1_ch1(), data, len), |
| 606 kMediumTimeout, clock); |
| 604 } | 607 } |
| 605 } | 608 } |
| 606 | 609 |
| 607 // This test waits for the transport to become receiving and writable on both | 610 // This test waits for the transport to become receiving and writable on both |
| 608 // end points. Once they are, the end points set new local ice parameters and | 611 // end points. Once they are, the end points set new local ice parameters and |
| 609 // restart the ice gathering. Finally it waits for the transport to select a | 612 // restart the ice gathering. Finally it waits for the transport to select a |
| 610 // new connection using the newly generated ice candidates. | 613 // new connection using the newly generated ice candidates. |
| 611 // Before calling this function the end points must be configured. | 614 // Before calling this function the end points must be configured. |
| 612 void TestHandleIceUfragPasswordChanged() { | 615 void TestHandleIceUfragPasswordChanged() { |
| 616 rtc::ScopedFakeClock clock; |
| 613 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); | 617 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| 614 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); | 618 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| 615 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 619 EXPECT_TRUE_SIMULATED_WAIT( |
| 616 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 620 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 617 kShortTimeout, kShortTimeout); | 621 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 622 kMediumTimeout, clock); |
| 618 | 623 |
| 619 const Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); | 624 const Candidate* old_local_candidate1 = LocalCandidate(ep1_ch1()); |
| 620 const Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); | 625 const Candidate* old_local_candidate2 = LocalCandidate(ep2_ch1()); |
| 621 const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); | 626 const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); |
| 622 const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); | 627 const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); |
| 623 | 628 |
| 624 ep1_ch1()->SetIceParameters(kIceParams[2]); | 629 ep1_ch1()->SetIceParameters(kIceParams[2]); |
| 625 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); | 630 ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
| 626 ep1_ch1()->MaybeStartGathering(); | 631 ep1_ch1()->MaybeStartGathering(); |
| 627 ep2_ch1()->SetIceParameters(kIceParams[3]); | 632 ep2_ch1()->SetIceParameters(kIceParams[3]); |
| 628 | 633 |
| 629 ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); | 634 ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); |
| 630 ep2_ch1()->MaybeStartGathering(); | 635 ep2_ch1()->MaybeStartGathering(); |
| 631 | 636 |
| 632 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep1_ch1())->generation() != | 637 EXPECT_TRUE_SIMULATED_WAIT(LocalCandidate(ep1_ch1())->generation() != |
| 633 old_local_candidate1->generation(), | 638 old_local_candidate1->generation(), |
| 634 kShortTimeout, kShortTimeout); | 639 kMediumTimeout, clock); |
| 635 EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep2_ch1())->generation() != | 640 EXPECT_TRUE_SIMULATED_WAIT(LocalCandidate(ep2_ch1())->generation() != |
| 636 old_local_candidate2->generation(), | 641 old_local_candidate2->generation(), |
| 637 kShortTimeout, kShortTimeout); | 642 kMediumTimeout, clock); |
| 638 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep1_ch1())->generation() != | 643 EXPECT_TRUE_SIMULATED_WAIT(RemoteCandidate(ep1_ch1())->generation() != |
| 639 old_remote_candidate1->generation(), | 644 old_remote_candidate1->generation(), |
| 640 kShortTimeout, kShortTimeout); | 645 kMediumTimeout, clock); |
| 641 EXPECT_TRUE_WAIT_MARGIN(RemoteCandidate(ep2_ch1())->generation() != | 646 EXPECT_TRUE_SIMULATED_WAIT(RemoteCandidate(ep2_ch1())->generation() != |
| 642 old_remote_candidate2->generation(), | 647 old_remote_candidate2->generation(), |
| 643 kShortTimeout, kShortTimeout); | 648 kMediumTimeout, clock); |
| 644 EXPECT_EQ(1u, RemoteCandidate(ep2_ch1())->generation()); | 649 EXPECT_EQ(1u, RemoteCandidate(ep2_ch1())->generation()); |
| 645 EXPECT_EQ(1u, RemoteCandidate(ep1_ch1())->generation()); | 650 EXPECT_EQ(1u, RemoteCandidate(ep1_ch1())->generation()); |
| 646 } | 651 } |
| 647 | 652 |
| 648 void TestSignalRoleConflict() { | 653 void TestSignalRoleConflict() { |
| 649 SetIceTiebreaker(0, | 654 rtc::ScopedFakeClock clock; |
| 650 kLowTiebreaker); // Default EP1 is in controlling state. | 655 // Default EP1 is in controlling state. |
| 656 SetIceTiebreaker(0, kLowTiebreaker); |
| 651 | 657 |
| 652 SetIceRole(1, ICEROLE_CONTROLLING); | 658 SetIceRole(1, ICEROLE_CONTROLLING); |
| 653 SetIceTiebreaker(1, kHighTiebreaker); | 659 SetIceTiebreaker(1, kHighTiebreaker); |
| 654 | 660 |
| 655 // Creating channels with both channels role set to CONTROLLING. | 661 // Creating channels with both channels role set to CONTROLLING. |
| 656 CreateChannels(); | 662 CreateChannels(); |
| 657 // Since both the channels initiated with controlling state and channel2 | 663 // Since both the channels initiated with controlling state and channel2 |
| 658 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. | 664 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. |
| 659 EXPECT_TRUE_WAIT(GetRoleConflict(0), kShortTimeout); | 665 EXPECT_TRUE_SIMULATED_WAIT(GetRoleConflict(0), kShortTimeout, clock); |
| 660 EXPECT_FALSE(GetRoleConflict(1)); | 666 EXPECT_FALSE(GetRoleConflict(1)); |
| 661 | 667 |
| 662 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 668 EXPECT_TRUE_SIMULATED_WAIT( |
| 663 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 669 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 664 kShortTimeout); | 670 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 671 kShortTimeout, clock); |
| 665 | 672 |
| 666 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 673 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 667 ep2_ch1()->selected_connection()); | 674 ep2_ch1()->selected_connection()); |
| 668 | 675 |
| 669 TestSendRecv(); | 676 TestSendRecv(clock); |
| 670 } | 677 } |
| 671 | 678 |
| 672 void OnReadyToSend(TransportChannel* ch) { | 679 void OnReadyToSend(TransportChannel* ch) { |
| 673 GetEndpoint(ch)->ready_to_send_ = true; | 680 GetEndpoint(ch)->ready_to_send_ = true; |
| 674 } | 681 } |
| 675 | 682 |
| 676 // We pass the candidates directly to the other side. | 683 // We pass the candidates directly to the other side. |
| 677 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { | 684 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { |
| 678 if (force_relay_ && c.type() != RELAY_PORT_TYPE) | 685 if (force_relay_ && c.type() != RELAY_PORT_TYPE) |
| 679 return; | 686 return; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeSymmetricNat) { | 1155 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeSymmetricNat) { |
| 1149 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1156 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
| 1150 kDefaultPortAllocatorFlags); | 1157 kDefaultPortAllocatorFlags); |
| 1151 CreateChannels(); | 1158 CreateChannels(); |
| 1152 TestHandleIceUfragPasswordChanged(); | 1159 TestHandleIceUfragPasswordChanged(); |
| 1153 DestroyChannels(); | 1160 DestroyChannels(); |
| 1154 } | 1161 } |
| 1155 | 1162 |
| 1156 // Test the operation of GetStats. | 1163 // Test the operation of GetStats. |
| 1157 TEST_F(P2PTransportChannelTest, GetStats) { | 1164 TEST_F(P2PTransportChannelTest, GetStats) { |
| 1165 rtc::ScopedFakeClock clock; |
| 1158 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1166 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1159 kDefaultPortAllocatorFlags); | 1167 kDefaultPortAllocatorFlags); |
| 1160 CreateChannels(); | 1168 CreateChannels(); |
| 1161 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1169 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1162 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1170 ep2_ch1()->receiving() && |
| 1163 kShortTimeout, kShortTimeout); | 1171 ep2_ch1()->writable(), |
| 1164 TestSendRecv(); | 1172 kMediumTimeout, clock); |
| 1173 TestSendRecv(clock); |
| 1165 ConnectionInfos infos; | 1174 ConnectionInfos infos; |
| 1166 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); | 1175 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); |
| 1167 ASSERT_TRUE(infos.size() >= 1); | 1176 ASSERT_TRUE(infos.size() >= 1); |
| 1168 ConnectionInfo* best_conn_info = nullptr; | 1177 ConnectionInfo* best_conn_info = nullptr; |
| 1169 for (ConnectionInfo& info : infos) { | 1178 for (ConnectionInfo& info : infos) { |
| 1170 if (info.best_connection) { | 1179 if (info.best_connection) { |
| 1171 best_conn_info = &info; | 1180 best_conn_info = &info; |
| 1172 break; | 1181 break; |
| 1173 } | 1182 } |
| 1174 } | 1183 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 // Wait to make sure the selected connection is not changed. | 1516 // Wait to make sure the selected connection is not changed. |
| 1508 SIMULATED_WAIT(ep2_ch1()->selected_connection() != selected_connection, | 1517 SIMULATED_WAIT(ep2_ch1()->selected_connection() != selected_connection, |
| 1509 kShortTimeout, clock); | 1518 kShortTimeout, clock); |
| 1510 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); | 1519 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); |
| 1511 DestroyChannels(); | 1520 DestroyChannels(); |
| 1512 } | 1521 } |
| 1513 | 1522 |
| 1514 // Test that a host behind NAT cannot be reached when incoming_only | 1523 // Test that a host behind NAT cannot be reached when incoming_only |
| 1515 // is set to true. | 1524 // is set to true. |
| 1516 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { | 1525 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { |
| 1526 rtc::ScopedFakeClock clock; |
| 1517 ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags, | 1527 ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags, |
| 1518 kDefaultPortAllocatorFlags); | 1528 kDefaultPortAllocatorFlags); |
| 1519 | 1529 |
| 1520 SetAllocatorFlags(0, kOnlyLocalPorts); | 1530 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1521 CreateChannels(); | 1531 CreateChannels(); |
| 1522 ep1_ch1()->set_incoming_only(true); | 1532 ep1_ch1()->set_incoming_only(true); |
| 1523 | 1533 |
| 1524 // Pump for 1 second and verify that the channels are not connected. | 1534 // Pump for 1 second and verify that the channels are not connected. |
| 1525 rtc::Thread::Current()->ProcessMessages(kShortTimeout); | 1535 SIMULATED_WAIT(false, kShortTimeout, clock); |
| 1526 | 1536 |
| 1527 EXPECT_FALSE(ep1_ch1()->receiving()); | 1537 EXPECT_FALSE(ep1_ch1()->receiving()); |
| 1528 EXPECT_FALSE(ep1_ch1()->writable()); | 1538 EXPECT_FALSE(ep1_ch1()->writable()); |
| 1529 EXPECT_FALSE(ep2_ch1()->receiving()); | 1539 EXPECT_FALSE(ep2_ch1()->receiving()); |
| 1530 EXPECT_FALSE(ep2_ch1()->writable()); | 1540 EXPECT_FALSE(ep2_ch1()->writable()); |
| 1531 | 1541 |
| 1532 DestroyChannels(); | 1542 DestroyChannels(); |
| 1533 } | 1543 } |
| 1534 | 1544 |
| 1535 // Test that a peer behind NAT can connect to a peer that has | 1545 // Test that a peer behind NAT can connect to a peer that has |
| 1536 // incoming_only flag set. | 1546 // incoming_only flag set. |
| 1537 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { | 1547 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { |
| 1548 rtc::ScopedFakeClock clock; |
| 1538 ConfigureEndpoints(OPEN, NAT_FULL_CONE, kDefaultPortAllocatorFlags, | 1549 ConfigureEndpoints(OPEN, NAT_FULL_CONE, kDefaultPortAllocatorFlags, |
| 1539 kDefaultPortAllocatorFlags); | 1550 kDefaultPortAllocatorFlags); |
| 1540 | 1551 |
| 1541 SetAllocatorFlags(0, kOnlyLocalPorts); | 1552 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1542 CreateChannels(); | 1553 CreateChannels(); |
| 1543 ep1_ch1()->set_incoming_only(true); | 1554 ep1_ch1()->set_incoming_only(true); |
| 1544 | 1555 |
| 1545 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1556 EXPECT_TRUE_SIMULATED_WAIT( |
| 1546 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1557 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && |
| 1547 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1558 ep1_ch1()->writable() && ep2_ch1()->receiving() && |
| 1548 kShortTimeout, kShortTimeout); | 1559 ep2_ch1()->writable(), |
| 1560 kMediumTimeout, clock); |
| 1549 | 1561 |
| 1550 DestroyChannels(); | 1562 DestroyChannels(); |
| 1551 } | 1563 } |
| 1552 | 1564 |
| 1553 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { | 1565 TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { |
| 1566 rtc::ScopedFakeClock clock; |
| 1554 AddAddress(0, kPublicAddrs[0]); | 1567 AddAddress(0, kPublicAddrs[0]); |
| 1555 AddAddress(1, kPublicAddrs[1]); | 1568 AddAddress(1, kPublicAddrs[1]); |
| 1556 | 1569 |
| 1557 SetAllocationStepDelay(0, kMinimumStepDelay); | 1570 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1558 SetAllocationStepDelay(1, kMinimumStepDelay); | 1571 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1559 | 1572 |
| 1560 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | | 1573 int kOnlyLocalTcpPorts = PORTALLOCATOR_DISABLE_UDP | |
| 1561 PORTALLOCATOR_DISABLE_STUN | | 1574 PORTALLOCATOR_DISABLE_STUN | |
| 1562 PORTALLOCATOR_DISABLE_RELAY; | 1575 PORTALLOCATOR_DISABLE_RELAY; |
| 1563 // Disable all protocols except TCP. | 1576 // Disable all protocols except TCP. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1578 CreateChannels(); | 1591 CreateChannels(); |
| 1579 | 1592 |
| 1580 // Verify tcp candidates. | 1593 // Verify tcp candidates. |
| 1581 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); | 1594 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); |
| 1582 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); | 1595 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); |
| 1583 | 1596 |
| 1584 // Resume candidates. | 1597 // Resume candidates. |
| 1585 ResumeCandidates(0); | 1598 ResumeCandidates(0); |
| 1586 ResumeCandidates(1); | 1599 ResumeCandidates(1); |
| 1587 | 1600 |
| 1588 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1601 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1589 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1602 ep2_ch1()->receiving() && |
| 1590 kShortTimeout); | 1603 ep2_ch1()->writable(), |
| 1604 kShortTimeout, clock); |
| 1591 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1605 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1592 ep2_ch1()->selected_connection() && | 1606 ep2_ch1()->selected_connection() && |
| 1593 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1607 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1594 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1608 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1595 | 1609 |
| 1596 TestSendRecv(); | 1610 TestSendRecv(clock); |
| 1597 DestroyChannels(); | 1611 DestroyChannels(); |
| 1598 } | 1612 } |
| 1599 | 1613 |
| 1600 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { | 1614 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { |
| 1601 AddAddress(0, kPublicAddrs[0]); | 1615 AddAddress(0, kPublicAddrs[0]); |
| 1602 AddAddress(1, kPublicAddrs[1]); | 1616 AddAddress(1, kPublicAddrs[1]); |
| 1603 TestSignalRoleConflict(); | 1617 TestSignalRoleConflict(); |
| 1604 } | 1618 } |
| 1605 | 1619 |
| 1606 // Tests that the ice configs (protocol, tiebreaker and role) can be passed | 1620 // Tests that the ice configs (protocol, tiebreaker and role) can be passed |
| 1607 // down to ports. | 1621 // down to ports. |
| 1608 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { | 1622 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { |
| 1623 rtc::ScopedFakeClock clock; |
| 1609 AddAddress(0, kPublicAddrs[0]); | 1624 AddAddress(0, kPublicAddrs[0]); |
| 1610 AddAddress(1, kPublicAddrs[1]); | 1625 AddAddress(1, kPublicAddrs[1]); |
| 1611 | 1626 |
| 1612 // Give the first connection the higher tiebreaker so its role won't | 1627 // Give the first connection the higher tiebreaker so its role won't |
| 1613 // change unless we tell it to. | 1628 // change unless we tell it to. |
| 1614 SetIceRole(0, ICEROLE_CONTROLLING); | 1629 SetIceRole(0, ICEROLE_CONTROLLING); |
| 1615 SetIceTiebreaker(0, kHighTiebreaker); | 1630 SetIceTiebreaker(0, kHighTiebreaker); |
| 1616 SetIceRole(1, ICEROLE_CONTROLLING); | 1631 SetIceRole(1, ICEROLE_CONTROLLING); |
| 1617 SetIceTiebreaker(1, kLowTiebreaker); | 1632 SetIceTiebreaker(1, kLowTiebreaker); |
| 1618 | 1633 |
| 1619 CreateChannels(); | 1634 CreateChannels(); |
| 1620 | 1635 |
| 1621 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), kShortTimeout); | 1636 EXPECT_EQ_SIMULATED_WAIT(2u, ep1_ch1()->ports().size(), kShortTimeout, clock); |
| 1622 | 1637 |
| 1623 const std::vector<PortInterface*> ports_before = ep1_ch1()->ports(); | 1638 const std::vector<PortInterface*> ports_before = ep1_ch1()->ports(); |
| 1624 for (size_t i = 0; i < ports_before.size(); ++i) { | 1639 for (size_t i = 0; i < ports_before.size(); ++i) { |
| 1625 EXPECT_EQ(ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); | 1640 EXPECT_EQ(ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); |
| 1626 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); | 1641 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); |
| 1627 } | 1642 } |
| 1628 | 1643 |
| 1629 ep1_ch1()->SetIceRole(ICEROLE_CONTROLLED); | 1644 ep1_ch1()->SetIceRole(ICEROLE_CONTROLLED); |
| 1630 ep1_ch1()->SetIceTiebreaker(kLowTiebreaker); | 1645 ep1_ch1()->SetIceTiebreaker(kLowTiebreaker); |
| 1631 | 1646 |
| 1632 const std::vector<PortInterface*> ports_after = ep1_ch1()->ports(); | 1647 const std::vector<PortInterface*> ports_after = ep1_ch1()->ports(); |
| 1633 for (size_t i = 0; i < ports_after.size(); ++i) { | 1648 for (size_t i = 0; i < ports_after.size(); ++i) { |
| 1634 EXPECT_EQ(ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); | 1649 EXPECT_EQ(ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); |
| 1635 // SetIceTiebreaker after ports have been created will fail. So expect the | 1650 // SetIceTiebreaker after ports have been created will fail. So expect the |
| 1636 // original value. | 1651 // original value. |
| 1637 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); | 1652 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); |
| 1638 } | 1653 } |
| 1639 | 1654 |
| 1640 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1655 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1641 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1656 ep2_ch1()->receiving() && |
| 1642 kShortTimeout); | 1657 ep2_ch1()->writable(), |
| 1658 kShortTimeout, clock); |
| 1643 | 1659 |
| 1644 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1660 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1645 ep2_ch1()->selected_connection()); | 1661 ep2_ch1()->selected_connection()); |
| 1646 | 1662 |
| 1647 TestSendRecv(); | 1663 TestSendRecv(clock); |
| 1648 DestroyChannels(); | 1664 DestroyChannels(); |
| 1649 } | 1665 } |
| 1650 | 1666 |
| 1651 // Verify that we can set DSCP value and retrieve properly from P2PTC. | 1667 // Verify that we can set DSCP value and retrieve properly from P2PTC. |
| 1652 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { | 1668 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { |
| 1653 AddAddress(0, kPublicAddrs[0]); | 1669 AddAddress(0, kPublicAddrs[0]); |
| 1654 AddAddress(1, kPublicAddrs[1]); | 1670 AddAddress(1, kPublicAddrs[1]); |
| 1655 | 1671 |
| 1656 CreateChannels(); | 1672 CreateChannels(); |
| 1657 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1673 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1671 GetEndpoint(1)->cd1_.ch_->SetOption( | 1687 GetEndpoint(1)->cd1_.ch_->SetOption( |
| 1672 rtc::Socket::OPT_DSCP, rtc::DSCP_AF41); | 1688 rtc::Socket::OPT_DSCP, rtc::DSCP_AF41); |
| 1673 EXPECT_EQ(rtc::DSCP_AF41, | 1689 EXPECT_EQ(rtc::DSCP_AF41, |
| 1674 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); | 1690 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); |
| 1675 EXPECT_EQ(rtc::DSCP_AF41, | 1691 EXPECT_EQ(rtc::DSCP_AF41, |
| 1676 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); | 1692 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); |
| 1677 } | 1693 } |
| 1678 | 1694 |
| 1679 // Verify IPv6 connection is preferred over IPv4. | 1695 // Verify IPv6 connection is preferred over IPv4. |
| 1680 TEST_F(P2PTransportChannelTest, TestIPv6Connections) { | 1696 TEST_F(P2PTransportChannelTest, TestIPv6Connections) { |
| 1697 rtc::ScopedFakeClock clock; |
| 1681 AddAddress(0, kIPv6PublicAddrs[0]); | 1698 AddAddress(0, kIPv6PublicAddrs[0]); |
| 1682 AddAddress(0, kPublicAddrs[0]); | 1699 AddAddress(0, kPublicAddrs[0]); |
| 1683 AddAddress(1, kIPv6PublicAddrs[1]); | 1700 AddAddress(1, kIPv6PublicAddrs[1]); |
| 1684 AddAddress(1, kPublicAddrs[1]); | 1701 AddAddress(1, kPublicAddrs[1]); |
| 1685 | 1702 |
| 1686 SetAllocationStepDelay(0, kMinimumStepDelay); | 1703 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1687 SetAllocationStepDelay(1, kMinimumStepDelay); | 1704 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1688 | 1705 |
| 1689 // Enable IPv6 | 1706 // Enable IPv6 |
| 1690 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); | 1707 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); |
| 1691 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); | 1708 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); |
| 1692 | 1709 |
| 1693 CreateChannels(); | 1710 CreateChannels(); |
| 1694 | 1711 |
| 1695 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1712 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1696 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1713 ep2_ch1()->receiving() && |
| 1697 kShortTimeout); | 1714 ep2_ch1()->writable(), |
| 1715 kShortTimeout, clock); |
| 1698 EXPECT_TRUE( | 1716 EXPECT_TRUE( |
| 1699 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && | 1717 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
| 1700 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && | 1718 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && |
| 1701 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); | 1719 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); |
| 1702 | 1720 |
| 1703 TestSendRecv(); | 1721 TestSendRecv(clock); |
| 1704 DestroyChannels(); | 1722 DestroyChannels(); |
| 1705 } | 1723 } |
| 1706 | 1724 |
| 1707 // Testing forceful TURN connections. | 1725 // Testing forceful TURN connections. |
| 1708 TEST_F(P2PTransportChannelTest, TestForceTurn) { | 1726 TEST_F(P2PTransportChannelTest, TestForceTurn) { |
| 1727 rtc::ScopedFakeClock clock; |
| 1709 ConfigureEndpoints( | 1728 ConfigureEndpoints( |
| 1710 NAT_PORT_RESTRICTED, NAT_SYMMETRIC, | 1729 NAT_PORT_RESTRICTED, NAT_SYMMETRIC, |
| 1711 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET, | 1730 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET, |
| 1712 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1731 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1713 set_force_relay(true); | 1732 set_force_relay(true); |
| 1714 | 1733 |
| 1715 SetAllocationStepDelay(0, kMinimumStepDelay); | 1734 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1716 SetAllocationStepDelay(1, kMinimumStepDelay); | 1735 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1717 | 1736 |
| 1718 CreateChannels(); | 1737 CreateChannels(); |
| 1719 | 1738 |
| 1720 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1739 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1721 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1740 ep2_ch1()->receiving() && |
| 1722 kMediumTimeout); | 1741 ep2_ch1()->writable(), |
| 1742 kMediumTimeout, clock); |
| 1723 | 1743 |
| 1724 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1744 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1725 ep2_ch1()->selected_connection()); | 1745 ep2_ch1()->selected_connection()); |
| 1726 | 1746 |
| 1727 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); | 1747 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); |
| 1728 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); | 1748 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); |
| 1729 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); | 1749 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); |
| 1730 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); | 1750 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); |
| 1731 | 1751 |
| 1732 TestSendRecv(); | 1752 TestSendRecv(clock); |
| 1733 DestroyChannels(); | 1753 DestroyChannels(); |
| 1734 } | 1754 } |
| 1735 | 1755 |
| 1736 // Test that if continual gathering is set to true, ICE gathering state will | 1756 // Test that if continual gathering is set to true, ICE gathering state will |
| 1737 // not change to "Complete", and vice versa. | 1757 // not change to "Complete", and vice versa. |
| 1738 TEST_F(P2PTransportChannelTest, TestContinualGathering) { | 1758 TEST_F(P2PTransportChannelTest, TestContinualGathering) { |
| 1739 rtc::ScopedFakeClock clock; | 1759 rtc::ScopedFakeClock clock; |
| 1740 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1760 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1741 kDefaultPortAllocatorFlags); | 1761 kDefaultPortAllocatorFlags); |
| 1742 SetAllocationStepDelay(0, kDefaultStepDelay); | 1762 SetAllocationStepDelay(0, kDefaultStepDelay); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 EXPECT_TRUE(pooled_session_1->ReadyCandidates().empty()); | 1809 EXPECT_TRUE(pooled_session_1->ReadyCandidates().empty()); |
| 1790 EXPECT_TRUE(pooled_session_2->ReadyPorts().empty()); | 1810 EXPECT_TRUE(pooled_session_2->ReadyPorts().empty()); |
| 1791 EXPECT_TRUE(pooled_session_2->ReadyCandidates().empty()); | 1811 EXPECT_TRUE(pooled_session_2->ReadyCandidates().empty()); |
| 1792 // Now let the endpoints connect and try exchanging some data. | 1812 // Now let the endpoints connect and try exchanging some data. |
| 1793 CreateChannels(); | 1813 CreateChannels(); |
| 1794 EXPECT_TRUE_SIMULATED_WAIT( | 1814 EXPECT_TRUE_SIMULATED_WAIT( |
| 1795 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && | 1815 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && |
| 1796 ep1_ch1()->writable() && ep2_ch1()->receiving() && | 1816 ep1_ch1()->writable() && ep2_ch1()->receiving() && |
| 1797 ep2_ch1()->writable(), | 1817 ep2_ch1()->writable(), |
| 1798 kMediumTimeout, clock); | 1818 kMediumTimeout, clock); |
| 1799 TestSendRecv(); | 1819 TestSendRecv(clock); |
| 1800 // Make sure the P2PTransportChannels are actually using ports from the | 1820 // Make sure the P2PTransportChannels are actually using ports from the |
| 1801 // pooled sessions. | 1821 // pooled sessions. |
| 1802 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); | 1822 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); |
| 1803 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); | 1823 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); |
| 1804 EXPECT_NE(pooled_ports_1.end(), | 1824 EXPECT_NE(pooled_ports_1.end(), |
| 1805 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1825 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
| 1806 ep1_ch1()->selected_connection()->port())); | 1826 ep1_ch1()->selected_connection()->port())); |
| 1807 EXPECT_NE(pooled_ports_2.end(), | 1827 EXPECT_NE(pooled_ports_2.end(), |
| 1808 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1828 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
| 1809 ep2_ch1()->selected_connection()->port())); | 1829 ep2_ch1()->selected_connection()->port())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1834 EXPECT_TRUE_SIMULATED_WAIT(pooled_session_1->CandidatesAllocationDone() && | 1854 EXPECT_TRUE_SIMULATED_WAIT(pooled_session_1->CandidatesAllocationDone() && |
| 1835 pooled_session_2->CandidatesAllocationDone(), | 1855 pooled_session_2->CandidatesAllocationDone(), |
| 1836 kDefaultTimeout, clock); | 1856 kDefaultTimeout, clock); |
| 1837 // Now let the endpoints connect and try exchanging some data. | 1857 // Now let the endpoints connect and try exchanging some data. |
| 1838 CreateChannels(); | 1858 CreateChannels(); |
| 1839 EXPECT_TRUE_SIMULATED_WAIT( | 1859 EXPECT_TRUE_SIMULATED_WAIT( |
| 1840 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && | 1860 ep1_ch1() != NULL && ep2_ch1() != NULL && ep1_ch1()->receiving() && |
| 1841 ep1_ch1()->writable() && ep2_ch1()->receiving() && | 1861 ep1_ch1()->writable() && ep2_ch1()->receiving() && |
| 1842 ep2_ch1()->writable(), | 1862 ep2_ch1()->writable(), |
| 1843 kMediumTimeout, clock); | 1863 kMediumTimeout, clock); |
| 1844 TestSendRecv(); | 1864 TestSendRecv(clock); |
| 1845 // Make sure the P2PTransportChannels are actually using ports from the | 1865 // Make sure the P2PTransportChannels are actually using ports from the |
| 1846 // pooled sessions. | 1866 // pooled sessions. |
| 1847 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); | 1867 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); |
| 1848 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); | 1868 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); |
| 1849 EXPECT_NE(pooled_ports_1.end(), | 1869 EXPECT_NE(pooled_ports_1.end(), |
| 1850 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1870 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
| 1851 ep1_ch1()->selected_connection()->port())); | 1871 ep1_ch1()->selected_connection()->port())); |
| 1852 EXPECT_NE(pooled_ports_2.end(), | 1872 EXPECT_NE(pooled_ports_2.end(), |
| 1853 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1873 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
| 1854 ep2_ch1()->selected_connection()->port())); | 1874 ep2_ch1()->selected_connection()->port())); |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3260 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); | 3280 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2)); |
| 3261 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3281 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
| 3262 ASSERT_TRUE(conn2 != nullptr); | 3282 ASSERT_TRUE(conn2 != nullptr); |
| 3263 conn2->ReceivedPing(); | 3283 conn2->ReceivedPing(); |
| 3264 conn2->ReceivedPingResponse(LOW_RTT, "id"); | 3284 conn2->ReceivedPingResponse(LOW_RTT, "id"); |
| 3265 | 3285 |
| 3266 // Wait for conn1 to be pruned. | 3286 // Wait for conn1 to be pruned. |
| 3267 EXPECT_TRUE_WAIT(conn1->pruned(), kMediumTimeout); | 3287 EXPECT_TRUE_WAIT(conn1->pruned(), kMediumTimeout); |
| 3268 // Destroy the connection to test SignalUnknownAddress. | 3288 // Destroy the connection to test SignalUnknownAddress. |
| 3269 conn1->Destroy(); | 3289 conn1->Destroy(); |
| 3270 EXPECT_TRUE_WAIT(GetConnectionTo(&ch, "1.1.1.1", 1) == nullptr, 1000); | 3290 EXPECT_TRUE_WAIT(GetConnectionTo(&ch, "1.1.1.1", 1) == nullptr, |
| 3291 kMediumTimeout); |
| 3271 | 3292 |
| 3272 // Create a minimal STUN message with prflx priority. | 3293 // Create a minimal STUN message with prflx priority. |
| 3273 IceMessage request; | 3294 IceMessage request; |
| 3274 request.SetType(STUN_BINDING_REQUEST); | 3295 request.SetType(STUN_BINDING_REQUEST); |
| 3275 request.AddAttribute( | 3296 request.AddAttribute( |
| 3276 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); | 3297 new StunByteStringAttribute(STUN_ATTR_USERNAME, kIceUfrag[1])); |
| 3277 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; | 3298 uint32_t prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24; |
| 3278 request.AddAttribute( | 3299 request.AddAttribute( |
| 3279 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); | 3300 new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); |
| 3280 EXPECT_NE(prflx_priority, remote_priority); | 3301 EXPECT_NE(prflx_priority, remote_priority); |
| 3281 | 3302 |
| 3282 Port* port = GetPort(&ch); | 3303 Port* port = GetPort(&ch); |
| 3283 // conn1 should be resurrected with original priority. | 3304 // conn1 should be resurrected with original priority. |
| 3284 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, | 3305 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), PROTO_UDP, |
| 3285 &request, kIceUfrag[1], false); | 3306 &request, kIceUfrag[1], false); |
| 3286 conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3307 conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| 3287 ASSERT_TRUE(conn1 != nullptr); | 3308 ASSERT_TRUE(conn1 != nullptr); |
| 3288 EXPECT_EQ(conn1->remote_candidate().priority(), remote_priority); | 3309 EXPECT_EQ(conn1->remote_candidate().priority(), remote_priority); |
| 3289 | 3310 |
| 3290 // conn3, a real prflx connection, should have prflx priority. | 3311 // conn3, a real prflx connection, should have prflx priority. |
| 3291 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 1), PROTO_UDP, | 3312 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 1), PROTO_UDP, |
| 3292 &request, kIceUfrag[1], false); | 3313 &request, kIceUfrag[1], false); |
| 3293 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 1); | 3314 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 1); |
| 3294 ASSERT_TRUE(conn3 != nullptr); | 3315 ASSERT_TRUE(conn3 != nullptr); |
| 3295 EXPECT_EQ(conn3->remote_candidate().priority(), prflx_priority); | 3316 EXPECT_EQ(conn3->remote_candidate().priority(), prflx_priority); |
| 3296 } | 3317 } |
| 3297 | 3318 |
| 3298 TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) { | 3319 TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) { |
| 3320 rtc::ScopedFakeClock clock; |
| 3299 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3321 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 3300 P2PTransportChannel ch("receiving state change", 1, &pa); | 3322 P2PTransportChannel ch("receiving state change", 1, &pa); |
| 3301 PrepareChannel(&ch); | 3323 PrepareChannel(&ch); |
| 3302 // Default receiving timeout and checking receiving interval should not be too | 3324 // Default receiving timeout and checking receiving interval should not be too |
| 3303 // small. | 3325 // small. |
| 3304 EXPECT_LE(1000, ch.receiving_timeout()); | 3326 EXPECT_LE(1000, ch.receiving_timeout()); |
| 3305 EXPECT_LE(200, ch.check_receiving_interval()); | 3327 EXPECT_LE(200, ch.check_receiving_interval()); |
| 3306 ch.SetIceConfig(CreateIceConfig(500, GATHER_ONCE)); | 3328 ch.SetIceConfig(CreateIceConfig(500, GATHER_ONCE)); |
| 3307 EXPECT_EQ(500, ch.receiving_timeout()); | 3329 EXPECT_EQ(500, ch.receiving_timeout()); |
| 3308 EXPECT_EQ(50, ch.check_receiving_interval()); | 3330 EXPECT_EQ(50, ch.check_receiving_interval()); |
| 3309 ch.MaybeStartGathering(); | 3331 ch.MaybeStartGathering(); |
| 3310 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); | 3332 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); |
| 3311 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3333 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1, &clock); |
| 3312 ASSERT_TRUE(conn1 != nullptr); | 3334 ASSERT_TRUE(conn1 != nullptr); |
| 3313 | 3335 |
| 3314 conn1->ReceivedPing(); | 3336 conn1->ReceivedPing(); |
| 3315 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); | 3337 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); |
| 3316 EXPECT_TRUE_WAIT(ch.receiving(), 1000); | 3338 EXPECT_TRUE_SIMULATED_WAIT(ch.receiving(), kShortTimeout, clock); |
| 3317 EXPECT_TRUE_WAIT(!ch.receiving(), 1000); | 3339 EXPECT_TRUE_SIMULATED_WAIT(!ch.receiving(), kShortTimeout, clock); |
| 3318 } | 3340 } |
| 3319 | 3341 |
| 3320 // The controlled side will select a connection as the "selected connection" | 3342 // The controlled side will select a connection as the "selected connection" |
| 3321 // based on priority until the controlling side nominates a connection, at which | 3343 // based on priority until the controlling side nominates a connection, at which |
| 3322 // point the controlled side will select that connection as the | 3344 // point the controlled side will select that connection as the |
| 3323 // "selected connection". Plus, SignalSelectedCandidatePair will be fired if the | 3345 // "selected connection". Plus, SignalSelectedCandidatePair will be fired if the |
| 3324 // selected connection changes and SignalReadyToSend will be fired if the new | 3346 // selected connection changes and SignalReadyToSend will be fired if the new |
| 3325 // selected connection is writable. | 3347 // selected connection is writable. |
| 3326 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { | 3348 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { |
| 3327 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3349 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3784 ch.SetIceConfig(CreateIceConfig(500, GATHER_ONCE)); | 3806 ch.SetIceConfig(CreateIceConfig(500, GATHER_ONCE)); |
| 3785 // Wait until conn2 becomes not receiving. | 3807 // Wait until conn2 becomes not receiving. |
| 3786 EXPECT_TRUE_SIMULATED_WAIT(!conn2->receiving(), kMediumTimeout, clock); | 3808 EXPECT_TRUE_SIMULATED_WAIT(!conn2->receiving(), kMediumTimeout, clock); |
| 3787 | 3809 |
| 3788 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 1)); | 3810 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 1)); |
| 3789 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3, &clock); | 3811 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3, &clock); |
| 3790 ASSERT_TRUE(conn3 != nullptr); | 3812 ASSERT_TRUE(conn3 != nullptr); |
| 3791 // The selected connection should still be conn2. Even through conn3 has lower | 3813 // The selected connection should still be conn2. Even through conn3 has lower |
| 3792 // priority and is not receiving/writable, it is not pruned because the | 3814 // priority and is not receiving/writable, it is not pruned because the |
| 3793 // selected connection is not receiving. | 3815 // selected connection is not receiving. |
| 3794 SIMULATED_WAIT(conn3->pruned(), 1000, clock); | 3816 SIMULATED_WAIT(conn3->pruned(), kShortTimeout, clock); |
| 3795 EXPECT_FALSE(conn3->pruned()); | 3817 EXPECT_FALSE(conn3->pruned()); |
| 3796 } | 3818 } |
| 3797 | 3819 |
| 3798 TEST_F(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) { | 3820 TEST_F(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) { |
| 3799 rtc::ScopedFakeClock clock; | 3821 rtc::ScopedFakeClock clock; |
| 3800 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3822 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 3801 P2PTransportChannel ch("test channel", 1, &pa); | 3823 P2PTransportChannel ch("test channel", 1, &pa); |
| 3802 PrepareChannel(&ch); | 3824 PrepareChannel(&ch); |
| 3803 ch.SetIceRole(ICEROLE_CONTROLLED); | 3825 ch.SetIceRole(ICEROLE_CONTROLLED); |
| 3804 ch.MaybeStartGathering(); | 3826 ch.MaybeStartGathering(); |
| 3805 Connection* conn1 = | 3827 Connection* conn1 = |
| 3806 CreateConnectionWithCandidate(ch, clock, "1.1.1.1", 1, 100, true); | 3828 CreateConnectionWithCandidate(ch, clock, "1.1.1.1", 1, 100, true); |
| 3807 ASSERT_TRUE(conn1 != nullptr); | 3829 ASSERT_TRUE(conn1 != nullptr); |
| 3808 Connection* conn2 = | 3830 Connection* conn2 = |
| 3809 CreateConnectionWithCandidate(ch, clock, "2.2.2.2", 2, 200, false); | 3831 CreateConnectionWithCandidate(ch, clock, "2.2.2.2", 2, 200, false); |
| 3810 ASSERT_TRUE(conn2 != nullptr); | 3832 ASSERT_TRUE(conn2 != nullptr); |
| 3811 // Even if conn1 is writable, nominated, receiving data, it should not prune | 3833 // Even if conn1 is writable, nominated, receiving data, it should not prune |
| 3812 // conn2. | 3834 // conn2. |
| 3813 NominateConnection(conn1); | 3835 NominateConnection(conn1); |
| 3814 SIMULATED_WAIT(false, 1, clock); | 3836 SIMULATED_WAIT(false, 1, clock); |
| 3815 conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 3837 conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 3816 SIMULATED_WAIT(conn2->pruned(), 100, clock); | 3838 SIMULATED_WAIT(conn2->pruned(), 100, clock); |
| 3817 EXPECT_FALSE(conn2->pruned()); | 3839 EXPECT_FALSE(conn2->pruned()); |
| 3818 } | 3840 } |
| 3819 | 3841 |
| 3820 // Test that GetState returns the state correctly. | 3842 // Test that GetState returns the state correctly. |
| 3821 TEST_F(P2PTransportChannelPingTest, TestGetState) { | 3843 TEST_F(P2PTransportChannelPingTest, TestGetState) { |
| 3844 rtc::ScopedFakeClock clock; |
| 3822 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3845 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 3823 P2PTransportChannel ch("test channel", 1, &pa); | 3846 P2PTransportChannel ch("test channel", 1, &pa); |
| 3824 PrepareChannel(&ch); | 3847 PrepareChannel(&ch); |
| 3825 ch.MaybeStartGathering(); | 3848 ch.MaybeStartGathering(); |
| 3826 EXPECT_EQ(TransportChannelState::STATE_INIT, ch.GetState()); | 3849 EXPECT_EQ(TransportChannelState::STATE_INIT, ch.GetState()); |
| 3827 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 3850 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
| 3828 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); | 3851 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); |
| 3829 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3852 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1, &clock); |
| 3830 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3853 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2, &clock); |
| 3831 ASSERT_TRUE(conn1 != nullptr); | 3854 ASSERT_TRUE(conn1 != nullptr); |
| 3832 ASSERT_TRUE(conn2 != nullptr); | 3855 ASSERT_TRUE(conn2 != nullptr); |
| 3833 // Now there are two connections, so the transport channel is connecting. | 3856 // Now there are two connections, so the transport channel is connecting. |
| 3834 EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState()); | 3857 EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState()); |
| 3835 // |conn1| becomes writable and receiving; it then should prune |conn2|. | 3858 // |conn1| becomes writable and receiving; it then should prune |conn2|. |
| 3836 conn1->ReceivedPingResponse(LOW_RTT, "id"); | 3859 conn1->ReceivedPingResponse(LOW_RTT, "id"); |
| 3837 EXPECT_TRUE_WAIT(conn2->pruned(), 1000); | 3860 EXPECT_TRUE_SIMULATED_WAIT(conn2->pruned(), kShortTimeout, clock); |
| 3838 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); | 3861 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); |
| 3839 conn1->Prune(); // All connections are pruned. | 3862 conn1->Prune(); // All connections are pruned. |
| 3840 // Need to wait until the channel state is updated. | 3863 // Need to wait until the channel state is updated. |
| 3841 EXPECT_EQ_WAIT(TransportChannelState::STATE_FAILED, ch.GetState(), 1000); | 3864 EXPECT_EQ_SIMULATED_WAIT(TransportChannelState::STATE_FAILED, ch.GetState(), |
| 3865 kShortTimeout, clock); |
| 3842 } | 3866 } |
| 3843 | 3867 |
| 3844 // Test that when a low-priority connection is pruned, it is not deleted | 3868 // Test that when a low-priority connection is pruned, it is not deleted |
| 3845 // right away, and it can become active and be pruned again. | 3869 // right away, and it can become active and be pruned again. |
| 3846 TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { | 3870 TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { |
| 3847 rtc::ScopedFakeClock clock; | 3871 rtc::ScopedFakeClock clock; |
| 3848 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3872 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 3849 P2PTransportChannel ch("test channel", 1, &pa); | 3873 P2PTransportChannel ch("test channel", 1, &pa); |
| 3850 PrepareChannel(&ch); | 3874 PrepareChannel(&ch); |
| 3851 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | 3875 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 conn1->ReceivedPingResponse(LOW_RTT, "id"); | 3911 conn1->ReceivedPingResponse(LOW_RTT, "id"); |
| 3888 EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout, | 3912 EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout, |
| 3889 clock); | 3913 clock); |
| 3890 EXPECT_TRUE_SIMULATED_WAIT(!conn2->active(), kDefaultTimeout, clock); | 3914 EXPECT_TRUE_SIMULATED_WAIT(!conn2->active(), kDefaultTimeout, clock); |
| 3891 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); | 3915 EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState()); |
| 3892 } | 3916 } |
| 3893 | 3917 |
| 3894 // Test that if all connections in a channel has timed out on writing, they | 3918 // Test that if all connections in a channel has timed out on writing, they |
| 3895 // will all be deleted. We use Prune to simulate write_time_out. | 3919 // will all be deleted. We use Prune to simulate write_time_out. |
| 3896 TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { | 3920 TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { |
| 3921 rtc::ScopedFakeClock clock; |
| 3897 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3922 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 3898 P2PTransportChannel ch("test channel", 1, &pa); | 3923 P2PTransportChannel ch("test channel", 1, &pa); |
| 3899 PrepareChannel(&ch); | 3924 PrepareChannel(&ch); |
| 3900 ch.MaybeStartGathering(); | 3925 ch.MaybeStartGathering(); |
| 3901 // Have one connection only but later becomes write-time-out. | 3926 // Have one connection only but later becomes write-time-out. |
| 3902 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); | 3927 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100)); |
| 3903 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 3928 Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1, &clock); |
| 3904 ASSERT_TRUE(conn1 != nullptr); | 3929 ASSERT_TRUE(conn1 != nullptr); |
| 3905 conn1->ReceivedPing(); // Becomes receiving | 3930 conn1->ReceivedPing(); // Becomes receiving |
| 3906 conn1->Prune(); | 3931 conn1->Prune(); |
| 3907 EXPECT_TRUE_WAIT(ch.connections().empty(), 1000); | 3932 EXPECT_TRUE_SIMULATED_WAIT(ch.connections().empty(), kShortTimeout, clock); |
| 3908 | 3933 |
| 3909 // Have two connections but both become write-time-out later. | 3934 // Have two connections but both become write-time-out later. |
| 3910 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); | 3935 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1)); |
| 3911 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 3936 Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2, &clock); |
| 3912 ASSERT_TRUE(conn2 != nullptr); | 3937 ASSERT_TRUE(conn2 != nullptr); |
| 3913 conn2->ReceivedPing(); // Becomes receiving | 3938 conn2->ReceivedPing(); // Becomes receiving |
| 3914 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 2)); | 3939 ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "3.3.3.3", 3, 2)); |
| 3915 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 3940 Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3, &clock); |
| 3916 ASSERT_TRUE(conn3 != nullptr); | 3941 ASSERT_TRUE(conn3 != nullptr); |
| 3917 conn3->ReceivedPing(); // Becomes receiving | 3942 conn3->ReceivedPing(); // Becomes receiving |
| 3918 // Now prune both conn2 and conn3; they will be deleted soon. | 3943 // Now prune both conn2 and conn3; they will be deleted soon. |
| 3919 conn2->Prune(); | 3944 conn2->Prune(); |
| 3920 conn3->Prune(); | 3945 conn3->Prune(); |
| 3921 EXPECT_TRUE_WAIT(ch.connections().empty(), 1000); | 3946 EXPECT_TRUE_SIMULATED_WAIT(ch.connections().empty(), kShortTimeout, clock); |
| 3922 } | 3947 } |
| 3923 | 3948 |
| 3924 // Tests that after a port allocator session is started, it will be stopped | 3949 // Tests that after a port allocator session is started, it will be stopped |
| 3925 // when a new connection becomes writable and receiving. Also tests that if a | 3950 // when a new connection becomes writable and receiving. Also tests that if a |
| 3926 // connection belonging to an old session becomes writable, it won't stop | 3951 // connection belonging to an old session becomes writable, it won't stop |
| 3927 // the current port allocator session. | 3952 // the current port allocator session. |
| 3928 TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { | 3953 TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { |
| 3929 FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 3954 FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 3930 P2PTransportChannel ch("test channel", 1, &pa); | 3955 P2PTransportChannel ch("test channel", 1, &pa); |
| 3931 PrepareChannel(&ch); | 3956 PrepareChannel(&ch); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4235 | 4260 |
| 4236 // TCP Relay/Relay is the next. | 4261 // TCP Relay/Relay is the next. |
| 4237 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4262 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
| 4238 TCP_PROTOCOL_NAME); | 4263 TCP_PROTOCOL_NAME); |
| 4239 | 4264 |
| 4240 // Finally, Local/Relay will be pinged. | 4265 // Finally, Local/Relay will be pinged. |
| 4241 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4266 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
| 4242 } | 4267 } |
| 4243 | 4268 |
| 4244 } // namespace cricket { | 4269 } // namespace cricket { |
| OLD | NEW |