Chromium Code Reviews| 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 GetEndpoint(ch)->saved_candidates_.push_back(new CandidateData(ch, c)); | 643 GetEndpoint(ch)->saved_candidates_.push_back(new CandidateData(ch, c)); |
| 644 } else { | 644 } else { |
| 645 main_->Post(this, MSG_CANDIDATE, new CandidateData(ch, c)); | 645 main_->Post(this, MSG_CANDIDATE, new CandidateData(ch, c)); |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 | 648 |
| 649 void PauseCandidates(int endpoint) { | 649 void PauseCandidates(int endpoint) { |
| 650 GetEndpoint(endpoint)->save_candidates_ = true; | 650 GetEndpoint(endpoint)->save_candidates_ = true; |
| 651 } | 651 } |
| 652 | 652 |
| 653 // Tcp candidate verification has to be done when they are generated. | |
| 654 void VerifySavedTcpCandidates(int endpoint, const std::string& tcptype) { | |
| 655 Endpoint* ed = GetEndpoint(endpoint); | |
| 656 std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); | |
|
juberti
2015/11/17 02:01:05
can this be done as a c++ foreach? (e.g. for (cand
| |
| 657 for (; it != ed->saved_candidates_.end(); ++it) { | |
| 658 EXPECT_EQ((*it)->candidate.protocol(),cricket::TCP_PROTOCOL_NAME); | |
|
juberti
2015/11/17 02:01:05
space after comma
| |
| 659 EXPECT_EQ((*it)->candidate.tcptype(), tcptype); | |
| 660 if ((*it)->candidate.tcptype() == cricket::TCPTYPE_ACTIVE_STR) { | |
| 661 EXPECT_EQ((*it)->candidate.address().port(), cricket::DISCARD_PORT); | |
| 662 continue; | |
|
juberti
2015/11/17 02:01:05
this is kind of weird structure; I think
if (a) {
| |
| 663 } | |
| 664 if ((*it)->candidate.tcptype() == cricket::TCPTYPE_PASSIVE_STR) { | |
| 665 EXPECT_NE((*it)->candidate.address().port(), cricket::DISCARD_PORT); | |
| 666 continue; | |
| 667 } | |
| 668 RTC_DCHECK(false); | |
| 669 } | |
| 670 } | |
| 671 | |
| 653 void ResumeCandidates(int endpoint) { | 672 void ResumeCandidates(int endpoint) { |
| 654 Endpoint* ed = GetEndpoint(endpoint); | 673 Endpoint* ed = GetEndpoint(endpoint); |
| 655 std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); | 674 std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); |
| 656 for (; it != ed->saved_candidates_.end(); ++it) { | 675 for (; it != ed->saved_candidates_.end(); ++it) { |
| 657 main_->Post(this, MSG_CANDIDATE, *it); | 676 main_->Post(this, MSG_CANDIDATE, *it); |
| 658 } | 677 } |
| 659 ed->saved_candidates_.clear(); | 678 ed->saved_candidates_.clear(); |
| 660 ed->save_candidates_ = false; | 679 ed->save_candidates_ = false; |
| 661 } | 680 } |
| 662 | 681 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | | 1302 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | |
| 1284 cricket::PORTALLOCATOR_DISABLE_STUN | | 1303 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 1285 cricket::PORTALLOCATOR_DISABLE_RELAY; | 1304 cricket::PORTALLOCATOR_DISABLE_RELAY; |
| 1286 // Disable all protocols except TCP. | 1305 // Disable all protocols except TCP. |
| 1287 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1306 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
| 1288 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1307 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
| 1289 | 1308 |
| 1290 SetAllowTcpListen(0, true); // actpass. | 1309 SetAllowTcpListen(0, true); // actpass. |
| 1291 SetAllowTcpListen(1, false); // active. | 1310 SetAllowTcpListen(1, false); // active. |
| 1292 | 1311 |
| 1312 // Pause candidate so we could verify the candidate properties. | |
| 1313 PauseCandidates(0); | |
| 1314 PauseCandidates(1); | |
| 1293 CreateChannels(1); | 1315 CreateChannels(1); |
| 1294 | 1316 |
| 1317 // Verify tcp candidates. | |
| 1318 VerifySavedTcpCandidates(0, cricket::TCPTYPE_PASSIVE_STR); | |
| 1319 VerifySavedTcpCandidates(1, cricket::TCPTYPE_ACTIVE_STR); | |
| 1320 | |
| 1321 // Resume candidates. | |
| 1322 ResumeCandidates(0); | |
| 1323 ResumeCandidates(1); | |
| 1324 | |
| 1295 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1325 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1296 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1326 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1297 1000); | 1327 1000); |
| 1298 EXPECT_TRUE( | 1328 EXPECT_TRUE( |
| 1299 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1329 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
| 1300 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1330 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1301 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1331 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1302 | 1332 |
| 1303 std::string kTcpProtocol = "tcp"; | |
| 1304 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep1_ch1())->protocol()); | |
| 1305 EXPECT_EQ(kTcpProtocol, LocalCandidate(ep1_ch1())->protocol()); | |
| 1306 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep2_ch1())->protocol()); | |
| 1307 EXPECT_EQ(kTcpProtocol, LocalCandidate(ep2_ch1())->protocol()); | |
| 1308 | |
| 1309 TestSendRecv(1); | 1333 TestSendRecv(1); |
| 1310 DestroyChannels(); | 1334 DestroyChannels(); |
| 1311 } | 1335 } |
| 1312 | 1336 |
| 1313 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { | 1337 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { |
| 1314 AddAddress(0, kPublicAddrs[0]); | 1338 AddAddress(0, kPublicAddrs[0]); |
| 1315 AddAddress(1, kPublicAddrs[1]); | 1339 AddAddress(1, kPublicAddrs[1]); |
| 1316 TestSignalRoleConflict(); | 1340 TestSignalRoleConflict(); |
| 1317 } | 1341 } |
| 1318 | 1342 |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2217 // It should stop getting ports after a new connection becomes strongly | 2241 // It should stop getting ports after a new connection becomes strongly |
| 2218 // connected. | 2242 // connected. |
| 2219 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2243 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| 2220 ch.MaybeStartGathering(); | 2244 ch.MaybeStartGathering(); |
| 2221 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); | 2245 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); |
| 2222 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2246 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
| 2223 ASSERT_TRUE(conn2 != nullptr); | 2247 ASSERT_TRUE(conn2 != nullptr); |
| 2224 conn2->ReceivedPingResponse(); // Becomes writable and receiving | 2248 conn2->ReceivedPingResponse(); // Becomes writable and receiving |
| 2225 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 2249 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
| 2226 } | 2250 } |
| OLD | NEW |