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 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1666 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
1667 ep1_ch1()->selected_connection()->port())); | 1667 ep1_ch1()->selected_connection()->port())); |
1668 EXPECT_NE(pooled_ports_2.end(), | 1668 EXPECT_NE(pooled_ports_2.end(), |
1669 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1669 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
1670 ep2_ch1()->selected_connection()->port())); | 1670 ep2_ch1()->selected_connection()->port())); |
1671 } | 1671 } |
1672 | 1672 |
1673 // Test that when the "presume_writable_when_fully_relayed" flag is set to | 1673 // Test that when the "presume_writable_when_fully_relayed" flag is set to |
1674 // true and there's a TURN-TURN candidate pair, it's presumed to be writable | 1674 // true and there's a TURN-TURN candidate pair, it's presumed to be writable |
1675 // as soon as it's created. | 1675 // as soon as it's created. |
| 1676 // TODO(deadbeef): Move this and other "presumed writable" tests into a test |
| 1677 // class that operates on a single P2PTransportChannel, once an appropriate one |
| 1678 // (which supports TURN servers and TURN candidate gathering) is available. |
1676 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { | 1679 TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { |
1677 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1680 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
1678 kDefaultPortAllocatorFlags); | 1681 kDefaultPortAllocatorFlags); |
1679 // Only configure one channel so we can control when the remote candidate | 1682 // Only configure one channel so we can control when the remote candidate |
1680 // is added. | 1683 // is added. |
1681 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( | 1684 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
1682 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); | 1685 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
1683 IceConfig config; | 1686 IceConfig config; |
1684 config.presume_writable_when_fully_relayed = true; | 1687 config.presume_writable_when_fully_relayed = true; |
1685 ep1_ch1()->SetIceConfig(config); | 1688 ep1_ch1()->SetIceConfig(config); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); | 1794 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); |
1792 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); | 1795 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); |
1793 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); | 1796 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); |
1794 EXPECT_TRUE(ep1_ch1()->writable()); | 1797 EXPECT_TRUE(ep1_ch1()->writable()); |
1795 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); | 1798 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); |
1796 EXPECT_NE(old_selected_connection, ep1_ch1()->selected_connection()); | 1799 EXPECT_NE(old_selected_connection, ep1_ch1()->selected_connection()); |
1797 // Explitly destroy channels, before fake clock is destroyed. | 1800 // Explitly destroy channels, before fake clock is destroyed. |
1798 DestroyChannels(); | 1801 DestroyChannels(); |
1799 } | 1802 } |
1800 | 1803 |
| 1804 // Ensure that "SignalReadyToSend" is fired as expected with a "presumed |
| 1805 // writable" connection. Previously this did not work. |
| 1806 TEST_F(P2PTransportChannelTest, SignalReadyToSendWithPresumedWritable) { |
| 1807 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1808 kDefaultPortAllocatorFlags); |
| 1809 // Only test one endpoint, so we can ensure the connection doesn't receive a |
| 1810 // binding response and advance beyond being "presumed" writable. |
| 1811 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
| 1812 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
| 1813 IceConfig config; |
| 1814 config.presume_writable_when_fully_relayed = true; |
| 1815 ep1_ch1()->SetIceConfig(config); |
| 1816 ep1_ch1()->MaybeStartGathering(); |
| 1817 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, |
| 1818 ep1_ch1()->gathering_state(), kDefaultTimeout); |
| 1819 ep1_ch1()->AddRemoteCandidate( |
| 1820 CreateUdpCandidate(RELAY_PORT_TYPE, "1.1.1.1", 1, 0)); |
| 1821 // Sanity checking the type of the connection. |
| 1822 EXPECT_TRUE(ep1_ch1()->selected_connection() != nullptr); |
| 1823 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); |
| 1824 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); |
| 1825 |
| 1826 // Tell the socket server to block packets (returning EWOULDBLOCK). |
| 1827 virtual_socket_server()->SetSendingBlocked(true); |
| 1828 const char* data = "test"; |
| 1829 int len = static_cast<int>(strlen(data)); |
| 1830 EXPECT_EQ(-1, SendData(ep1_ch1(), data, len)); |
| 1831 |
| 1832 // Reset |ready_to_send_| flag, which is set to true if the event fires as it |
| 1833 // should. |
| 1834 GetEndpoint(0)->ready_to_send_ = false; |
| 1835 virtual_socket_server()->SetSendingBlocked(false); |
| 1836 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); |
| 1837 EXPECT_EQ(len, SendData(ep1_ch1(), data, len)); |
| 1838 } |
| 1839 |
1801 // Test what happens when we have 2 users behind the same NAT. This can lead | 1840 // Test what happens when we have 2 users behind the same NAT. This can lead |
1802 // to interesting behavior because the STUN server will only give out the | 1841 // to interesting behavior because the STUN server will only give out the |
1803 // address of the outermost NAT. | 1842 // address of the outermost NAT. |
1804 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { | 1843 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { |
1805 protected: | 1844 protected: |
1806 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { | 1845 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { |
1807 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); | 1846 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); |
1808 rtc::NATSocketServer::Translator* outer_nat = | 1847 rtc::NATSocketServer::Translator* outer_nat = |
1809 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], | 1848 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], |
1810 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); | 1849 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); |
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4001 | 4040 |
4002 // TCP Relay/Relay is the next. | 4041 // TCP Relay/Relay is the next. |
4003 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4042 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
4004 TCP_PROTOCOL_NAME); | 4043 TCP_PROTOCOL_NAME); |
4005 | 4044 |
4006 // Finally, Local/Relay will be pinged. | 4045 // Finally, Local/Relay will be pinged. |
4007 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4046 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
4008 } | 4047 } |
4009 | 4048 |
4010 } // namespace cricket { | 4049 } // namespace cricket { |
OLD | NEW |