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

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

Issue 1421123003: When all connections timed out on writing, delete them all. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge to head Created 5 years, 1 month 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 | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | no next file » | 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 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 conn2->ReceivedPingResponse(); 2152 conn2->ReceivedPingResponse();
2153 EXPECT_EQ_WAIT(conn2, ch.best_connection(), 1000); 2153 EXPECT_EQ_WAIT(conn2, ch.best_connection(), 1000);
2154 EXPECT_EQ(cricket::TransportChannelState::STATE_CONNECTING, ch.GetState()); 2154 EXPECT_EQ(cricket::TransportChannelState::STATE_CONNECTING, ch.GetState());
2155 2155
2156 // When |conn1| comes back again, |conn2| will be pruned again. 2156 // When |conn1| comes back again, |conn2| will be pruned again.
2157 conn1->ReceivedPingResponse(); 2157 conn1->ReceivedPingResponse();
2158 EXPECT_EQ_WAIT(conn1, ch.best_connection(), 1000); 2158 EXPECT_EQ_WAIT(conn1, ch.best_connection(), 1000);
2159 EXPECT_TRUE_WAIT(!conn2->active(), 1000); 2159 EXPECT_TRUE_WAIT(!conn2->active(), 1000);
2160 EXPECT_EQ(cricket::TransportChannelState::STATE_COMPLETED, ch.GetState()); 2160 EXPECT_EQ(cricket::TransportChannelState::STATE_COMPLETED, ch.GetState());
2161 } 2161 }
2162
2163 // Test that if all connections in a channel has timed out on writing, they
2164 // will all be deleted. We use Prune to simulate write_time_out.
2165 TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) {
2166 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2167 cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa);
2168 PrepareChannel(&ch);
2169 ch.Connect();
2170 ch.MaybeStartGathering();
2171 // Have one connection only but later becomes write-time-out.
2172 ch.AddRemoteCandidate(CreateCandidate("1.1.1.1", 1, 100));
2173 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
2174 ASSERT_TRUE(conn1 != nullptr);
2175 conn1->ReceivedPing(); // Becomes receiving
2176 conn1->Prune();
2177 EXPECT_TRUE_WAIT(ch.connections().empty(), 1000);
2178
2179 // Have two connections but both become write-time-out later.
2180 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 1));
2181 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
2182 ASSERT_TRUE(conn2 != nullptr);
2183 conn2->ReceivedPing(); // Becomes receiving
2184 ch.AddRemoteCandidate(CreateCandidate("3.3.3.3", 3, 2));
2185 cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
2186 ASSERT_TRUE(conn3 != nullptr);
2187 conn3->ReceivedPing(); // Becomes receiving
2188 // Now prune both conn2 and conn3; they will be deleted soon.
2189 conn2->Prune();
2190 conn3->Prune();
2191 EXPECT_TRUE_WAIT(ch.connections().empty(), 1000);
2192 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698