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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 static const char kIceUfrag0[] = "UF00"; | 77 static const char kIceUfrag0[] = "UF00"; |
78 // Based on ICE_PWD_LENGTH | 78 // Based on ICE_PWD_LENGTH |
79 static const char kIcePwd0[] = "TESTICEPWD00000000000000"; | 79 static const char kIcePwd0[] = "TESTICEPWD00000000000000"; |
80 | 80 |
81 static const char kContentName[] = "test content"; | 81 static const char kContentName[] = "test content"; |
82 | 82 |
83 static const int kDefaultAllocationTimeout = 3000; | 83 static const int kDefaultAllocationTimeout = 3000; |
84 static const char kTurnUsername[] = "test"; | 84 static const char kTurnUsername[] = "test"; |
85 static const char kTurnPassword[] = "test"; | 85 static const char kTurnPassword[] = "test"; |
86 | 86 |
87 // STUN timeout (with all retries) is 9500ms. | 87 // STUN timeout (with all retries) is cricket::STUN_TOTAL_TIMEOUT. |
88 // Add some margin of error for slow bots. | 88 // Add some margin of error for slow bots. |
89 // TODO(deadbeef): Use simulated clock instead of just increasing timeouts to | 89 static const int kStunTimeoutMs = cricket::STUN_TOTAL_TIMEOUT; |
90 // fix flaky tests. | |
91 static const int kStunTimeoutMs = 15000; | |
92 | 90 |
93 namespace cricket { | 91 namespace cricket { |
94 | 92 |
95 // Helper for dumping candidates | 93 // Helper for dumping candidates |
96 std::ostream& operator<<(std::ostream& os, | 94 std::ostream& operator<<(std::ostream& os, |
97 const std::vector<Candidate>& candidates) { | 95 const std::vector<Candidate>& candidates) { |
98 os << '['; | 96 os << '['; |
99 bool first = true; | 97 bool first = true; |
100 for (const Candidate& c : candidates) { | 98 for (const Candidate& c : candidates) { |
101 if (!first) { | 99 if (!first) { |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); | 1222 EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr); |
1225 // RelayPort connection timeout is 3sec. TCP connection with RelayServer | 1223 // RelayPort connection timeout is 3sec. TCP connection with RelayServer |
1226 // will be tried after about 3 seconds. | 1224 // will be tried after about 3 seconds. |
1227 EXPECT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 3500, fake_clock); | 1225 EXPECT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 3500, fake_clock); |
1228 EXPECT_EQ(3U, ports_.size()); | 1226 EXPECT_EQ(3U, ports_.size()); |
1229 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); | 1227 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr); |
1230 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); | 1228 EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr); |
1231 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", | 1229 EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp", |
1232 kRelaySslTcpIntAddr); | 1230 kRelaySslTcpIntAddr); |
1233 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); | 1231 EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr); |
1234 // We wait at least for a full STUN timeout, which is currently 9.5 | 1232 // We wait at least for a full STUN timeout, which |
1235 // seconds. But since 3-3.5 seconds already passed (see above), we | 1233 // cricket::STUN_TOTAL_TIMEOUT seconds. But since 3-3.5 seconds |
1236 // only need 6.5 more seconds. | 1234 // already passed (see above), we wait 3 seconds less than that. |
1237 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, 6500, fake_clock); | 1235 EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, |
| 1236 cricket::STUN_TOTAL_TIMEOUT - 3000, fake_clock); |
1238 } | 1237 } |
1239 | 1238 |
1240 TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { | 1239 TEST_F(BasicPortAllocatorTest, TestCandidatePriorityOfMultipleInterfaces) { |
1241 AddInterface(kClientAddr); | 1240 AddInterface(kClientAddr); |
1242 AddInterface(kClientAddr2); | 1241 AddInterface(kClientAddr2); |
1243 // Allocating only host UDP ports. This is done purely for testing | 1242 // Allocating only host UDP ports. This is done purely for testing |
1244 // convenience. | 1243 // convenience. |
1245 allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | | 1244 allocator().set_flags(PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | |
1246 PORTALLOCATOR_DISABLE_RELAY); | 1245 PORTALLOCATOR_DISABLE_RELAY); |
1247 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); | 1246 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 for (const Candidate& candidate : candidates) { | 1893 for (const Candidate& candidate : candidates) { |
1895 // Expect only relay candidates now that the filter is applied. | 1894 // Expect only relay candidates now that the filter is applied. |
1896 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); | 1895 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); |
1897 // Expect that the raddr is emptied due to the CF_RELAY filter. | 1896 // Expect that the raddr is emptied due to the CF_RELAY filter. |
1898 EXPECT_EQ(candidate.related_address(), | 1897 EXPECT_EQ(candidate.related_address(), |
1899 rtc::EmptySocketAddressWithFamily(candidate.address().family())); | 1898 rtc::EmptySocketAddressWithFamily(candidate.address().family())); |
1900 } | 1899 } |
1901 } | 1900 } |
1902 | 1901 |
1903 } // namespace cricket | 1902 } // namespace cricket |
OLD | NEW |