Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webrtc/p2p/client/basicportallocator_unittest.cc

Issue 2450983002: Do not rely on specific ordering on generated candidates in TestGetAllPortsPortRange (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 // Check that an invalid port range fails. 913 // Check that an invalid port range fails.
914 EXPECT_FALSE(SetPortRange(kMaxPort, kMinPort)); 914 EXPECT_FALSE(SetPortRange(kMaxPort, kMinPort));
915 // Check that a null port range succeeds. 915 // Check that a null port range succeeds.
916 EXPECT_TRUE(SetPortRange(0, 0)); 916 EXPECT_TRUE(SetPortRange(0, 0));
917 // Check that a valid port range succeeds. 917 // Check that a valid port range succeeds.
918 EXPECT_TRUE(SetPortRange(kMinPort, kMaxPort)); 918 EXPECT_TRUE(SetPortRange(kMinPort, kMaxPort));
919 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); 919 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
920 session_->StartGettingPorts(); 920 session_->StartGettingPorts();
921 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); 921 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
922 EXPECT_EQ(4U, ports_.size()); 922 EXPECT_EQ(4U, ports_.size());
923 // Check the port number for the UDP port object. 923
924 EXPECT_PRED3(CheckPort, candidates_[0].address(), kMinPort, kMaxPort); 924 int num_nonrelay_candidates = 0;
925 // Check the port number for the STUN port object. 925 for (const Candidate& candidate : candidates_) {
926 EXPECT_PRED3(CheckPort, candidates_[1].address(), kMinPort, kMaxPort); 926 // Check the port number for the UDP/STUN/TCP port object.
Taylor Brandstetter 2016/10/27 16:54:08 nit: "object" -> "objects"
honghaiz3 2016/10/27 17:31:58 Done.
927 if (candidate.type() != RELAY_PORT_TYPE) {
928 EXPECT_PRED3(CheckPort, candidate.address(), kMinPort, kMaxPort);
929 ++num_nonrelay_candidates;
930 }
931 }
932 EXPECT_EQ(3, num_nonrelay_candidates);
927 // Check the port number used to connect to the relay server. 933 // Check the port number used to connect to the relay server.
928 EXPECT_PRED3(CheckPort, relay_server_.GetConnection(0).source(), kMinPort, 934 EXPECT_PRED3(CheckPort, relay_server_.GetConnection(0).source(), kMinPort,
929 kMaxPort); 935 kMaxPort);
930 // Check the port number for the TCP port object.
931 EXPECT_PRED3(CheckPort, candidates_[5].address(), kMinPort, kMaxPort);
932 EXPECT_TRUE(candidate_allocation_done_); 936 EXPECT_TRUE(candidate_allocation_done_);
933 } 937 }
934 938
935 // Test that we don't crash or malfunction if we have no network adapters. 939 // Test that we don't crash or malfunction if we have no network adapters.
936 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoAdapters) { 940 TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoAdapters) {
937 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP)); 941 EXPECT_TRUE(CreateSession(ICE_CANDIDATE_COMPONENT_RTP));
938 session_->StartGettingPorts(); 942 session_->StartGettingPorts();
939 rtc::Thread::Current()->ProcessMessages(100); 943 rtc::Thread::Current()->ProcessMessages(100);
940 // Without network adapter, we should not get any candidate. 944 // Without network adapter, we should not get any candidate.
941 EXPECT_EQ(0U, candidates_.size()); 945 EXPECT_EQ(0U, candidates_.size());
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 for (const Candidate& candidate : candidates) { 1796 for (const Candidate& candidate : candidates) {
1793 // Expect only relay candidates now that the filter is applied. 1797 // Expect only relay candidates now that the filter is applied.
1794 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type()); 1798 EXPECT_EQ(std::string(RELAY_PORT_TYPE), candidate.type());
1795 // Expect that the raddr is emptied due to the CF_RELAY filter. 1799 // Expect that the raddr is emptied due to the CF_RELAY filter.
1796 EXPECT_EQ(candidate.related_address(), 1800 EXPECT_EQ(candidate.related_address(),
1797 rtc::EmptySocketAddressWithFamily(candidate.address().family())); 1801 rtc::EmptySocketAddressWithFamily(candidate.address().family()));
1798 } 1802 }
1799 } 1803 }
1800 1804
1801 } // namespace cricket 1805 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698