From a73df559d63b74acc1aeb8d9a4a8d26af6e6c6db Mon Sep 17 00:00:00 2001 From: honghaiz Date: Thu, 27 Oct 2016 11:44:17 -0700 Subject: [PATCH] Do not rely on specific ordering on generated candidates in TestGetAllPortsPortRange This fixes another WebRTC swarming tests. BUG=webrtc:6500 Review-Url: https://codereview.webrtc.org/2450983002 Cr-Commit-Position: refs/heads/master@{#14804} --- webrtc/p2p/client/basicportallocator_unittest.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/webrtc/p2p/client/basicportallocator_unittest.cc b/webrtc/p2p/client/basicportallocator_unittest.cc index afd65a42c5..253a15aaf3 100644 --- a/webrtc/p2p/client/basicportallocator_unittest.cc +++ b/webrtc/p2p/client/basicportallocator_unittest.cc @@ -920,15 +920,19 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsPortRange) { session_->StartGettingPorts(); ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); EXPECT_EQ(4U, ports_.size()); - // Check the port number for the UDP port object. - EXPECT_PRED3(CheckPort, candidates_[0].address(), kMinPort, kMaxPort); - // Check the port number for the STUN port object. - EXPECT_PRED3(CheckPort, candidates_[1].address(), kMinPort, kMaxPort); + + int num_nonrelay_candidates = 0; + for (const Candidate& candidate : candidates_) { + // Check the port number for the UDP/STUN/TCP port objects. + if (candidate.type() != RELAY_PORT_TYPE) { + EXPECT_PRED3(CheckPort, candidate.address(), kMinPort, kMaxPort); + ++num_nonrelay_candidates; + } + } + EXPECT_EQ(3, num_nonrelay_candidates); // Check the port number used to connect to the relay server. EXPECT_PRED3(CheckPort, relay_server_.GetConnection(0).source(), kMinPort, kMaxPort); - // Check the port number for the TCP port object. - EXPECT_PRED3(CheckPort, candidates_[5].address(), kMinPort, kMaxPort); EXPECT_TRUE(candidate_allocation_done_); }