| OLD | NEW |
| 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 12 matching lines...) Expand all Loading... |
| 23 using cricket::ServerAddresses; | 23 using cricket::ServerAddresses; |
| 24 using rtc::SocketAddress; | 24 using rtc::SocketAddress; |
| 25 | 25 |
| 26 static const SocketAddress kLocalAddr("127.0.0.1", 0); | 26 static const SocketAddress kLocalAddr("127.0.0.1", 0); |
| 27 static const SocketAddress kStunAddr1("127.0.0.1", 5000); | 27 static const SocketAddress kStunAddr1("127.0.0.1", 5000); |
| 28 static const SocketAddress kStunAddr2("127.0.0.1", 4000); | 28 static const SocketAddress kStunAddr2("127.0.0.1", 4000); |
| 29 static const SocketAddress kStunAddr3("127.0.0.1", 3000); | 29 static const SocketAddress kStunAddr3("127.0.0.1", 3000); |
| 30 static const SocketAddress kBadAddr("0.0.0.1", 5000); | 30 static const SocketAddress kBadAddr("0.0.0.1", 5000); |
| 31 static const SocketAddress kStunHostnameAddr("localhost", 5000); | 31 static const SocketAddress kStunHostnameAddr("localhost", 5000); |
| 32 static const SocketAddress kBadHostnameAddr("not-a-real-hostname", 5000); | 32 static const SocketAddress kBadHostnameAddr("not-a-real-hostname", 5000); |
| 33 static const int kTimeoutMs = 10000; | 33 // STUN timeout (with all retries) is 9500ms. |
| 34 // Add some margin of error for slow bots. |
| 35 // TODO(deadbeef): Use simulated clock instead of just increasing timeouts to |
| 36 // fix flaky tests. |
| 37 static const int kTimeoutMs = 15000; |
| 34 // stun prio = 100 << 24 | 30 (IPV4) << 8 | 256 - 0 | 38 // stun prio = 100 << 24 | 30 (IPV4) << 8 | 256 - 0 |
| 35 static const uint32_t kStunCandidatePriority = 1677729535; | 39 static const uint32_t kStunCandidatePriority = 1677729535; |
| 36 static const int kInfiniteLifetime = -1; | 40 static const int kInfiniteLifetime = -1; |
| 37 static const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000; | 41 static const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000; |
| 38 | 42 |
| 39 // Tests connecting a StunPort to a fake STUN server (cricket::StunServer) | 43 // Tests connecting a StunPort to a fake STUN server (cricket::StunServer) |
| 40 // TODO: Use a VirtualSocketServer here. We have to use a | 44 // TODO: Use a VirtualSocketServer here. We have to use a |
| 41 // PhysicalSocketServer right now since DNS is not part of SocketServer yet. | 45 // PhysicalSocketServer right now since DNS is not part of SocketServer yet. |
| 42 class StunPortTest : public testing::Test, | 46 class StunPortTest : public testing::Test, |
| 43 public sigslot::has_slots<> { | 47 public sigslot::has_slots<> { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 360 |
| 357 // Test that by default, the STUN binding requests will last for a long time. | 361 // Test that by default, the STUN binding requests will last for a long time. |
| 358 TEST_F(StunPortTest, TestStunBindingRequestLongLifetime) { | 362 TEST_F(StunPortTest, TestStunBindingRequestLongLifetime) { |
| 359 SetKeepaliveDelay(101); | 363 SetKeepaliveDelay(101); |
| 360 CreateStunPort(kStunAddr1); | 364 CreateStunPort(kStunAddr1); |
| 361 PrepareAddress(); | 365 PrepareAddress(); |
| 362 EXPECT_TRUE_WAIT(done(), kTimeoutMs); | 366 EXPECT_TRUE_WAIT(done(), kTimeoutMs); |
| 363 rtc::Thread::Current()->ProcessMessages(1000); | 367 rtc::Thread::Current()->ProcessMessages(1000); |
| 364 EXPECT_TRUE(port()->HasPendingRequest(cricket::STUN_BINDING_REQUEST)); | 368 EXPECT_TRUE(port()->HasPendingRequest(cricket::STUN_BINDING_REQUEST)); |
| 365 } | 369 } |
| OLD | NEW |