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

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

Issue 1376983002: Do not time out a port if its role switched from controlled to controlling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 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 | « webrtc/p2p/base/port.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 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 // Set up channels and ensure both ports will be deleted. 2403 // Set up channels and ensure both ports will be deleted.
2404 TestChannel ch1(port1); 2404 TestChannel ch1(port1);
2405 TestChannel ch2(port2); 2405 TestChannel ch2(port2);
2406 2406
2407 // Simulate a connection that succeeds, and then is destroyed. 2407 // Simulate a connection that succeeds, and then is destroyed.
2408 StartConnectAndStopChannels(&ch1, &ch2); 2408 StartConnectAndStopChannels(&ch1, &ch2);
2409 2409
2410 // The controlled port should be destroyed after 10 milliseconds. 2410 // The controlled port should be destroyed after 10 milliseconds.
2411 EXPECT_TRUE_WAIT(destroyed(), kTimeout); 2411 EXPECT_TRUE_WAIT(destroyed(), kTimeout);
2412 } 2412 }
2413
2414 // This test case verifies that if the role of a port changes from controlled
2415 // to controlling after all connections fail, the port will not be destroyed.
2416 TEST_F(PortTest, TestControlledToControllingNotDestroyed) {
2417 UDPPort* port1 = CreateUdpPort(kLocalAddr1);
2418 port1->SetIceRole(cricket::ICEROLE_CONTROLLING);
2419 port1->SetIceTiebreaker(kTiebreaker1);
2420
2421 UDPPort* port2 = CreateUdpPort(kLocalAddr2);
2422 ConnectToSignalDestroyed(port2);
2423 port2->set_timeout_delay(10); // milliseconds
2424 port2->SetIceRole(cricket::ICEROLE_CONTROLLED);
2425 port2->SetIceTiebreaker(kTiebreaker2);
2426
2427 // The connection must not be destroyed before a connection is attempted.
2428 EXPECT_FALSE(destroyed());
2429
2430 port1->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT);
2431 port2->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT);
2432
2433 // Set up channels and ensure both ports will be deleted.
2434 TestChannel ch1(port1);
2435 TestChannel ch2(port2);
2436
2437 // Simulate a connection that succeeds, and then is destroyed.
2438 StartConnectAndStopChannels(&ch1, &ch2);
2439 // Switch the role after all connections are destroyed.
2440 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout);
2441 port1->SetIceRole(cricket::ICEROLE_CONTROLLED);
2442 port2->SetIceRole(cricket::ICEROLE_CONTROLLING);
2443
2444 // After the connection is destroyed, the port should not be destroyed.
2445 rtc::Thread::Current()->ProcessMessages(kTimeout);
2446 EXPECT_FALSE(destroyed());
2447 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698