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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 470 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 471 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | | 471 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | |
| 472 cricket::PORTALLOCATOR_DISABLE_RELAY | | 472 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 473 cricket::PORTALLOCATOR_DISABLE_TCP); | 473 cricket::PORTALLOCATOR_DISABLE_TCP); |
| 474 session_->StartGettingPorts(); | 474 session_->StartGettingPorts(); |
| 475 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 475 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
| 476 EXPECT_EQ(1U, candidates_.size()); | 476 EXPECT_EQ(1U, candidates_.size()); |
| 477 EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); | 477 EXPECT_EQ(0x12345602U, candidates_[0].address().ip()); |
| 478 } | 478 } |
| 479 | 479 |
| 480 // Test that high cost networks are filtered if the flag | |
| 481 // GATHER_LOW_COST_NETWORK_ONLY is enabled. | |
| 482 TEST_F(BasicPortAllocatorTest, TestGatherLowCostNetworkOnly) { | |
| 483 SocketAddress addr_wifi(IPAddress(0x12345600U), 0); | |
| 484 SocketAddress addr_cellular(IPAddress(0x12345601U), 0); | |
| 485 SocketAddress addr_unknown1(IPAddress(0x12345602U), 0); | |
| 486 SocketAddress addr_unknown2(IPAddress(0x12345603U), 0); | |
| 487 // If both Wifi and Cellular interfaces are present, only gather on the Wifi | |
| 488 // interface. | |
| 489 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); | |
| 490 AddInterface(addr_cellular, "test_cell0", rtc::ADAPTER_TYPE_CELLULAR); | |
| 491 allocator().set_flags(cricket::PORTALLOCATOR_DISABLE_STUN | | |
| 492 cricket::PORTALLOCATOR_DISABLE_RELAY | | |
| 493 cricket::PORTALLOCATOR_DISABLE_TCP | | |
| 494 cricket::PORTALLOCATOR_GATHER_LOW_COST_NETWORK_ONLY); | |
| 495 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | |
| 496 session_->StartGettingPorts(); | |
| 497 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | |
| 498 EXPECT_EQ(1U, candidates_.size()); | |
| 499 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); | |
| 500 | |
| 501 // If both Cellular and Unknown interfaces are present, only gather on the | |
| 502 // Unknown interfaces. | |
|
pthatcher1
2016/05/17 20:44:28
Unknown => unknown
(and Cellular and Wifi here al
honghaiz3
2016/05/18 05:55:03
Done.
| |
| 503 candidates_.clear(); | |
| 504 candidate_allocation_done_ = false; | |
| 505 RemoveInterface(addr_wifi); | |
| 506 AddInterface(addr_unknown1, "test_unknown0", rtc::ADAPTER_TYPE_UNKNOWN); | |
| 507 AddInterface(addr_unknown2, "test_unknown1", rtc::ADAPTER_TYPE_UNKNOWN); | |
| 508 session_->StartGettingPorts(); | |
| 509 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | |
| 510 EXPECT_EQ(2U, candidates_.size()); | |
| 511 EXPECT_TRUE((addr_unknown1.EqualIPs(candidates_[0].address()) && | |
| 512 addr_unknown2.EqualIPs(candidates_[1].address())) || | |
| 513 (addr_unknown1.EqualIPs(candidates_[1].address()) && | |
| 514 addr_unknown2.EqualIPs(candidates_[0].address()))); | |
| 515 | |
| 516 // If Wifi, Cellular, Unknown interfaces are all present, only gather on the | |
| 517 // Wifi interface. | |
| 518 candidates_.clear(); | |
| 519 candidate_allocation_done_ = false; | |
| 520 AddInterface(addr_wifi, "test_wlan0", rtc::ADAPTER_TYPE_WIFI); | |
| 521 session_->StartGettingPorts(); | |
| 522 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | |
| 523 EXPECT_EQ(1U, candidates_.size()); | |
| 524 EXPECT_TRUE(addr_wifi.EqualIPs(candidates_[0].address())); | |
| 525 } | |
| 526 | |
| 480 // Tests that we allocator session not trying to allocate ports for every 250ms. | 527 // Tests that we allocator session not trying to allocate ports for every 250ms. |
| 481 TEST_F(BasicPortAllocatorTest, TestNoNetworkInterface) { | 528 TEST_F(BasicPortAllocatorTest, TestNoNetworkInterface) { |
| 482 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 529 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 483 session_->StartGettingPorts(); | 530 session_->StartGettingPorts(); |
| 484 // Waiting for one second to make sure BasicPortAllocatorSession has not | 531 // Waiting for one second to make sure BasicPortAllocatorSession has not |
| 485 // called OnAllocate multiple times. In old behavior it's called every 250ms. | 532 // called OnAllocate multiple times. In old behavior it's called every 250ms. |
| 486 // When there are no network interfaces, each execution of OnAllocate will | 533 // When there are no network interfaces, each execution of OnAllocate will |
| 487 // result in SignalCandidatesAllocationDone signal. | 534 // result in SignalCandidatesAllocationDone signal. |
| 488 rtc::Thread::Current()->ProcessMessages(1000); | 535 rtc::Thread::Current()->ProcessMessages(1000); |
| 489 EXPECT_TRUE(candidate_allocation_done_); | 536 EXPECT_TRUE(candidate_allocation_done_); |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1491 EXPECT_EQ(1, port->component()); | 1538 EXPECT_EQ(1, port->component()); |
| 1492 EXPECT_EQ(kIceUfrag0, port->username_fragment()); | 1539 EXPECT_EQ(kIceUfrag0, port->username_fragment()); |
| 1493 EXPECT_EQ(kIcePwd0, port->password()); | 1540 EXPECT_EQ(kIcePwd0, port->password()); |
| 1494 } | 1541 } |
| 1495 for (const cricket::Candidate& candidate : candidates) { | 1542 for (const cricket::Candidate& candidate : candidates) { |
| 1496 EXPECT_EQ(1, candidate.component()); | 1543 EXPECT_EQ(1, candidate.component()); |
| 1497 EXPECT_EQ(kIceUfrag0, candidate.username()); | 1544 EXPECT_EQ(kIceUfrag0, candidate.username()); |
| 1498 EXPECT_EQ(kIcePwd0, candidate.password()); | 1545 EXPECT_EQ(kIcePwd0, candidate.password()); |
| 1499 } | 1546 } |
| 1500 } | 1547 } |
| OLD | NEW |