OLD | NEW |
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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 ch1.Start(); | 1293 ch1.Start(); |
1294 ch2.Start(); | 1294 ch2.Start(); |
1295 ASSERT_EQ_WAIT(1, ch1.complete_count(), kDefaultTimeout); | 1295 ASSERT_EQ_WAIT(1, ch1.complete_count(), kDefaultTimeout); |
1296 ASSERT_EQ_WAIT(1, ch2.complete_count(), kDefaultTimeout); | 1296 ASSERT_EQ_WAIT(1, ch2.complete_count(), kDefaultTimeout); |
1297 | 1297 |
1298 // Test case that the connection has never received anything. | 1298 // Test case that the connection has never received anything. |
1299 int64_t before_created = rtc::TimeMillis(); | 1299 int64_t before_created = rtc::TimeMillis(); |
1300 ch1.CreateConnection(GetCandidate(port2)); | 1300 ch1.CreateConnection(GetCandidate(port2)); |
1301 int64_t after_created = rtc::TimeMillis(); | 1301 int64_t after_created = rtc::TimeMillis(); |
1302 Connection* conn = ch1.conn(); | 1302 Connection* conn = ch1.conn(); |
1303 ASSERT(conn != nullptr); | 1303 ASSERT_NE(conn, nullptr); |
1304 // It is not dead if it is after MIN_CONNECTION_LIFETIME but not pruned. | 1304 // It is not dead if it is after MIN_CONNECTION_LIFETIME but not pruned. |
1305 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); | 1305 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); |
1306 rtc::Thread::Current()->ProcessMessages(0); | 1306 rtc::Thread::Current()->ProcessMessages(0); |
1307 EXPECT_TRUE(ch1.conn() != nullptr); | 1307 EXPECT_TRUE(ch1.conn() != nullptr); |
1308 // It is not dead if it is before MIN_CONNECTION_LIFETIME and pruned. | 1308 // It is not dead if it is before MIN_CONNECTION_LIFETIME and pruned. |
1309 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); | 1309 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); |
1310 conn->Prune(); | 1310 conn->Prune(); |
1311 rtc::Thread::Current()->ProcessMessages(0); | 1311 rtc::Thread::Current()->ProcessMessages(0); |
1312 EXPECT_TRUE(ch1.conn() != nullptr); | 1312 EXPECT_TRUE(ch1.conn() != nullptr); |
1313 // It will be dead after MIN_CONNECTION_LIFETIME and pruned. | 1313 // It will be dead after MIN_CONNECTION_LIFETIME and pruned. |
1314 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); | 1314 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); |
1315 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); | 1315 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); |
1316 | 1316 |
1317 // Test case that the connection has received something. | 1317 // Test case that the connection has received something. |
1318 // Create a connection again and receive a ping. | 1318 // Create a connection again and receive a ping. |
1319 ch1.CreateConnection(GetCandidate(port2)); | 1319 ch1.CreateConnection(GetCandidate(port2)); |
1320 conn = ch1.conn(); | 1320 conn = ch1.conn(); |
1321 ASSERT(conn != nullptr); | 1321 ASSERT_NE(conn, nullptr); |
1322 int64_t before_last_receiving = rtc::TimeMillis(); | 1322 int64_t before_last_receiving = rtc::TimeMillis(); |
1323 conn->ReceivedPing(); | 1323 conn->ReceivedPing(); |
1324 int64_t after_last_receiving = rtc::TimeMillis(); | 1324 int64_t after_last_receiving = rtc::TimeMillis(); |
1325 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT | 1325 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT |
1326 conn->UpdateState( | 1326 conn->UpdateState( |
1327 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); | 1327 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); |
1328 rtc::Thread::Current()->ProcessMessages(100); | 1328 rtc::Thread::Current()->ProcessMessages(100); |
1329 EXPECT_TRUE(ch1.conn() != nullptr); | 1329 EXPECT_TRUE(ch1.conn() != nullptr); |
1330 conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); | 1330 conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); |
1331 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); | 1331 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2762 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); | 2762 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); |
2763 EXPECT_NE(conn1, conn2); | 2763 EXPECT_NE(conn1, conn2); |
2764 conn_in_use = port->GetConnection(address); | 2764 conn_in_use = port->GetConnection(address); |
2765 EXPECT_EQ(conn2, conn_in_use); | 2765 EXPECT_EQ(conn2, conn_in_use); |
2766 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); | 2766 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); |
2767 | 2767 |
2768 // Make sure the new connection was not deleted. | 2768 // Make sure the new connection was not deleted. |
2769 rtc::Thread::Current()->ProcessMessages(300); | 2769 rtc::Thread::Current()->ProcessMessages(300); |
2770 EXPECT_TRUE(port->GetConnection(address) != nullptr); | 2770 EXPECT_TRUE(port->GetConnection(address) != nullptr); |
2771 } | 2771 } |
OLD | NEW |