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

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

Issue 2068263003: Do not delete a connection in the turn port with permission error or refresh error. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . 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 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 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 // highest priority one. 2047 // highest priority one.
2048 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch)); 2048 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
2049 2049
2050 // Receiving a ping causes a triggered check which should make conn1 2050 // Receiving a ping causes a triggered check which should make conn1
2051 // be pinged first instead of conn2, even though conn2 has a higher 2051 // be pinged first instead of conn2, even though conn2 has a higher
2052 // priority. 2052 // priority.
2053 conn1->ReceivedPing(); 2053 conn1->ReceivedPing();
2054 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); 2054 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch));
2055 } 2055 }
2056 2056
2057 TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) {
2058 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2059 cricket::P2PTransportChannel ch("trigger checks", 1, &pa);
2060 PrepareChannel(&ch);
2061 ch.Connect();
2062 ch.MaybeStartGathering();
2063 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
2064 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 2));
2065
2066 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
2067 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
2068 ASSERT_TRUE(conn1 != nullptr);
2069 ASSERT_TRUE(conn2 != nullptr);
2070
2071 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
2072 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch));
2073 conn1->ReceivedPingResponse();
2074 ASSERT_TRUE(conn1->writable());
2075 conn1->ReceivedPing();
2076
2077 // Ping received, but the connection is already writable, so no
2078 // "triggered check" and conn2 is pinged before conn1 because it has
2079 // a higher priority.
2080 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
honghaiz3 2016/06/16 00:59:57 I only moved this test up so that two tests on tig
2081 }
2082
2057 TEST_F(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) { 2083 TEST_F(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) {
2058 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); 2084 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2059 cricket::P2PTransportChannel ch("ping sufficiently", 1, &pa); 2085 cricket::P2PTransportChannel ch("ping sufficiently", 1, &pa);
2060 PrepareChannel(&ch); 2086 PrepareChannel(&ch);
2061 ch.Connect(); 2087 ch.Connect();
2062 ch.MaybeStartGathering(); 2088 ch.MaybeStartGathering();
2063 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1)); 2089 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
2064 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 2)); 2090 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 2));
2065 2091
2066 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); 2092 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
2067 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); 2093 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
2068 ASSERT_TRUE(conn1 != nullptr); 2094 ASSERT_TRUE(conn1 != nullptr);
2069 ASSERT_TRUE(conn2 != nullptr); 2095 ASSERT_TRUE(conn2 != nullptr);
2070 2096
2071 // Low-priority connection becomes writable so that the other connection 2097 // Low-priority connection becomes writable so that the other connection
2072 // is not pruned. 2098 // is not pruned.
2073 conn1->ReceivedPingResponse(); 2099 conn1->ReceivedPingResponse();
2074 EXPECT_TRUE_WAIT( 2100 EXPECT_TRUE_WAIT(
2075 conn1->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL && 2101 conn1->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL &&
2076 conn2->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL, 2102 conn2->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL,
2077 kDefaultTimeout); 2103 kDefaultTimeout);
2078 } 2104 }
2079 2105
2080 TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { 2106 TEST_F(P2PTransportChannelPingTest, TestFailedConnectionNotPingable) {
2081 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); 2107 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2082 cricket::P2PTransportChannel ch("trigger checks", 1, &pa); 2108 cricket::P2PTransportChannel ch("do not ping failed connection", 1, &pa);
pthatcher1 2016/06/16 22:34:21 do not => Do not failed connection => failed conne
honghaiz3 2016/06/16 23:22:53 Done.
2083 PrepareChannel(&ch); 2109 PrepareChannel(&ch);
2084 ch.Connect(); 2110 ch.Connect();
2085 ch.MaybeStartGathering(); 2111 ch.MaybeStartGathering();
2086 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1)); 2112 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
2087 ch.AddRemoteCandidate(CreateHostCandidate("2.2.2.2", 2, 2));
2088 2113
2089 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); 2114 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
2090 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
2091 ASSERT_TRUE(conn1 != nullptr); 2115 ASSERT_TRUE(conn1 != nullptr);
2092 ASSERT_TRUE(conn2 != nullptr);
2093 2116
2094 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch)); 2117 EXPECT_EQ(conn1, ch.FindNextPingableConnection());
2095 EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); 2118 conn1->Prune(); // A pruned connection may still be pingable.
2096 conn1->ReceivedPingResponse(); 2119 EXPECT_EQ(conn1, ch.FindNextPingableConnection());
2097 ASSERT_TRUE(conn1->writable()); 2120 conn1->FailAndPrune();
2098 conn1->ReceivedPing(); 2121 EXPECT_TRUE(nullptr == ch.FindNextPingableConnection());
2099
2100 // Ping received, but the connection is already writable, so no
2101 // "triggered check" and conn2 is pinged before conn1 because it has
2102 // a higher priority.
2103 EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
2104 } 2122 }
2105 2123
2106 TEST_F(P2PTransportChannelPingTest, TestSignalStateChanged) { 2124 TEST_F(P2PTransportChannelPingTest, TestSignalStateChanged) {
2107 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); 2125 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2108 cricket::P2PTransportChannel ch("state change", 1, &pa); 2126 cricket::P2PTransportChannel ch("state change", 1, &pa);
2109 PrepareChannel(&ch); 2127 PrepareChannel(&ch);
2110 ch.Connect(); 2128 ch.Connect();
2111 ch.MaybeStartGathering(); 2129 ch.MaybeStartGathering();
2112 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1)); 2130 ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
2113 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); 2131 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 2934
2917 // TCP Relay/Relay is the next. 2935 // TCP Relay/Relay is the next.
2918 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, 2936 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE,
2919 cricket::RELAY_PORT_TYPE, 2937 cricket::RELAY_PORT_TYPE,
2920 cricket::TCP_PROTOCOL_NAME); 2938 cricket::TCP_PROTOCOL_NAME);
2921 2939
2922 // Finally, Local/Relay will be pinged. 2940 // Finally, Local/Relay will be pinged.
2923 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, 2941 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE,
2924 cricket::RELAY_PORT_TYPE); 2942 cricket::RELAY_PORT_TYPE);
2925 } 2943 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698