Chromium Code Reviews| 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 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 13 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 14 #include "webrtc/p2p/base/jseptransport.h" | 14 #include "webrtc/p2p/base/jseptransport.h" |
| 15 #include "webrtc/p2p/base/relayport.h" | 15 #include "webrtc/p2p/base/relayport.h" |
| 16 #include "webrtc/p2p/base/stunport.h" | 16 #include "webrtc/p2p/base/stunport.h" |
| 17 #include "webrtc/p2p/base/tcpport.h" | 17 #include "webrtc/p2p/base/tcpport.h" |
| 18 #include "webrtc/p2p/base/testrelayserver.h" | 18 #include "webrtc/p2p/base/testrelayserver.h" |
| 19 #include "webrtc/p2p/base/teststunserver.h" | 19 #include "webrtc/p2p/base/teststunserver.h" |
| 20 #include "webrtc/p2p/base/testturnserver.h" | 20 #include "webrtc/p2p/base/testturnserver.h" |
| 21 #include "webrtc/p2p/base/turnport.h" | 21 #include "webrtc/p2p/base/turnport.h" |
| 22 #include "webrtc/base/arraysize.h" | 22 #include "webrtc/base/arraysize.h" |
| 23 #include "webrtc/base/buffer.h" | 23 #include "webrtc/base/buffer.h" |
| 24 #include "webrtc/base/checks.h" | |
| 24 #include "webrtc/base/crc32.h" | 25 #include "webrtc/base/crc32.h" |
| 25 #include "webrtc/base/gunit.h" | 26 #include "webrtc/base/gunit.h" |
| 26 #include "webrtc/base/helpers.h" | 27 #include "webrtc/base/helpers.h" |
| 27 #include "webrtc/base/logging.h" | 28 #include "webrtc/base/logging.h" |
| 28 #include "webrtc/base/natserver.h" | 29 #include "webrtc/base/natserver.h" |
| 29 #include "webrtc/base/natsocketfactory.h" | 30 #include "webrtc/base/natsocketfactory.h" |
| 30 #include "webrtc/base/physicalsocketserver.h" | 31 #include "webrtc/base/physicalsocketserver.h" |
| 31 #include "webrtc/base/socketaddress.h" | 32 #include "webrtc/base/socketaddress.h" |
| 32 #include "webrtc/base/ssladapter.h" | 33 #include "webrtc/base/ssladapter.h" |
| 33 #include "webrtc/base/stringutils.h" | 34 #include "webrtc/base/stringutils.h" |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 ch1.Start(); | 1294 ch1.Start(); |
| 1294 ch2.Start(); | 1295 ch2.Start(); |
| 1295 ASSERT_EQ_WAIT(1, ch1.complete_count(), kDefaultTimeout); | 1296 ASSERT_EQ_WAIT(1, ch1.complete_count(), kDefaultTimeout); |
| 1296 ASSERT_EQ_WAIT(1, ch2.complete_count(), kDefaultTimeout); | 1297 ASSERT_EQ_WAIT(1, ch2.complete_count(), kDefaultTimeout); |
| 1297 | 1298 |
| 1298 // Test case that the connection has never received anything. | 1299 // Test case that the connection has never received anything. |
| 1299 int64_t before_created = rtc::TimeMillis(); | 1300 int64_t before_created = rtc::TimeMillis(); |
| 1300 ch1.CreateConnection(GetCandidate(port2)); | 1301 ch1.CreateConnection(GetCandidate(port2)); |
| 1301 int64_t after_created = rtc::TimeMillis(); | 1302 int64_t after_created = rtc::TimeMillis(); |
| 1302 Connection* conn = ch1.conn(); | 1303 Connection* conn = ch1.conn(); |
| 1303 ASSERT(conn != nullptr); | 1304 RTC_CHECK(conn != nullptr); |
|
kwiberg-webrtc
2017/01/17 09:39:25
This is a top-level test function, so you can use
nisse-webrtc
2017/01/17 12:19:21
Done.
| |
| 1304 // It is not dead if it is after MIN_CONNECTION_LIFETIME but not pruned. | 1305 // It is not dead if it is after MIN_CONNECTION_LIFETIME but not pruned. |
| 1305 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); | 1306 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); |
| 1306 rtc::Thread::Current()->ProcessMessages(0); | 1307 rtc::Thread::Current()->ProcessMessages(0); |
| 1307 EXPECT_TRUE(ch1.conn() != nullptr); | 1308 EXPECT_TRUE(ch1.conn() != nullptr); |
| 1308 // It is not dead if it is before MIN_CONNECTION_LIFETIME and pruned. | 1309 // It is not dead if it is before MIN_CONNECTION_LIFETIME and pruned. |
| 1309 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); | 1310 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); |
| 1310 conn->Prune(); | 1311 conn->Prune(); |
| 1311 rtc::Thread::Current()->ProcessMessages(0); | 1312 rtc::Thread::Current()->ProcessMessages(0); |
| 1312 EXPECT_TRUE(ch1.conn() != nullptr); | 1313 EXPECT_TRUE(ch1.conn() != nullptr); |
| 1313 // It will be dead after MIN_CONNECTION_LIFETIME and pruned. | 1314 // It will be dead after MIN_CONNECTION_LIFETIME and pruned. |
| 1314 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); | 1315 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); |
| 1315 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); | 1316 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); |
| 1316 | 1317 |
| 1317 // Test case that the connection has received something. | 1318 // Test case that the connection has received something. |
| 1318 // Create a connection again and receive a ping. | 1319 // Create a connection again and receive a ping. |
| 1319 ch1.CreateConnection(GetCandidate(port2)); | 1320 ch1.CreateConnection(GetCandidate(port2)); |
| 1320 conn = ch1.conn(); | 1321 conn = ch1.conn(); |
| 1321 ASSERT(conn != nullptr); | 1322 RTC_CHECK(conn != nullptr); |
| 1322 int64_t before_last_receiving = rtc::TimeMillis(); | 1323 int64_t before_last_receiving = rtc::TimeMillis(); |
| 1323 conn->ReceivedPing(); | 1324 conn->ReceivedPing(); |
| 1324 int64_t after_last_receiving = rtc::TimeMillis(); | 1325 int64_t after_last_receiving = rtc::TimeMillis(); |
| 1325 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT | 1326 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT |
| 1326 conn->UpdateState( | 1327 conn->UpdateState( |
| 1327 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); | 1328 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); |
| 1328 rtc::Thread::Current()->ProcessMessages(100); | 1329 rtc::Thread::Current()->ProcessMessages(100); |
| 1329 EXPECT_TRUE(ch1.conn() != nullptr); | 1330 EXPECT_TRUE(ch1.conn() != nullptr); |
| 1330 conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); | 1331 conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); |
| 1331 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kDefaultTimeout); | 1332 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); | 2763 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); |
| 2763 EXPECT_NE(conn1, conn2); | 2764 EXPECT_NE(conn1, conn2); |
| 2764 conn_in_use = port->GetConnection(address); | 2765 conn_in_use = port->GetConnection(address); |
| 2765 EXPECT_EQ(conn2, conn_in_use); | 2766 EXPECT_EQ(conn2, conn_in_use); |
| 2766 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); | 2767 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); |
| 2767 | 2768 |
| 2768 // Make sure the new connection was not deleted. | 2769 // Make sure the new connection was not deleted. |
| 2769 rtc::Thread::Current()->ProcessMessages(300); | 2770 rtc::Thread::Current()->ProcessMessages(300); |
| 2770 EXPECT_TRUE(port->GetConnection(address) != nullptr); | 2771 EXPECT_TRUE(port->GetConnection(address) != nullptr); |
| 2771 } | 2772 } |
| OLD | NEW |