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

Side by Side Diff: webrtc/p2p/base/portallocator_unittest.cc

Issue 2881973002: Get tests working on systems that only support IPv6. (Closed)
Patch Set: Created 3 years, 7 months 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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
11 #include <memory> 11 #include <memory>
12 12
13 #include "webrtc/base/gunit.h" 13 #include "webrtc/base/gunit.h"
14 #include "webrtc/base/physicalsocketserver.h"
14 #include "webrtc/base/thread.h" 15 #include "webrtc/base/thread.h"
16 #include "webrtc/base/virtualsocketserver.h"
15 #include "webrtc/p2p/base/fakeportallocator.h" 17 #include "webrtc/p2p/base/fakeportallocator.h"
16 #include "webrtc/p2p/base/portallocator.h" 18 #include "webrtc/p2p/base/portallocator.h"
17 19
18 static const char kContentName[] = "test content"; 20 static const char kContentName[] = "test content";
19 // Based on ICE_UFRAG_LENGTH 21 // Based on ICE_UFRAG_LENGTH
20 static const char kIceUfrag[] = "UF00"; 22 static const char kIceUfrag[] = "UF00";
21 // Based on ICE_PWD_LENGTH 23 // Based on ICE_PWD_LENGTH
22 static const char kIcePwd[] = "TESTICEPWD00000000000000"; 24 static const char kIcePwd[] = "TESTICEPWD00000000000000";
23 static const char kTurnUsername[] = "test"; 25 static const char kTurnUsername[] = "test";
24 static const char kTurnPassword[] = "test"; 26 static const char kTurnPassword[] = "test";
25 27
26 class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> { 28 class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
27 public: 29 public:
28 PortAllocatorTest() { 30 PortAllocatorTest()
31 : pss_(new rtc::PhysicalSocketServer),
32 vss_(new rtc::VirtualSocketServer(pss_.get())),
33 main_(vss_.get()) {
29 allocator_.reset( 34 allocator_.reset(
30 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); 35 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
31 } 36 }
32 37
33 protected: 38 protected:
34 void SetConfigurationWithPoolSize(int candidate_pool_size) { 39 void SetConfigurationWithPoolSize(int candidate_pool_size) {
35 EXPECT_TRUE(allocator_->SetConfiguration( 40 EXPECT_TRUE(allocator_->SetConfiguration(
36 cricket::ServerAddresses(), std::vector<cricket::RelayServerConfig>(), 41 cricket::ServerAddresses(), std::vector<cricket::RelayServerConfig>(),
37 candidate_pool_size, false)); 42 candidate_pool_size, false));
38 } 43 }
(...skipping 30 matching lines...) Expand all
69 74
70 int GetAllPooledSessionsReturnCount() { 75 int GetAllPooledSessionsReturnCount() {
71 int count = 0; 76 int count = 0;
72 while (GetPooledSession()) { 77 while (GetPooledSession()) {
73 TakePooledSession(); 78 TakePooledSession();
74 ++count; 79 ++count;
75 } 80 }
76 return count; 81 return count;
77 } 82 }
78 83
84 std::unique_ptr<rtc::PhysicalSocketServer> pss_;
85 std::unique_ptr<rtc::VirtualSocketServer> vss_;
86 rtc::AutoSocketServerThread main_;
79 std::unique_ptr<cricket::FakePortAllocator> allocator_; 87 std::unique_ptr<cricket::FakePortAllocator> allocator_;
80 rtc::SocketAddress stun_server_1{"11.11.11.11", 3478}; 88 rtc::SocketAddress stun_server_1{"11.11.11.11", 3478};
81 rtc::SocketAddress stun_server_2{"22.22.22.22", 3478}; 89 rtc::SocketAddress stun_server_2{"22.22.22.22", 3478};
82 cricket::RelayServerConfig turn_server_1{"11.11.11.11", 3478, 90 cricket::RelayServerConfig turn_server_1{"11.11.11.11", 3478,
83 kTurnUsername, kTurnPassword, 91 kTurnUsername, kTurnPassword,
84 cricket::PROTO_UDP, false}; 92 cricket::PROTO_UDP, false};
85 cricket::RelayServerConfig turn_server_2{"22.22.22.22", 3478, 93 cricket::RelayServerConfig turn_server_2{"22.22.22.22", 3478,
86 kTurnUsername, kTurnPassword, 94 kTurnUsername, kTurnPassword,
87 cricket::PROTO_UDP, false}; 95 cricket::PROTO_UDP, false};
88 }; 96 };
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter()); 272 EXPECT_EQ(cricket::CF_RELAY, session->candidate_filter());
265 } 273 }
266 274
267 // Verify that after DiscardCandidatePool, TakePooledSession doesn't return 275 // Verify that after DiscardCandidatePool, TakePooledSession doesn't return
268 // anything. 276 // anything.
269 TEST_F(PortAllocatorTest, DiscardCandidatePool) { 277 TEST_F(PortAllocatorTest, DiscardCandidatePool) {
270 SetConfigurationWithPoolSize(1); 278 SetConfigurationWithPoolSize(1);
271 allocator_->DiscardCandidatePool(); 279 allocator_->DiscardCandidatePool();
272 EXPECT_EQ(0, GetAllPooledSessionsReturnCount()); 280 EXPECT_EQ(0, GetAllPooledSessionsReturnCount());
273 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698