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

Unified Diff: webrtc/p2p/base/port_unittest.cc

Issue 1544003002: Delete a connection after it is pruned or becomes write_timeout (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix comments Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port_unittest.cc
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index 4bff58adc7e176728800ca2a4fcffcc1c784d99b..34806d9a79e0b8e8cc36118cde518bd1989a6eda 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -1255,19 +1255,26 @@ TEST_F(PortTest, TestConnectionDead) {
ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout);
ASSERT_EQ_WAIT(1, ch2.complete_count(), kTimeout);
+ // Test case that the connection has never received anything.
uint32_t before_created = rtc::Time();
ch1.CreateConnection(GetCandidate(port2));
uint32_t after_created = rtc::Time();
Connection* conn = ch1.conn();
ASSERT(conn != nullptr);
- // If the connection has never received anything, it will be dead after
- // MIN_CONNECTION_LIFETIME
+ // It is not dead if it is after MIN_CONNECTION_LIFETIME but not pruned.
+ conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1);
+ rtc::Thread::Current()->ProcessMessages(0);
+ EXPECT_TRUE(ch1.conn() != nullptr);
+ // It is not dead if it is before MIN_CONNECTION_LIFETIME and pruned.
conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1);
- rtc::Thread::Current()->ProcessMessages(100);
+ conn->Prune();
+ rtc::Thread::Current()->ProcessMessages(0);
EXPECT_TRUE(ch1.conn() != nullptr);
+ // It will be dead after MIN_CONNECTION_LIFETIME and pruned.
conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1);
EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout);
+ // Test case that the connection has received something.
// Create a connection again and receive a ping.
ch1.CreateConnection(GetCandidate(port2));
conn = ch1.conn();
« 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