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

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

Issue 2374183005: Emit SignalReadyToSend even for "presumed writable" connections. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | webrtc/p2p/base/port.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0)); 1799 CreateUdpCandidate(RELAY_PORT_TYPE, "2.2.2.2", 2, 0));
1800 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type()); 1800 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type());
1801 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type()); 1801 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type());
1802 EXPECT_TRUE(ep1_ch1()->writable()); 1802 EXPECT_TRUE(ep1_ch1()->writable());
1803 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_); 1803 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_);
1804 EXPECT_NE(old_selected_connection, ep1_ch1()->selected_connection()); 1804 EXPECT_NE(old_selected_connection, ep1_ch1()->selected_connection());
1805 // Explitly destroy channels, before fake clock is destroyed. 1805 // Explitly destroy channels, before fake clock is destroyed.
1806 DestroyChannels(); 1806 DestroyChannels();
1807 } 1807 }
1808 1808
1809 // Ensure that "SignalReadyToSend" is fired as expected with a "presumed
1810 // writable" connection. Previously this did not work.
1811 TEST_F(P2PTransportChannelTest, SignalReadyToSendWithPresumedWritable) {
1812 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
1813 kDefaultPortAllocatorFlags);
1814 // Only test one endpoint, so we can ensure the connection doesn't receive a
honghaiz3 2016/09/29 20:04:51 If you only test one endpoint, would it be better
Taylor Brandstetter 2016/09/29 21:09:09 I could, but then I'd have to add a TURN server to
honghaiz3 2016/09/29 21:47:59 I will leave it for you to decide. If you wait for
Taylor Brandstetter 2016/09/29 22:24:11 I looked into this, but the TURN server and networ
1815 // binding response and advance beyond being "presumed" writable.
honghaiz3 2016/09/29 20:04:51 nit: s/advance/advances/ ?
Taylor Brandstetter 2016/09/29 21:09:09 I think "advances" is correct here ("doesn't advan
honghaiz3 2016/09/29 21:47:59 I thought you meant (does not receive) and (advanc
1816 GetEndpoint(0)->cd1_.ch_.reset(CreateChannel(
1817 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1]));
1818 IceConfig config;
1819 config.presume_writable_when_fully_relayed = true;
1820 ep1_ch1()->SetIceConfig(config);
1821 ep1_ch1()->MaybeStartGathering();
1822 EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete,
1823 ep1_ch1()->gathering_state(), kDefaultTimeout);
1824 ep1_ch1()->AddRemoteCandidate(
1825 CreateUdpCandidate(RELAY_PORT_TYPE, "1.1.1.1", 1, 0));
1826 // Sanity checking the type of the connection.
1827 EXPECT_TRUE(ep1_ch1()->selected_connection() != nullptr);
1828 EXPECT_EQ(RELAY_PORT_TYPE, LocalCandidate(ep1_ch1())->type());
1829 EXPECT_EQ(RELAY_PORT_TYPE, RemoteCandidate(ep1_ch1())->type());
1830
1831 // Tell the socket server to block packets (returning EWOULDBLOCK).
1832 virtual_socket_server()->SetSendingBlocked(true);
1833 const char* data = "test";
1834 int len = static_cast<int>(strlen(data));
1835 EXPECT_EQ(-1, SendData(ep1_ch1(), data, len));
1836
1837 // Reset |ready_to_send_| flag, which is set to true if the event fires as it
1838 // should.
1839 GetEndpoint(0)->ready_to_send_ = false;
1840 virtual_socket_server()->SetSendingBlocked(false);
1841 EXPECT_TRUE(GetEndpoint(0)->ready_to_send_);
1842 EXPECT_EQ(len, SendData(ep1_ch1(), data, len));
1843 }
1844
1809 // Test what happens when we have 2 users behind the same NAT. This can lead 1845 // Test what happens when we have 2 users behind the same NAT. This can lead
1810 // to interesting behavior because the STUN server will only give out the 1846 // to interesting behavior because the STUN server will only give out the
1811 // address of the outermost NAT. 1847 // address of the outermost NAT.
1812 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { 1848 class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase {
1813 protected: 1849 protected:
1814 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) { 1850 void ConfigureEndpoints(Config nat_type, Config config1, Config config2) {
1815 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC); 1851 ASSERT(nat_type >= NAT_FULL_CONE && nat_type <= NAT_SYMMETRIC);
1816 rtc::NATSocketServer::Translator* outer_nat = 1852 rtc::NATSocketServer::Translator* outer_nat =
1817 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0], 1853 nat()->AddTranslator(kPublicAddrs[0], kNatAddrs[0],
1818 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); 1854 static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE));
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4013 4049
4014 // TCP Relay/Relay is the next. 4050 // TCP Relay/Relay is the next.
4015 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, 4051 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE,
4016 TCP_PROTOCOL_NAME); 4052 TCP_PROTOCOL_NAME);
4017 4053
4018 // Finally, Local/Relay will be pinged. 4054 // Finally, Local/Relay will be pinged.
4019 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); 4055 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE);
4020 } 4056 }
4021 4057
4022 } // namespace cricket { 4058 } // namespace cricket {
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698