| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return ep2_.GetChannelData(channel); | 308 return ep2_.GetChannelData(channel); |
| 309 } | 309 } |
| 310 | 310 |
| 311 IceParameters IceParamsWithRenomination(const IceParameters& ice, | 311 IceParameters IceParamsWithRenomination(const IceParameters& ice, |
| 312 bool renomination) { | 312 bool renomination) { |
| 313 IceParameters new_ice = ice; | 313 IceParameters new_ice = ice; |
| 314 new_ice.renomination = renomination; | 314 new_ice.renomination = renomination; |
| 315 return new_ice; | 315 return new_ice; |
| 316 } | 316 } |
| 317 | 317 |
| 318 void CreateChannels(int num, | 318 void CreateChannels(const IceConfig& ep1_config, |
| 319 const IceConfig& ep1_config, | |
| 320 const IceConfig& ep2_config, | 319 const IceConfig& ep2_config, |
| 321 bool renomination = false) { | 320 bool renomination = false) { |
| 322 IceParameters ice_ep1_cd1_ch = | 321 IceParameters ice_ep1_cd1_ch = |
| 323 IceParamsWithRenomination(kIceParams[0], renomination); | 322 IceParamsWithRenomination(kIceParams[0], renomination); |
| 324 IceParameters ice_ep2_cd1_ch = | 323 IceParameters ice_ep2_cd1_ch = |
| 325 IceParamsWithRenomination(kIceParams[1], renomination); | 324 IceParamsWithRenomination(kIceParams[1], renomination); |
| 326 ep1_.cd1_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, | 325 ep1_.cd1_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| 327 ice_ep1_cd1_ch, ice_ep2_cd1_ch)); | 326 ice_ep1_cd1_ch, ice_ep2_cd1_ch)); |
| 328 ep2_.cd1_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, | 327 ep2_.cd1_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| 329 ice_ep2_cd1_ch, ice_ep1_cd1_ch)); | 328 ice_ep2_cd1_ch, ice_ep1_cd1_ch)); |
| 330 ep1_.cd1_.ch_->SetIceConfig(ep1_config); | 329 ep1_.cd1_.ch_->SetIceConfig(ep1_config); |
| 331 ep2_.cd1_.ch_->SetIceConfig(ep2_config); | 330 ep2_.cd1_.ch_->SetIceConfig(ep2_config); |
| 332 ep1_.cd1_.ch_->MaybeStartGathering(); | 331 ep1_.cd1_.ch_->MaybeStartGathering(); |
| 333 ep2_.cd1_.ch_->MaybeStartGathering(); | 332 ep2_.cd1_.ch_->MaybeStartGathering(); |
| 334 if (num == 2) { | |
| 335 IceParameters ice_ep1_cd2_ch = | |
| 336 IceParamsWithRenomination(kIceParams[2], renomination); | |
| 337 IceParameters ice_ep2_cd2_ch = | |
| 338 IceParamsWithRenomination(kIceParams[3], renomination); | |
| 339 ep1_.cd2_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, | |
| 340 ice_ep1_cd2_ch, ice_ep2_cd2_ch)); | |
| 341 ep2_.cd2_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, | |
| 342 ice_ep2_cd2_ch, ice_ep1_cd2_ch)); | |
| 343 ep1_.cd2_.ch_->SetIceConfig(ep1_config); | |
| 344 ep2_.cd2_.ch_->SetIceConfig(ep2_config); | |
| 345 ep1_.cd2_.ch_->MaybeStartGathering(); | |
| 346 ep2_.cd2_.ch_->MaybeStartGathering(); | |
| 347 } | |
| 348 } | 333 } |
| 349 | 334 |
| 350 void CreateChannels(int num) { | 335 void CreateChannels() { |
| 351 IceConfig default_config; | 336 IceConfig default_config; |
| 352 CreateChannels(num, default_config, default_config, false); | 337 CreateChannels(default_config, default_config, false); |
| 353 } | 338 } |
| 354 | 339 |
| 355 P2PTransportChannel* CreateChannel(int endpoint, | 340 P2PTransportChannel* CreateChannel(int endpoint, |
| 356 int component, | 341 int component, |
| 357 const IceParameters& local_ice, | 342 const IceParameters& local_ice, |
| 358 const IceParameters& remote_ice) { | 343 const IceParameters& remote_ice) { |
| 359 P2PTransportChannel* channel = new P2PTransportChannel( | 344 P2PTransportChannel* channel = new P2PTransportChannel( |
| 360 "test content name", component, GetAllocator(endpoint)); | 345 "test content name", component, GetAllocator(endpoint)); |
| 361 channel->SignalReadyToSend.connect( | 346 channel->SignalReadyToSend.connect( |
| 362 this, &P2PTransportChannelTestBase::OnReadyToSend); | 347 this, &P2PTransportChannelTestBase::OnReadyToSend); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 EXPECT_EQ(expected.controlling_type, remote_type); | 512 EXPECT_EQ(expected.controlling_type, remote_type); |
| 528 EXPECT_EQ(expected.controlled_protocol, local_protocol); | 513 EXPECT_EQ(expected.controlled_protocol, local_protocol); |
| 529 EXPECT_EQ(expected.controlling_protocol, remote_protocol); | 514 EXPECT_EQ(expected.controlling_protocol, remote_protocol); |
| 530 } | 515 } |
| 531 | 516 |
| 532 void Test(const Result& expected) { | 517 void Test(const Result& expected) { |
| 533 int64_t connect_start = rtc::TimeMillis(); | 518 int64_t connect_start = rtc::TimeMillis(); |
| 534 int64_t connect_time; | 519 int64_t connect_time; |
| 535 | 520 |
| 536 // Create the channels and wait for them to connect. | 521 // Create the channels and wait for them to connect. |
| 537 CreateChannels(1); | 522 CreateChannels(); |
| 538 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 523 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
| 539 ep2_ch1() != NULL && | 524 ep2_ch1() != NULL && |
| 540 ep1_ch1()->receiving() && | 525 ep1_ch1()->receiving() && |
| 541 ep1_ch1()->writable() && | 526 ep1_ch1()->writable() && |
| 542 ep2_ch1()->receiving() && | 527 ep2_ch1()->receiving() && |
| 543 ep2_ch1()->writable(), | 528 ep2_ch1()->writable(), |
| 544 expected.connect_wait, | 529 expected.connect_wait, |
| 545 1000); | 530 1000); |
| 546 connect_time = rtc::TimeMillis() - connect_start; | 531 connect_time = rtc::TimeMillis() - connect_start; |
| 547 if (connect_time < expected.connect_wait) { | 532 if (connect_time < expected.connect_wait) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 570 | 555 |
| 571 converge_time = rtc::TimeMillis() - converge_start; | 556 converge_time = rtc::TimeMillis() - converge_start; |
| 572 if (converge_time < converge_wait) { | 557 if (converge_time < converge_wait) { |
| 573 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; | 558 LOG(LS_INFO) << "Converge time: " << converge_time << " ms"; |
| 574 } else { | 559 } else { |
| 575 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" | 560 LOG(LS_INFO) << "Converge time: " << "TIMEOUT (" |
| 576 << converge_wait << " ms)"; | 561 << converge_wait << " ms)"; |
| 577 } | 562 } |
| 578 } | 563 } |
| 579 // Try sending some data to other end. | 564 // Try sending some data to other end. |
| 580 TestSendRecv(1); | 565 TestSendRecv(); |
| 581 | 566 |
| 582 // Destroy the channels, and wait for them to be fully cleaned up. | 567 // Destroy the channels, and wait for them to be fully cleaned up. |
| 583 DestroyChannels(); | 568 DestroyChannels(); |
| 584 } | 569 } |
| 585 | 570 |
| 586 void TestSendRecv(int channels) { | 571 void TestSendRecv() { |
| 587 for (int i = 0; i < 10; ++i) { | 572 for (int i = 0; i < 10; ++i) { |
| 588 const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | 573 const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
| 589 int len = static_cast<int>(strlen(data)); | 574 int len = static_cast<int>(strlen(data)); |
| 590 // local_channel1 <==> remote_channel1 | 575 // local_channel1 <==> remote_channel1 |
| 591 EXPECT_EQ_WAIT(len, SendData(ep1_ch1(), data, len), 1000); | 576 EXPECT_EQ_WAIT(len, SendData(ep1_ch1(), data, len), 1000); |
| 592 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch1(), data, len), 1000); | 577 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch1(), data, len), 1000); |
| 593 EXPECT_EQ_WAIT(len, SendData(ep2_ch1(), data, len), 1000); | 578 EXPECT_EQ_WAIT(len, SendData(ep2_ch1(), data, len), 1000); |
| 594 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch1(), data, len), 1000); | 579 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch1(), data, len), 1000); |
| 595 if (channels == 2 && ep1_ch2() && ep2_ch2()) { | |
| 596 // local_channel2 <==> remote_channel2 | |
| 597 EXPECT_EQ_WAIT(len, SendData(ep1_ch2(), data, len), 1000); | |
| 598 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep2_ch2(), data, len), 1000); | |
| 599 EXPECT_EQ_WAIT(len, SendData(ep2_ch2(), data, len), 1000); | |
| 600 EXPECT_TRUE_WAIT(CheckDataOnChannel(ep1_ch2(), data, len), 1000); | |
| 601 } | |
| 602 } | 580 } |
| 603 } | 581 } |
| 604 | 582 |
| 605 // This test waits for the transport to become receiving and writable on both | 583 // This test waits for the transport to become receiving and writable on both |
| 606 // end points. Once they are, the end points set new local ice parameters and | 584 // end points. Once they are, the end points set new local ice parameters and |
| 607 // restart the ice gathering. Finally it waits for the transport to select a | 585 // restart the ice gathering. Finally it waits for the transport to select a |
| 608 // new connection using the newly generated ice candidates. | 586 // new connection using the newly generated ice candidates. |
| 609 // Before calling this function the end points must be configured. | 587 // Before calling this function the end points must be configured. |
| 610 void TestHandleIceUfragPasswordChanged() { | 588 void TestHandleIceUfragPasswordChanged() { |
| 611 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); | 589 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 622 } |
| 645 | 623 |
| 646 void TestSignalRoleConflict() { | 624 void TestSignalRoleConflict() { |
| 647 SetIceTiebreaker(0, | 625 SetIceTiebreaker(0, |
| 648 kLowTiebreaker); // Default EP1 is in controlling state. | 626 kLowTiebreaker); // Default EP1 is in controlling state. |
| 649 | 627 |
| 650 SetIceRole(1, ICEROLE_CONTROLLING); | 628 SetIceRole(1, ICEROLE_CONTROLLING); |
| 651 SetIceTiebreaker(1, kHighTiebreaker); | 629 SetIceTiebreaker(1, kHighTiebreaker); |
| 652 | 630 |
| 653 // Creating channels with both channels role set to CONTROLLING. | 631 // Creating channels with both channels role set to CONTROLLING. |
| 654 CreateChannels(1); | 632 CreateChannels(); |
| 655 // Since both the channels initiated with controlling state and channel2 | 633 // Since both the channels initiated with controlling state and channel2 |
| 656 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. | 634 // has higher tiebreaker value, channel1 should receive SignalRoleConflict. |
| 657 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); | 635 EXPECT_TRUE_WAIT(GetRoleConflict(0), 1000); |
| 658 EXPECT_FALSE(GetRoleConflict(1)); | 636 EXPECT_FALSE(GetRoleConflict(1)); |
| 659 | 637 |
| 660 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && | 638 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && |
| 661 ep1_ch1()->writable() && | 639 ep1_ch1()->writable() && |
| 662 ep2_ch1()->receiving() && | 640 ep2_ch1()->receiving() && |
| 663 ep2_ch1()->writable(), | 641 ep2_ch1()->writable(), |
| 664 1000); | 642 1000); |
| 665 | 643 |
| 666 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 644 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 667 ep2_ch1()->selected_connection()); | 645 ep2_ch1()->selected_connection()); |
| 668 | 646 |
| 669 TestSendRecv(1); | 647 TestSendRecv(); |
| 670 } | 648 } |
| 671 | 649 |
| 672 void OnReadyToSend(TransportChannel* ch) { | 650 void OnReadyToSend(TransportChannel* ch) { |
| 673 GetEndpoint(ch)->ready_to_send_ = true; | 651 GetEndpoint(ch)->ready_to_send_ = true; |
| 674 } | 652 } |
| 675 | 653 |
| 676 // We pass the candidates directly to the other side. | 654 // We pass the candidates directly to the other side. |
| 677 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { | 655 void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) { |
| 678 if (force_relay_ && c.type() != RELAY_PORT_TYPE) | 656 if (force_relay_ && c.type() != RELAY_PORT_TYPE) |
| 679 return; | 657 return; |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP) | 1127 P2P_TEST_SET(BLOCK_UDP_AND_INCOMING_TCP) |
| 1150 P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP) | 1128 P2P_TEST_SET(BLOCK_ALL_BUT_OUTGOING_HTTP) |
| 1151 P2P_TEST_SET(PROXY_HTTPS) | 1129 P2P_TEST_SET(PROXY_HTTPS) |
| 1152 P2P_TEST_SET(PROXY_SOCKS) | 1130 P2P_TEST_SET(PROXY_SOCKS) |
| 1153 | 1131 |
| 1154 // Test that we restart candidate allocation when local ufrag&pwd changed. | 1132 // Test that we restart candidate allocation when local ufrag&pwd changed. |
| 1155 // Standard Ice protocol is used. | 1133 // Standard Ice protocol is used. |
| 1156 TEST_F(P2PTransportChannelTest, HandleUfragPwdChange) { | 1134 TEST_F(P2PTransportChannelTest, HandleUfragPwdChange) { |
| 1157 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1135 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1158 kDefaultPortAllocatorFlags); | 1136 kDefaultPortAllocatorFlags); |
| 1159 CreateChannels(1); | 1137 CreateChannels(); |
| 1160 TestHandleIceUfragPasswordChanged(); | 1138 TestHandleIceUfragPasswordChanged(); |
| 1161 DestroyChannels(); | 1139 DestroyChannels(); |
| 1162 } | 1140 } |
| 1163 | 1141 |
| 1164 // Same as above test, but with a symmetric NAT. | 1142 // Same as above test, but with a symmetric NAT. |
| 1165 // We should end up with relay<->prflx candidate pairs, with generation "1". | 1143 // We should end up with relay<->prflx candidate pairs, with generation "1". |
| 1166 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeSymmetricNat) { | 1144 TEST_F(P2PTransportChannelTest, HandleUfragPwdChangeSymmetricNat) { |
| 1167 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1145 ConfigureEndpoints(NAT_SYMMETRIC, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
| 1168 kDefaultPortAllocatorFlags); | 1146 kDefaultPortAllocatorFlags); |
| 1169 CreateChannels(1); | 1147 CreateChannels(); |
| 1170 TestHandleIceUfragPasswordChanged(); | 1148 TestHandleIceUfragPasswordChanged(); |
| 1171 DestroyChannels(); | 1149 DestroyChannels(); |
| 1172 } | 1150 } |
| 1173 | 1151 |
| 1174 // Test the operation of GetStats. | 1152 // Test the operation of GetStats. |
| 1175 TEST_F(P2PTransportChannelTest, GetStats) { | 1153 TEST_F(P2PTransportChannelTest, GetStats) { |
| 1176 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1154 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1177 kDefaultPortAllocatorFlags); | 1155 kDefaultPortAllocatorFlags); |
| 1178 CreateChannels(1); | 1156 CreateChannels(); |
| 1179 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1157 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1180 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1158 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1181 1000, 1000); | 1159 1000, 1000); |
| 1182 TestSendRecv(1); | 1160 TestSendRecv(); |
| 1183 ConnectionInfos infos; | 1161 ConnectionInfos infos; |
| 1184 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); | 1162 ASSERT_TRUE(ep1_ch1()->GetStats(&infos)); |
| 1185 ASSERT_TRUE(infos.size() >= 1); | 1163 ASSERT_TRUE(infos.size() >= 1); |
| 1186 ConnectionInfo* best_conn_info = nullptr; | 1164 ConnectionInfo* best_conn_info = nullptr; |
| 1187 for (ConnectionInfo& info : infos) { | 1165 for (ConnectionInfo& info : infos) { |
| 1188 if (info.best_connection) { | 1166 if (info.best_connection) { |
| 1189 best_conn_info = &info; | 1167 best_conn_info = &info; |
| 1190 break; | 1168 break; |
| 1191 } | 1169 } |
| 1192 } | 1170 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1203 DestroyChannels(); | 1181 DestroyChannels(); |
| 1204 } | 1182 } |
| 1205 | 1183 |
| 1206 // Test that we properly create a connection on a STUN ping from unknown address | 1184 // Test that we properly create a connection on a STUN ping from unknown address |
| 1207 // when the signaling is slow. | 1185 // when the signaling is slow. |
| 1208 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { | 1186 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
| 1209 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1187 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1210 kDefaultPortAllocatorFlags); | 1188 kDefaultPortAllocatorFlags); |
| 1211 // Emulate no remote parameters coming in. | 1189 // Emulate no remote parameters coming in. |
| 1212 set_remote_ice_parameter_source(FROM_CANDIDATE); | 1190 set_remote_ice_parameter_source(FROM_CANDIDATE); |
| 1213 CreateChannels(1); | 1191 CreateChannels(); |
| 1214 // Only have remote parameters come in for ep2, not ep1. | 1192 // Only have remote parameters come in for ep2, not ep1. |
| 1215 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); | 1193 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| 1216 | 1194 |
| 1217 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1195 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
| 1218 // candidate. | 1196 // candidate. |
| 1219 PauseCandidates(1); | 1197 PauseCandidates(1); |
| 1220 | 1198 |
| 1221 // Wait until the callee becomes writable to make sure that a ping request is | 1199 // Wait until the callee becomes writable to make sure that a ping request is |
| 1222 // received by the caller before his remote ICE credentials are set. | 1200 // received by the caller before his remote ICE credentials are set. |
| 1223 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); | 1201 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1245 DestroyChannels(); | 1223 DestroyChannels(); |
| 1246 } | 1224 } |
| 1247 | 1225 |
| 1248 // Test that we properly create a connection on a STUN ping from unknown address | 1226 // Test that we properly create a connection on a STUN ping from unknown address |
| 1249 // when the signaling is slow and the end points are behind NAT. | 1227 // when the signaling is slow and the end points are behind NAT. |
| 1250 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { | 1228 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
| 1251 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, | 1229 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
| 1252 kDefaultPortAllocatorFlags); | 1230 kDefaultPortAllocatorFlags); |
| 1253 // Emulate no remote parameters coming in. | 1231 // Emulate no remote parameters coming in. |
| 1254 set_remote_ice_parameter_source(FROM_CANDIDATE); | 1232 set_remote_ice_parameter_source(FROM_CANDIDATE); |
| 1255 CreateChannels(1); | 1233 CreateChannels(); |
| 1256 // Only have remote parameters come in for ep2, not ep1. | 1234 // Only have remote parameters come in for ep2, not ep1. |
| 1257 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); | 1235 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| 1258 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive | 1236 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
| 1259 // candidate. | 1237 // candidate. |
| 1260 PauseCandidates(1); | 1238 PauseCandidates(1); |
| 1261 | 1239 |
| 1262 // Wait until the callee becomes writable to make sure that a ping request is | 1240 // Wait until the callee becomes writable to make sure that a ping request is |
| 1263 // received by the caller before his remote ICE credentials are set. | 1241 // received by the caller before his remote ICE credentials are set. |
| 1264 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); | 1242 ASSERT_TRUE_WAIT(ep2_ch1()->selected_connection() != nullptr, 3000); |
| 1265 // Add two sets of remote ICE credentials, so that the ones used by the | 1243 // Add two sets of remote ICE credentials, so that the ones used by the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 TEST_F(P2PTransportChannelTest, | 1277 TEST_F(P2PTransportChannelTest, |
| 1300 PeerReflexiveCandidateBeforeSignalingWithIceRestart) { | 1278 PeerReflexiveCandidateBeforeSignalingWithIceRestart) { |
| 1301 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1279 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1302 kDefaultPortAllocatorFlags); | 1280 kDefaultPortAllocatorFlags); |
| 1303 // Only gather relay candidates, so that when the prflx candidate arrives | 1281 // Only gather relay candidates, so that when the prflx candidate arrives |
| 1304 // it's prioritized above the current candidate pair. | 1282 // it's prioritized above the current candidate pair. |
| 1305 GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); | 1283 GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); |
| 1306 GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); | 1284 GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); |
| 1307 // Setting this allows us to control when SetRemoteIceParameters is called. | 1285 // Setting this allows us to control when SetRemoteIceParameters is called. |
| 1308 set_remote_ice_parameter_source(FROM_CANDIDATE); | 1286 set_remote_ice_parameter_source(FROM_CANDIDATE); |
| 1309 CreateChannels(1); | 1287 CreateChannels(); |
| 1310 // Wait for the initial connection to be made. | 1288 // Wait for the initial connection to be made. |
| 1311 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); | 1289 ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| 1312 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); | 1290 ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| 1313 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1291 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1314 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1292 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1315 kDefaultTimeout); | 1293 kDefaultTimeout); |
| 1316 | 1294 |
| 1317 // Simulate an ICE restart on ep2, but don't signal the candidate or new | 1295 // Simulate an ICE restart on ep2, but don't signal the candidate or new |
| 1318 // ICE parameters until after a prflx connection has been made. | 1296 // ICE parameters until after a prflx connection has been made. |
| 1319 PauseCandidates(1); | 1297 PauseCandidates(1); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1345 kDefaultTimeout); | 1323 kDefaultTimeout); |
| 1346 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); | 1324 EXPECT_EQ(prflx_selected_connection, ep1_ch1()->selected_connection()); |
| 1347 DestroyChannels(); | 1325 DestroyChannels(); |
| 1348 } | 1326 } |
| 1349 | 1327 |
| 1350 // Test that if remote candidates don't have ufrag and pwd, we still work. | 1328 // Test that if remote candidates don't have ufrag and pwd, we still work. |
| 1351 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { | 1329 TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
| 1352 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); | 1330 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| 1353 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1331 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1354 kDefaultPortAllocatorFlags); | 1332 kDefaultPortAllocatorFlags); |
| 1355 CreateChannels(1); | 1333 CreateChannels(); |
| 1356 const Connection* selected_connection = NULL; | 1334 const Connection* selected_connection = NULL; |
| 1357 // Wait until the callee's connections are created. | 1335 // Wait until the callee's connections are created. |
| 1358 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); | 1336 WAIT((selected_connection = ep2_ch1()->selected_connection()) != NULL, 1000); |
| 1359 // Wait to see if they get culled; they shouldn't. | 1337 // Wait to see if they get culled; they shouldn't. |
| 1360 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); | 1338 WAIT(ep2_ch1()->selected_connection() != selected_connection, 1000); |
| 1361 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); | 1339 EXPECT_TRUE(ep2_ch1()->selected_connection() == selected_connection); |
| 1362 DestroyChannels(); | 1340 DestroyChannels(); |
| 1363 } | 1341 } |
| 1364 | 1342 |
| 1365 // Test that a host behind NAT cannot be reached when incoming_only | 1343 // Test that a host behind NAT cannot be reached when incoming_only |
| 1366 // is set to true. | 1344 // is set to true. |
| 1367 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { | 1345 TEST_F(P2PTransportChannelTest, IncomingOnlyBlocked) { |
| 1368 ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags, | 1346 ConfigureEndpoints(NAT_FULL_CONE, OPEN, kDefaultPortAllocatorFlags, |
| 1369 kDefaultPortAllocatorFlags); | 1347 kDefaultPortAllocatorFlags); |
| 1370 | 1348 |
| 1371 SetAllocatorFlags(0, kOnlyLocalPorts); | 1349 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1372 CreateChannels(1); | 1350 CreateChannels(); |
| 1373 ep1_ch1()->set_incoming_only(true); | 1351 ep1_ch1()->set_incoming_only(true); |
| 1374 | 1352 |
| 1375 // Pump for 1 second and verify that the channels are not connected. | 1353 // Pump for 1 second and verify that the channels are not connected. |
| 1376 rtc::Thread::Current()->ProcessMessages(1000); | 1354 rtc::Thread::Current()->ProcessMessages(1000); |
| 1377 | 1355 |
| 1378 EXPECT_FALSE(ep1_ch1()->receiving()); | 1356 EXPECT_FALSE(ep1_ch1()->receiving()); |
| 1379 EXPECT_FALSE(ep1_ch1()->writable()); | 1357 EXPECT_FALSE(ep1_ch1()->writable()); |
| 1380 EXPECT_FALSE(ep2_ch1()->receiving()); | 1358 EXPECT_FALSE(ep2_ch1()->receiving()); |
| 1381 EXPECT_FALSE(ep2_ch1()->writable()); | 1359 EXPECT_FALSE(ep2_ch1()->writable()); |
| 1382 | 1360 |
| 1383 DestroyChannels(); | 1361 DestroyChannels(); |
| 1384 } | 1362 } |
| 1385 | 1363 |
| 1386 // Test that a peer behind NAT can connect to a peer that has | 1364 // Test that a peer behind NAT can connect to a peer that has |
| 1387 // incoming_only flag set. | 1365 // incoming_only flag set. |
| 1388 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { | 1366 TEST_F(P2PTransportChannelTest, IncomingOnlyOpen) { |
| 1389 ConfigureEndpoints(OPEN, NAT_FULL_CONE, kDefaultPortAllocatorFlags, | 1367 ConfigureEndpoints(OPEN, NAT_FULL_CONE, kDefaultPortAllocatorFlags, |
| 1390 kDefaultPortAllocatorFlags); | 1368 kDefaultPortAllocatorFlags); |
| 1391 | 1369 |
| 1392 SetAllocatorFlags(0, kOnlyLocalPorts); | 1370 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1393 CreateChannels(1); | 1371 CreateChannels(); |
| 1394 ep1_ch1()->set_incoming_only(true); | 1372 ep1_ch1()->set_incoming_only(true); |
| 1395 | 1373 |
| 1396 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1374 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
| 1397 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1375 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1398 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1376 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1399 1000, 1000); | 1377 1000, 1000); |
| 1400 | 1378 |
| 1401 DestroyChannels(); | 1379 DestroyChannels(); |
| 1402 } | 1380 } |
| 1403 | 1381 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1419 SetAllowTcpListen(1, false); // active. | 1397 SetAllowTcpListen(1, false); // active. |
| 1420 | 1398 |
| 1421 // We want SetRemoteIceParameters to be called as it normally would. | 1399 // We want SetRemoteIceParameters to be called as it normally would. |
| 1422 // Otherwise we won't know what parameters to use for the expected | 1400 // Otherwise we won't know what parameters to use for the expected |
| 1423 // prflx TCP candidates. | 1401 // prflx TCP candidates. |
| 1424 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); | 1402 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| 1425 | 1403 |
| 1426 // Pause candidate so we could verify the candidate properties. | 1404 // Pause candidate so we could verify the candidate properties. |
| 1427 PauseCandidates(0); | 1405 PauseCandidates(0); |
| 1428 PauseCandidates(1); | 1406 PauseCandidates(1); |
| 1429 CreateChannels(1); | 1407 CreateChannels(); |
| 1430 | 1408 |
| 1431 // Verify tcp candidates. | 1409 // Verify tcp candidates. |
| 1432 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); | 1410 VerifySavedTcpCandidates(0, TCPTYPE_PASSIVE_STR); |
| 1433 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); | 1411 VerifySavedTcpCandidates(1, TCPTYPE_ACTIVE_STR); |
| 1434 | 1412 |
| 1435 // Resume candidates. | 1413 // Resume candidates. |
| 1436 ResumeCandidates(0); | 1414 ResumeCandidates(0); |
| 1437 ResumeCandidates(1); | 1415 ResumeCandidates(1); |
| 1438 | 1416 |
| 1439 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1417 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1440 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1418 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1441 1000); | 1419 1000); |
| 1442 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1420 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1443 ep2_ch1()->selected_connection() && | 1421 ep2_ch1()->selected_connection() && |
| 1444 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1422 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1445 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1423 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1446 | 1424 |
| 1447 TestSendRecv(1); | 1425 TestSendRecv(); |
| 1448 DestroyChannels(); | 1426 DestroyChannels(); |
| 1449 } | 1427 } |
| 1450 | 1428 |
| 1451 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { | 1429 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { |
| 1452 AddAddress(0, kPublicAddrs[0]); | 1430 AddAddress(0, kPublicAddrs[0]); |
| 1453 AddAddress(1, kPublicAddrs[1]); | 1431 AddAddress(1, kPublicAddrs[1]); |
| 1454 TestSignalRoleConflict(); | 1432 TestSignalRoleConflict(); |
| 1455 } | 1433 } |
| 1456 | 1434 |
| 1457 // Tests that the ice configs (protocol, tiebreaker and role) can be passed | 1435 // Tests that the ice configs (protocol, tiebreaker and role) can be passed |
| 1458 // down to ports. | 1436 // down to ports. |
| 1459 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { | 1437 TEST_F(P2PTransportChannelTest, TestIceConfigWillPassDownToPort) { |
| 1460 AddAddress(0, kPublicAddrs[0]); | 1438 AddAddress(0, kPublicAddrs[0]); |
| 1461 AddAddress(1, kPublicAddrs[1]); | 1439 AddAddress(1, kPublicAddrs[1]); |
| 1462 | 1440 |
| 1463 // Give the first connection the higher tiebreaker so its role won't | 1441 // Give the first connection the higher tiebreaker so its role won't |
| 1464 // change unless we tell it to. | 1442 // change unless we tell it to. |
| 1465 SetIceRole(0, ICEROLE_CONTROLLING); | 1443 SetIceRole(0, ICEROLE_CONTROLLING); |
| 1466 SetIceTiebreaker(0, kHighTiebreaker); | 1444 SetIceTiebreaker(0, kHighTiebreaker); |
| 1467 SetIceRole(1, ICEROLE_CONTROLLING); | 1445 SetIceRole(1, ICEROLE_CONTROLLING); |
| 1468 SetIceTiebreaker(1, kLowTiebreaker); | 1446 SetIceTiebreaker(1, kLowTiebreaker); |
| 1469 | 1447 |
| 1470 CreateChannels(1); | 1448 CreateChannels(); |
| 1471 | 1449 |
| 1472 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), 1000); | 1450 EXPECT_EQ_WAIT(2u, ep1_ch1()->ports().size(), 1000); |
| 1473 | 1451 |
| 1474 const std::vector<PortInterface*> ports_before = ep1_ch1()->ports(); | 1452 const std::vector<PortInterface*> ports_before = ep1_ch1()->ports(); |
| 1475 for (size_t i = 0; i < ports_before.size(); ++i) { | 1453 for (size_t i = 0; i < ports_before.size(); ++i) { |
| 1476 EXPECT_EQ(ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); | 1454 EXPECT_EQ(ICEROLE_CONTROLLING, ports_before[i]->GetIceRole()); |
| 1477 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); | 1455 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); |
| 1478 } | 1456 } |
| 1479 | 1457 |
| 1480 ep1_ch1()->SetIceRole(ICEROLE_CONTROLLED); | 1458 ep1_ch1()->SetIceRole(ICEROLE_CONTROLLED); |
| 1481 ep1_ch1()->SetIceTiebreaker(kLowTiebreaker); | 1459 ep1_ch1()->SetIceTiebreaker(kLowTiebreaker); |
| 1482 | 1460 |
| 1483 const std::vector<PortInterface*> ports_after = ep1_ch1()->ports(); | 1461 const std::vector<PortInterface*> ports_after = ep1_ch1()->ports(); |
| 1484 for (size_t i = 0; i < ports_after.size(); ++i) { | 1462 for (size_t i = 0; i < ports_after.size(); ++i) { |
| 1485 EXPECT_EQ(ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); | 1463 EXPECT_EQ(ICEROLE_CONTROLLED, ports_before[i]->GetIceRole()); |
| 1486 // SetIceTiebreaker after ports have been created will fail. So expect the | 1464 // SetIceTiebreaker after ports have been created will fail. So expect the |
| 1487 // original value. | 1465 // original value. |
| 1488 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); | 1466 EXPECT_EQ(kHighTiebreaker, ports_before[i]->IceTiebreaker()); |
| 1489 } | 1467 } |
| 1490 | 1468 |
| 1491 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && | 1469 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && |
| 1492 ep1_ch1()->writable() && | 1470 ep1_ch1()->writable() && |
| 1493 ep2_ch1()->receiving() && | 1471 ep2_ch1()->receiving() && |
| 1494 ep2_ch1()->writable(), | 1472 ep2_ch1()->writable(), |
| 1495 1000); | 1473 1000); |
| 1496 | 1474 |
| 1497 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1475 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1498 ep2_ch1()->selected_connection()); | 1476 ep2_ch1()->selected_connection()); |
| 1499 | 1477 |
| 1500 TestSendRecv(1); | 1478 TestSendRecv(); |
| 1501 DestroyChannels(); | 1479 DestroyChannels(); |
| 1502 } | 1480 } |
| 1503 | 1481 |
| 1504 // Verify that we can set DSCP value and retrieve properly from P2PTC. | 1482 // Verify that we can set DSCP value and retrieve properly from P2PTC. |
| 1505 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { | 1483 TEST_F(P2PTransportChannelTest, TestDefaultDscpValue) { |
| 1506 AddAddress(0, kPublicAddrs[0]); | 1484 AddAddress(0, kPublicAddrs[0]); |
| 1507 AddAddress(1, kPublicAddrs[1]); | 1485 AddAddress(1, kPublicAddrs[1]); |
| 1508 | 1486 |
| 1509 CreateChannels(1); | 1487 CreateChannels(); |
| 1510 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1488 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
| 1511 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); | 1489 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); |
| 1512 EXPECT_EQ(rtc::DSCP_NO_CHANGE, | 1490 EXPECT_EQ(rtc::DSCP_NO_CHANGE, |
| 1513 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); | 1491 GetEndpoint(1)->cd1_.ch_->DefaultDscpValue()); |
| 1514 GetEndpoint(0)->cd1_.ch_->SetOption( | 1492 GetEndpoint(0)->cd1_.ch_->SetOption( |
| 1515 rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); | 1493 rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); |
| 1516 GetEndpoint(1)->cd1_.ch_->SetOption( | 1494 GetEndpoint(1)->cd1_.ch_->SetOption( |
| 1517 rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); | 1495 rtc::Socket::OPT_DSCP, rtc::DSCP_CS6); |
| 1518 EXPECT_EQ(rtc::DSCP_CS6, | 1496 EXPECT_EQ(rtc::DSCP_CS6, |
| 1519 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); | 1497 GetEndpoint(0)->cd1_.ch_->DefaultDscpValue()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1536 AddAddress(1, kIPv6PublicAddrs[1]); | 1514 AddAddress(1, kIPv6PublicAddrs[1]); |
| 1537 AddAddress(1, kPublicAddrs[1]); | 1515 AddAddress(1, kPublicAddrs[1]); |
| 1538 | 1516 |
| 1539 SetAllocationStepDelay(0, kMinimumStepDelay); | 1517 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1540 SetAllocationStepDelay(1, kMinimumStepDelay); | 1518 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1541 | 1519 |
| 1542 // Enable IPv6 | 1520 // Enable IPv6 |
| 1543 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); | 1521 SetAllocatorFlags(0, PORTALLOCATOR_ENABLE_IPV6); |
| 1544 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); | 1522 SetAllocatorFlags(1, PORTALLOCATOR_ENABLE_IPV6); |
| 1545 | 1523 |
| 1546 CreateChannels(1); | 1524 CreateChannels(); |
| 1547 | 1525 |
| 1548 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1526 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1549 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1527 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1550 1000); | 1528 1000); |
| 1551 EXPECT_TRUE( | 1529 EXPECT_TRUE( |
| 1552 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && | 1530 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
| 1553 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && | 1531 LocalCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[0]) && |
| 1554 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); | 1532 RemoteCandidate(ep1_ch1())->address().EqualIPs(kIPv6PublicAddrs[1])); |
| 1555 | 1533 |
| 1556 TestSendRecv(1); | 1534 TestSendRecv(); |
| 1557 DestroyChannels(); | 1535 DestroyChannels(); |
| 1558 } | 1536 } |
| 1559 | 1537 |
| 1560 // Testing forceful TURN connections. | 1538 // Testing forceful TURN connections. |
| 1561 TEST_F(P2PTransportChannelTest, TestForceTurn) { | 1539 TEST_F(P2PTransportChannelTest, TestForceTurn) { |
| 1562 ConfigureEndpoints( | 1540 ConfigureEndpoints( |
| 1563 NAT_PORT_RESTRICTED, NAT_SYMMETRIC, | 1541 NAT_PORT_RESTRICTED, NAT_SYMMETRIC, |
| 1564 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET, | 1542 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET, |
| 1565 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1543 kDefaultPortAllocatorFlags | PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
| 1566 set_force_relay(true); | 1544 set_force_relay(true); |
| 1567 | 1545 |
| 1568 SetAllocationStepDelay(0, kMinimumStepDelay); | 1546 SetAllocationStepDelay(0, kMinimumStepDelay); |
| 1569 SetAllocationStepDelay(1, kMinimumStepDelay); | 1547 SetAllocationStepDelay(1, kMinimumStepDelay); |
| 1570 | 1548 |
| 1571 CreateChannels(1); | 1549 CreateChannels(); |
| 1572 | 1550 |
| 1573 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1551 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1574 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1552 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1575 2000); | 1553 2000); |
| 1576 | 1554 |
| 1577 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1555 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1578 ep2_ch1()->selected_connection()); | 1556 ep2_ch1()->selected_connection()); |
| 1579 | 1557 |
| 1580 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); | 1558 EXPECT_EQ("relay", RemoteCandidate(ep1_ch1())->type()); |
| 1581 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); | 1559 EXPECT_EQ("relay", LocalCandidate(ep1_ch1())->type()); |
| 1582 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); | 1560 EXPECT_EQ("relay", RemoteCandidate(ep2_ch1())->type()); |
| 1583 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); | 1561 EXPECT_EQ("relay", LocalCandidate(ep2_ch1())->type()); |
| 1584 | 1562 |
| 1585 TestSendRecv(1); | 1563 TestSendRecv(); |
| 1586 DestroyChannels(); | 1564 DestroyChannels(); |
| 1587 } | 1565 } |
| 1588 | 1566 |
| 1589 // Test that if continual gathering is set to true, ICE gathering state will | 1567 // Test that if continual gathering is set to true, ICE gathering state will |
| 1590 // not change to "Complete", and vice versa. | 1568 // not change to "Complete", and vice versa. |
| 1591 TEST_F(P2PTransportChannelTest, TestContinualGathering) { | 1569 TEST_F(P2PTransportChannelTest, TestContinualGathering) { |
| 1592 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, | 1570 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| 1593 kDefaultPortAllocatorFlags); | 1571 kDefaultPortAllocatorFlags); |
| 1594 SetAllocationStepDelay(0, kDefaultStepDelay); | 1572 SetAllocationStepDelay(0, kDefaultStepDelay); |
| 1595 SetAllocationStepDelay(1, kDefaultStepDelay); | 1573 SetAllocationStepDelay(1, kDefaultStepDelay); |
| 1596 IceConfig continual_gathering_config = | 1574 IceConfig continual_gathering_config = |
| 1597 CreateIceConfig(1000, GATHER_CONTINUALLY); | 1575 CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 1598 // By default, ep2 does not gather continually. | 1576 // By default, ep2 does not gather continually. |
| 1599 IceConfig default_config; | 1577 IceConfig default_config; |
| 1600 CreateChannels(1, continual_gathering_config, default_config); | 1578 CreateChannels(continual_gathering_config, default_config); |
| 1601 | 1579 |
| 1602 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1580 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
| 1603 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1581 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1604 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1582 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1605 1000, 1000); | 1583 1000, 1000); |
| 1606 WAIT(IceGatheringState::kIceGatheringComplete == ep1_ch1()->gathering_state(), | 1584 WAIT(IceGatheringState::kIceGatheringComplete == ep1_ch1()->gathering_state(), |
| 1607 1000); | 1585 1000); |
| 1608 EXPECT_EQ(IceGatheringState::kIceGatheringGathering, | 1586 EXPECT_EQ(IceGatheringState::kIceGatheringGathering, |
| 1609 ep1_ch1()->gathering_state()); | 1587 ep1_ch1()->gathering_state()); |
| 1610 // By now, ep2 should have completed gathering. | 1588 // By now, ep2 should have completed gathering. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1632 const PortAllocatorSession* pooled_session_2 = | 1610 const PortAllocatorSession* pooled_session_2 = |
| 1633 allocator_2->GetPooledSession(); | 1611 allocator_2->GetPooledSession(); |
| 1634 ASSERT_NE(nullptr, pooled_session_1); | 1612 ASSERT_NE(nullptr, pooled_session_1); |
| 1635 ASSERT_NE(nullptr, pooled_session_2); | 1613 ASSERT_NE(nullptr, pooled_session_2); |
| 1636 // Sanity check that pooled sessions haven't gathered anything yet. | 1614 // Sanity check that pooled sessions haven't gathered anything yet. |
| 1637 EXPECT_TRUE(pooled_session_1->ReadyPorts().empty()); | 1615 EXPECT_TRUE(pooled_session_1->ReadyPorts().empty()); |
| 1638 EXPECT_TRUE(pooled_session_1->ReadyCandidates().empty()); | 1616 EXPECT_TRUE(pooled_session_1->ReadyCandidates().empty()); |
| 1639 EXPECT_TRUE(pooled_session_2->ReadyPorts().empty()); | 1617 EXPECT_TRUE(pooled_session_2->ReadyPorts().empty()); |
| 1640 EXPECT_TRUE(pooled_session_2->ReadyCandidates().empty()); | 1618 EXPECT_TRUE(pooled_session_2->ReadyCandidates().empty()); |
| 1641 // Now let the endpoints connect and try exchanging some data. | 1619 // Now let the endpoints connect and try exchanging some data. |
| 1642 CreateChannels(1); | 1620 CreateChannels(); |
| 1643 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1621 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
| 1644 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1622 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1645 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1623 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1646 1000, 1000); | 1624 1000, 1000); |
| 1647 TestSendRecv(1); | 1625 TestSendRecv(); |
| 1648 // Make sure the P2PTransportChannels are actually using ports from the | 1626 // Make sure the P2PTransportChannels are actually using ports from the |
| 1649 // pooled sessions. | 1627 // pooled sessions. |
| 1650 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); | 1628 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); |
| 1651 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); | 1629 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); |
| 1652 EXPECT_NE(pooled_ports_1.end(), | 1630 EXPECT_NE(pooled_ports_1.end(), |
| 1653 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1631 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
| 1654 ep1_ch1()->selected_connection()->port())); | 1632 ep1_ch1()->selected_connection()->port())); |
| 1655 EXPECT_NE(pooled_ports_2.end(), | 1633 EXPECT_NE(pooled_ports_2.end(), |
| 1656 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1634 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
| 1657 ep2_ch1()->selected_connection()->port())); | 1635 ep2_ch1()->selected_connection()->port())); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1675 const PortAllocatorSession* pooled_session_2 = | 1653 const PortAllocatorSession* pooled_session_2 = |
| 1676 allocator_2->GetPooledSession(); | 1654 allocator_2->GetPooledSession(); |
| 1677 ASSERT_NE(nullptr, pooled_session_1); | 1655 ASSERT_NE(nullptr, pooled_session_1); |
| 1678 ASSERT_NE(nullptr, pooled_session_2); | 1656 ASSERT_NE(nullptr, pooled_session_2); |
| 1679 // Wait for the pooled sessions to finish gathering before the | 1657 // Wait for the pooled sessions to finish gathering before the |
| 1680 // P2PTransportChannels try to use them. | 1658 // P2PTransportChannels try to use them. |
| 1681 EXPECT_TRUE_WAIT(pooled_session_1->CandidatesAllocationDone() && | 1659 EXPECT_TRUE_WAIT(pooled_session_1->CandidatesAllocationDone() && |
| 1682 pooled_session_2->CandidatesAllocationDone(), | 1660 pooled_session_2->CandidatesAllocationDone(), |
| 1683 kDefaultTimeout); | 1661 kDefaultTimeout); |
| 1684 // Now let the endpoints connect and try exchanging some data. | 1662 // Now let the endpoints connect and try exchanging some data. |
| 1685 CreateChannels(1); | 1663 CreateChannels(); |
| 1686 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && | 1664 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && ep2_ch1() != NULL && |
| 1687 ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1665 ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1688 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1666 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1689 1000, 1000); | 1667 1000, 1000); |
| 1690 TestSendRecv(1); | 1668 TestSendRecv(); |
| 1691 // Make sure the P2PTransportChannels are actually using ports from the | 1669 // Make sure the P2PTransportChannels are actually using ports from the |
| 1692 // pooled sessions. | 1670 // pooled sessions. |
| 1693 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); | 1671 auto pooled_ports_1 = pooled_session_1->ReadyPorts(); |
| 1694 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); | 1672 auto pooled_ports_2 = pooled_session_2->ReadyPorts(); |
| 1695 EXPECT_NE(pooled_ports_1.end(), | 1673 EXPECT_NE(pooled_ports_1.end(), |
| 1696 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), | 1674 std::find(pooled_ports_1.begin(), pooled_ports_1.end(), |
| 1697 ep1_ch1()->selected_connection()->port())); | 1675 ep1_ch1()->selected_connection()->port())); |
| 1698 EXPECT_NE(pooled_ports_2.end(), | 1676 EXPECT_NE(pooled_ports_2.end(), |
| 1699 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), | 1677 std::find(pooled_ports_2.begin(), pooled_ports_2.end(), |
| 1700 ep2_ch1()->selected_connection()->port())); | 1678 ep2_ch1()->selected_connection()->port())); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 AddAddress(1, kAlternateAddrs[1]); | 1898 AddAddress(1, kAlternateAddrs[1]); |
| 1921 AddAddress(1, kPublicAddrs[1]); | 1899 AddAddress(1, kPublicAddrs[1]); |
| 1922 | 1900 |
| 1923 // Use only local ports for simplicity. | 1901 // Use only local ports for simplicity. |
| 1924 SetAllocatorFlags(0, kOnlyLocalPorts); | 1902 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1925 SetAllocatorFlags(1, kOnlyLocalPorts); | 1903 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 1926 | 1904 |
| 1927 // Make the receiving timeout shorter for testing. | 1905 // Make the receiving timeout shorter for testing. |
| 1928 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | 1906 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| 1929 // Create channels and let them go writable, as usual. | 1907 // Create channels and let them go writable, as usual. |
| 1930 CreateChannels(1, config, config); | 1908 CreateChannels(config, config); |
| 1931 | 1909 |
| 1932 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1910 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1933 ep2_ch1()->receiving() && | 1911 ep2_ch1()->receiving() && |
| 1934 ep2_ch1()->writable(), | 1912 ep2_ch1()->writable(), |
| 1935 3000, clock); | 1913 3000, clock); |
| 1936 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1914 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1937 ep2_ch1()->selected_connection() && | 1915 ep2_ch1()->selected_connection() && |
| 1938 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1916 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1939 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1917 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1940 | 1918 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 AddAddress(0, kPublicAddrs[0]); | 1951 AddAddress(0, kPublicAddrs[0]); |
| 1974 AddAddress(1, kPublicAddrs[1]); | 1952 AddAddress(1, kPublicAddrs[1]); |
| 1975 | 1953 |
| 1976 // Use only local ports for simplicity. | 1954 // Use only local ports for simplicity. |
| 1977 SetAllocatorFlags(0, kOnlyLocalPorts); | 1955 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 1978 SetAllocatorFlags(1, kOnlyLocalPorts); | 1956 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 1979 | 1957 |
| 1980 // Make the receiving timeout shorter for testing. | 1958 // Make the receiving timeout shorter for testing. |
| 1981 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | 1959 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| 1982 // Create channels and let them go writable, as usual. | 1960 // Create channels and let them go writable, as usual. |
| 1983 CreateChannels(1, config, config); | 1961 CreateChannels(config, config); |
| 1984 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1962 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 1985 ep2_ch1()->receiving() && | 1963 ep2_ch1()->receiving() && |
| 1986 ep2_ch1()->writable(), | 1964 ep2_ch1()->writable(), |
| 1987 3000, clock); | 1965 3000, clock); |
| 1988 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 1966 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 1989 ep2_ch1()->selected_connection() && | 1967 ep2_ch1()->selected_connection() && |
| 1990 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1968 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 1991 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1969 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 1992 | 1970 |
| 1993 // Blackhole any traffic to or from the public addrs. | 1971 // Blackhole any traffic to or from the public addrs. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 | 2006 |
| 2029 // Use only local ports for simplicity. | 2007 // Use only local ports for simplicity. |
| 2030 SetAllocatorFlags(0, kOnlyLocalPorts); | 2008 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2031 SetAllocatorFlags(1, kOnlyLocalPorts); | 2009 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2032 | 2010 |
| 2033 // We want it to set the remote ICE parameters when creating channels. | 2011 // We want it to set the remote ICE parameters when creating channels. |
| 2034 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); | 2012 set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| 2035 // Make the receiving timeout shorter for testing. | 2013 // Make the receiving timeout shorter for testing. |
| 2036 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); | 2014 IceConfig config = CreateIceConfig(1000, GATHER_ONCE); |
| 2037 // Create channels with ICE renomination and let them go writable as usual. | 2015 // Create channels with ICE renomination and let them go writable as usual. |
| 2038 CreateChannels(1, config, config, true); | 2016 CreateChannels(config, config, true); |
| 2039 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2017 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2040 ep2_ch1()->receiving() && | 2018 ep2_ch1()->receiving() && |
| 2041 ep2_ch1()->writable(), | 2019 ep2_ch1()->writable(), |
| 2042 3000, clock); | 2020 3000, clock); |
| 2043 EXPECT_TRUE_SIMULATED_WAIT( | 2021 EXPECT_TRUE_SIMULATED_WAIT( |
| 2044 ep2_ch1()->selected_connection()->remote_nomination() > 0 && | 2022 ep2_ch1()->selected_connection()->remote_nomination() > 0 && |
| 2045 ep1_ch1()->selected_connection()->acked_nomination() > 0, | 2023 ep1_ch1()->selected_connection()->acked_nomination() > 0, |
| 2046 kDefaultTimeout, clock); | 2024 kDefaultTimeout, clock); |
| 2047 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); | 2025 const Connection* selected_connection1 = ep1_ch1()->selected_connection(); |
| 2048 Connection* selected_connection2 = | 2026 Connection* selected_connection2 = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2061 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 2084 // priority than others. This is due to FakeNetwork::AddInterface method. | 2062 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 2085 AddAddress(1, kAlternateAddrs[1]); | 2063 AddAddress(1, kAlternateAddrs[1]); |
| 2086 AddAddress(1, kPublicAddrs[1]); | 2064 AddAddress(1, kPublicAddrs[1]); |
| 2087 | 2065 |
| 2088 // Use only local ports for simplicity. | 2066 // Use only local ports for simplicity. |
| 2089 SetAllocatorFlags(0, kOnlyLocalPorts); | 2067 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2090 SetAllocatorFlags(1, kOnlyLocalPorts); | 2068 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2091 | 2069 |
| 2092 // Create channels and let them go writable, as usual. | 2070 // Create channels and let them go writable, as usual. |
| 2093 CreateChannels(1); | 2071 CreateChannels(); |
| 2094 | 2072 |
| 2095 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2073 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2096 ep2_ch1()->receiving() && | 2074 ep2_ch1()->receiving() && |
| 2097 ep2_ch1()->writable(), | 2075 ep2_ch1()->writable(), |
| 2098 3000, clock); | 2076 3000, clock); |
| 2099 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 2077 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 2100 ep2_ch1()->selected_connection() && | 2078 ep2_ch1()->selected_connection() && |
| 2101 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 2079 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 2102 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 2080 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 2103 | 2081 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 // priority than others. This is due to FakeNetwork::AddInterface method. | 2121 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 2144 AddAddress(0, kAlternateAddrs[0]); | 2122 AddAddress(0, kAlternateAddrs[0]); |
| 2145 AddAddress(0, kPublicAddrs[0]); | 2123 AddAddress(0, kPublicAddrs[0]); |
| 2146 AddAddress(1, kPublicAddrs[1]); | 2124 AddAddress(1, kPublicAddrs[1]); |
| 2147 | 2125 |
| 2148 // Use only local ports for simplicity. | 2126 // Use only local ports for simplicity. |
| 2149 SetAllocatorFlags(0, kOnlyLocalPorts); | 2127 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2150 SetAllocatorFlags(1, kOnlyLocalPorts); | 2128 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2151 | 2129 |
| 2152 // Create channels and let them go writable, as usual. | 2130 // Create channels and let them go writable, as usual. |
| 2153 CreateChannels(1); | 2131 CreateChannels(); |
| 2154 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2132 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2155 ep2_ch1()->receiving() && | 2133 ep2_ch1()->receiving() && |
| 2156 ep2_ch1()->writable(), | 2134 ep2_ch1()->writable(), |
| 2157 3000, clock); | 2135 3000, clock); |
| 2158 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 2136 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 2159 ep2_ch1()->selected_connection() && | 2137 ep2_ch1()->selected_connection() && |
| 2160 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 2138 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 2161 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 2139 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 2162 | 2140 |
| 2163 // Make the receiving timeout shorter for testing. | 2141 // Make the receiving timeout shorter for testing. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 auto& wifi = kPublicAddrs; | 2178 auto& wifi = kPublicAddrs; |
| 2201 auto& cellular = kAlternateAddrs; | 2179 auto& cellular = kAlternateAddrs; |
| 2202 AddAddress(0, wifi[0], "wifi0", rtc::ADAPTER_TYPE_WIFI); | 2180 AddAddress(0, wifi[0], "wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2203 AddAddress(0, cellular[0], "cellular0", rtc::ADAPTER_TYPE_CELLULAR); | 2181 AddAddress(0, cellular[0], "cellular0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2204 AddAddress(1, wifi[1], "wifi0", rtc::ADAPTER_TYPE_WIFI); | 2182 AddAddress(1, wifi[1], "wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2205 | 2183 |
| 2206 // Use only local ports for simplicity. | 2184 // Use only local ports for simplicity. |
| 2207 SetAllocatorFlags(0, kOnlyLocalPorts); | 2185 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2208 SetAllocatorFlags(1, kOnlyLocalPorts); | 2186 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2209 // Create channels and let them go writable, as usual. | 2187 // Create channels and let them go writable, as usual. |
| 2210 CreateChannels(1); | 2188 CreateChannels(); |
| 2211 // Make the receiving timeout shorter for testing. | 2189 // Make the receiving timeout shorter for testing. |
| 2212 // Set the backup connection ping interval to 25s. | 2190 // Set the backup connection ping interval to 25s. |
| 2213 IceConfig config = CreateIceConfig(1000, GATHER_ONCE, 25000); | 2191 IceConfig config = CreateIceConfig(1000, GATHER_ONCE, 25000); |
| 2214 // Ping the best connection more frequently since we don't have traffic. | 2192 // Ping the best connection more frequently since we don't have traffic. |
| 2215 config.stable_writable_connection_ping_interval = 900; | 2193 config.stable_writable_connection_ping_interval = 900; |
| 2216 ep1_ch1()->SetIceConfig(config); | 2194 ep1_ch1()->SetIceConfig(config); |
| 2217 ep2_ch1()->SetIceConfig(config); | 2195 ep2_ch1()->SetIceConfig(config); |
| 2218 // Need to wait to make sure the connections on both networks are writable. | 2196 // Need to wait to make sure the connections on both networks are writable. |
| 2219 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2197 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2220 ep2_ch1()->receiving() && | 2198 ep2_ch1()->receiving() && |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 AddAddress(0, wifi[0], "test0", rtc::ADAPTER_TYPE_WIFI); | 2231 AddAddress(0, wifi[0], "test0", rtc::ADAPTER_TYPE_WIFI); |
| 2254 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 2232 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2255 AddAddress(1, wifi[1], "test0", rtc::ADAPTER_TYPE_WIFI); | 2233 AddAddress(1, wifi[1], "test0", rtc::ADAPTER_TYPE_WIFI); |
| 2256 AddAddress(1, cellular[1], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 2234 AddAddress(1, cellular[1], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2257 | 2235 |
| 2258 // Use only local ports for simplicity. | 2236 // Use only local ports for simplicity. |
| 2259 SetAllocatorFlags(0, kOnlyLocalPorts); | 2237 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2260 SetAllocatorFlags(1, kOnlyLocalPorts); | 2238 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2261 | 2239 |
| 2262 // Create channels and let them go writable, as usual. | 2240 // Create channels and let them go writable, as usual. |
| 2263 CreateChannels(1); | 2241 CreateChannels(); |
| 2264 | 2242 |
| 2265 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2243 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2266 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2244 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2267 1000, 1000); | 2245 1000, 1000); |
| 2268 // Need to wait to make sure the connections on both networks are writable. | 2246 // Need to wait to make sure the connections on both networks are writable. |
| 2269 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection() && | 2247 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection() && |
| 2270 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 2248 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
| 2271 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | 2249 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), |
| 2272 1000); | 2250 1000); |
| 2273 EXPECT_TRUE_WAIT(ep2_ch1()->selected_connection() && | 2251 EXPECT_TRUE_WAIT(ep2_ch1()->selected_connection() && |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2286 auto& cellular = kPublicAddrs; | 2264 auto& cellular = kPublicAddrs; |
| 2287 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 2265 AddAddress(0, cellular[0], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2288 AddAddress(1, wifi[1], "test0", rtc::ADAPTER_TYPE_WIFI); | 2266 AddAddress(1, wifi[1], "test0", rtc::ADAPTER_TYPE_WIFI); |
| 2289 AddAddress(1, cellular[1], "test1", rtc::ADAPTER_TYPE_CELLULAR); | 2267 AddAddress(1, cellular[1], "test1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2290 | 2268 |
| 2291 // Use only local ports for simplicity. | 2269 // Use only local ports for simplicity. |
| 2292 SetAllocatorFlags(0, kOnlyLocalPorts); | 2270 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2293 SetAllocatorFlags(1, kOnlyLocalPorts); | 2271 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2294 | 2272 |
| 2295 // Create channels and let them go writable, as usual. | 2273 // Create channels and let them go writable, as usual. |
| 2296 CreateChannels(1); | 2274 CreateChannels(); |
| 2297 | 2275 |
| 2298 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2276 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2299 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2277 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2300 1000, 1000); | 2278 1000, 1000); |
| 2301 // Need to wait to make sure the connections on both networks are writable. | 2279 // Need to wait to make sure the connections on both networks are writable. |
| 2302 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection() && | 2280 EXPECT_TRUE_WAIT(ep1_ch1()->selected_connection() && |
| 2303 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), | 2281 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1]), |
| 2304 1000); | 2282 1000); |
| 2305 EXPECT_TRUE_WAIT(ep2_ch1()->selected_connection() && | 2283 EXPECT_TRUE_WAIT(ep2_ch1()->selected_connection() && |
| 2306 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]), | 2284 LocalCandidate(ep2_ch1())->address().EqualIPs(wifi[1]), |
| 2307 1000); | 2285 1000); |
| 2308 DestroyChannels(); | 2286 DestroyChannels(); |
| 2309 } | 2287 } |
| 2310 | 2288 |
| 2311 // Test that the backup connection is pinged at a rate no faster than | 2289 // Test that the backup connection is pinged at a rate no faster than |
| 2312 // what was configured. | 2290 // what was configured. |
| 2313 TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) { | 2291 TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) { |
| 2314 AddAddress(0, kPublicAddrs[0]); | 2292 AddAddress(0, kPublicAddrs[0]); |
| 2315 // Adding alternate address will make sure |kPublicAddrs| has the higher | 2293 // Adding alternate address will make sure |kPublicAddrs| has the higher |
| 2316 // priority than others. This is due to FakeNetwork::AddInterface method. | 2294 // priority than others. This is due to FakeNetwork::AddInterface method. |
| 2317 AddAddress(1, kAlternateAddrs[1]); | 2295 AddAddress(1, kAlternateAddrs[1]); |
| 2318 AddAddress(1, kPublicAddrs[1]); | 2296 AddAddress(1, kPublicAddrs[1]); |
| 2319 | 2297 |
| 2320 // Use only local ports for simplicity. | 2298 // Use only local ports for simplicity. |
| 2321 SetAllocatorFlags(0, kOnlyLocalPorts); | 2299 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2322 SetAllocatorFlags(1, kOnlyLocalPorts); | 2300 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2323 | 2301 |
| 2324 // Create channels and let them go writable, as usual. | 2302 // Create channels and let them go writable, as usual. |
| 2325 CreateChannels(1); | 2303 CreateChannels(); |
| 2326 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2304 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2327 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2305 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2328 1000, 1000); | 2306 1000, 1000); |
| 2329 int backup_ping_interval = 2000; | 2307 int backup_ping_interval = 2000; |
| 2330 ep2_ch1()->SetIceConfig( | 2308 ep2_ch1()->SetIceConfig( |
| 2331 CreateIceConfig(2000, GATHER_ONCE, backup_ping_interval)); | 2309 CreateIceConfig(2000, GATHER_ONCE, backup_ping_interval)); |
| 2332 // After the state becomes COMPLETED, the backup connection will be pinged | 2310 // After the state becomes COMPLETED, the backup connection will be pinged |
| 2333 // once every |backup_ping_interval| milliseconds. | 2311 // once every |backup_ping_interval| milliseconds. |
| 2334 ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == STATE_COMPLETED, 1000); | 2312 ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == STATE_COMPLETED, 1000); |
| 2335 const std::vector<Connection*>& connections = ep2_ch1()->connections(); | 2313 const std::vector<Connection*>& connections = ep2_ch1()->connections(); |
| 2336 ASSERT_EQ(2U, connections.size()); | 2314 ASSERT_EQ(2U, connections.size()); |
| 2337 Connection* backup_conn = connections[1]; | 2315 Connection* backup_conn = connections[1]; |
| 2338 EXPECT_TRUE_WAIT(backup_conn->writable(), 3000); | 2316 EXPECT_TRUE_WAIT(backup_conn->writable(), 3000); |
| 2339 int64_t last_ping_response_ms = backup_conn->last_ping_response_received(); | 2317 int64_t last_ping_response_ms = backup_conn->last_ping_response_received(); |
| 2340 EXPECT_TRUE_WAIT( | 2318 EXPECT_TRUE_WAIT( |
| 2341 last_ping_response_ms < backup_conn->last_ping_response_received(), 5000); | 2319 last_ping_response_ms < backup_conn->last_ping_response_received(), 5000); |
| 2342 int time_elapsed = | 2320 int time_elapsed = |
| 2343 backup_conn->last_ping_response_received() - last_ping_response_ms; | 2321 backup_conn->last_ping_response_received() - last_ping_response_ms; |
| 2344 LOG(LS_INFO) << "Time elapsed: " << time_elapsed; | 2322 LOG(LS_INFO) << "Time elapsed: " << time_elapsed; |
| 2345 EXPECT_GE(time_elapsed, backup_ping_interval); | 2323 EXPECT_GE(time_elapsed, backup_ping_interval); |
| 2346 | 2324 |
| 2347 DestroyChannels(); | 2325 DestroyChannels(); |
| 2348 } | 2326 } |
| 2349 | 2327 |
| 2350 TEST_F(P2PTransportChannelMultihomedTest, TestGetState) { | 2328 TEST_F(P2PTransportChannelMultihomedTest, TestGetState) { |
| 2351 AddAddress(0, kAlternateAddrs[0]); | 2329 AddAddress(0, kAlternateAddrs[0]); |
| 2352 AddAddress(0, kPublicAddrs[0]); | 2330 AddAddress(0, kPublicAddrs[0]); |
| 2353 AddAddress(1, kPublicAddrs[1]); | 2331 AddAddress(1, kPublicAddrs[1]); |
| 2354 // Create channels and let them go writable, as usual. | 2332 // Create channels and let them go writable, as usual. |
| 2355 CreateChannels(1); | 2333 CreateChannels(); |
| 2356 | 2334 |
| 2357 // Both transport channels will reach STATE_COMPLETED quickly. | 2335 // Both transport channels will reach STATE_COMPLETED quickly. |
| 2358 EXPECT_EQ_WAIT(TransportChannelState::STATE_COMPLETED, ep1_ch1()->GetState(), | 2336 EXPECT_EQ_WAIT(TransportChannelState::STATE_COMPLETED, ep1_ch1()->GetState(), |
| 2359 1000); | 2337 1000); |
| 2360 EXPECT_EQ_WAIT(TransportChannelState::STATE_COMPLETED, ep2_ch1()->GetState(), | 2338 EXPECT_EQ_WAIT(TransportChannelState::STATE_COMPLETED, ep2_ch1()->GetState(), |
| 2361 1000); | 2339 1000); |
| 2362 } | 2340 } |
| 2363 | 2341 |
| 2364 // Tests that when a network interface becomes inactive, if Continual Gathering | 2342 // Tests that when a network interface becomes inactive, if Continual Gathering |
| 2365 // policy is GATHER_CONTINUALLY, the ports associated with that network | 2343 // policy is GATHER_CONTINUALLY, the ports associated with that network |
| 2366 // will be removed from the port list of the channel, and the respective | 2344 // will be removed from the port list of the channel, and the respective |
| 2367 // remote candidates on the other participant will be removed eventually. | 2345 // remote candidates on the other participant will be removed eventually. |
| 2368 TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) { | 2346 TEST_F(P2PTransportChannelMultihomedTest, TestNetworkBecomesInactive) { |
| 2369 rtc::ScopedFakeClock clock; | 2347 rtc::ScopedFakeClock clock; |
| 2370 AddAddress(0, kPublicAddrs[0]); | 2348 AddAddress(0, kPublicAddrs[0]); |
| 2371 AddAddress(1, kPublicAddrs[1]); | 2349 AddAddress(1, kPublicAddrs[1]); |
| 2372 // Create channels and let them go writable, as usual. | 2350 // Create channels and let them go writable, as usual. |
| 2373 IceConfig ep1_config = CreateIceConfig(2000, GATHER_CONTINUALLY); | 2351 IceConfig ep1_config = CreateIceConfig(2000, GATHER_CONTINUALLY); |
| 2374 IceConfig ep2_config = CreateIceConfig(2000, GATHER_ONCE); | 2352 IceConfig ep2_config = CreateIceConfig(2000, GATHER_ONCE); |
| 2375 CreateChannels(1, ep1_config, ep2_config); | 2353 CreateChannels(ep1_config, ep2_config); |
| 2376 | 2354 |
| 2377 SetAllocatorFlags(0, kOnlyLocalPorts); | 2355 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2378 SetAllocatorFlags(1, kOnlyLocalPorts); | 2356 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2379 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2357 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2380 ep2_ch1()->receiving() && | 2358 ep2_ch1()->receiving() && |
| 2381 ep2_ch1()->writable(), | 2359 ep2_ch1()->writable(), |
| 2382 kDefaultTimeout, clock); | 2360 kDefaultTimeout, clock); |
| 2383 // More than one port has been created. | 2361 // More than one port has been created. |
| 2384 EXPECT_LE(1U, ep1_ch1()->ports().size()); | 2362 EXPECT_LE(1U, ep1_ch1()->ports().size()); |
| 2385 // Endpoint 1 enabled continual gathering; the port will be removed | 2363 // Endpoint 1 enabled continual gathering; the port will be removed |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2410 // interface is added. | 2388 // interface is added. |
| 2411 TEST_F(P2PTransportChannelMultihomedTest, | 2389 TEST_F(P2PTransportChannelMultihomedTest, |
| 2412 TestContinualGatheringOnNewInterface) { | 2390 TestContinualGatheringOnNewInterface) { |
| 2413 auto& wifi = kAlternateAddrs; | 2391 auto& wifi = kAlternateAddrs; |
| 2414 auto& cellular = kPublicAddrs; | 2392 auto& cellular = kPublicAddrs; |
| 2415 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); | 2393 AddAddress(0, wifi[0], "test_wifi0", rtc::ADAPTER_TYPE_WIFI); |
| 2416 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | 2394 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2417 // Set continual gathering policy. | 2395 // Set continual gathering policy. |
| 2418 IceConfig continual_gathering_config = | 2396 IceConfig continual_gathering_config = |
| 2419 CreateIceConfig(1000, GATHER_CONTINUALLY); | 2397 CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2420 CreateChannels(1, continual_gathering_config, continual_gathering_config); | 2398 CreateChannels(continual_gathering_config, continual_gathering_config); |
| 2421 SetAllocatorFlags(0, kOnlyLocalPorts); | 2399 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2422 SetAllocatorFlags(1, kOnlyLocalPorts); | 2400 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2423 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2401 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2424 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2402 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2425 kDefaultTimeout, kDefaultTimeout); | 2403 kDefaultTimeout, kDefaultTimeout); |
| 2426 | 2404 |
| 2427 // Add a new wifi interface on end point 2. We should expect a new connection | 2405 // Add a new wifi interface on end point 2. We should expect a new connection |
| 2428 // to be created and the new one will be the best connection. | 2406 // to be created and the new one will be the best connection. |
| 2429 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2407 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2430 const cricket::Connection* conn; | 2408 const cricket::Connection* conn; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2461 AddAddress(0, kPublicAddrs[0]); | 2439 AddAddress(0, kPublicAddrs[0]); |
| 2462 AddAddress(1, kPublicAddrs[1]); | 2440 AddAddress(1, kPublicAddrs[1]); |
| 2463 // Use only local ports for simplicity. | 2441 // Use only local ports for simplicity. |
| 2464 SetAllocatorFlags(0, kOnlyLocalPorts); | 2442 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2465 SetAllocatorFlags(1, kOnlyLocalPorts); | 2443 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2466 | 2444 |
| 2467 // Set continual gathering policy. | 2445 // Set continual gathering policy. |
| 2468 IceConfig continual_gathering_config = | 2446 IceConfig continual_gathering_config = |
| 2469 CreateIceConfig(1000, GATHER_CONTINUALLY); | 2447 CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2470 // Create channels and let them go writable, as usual. | 2448 // Create channels and let them go writable, as usual. |
| 2471 CreateChannels(1, continual_gathering_config, continual_gathering_config); | 2449 CreateChannels(continual_gathering_config, continual_gathering_config); |
| 2472 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2450 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2473 ep2_ch1()->receiving() && | 2451 ep2_ch1()->receiving() && |
| 2474 ep2_ch1()->writable(), | 2452 ep2_ch1()->writable(), |
| 2475 3000, clock); | 2453 3000, clock); |
| 2476 EXPECT_TRUE( | 2454 EXPECT_TRUE( |
| 2477 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && | 2455 ep1_ch1()->selected_connection() && ep2_ch1()->selected_connection() && |
| 2478 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 2456 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
| 2479 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 2457 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
| 2480 | 2458 |
| 2481 // Add the new address first and then remove the other one. | 2459 // Add the new address first and then remove the other one. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2518 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | 2496 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2519 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2497 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2520 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | 2498 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2521 // Use only local ports for simplicity. | 2499 // Use only local ports for simplicity. |
| 2522 SetAllocatorFlags(0, kOnlyLocalPorts); | 2500 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2523 SetAllocatorFlags(1, kOnlyLocalPorts); | 2501 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2524 | 2502 |
| 2525 // Set continual gathering policy. | 2503 // Set continual gathering policy. |
| 2526 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY_AND_RECOVER); | 2504 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY_AND_RECOVER); |
| 2527 // Create channels and let them go writable, as usual. | 2505 // Create channels and let them go writable, as usual. |
| 2528 CreateChannels(1, config, config); | 2506 CreateChannels(config, config); |
| 2529 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2507 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2530 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 2508 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 2531 3000, clock); | 2509 3000, clock); |
| 2532 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 2510 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 2533 ep2_ch1()->selected_connection() && | 2511 ep2_ch1()->selected_connection() && |
| 2534 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 2512 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
| 2535 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | 2513 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); |
| 2536 | 2514 |
| 2537 // First destroy all backup connection. | 2515 // First destroy all backup connection. |
| 2538 DestroyAllButBestConnection(ep1_ch1()); | 2516 DestroyAllButBestConnection(ep1_ch1()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2559 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | 2537 AddAddress(0, cellular[0], "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); |
| 2560 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); | 2538 AddAddress(1, wifi[1], "test_wifi1", rtc::ADAPTER_TYPE_WIFI); |
| 2561 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); | 2539 AddAddress(1, cellular[1], "test_cell1", rtc::ADAPTER_TYPE_CELLULAR); |
| 2562 // Use only local ports for simplicity. | 2540 // Use only local ports for simplicity. |
| 2563 SetAllocatorFlags(0, kOnlyLocalPorts); | 2541 SetAllocatorFlags(0, kOnlyLocalPorts); |
| 2564 SetAllocatorFlags(1, kOnlyLocalPorts); | 2542 SetAllocatorFlags(1, kOnlyLocalPorts); |
| 2565 | 2543 |
| 2566 // Create channels and let them go writable, as usual. | 2544 // Create channels and let them go writable, as usual. |
| 2567 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); | 2545 IceConfig config = CreateIceConfig(1000, GATHER_CONTINUALLY); |
| 2568 config.regather_on_failed_networks_interval = rtc::Optional<int>(2000); | 2546 config.regather_on_failed_networks_interval = rtc::Optional<int>(2000); |
| 2569 CreateChannels(1, config, config); | 2547 CreateChannels(config, config); |
| 2570 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 2548 EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| 2571 ep2_ch1()->receiving() && | 2549 ep2_ch1()->receiving() && |
| 2572 ep2_ch1()->writable(), | 2550 ep2_ch1()->writable(), |
| 2573 3000, clock); | 2551 3000, clock); |
| 2574 EXPECT_TRUE(ep1_ch1()->selected_connection() && | 2552 EXPECT_TRUE(ep1_ch1()->selected_connection() && |
| 2575 ep2_ch1()->selected_connection() && | 2553 ep2_ch1()->selected_connection() && |
| 2576 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && | 2554 LocalCandidate(ep1_ch1())->address().EqualIPs(wifi[0]) && |
| 2577 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); | 2555 RemoteCandidate(ep1_ch1())->address().EqualIPs(wifi[1])); |
| 2578 | 2556 |
| 2579 // Destroy all backup connections. | 2557 // Destroy all backup connections. |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4035 | 4013 |
| 4036 // TCP Relay/Relay is the next. | 4014 // TCP Relay/Relay is the next. |
| 4037 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 4015 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
| 4038 TCP_PROTOCOL_NAME); | 4016 TCP_PROTOCOL_NAME); |
| 4039 | 4017 |
| 4040 // Finally, Local/Relay will be pinged. | 4018 // Finally, Local/Relay will be pinged. |
| 4041 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 4019 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
| 4042 } | 4020 } |
| 4043 | 4021 |
| 4044 } // namespace cricket { | 4022 } // namespace cricket { |
| OLD | NEW |