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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 AddAddress(1, kAlternateAddrs[1]); | 1532 AddAddress(1, kAlternateAddrs[1]); |
1533 AddAddress(1, kPublicAddrs[1]); | 1533 AddAddress(1, kPublicAddrs[1]); |
1534 | 1534 |
1535 // Use only local ports for simplicity. | 1535 // Use only local ports for simplicity. |
1536 SetAllocatorFlags(0, kOnlyLocalPorts); | 1536 SetAllocatorFlags(0, kOnlyLocalPorts); |
1537 SetAllocatorFlags(1, kOnlyLocalPorts); | 1537 SetAllocatorFlags(1, kOnlyLocalPorts); |
1538 | 1538 |
1539 // Create channels and let them go writable, as usual. | 1539 // Create channels and let them go writable, as usual. |
1540 CreateChannels(1); | 1540 CreateChannels(1); |
1541 | 1541 |
| 1542 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1543 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1544 1000, 1000); |
| 1545 EXPECT_TRUE( |
| 1546 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1547 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1548 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1549 |
1542 // Make the receiving timeout shorter for testing. | 1550 // Make the receiving timeout shorter for testing. |
1543 cricket::IceConfig config = CreateIceConfig(1000, false); | 1551 cricket::IceConfig config = CreateIceConfig(1000, false); |
1544 ep1_ch1()->SetIceConfig(config); | 1552 ep1_ch1()->SetIceConfig(config); |
1545 ep2_ch1()->SetIceConfig(config); | 1553 ep2_ch1()->SetIceConfig(config); |
1546 | 1554 |
1547 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
1548 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
1549 1000); | |
1550 EXPECT_TRUE( | |
1551 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | |
1552 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | |
1553 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | |
1554 | |
1555 // Blackhole any traffic to or from the public addrs. | 1555 // Blackhole any traffic to or from the public addrs. |
1556 LOG(LS_INFO) << "Failing over..."; | 1556 LOG(LS_INFO) << "Failing over..."; |
1557 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); | 1557 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[1]); |
1558 // The best connections will switch, so keep references to them. | 1558 // The best connections will switch, so keep references to them. |
1559 const cricket::Connection* best_connection1 = ep1_ch1()->best_connection(); | 1559 const cricket::Connection* best_connection1 = ep1_ch1()->best_connection(); |
1560 const cricket::Connection* best_connection2 = ep2_ch1()->best_connection(); | 1560 const cricket::Connection* best_connection2 = ep2_ch1()->best_connection(); |
1561 // We should detect loss of receiving within 1 second or so. | 1561 // We should detect loss of receiving within 1 second or so. |
1562 EXPECT_TRUE_WAIT( | 1562 EXPECT_TRUE_WAIT( |
1563 !best_connection1->receiving() && !best_connection2->receiving(), 3000); | 1563 !best_connection1->receiving() && !best_connection2->receiving(), 3000); |
1564 | 1564 |
(...skipping 19 matching lines...) Expand all Loading... |
1584 AddAddress(0, kAlternateAddrs[0]); | 1584 AddAddress(0, kAlternateAddrs[0]); |
1585 AddAddress(0, kPublicAddrs[0]); | 1585 AddAddress(0, kPublicAddrs[0]); |
1586 AddAddress(1, kPublicAddrs[1]); | 1586 AddAddress(1, kPublicAddrs[1]); |
1587 | 1587 |
1588 // Use only local ports for simplicity. | 1588 // Use only local ports for simplicity. |
1589 SetAllocatorFlags(0, kOnlyLocalPorts); | 1589 SetAllocatorFlags(0, kOnlyLocalPorts); |
1590 SetAllocatorFlags(1, kOnlyLocalPorts); | 1590 SetAllocatorFlags(1, kOnlyLocalPorts); |
1591 | 1591 |
1592 // Create channels and let them go writable, as usual. | 1592 // Create channels and let them go writable, as usual. |
1593 CreateChannels(1); | 1593 CreateChannels(1); |
1594 // Make the receiving timeout shorter for testing. | 1594 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1595 cricket::IceConfig config = CreateIceConfig(1000, false); | 1595 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1596 ep1_ch1()->SetIceConfig(config); | 1596 1000, 1000); |
1597 ep2_ch1()->SetIceConfig(config); | |
1598 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | |
1599 ep2_ch1()->receiving() && ep2_ch1()->writable(), | |
1600 1000); | |
1601 EXPECT_TRUE( | 1597 EXPECT_TRUE( |
1602 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1598 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1603 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1599 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1604 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1600 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1605 | 1601 |
| 1602 // Make the receiving timeout shorter for testing. |
| 1603 cricket::IceConfig config = CreateIceConfig(1000, false); |
| 1604 ep1_ch1()->SetIceConfig(config); |
| 1605 ep2_ch1()->SetIceConfig(config); |
| 1606 |
1606 // Blackhole any traffic to or from the public addrs. | 1607 // Blackhole any traffic to or from the public addrs. |
1607 LOG(LS_INFO) << "Failing over..."; | 1608 LOG(LS_INFO) << "Failing over..."; |
1608 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); | 1609 fw()->AddRule(false, rtc::FP_ANY, rtc::FD_ANY, kPublicAddrs[0]); |
1609 // The best connections will switch, so keep references to them. | 1610 // The best connections will switch, so keep references to them. |
1610 const cricket::Connection* best_connection1 = ep1_ch1()->best_connection(); | 1611 const cricket::Connection* best_connection1 = ep1_ch1()->best_connection(); |
1611 const cricket::Connection* best_connection2 = ep2_ch1()->best_connection(); | 1612 const cricket::Connection* best_connection2 = ep2_ch1()->best_connection(); |
1612 // We should detect loss of receiving within 1 second or so. | 1613 // We should detect loss of receiving within 1 second or so. |
1613 EXPECT_TRUE_WAIT( | 1614 EXPECT_TRUE_WAIT( |
1614 !best_connection1->receiving() && !best_connection2->receiving(), 3000); | 1615 !best_connection1->receiving() && !best_connection2->receiving(), 3000); |
1615 | 1616 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 // It should stop getting ports after a new connection becomes strongly | 2212 // It should stop getting ports after a new connection becomes strongly |
2212 // connected. | 2213 // connected. |
2213 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2214 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
2214 ch.MaybeStartGathering(); | 2215 ch.MaybeStartGathering(); |
2215 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); | 2216 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); |
2216 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2217 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2217 ASSERT_TRUE(conn2 != nullptr); | 2218 ASSERT_TRUE(conn2 != nullptr); |
2218 conn2->ReceivedPingResponse(); // Becomes writable and receiving | 2219 conn2->ReceivedPingResponse(); // Becomes writable and receiving |
2219 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 2220 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
2220 } | 2221 } |
OLD | NEW |