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 |
| 11 #include <memory> |
| 12 |
11 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 13 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
12 #include "webrtc/p2p/base/p2pconstants.h" | 14 #include "webrtc/p2p/base/p2pconstants.h" |
13 #include "webrtc/p2p/base/p2ptransportchannel.h" | 15 #include "webrtc/p2p/base/p2ptransportchannel.h" |
14 #include "webrtc/p2p/base/testrelayserver.h" | 16 #include "webrtc/p2p/base/testrelayserver.h" |
15 #include "webrtc/p2p/base/teststunserver.h" | 17 #include "webrtc/p2p/base/teststunserver.h" |
16 #include "webrtc/p2p/base/testturnserver.h" | 18 #include "webrtc/p2p/base/testturnserver.h" |
17 #include "webrtc/p2p/client/basicportallocator.h" | 19 #include "webrtc/p2p/client/basicportallocator.h" |
18 #include "webrtc/p2p/client/httpportallocator.h" | 20 #include "webrtc/p2p/client/httpportallocator.h" |
19 #include "webrtc/base/fakenetwork.h" | 21 #include "webrtc/base/fakenetwork.h" |
20 #include "webrtc/base/firewallsocketserver.h" | 22 #include "webrtc/base/firewallsocketserver.h" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 365 |
364 ServerAddresses stun_servers; | 366 ServerAddresses stun_servers; |
365 if (!stun_server.IsNil()) { | 367 if (!stun_server.IsNil()) { |
366 stun_servers.insert(stun_server); | 368 stun_servers.insert(stun_server); |
367 } | 369 } |
368 allocator_.reset(new cricket::BasicPortAllocator( | 370 allocator_.reset(new cricket::BasicPortAllocator( |
369 &network_manager_, nat_socket_factory_.get(), stun_servers)); | 371 &network_manager_, nat_socket_factory_.get(), stun_servers)); |
370 allocator().set_step_delay(cricket::kMinimumStepDelay); | 372 allocator().set_step_delay(cricket::kMinimumStepDelay); |
371 } | 373 } |
372 | 374 |
373 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 375 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
374 rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; | 376 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
375 rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; | 377 std::unique_ptr<rtc::FirewallSocketServer> fss_; |
376 rtc::SocketServerScope ss_scope_; | 378 rtc::SocketServerScope ss_scope_; |
377 rtc::scoped_ptr<rtc::NATServer> nat_server_; | 379 std::unique_ptr<rtc::NATServer> nat_server_; |
378 rtc::NATSocketFactory nat_factory_; | 380 rtc::NATSocketFactory nat_factory_; |
379 rtc::scoped_ptr<rtc::BasicPacketSocketFactory> nat_socket_factory_; | 381 std::unique_ptr<rtc::BasicPacketSocketFactory> nat_socket_factory_; |
380 rtc::scoped_ptr<cricket::TestStunServer> stun_server_; | 382 std::unique_ptr<cricket::TestStunServer> stun_server_; |
381 cricket::TestRelayServer relay_server_; | 383 cricket::TestRelayServer relay_server_; |
382 cricket::TestTurnServer turn_server_; | 384 cricket::TestTurnServer turn_server_; |
383 rtc::FakeNetworkManager network_manager_; | 385 rtc::FakeNetworkManager network_manager_; |
384 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; | 386 std::unique_ptr<cricket::BasicPortAllocator> allocator_; |
385 rtc::scoped_ptr<cricket::PortAllocatorSession> session_; | 387 std::unique_ptr<cricket::PortAllocatorSession> session_; |
386 std::vector<cricket::PortInterface*> ports_; | 388 std::vector<cricket::PortInterface*> ports_; |
387 std::vector<cricket::Candidate> candidates_; | 389 std::vector<cricket::Candidate> candidates_; |
388 bool candidate_allocation_done_; | 390 bool candidate_allocation_done_; |
389 }; | 391 }; |
390 | 392 |
391 // Tests that we can init the port allocator and create a session. | 393 // Tests that we can init the port allocator and create a session. |
392 TEST_F(PortAllocatorTest, TestBasic) { | 394 TEST_F(PortAllocatorTest, TestBasic) { |
393 EXPECT_EQ(&network_manager_, allocator().network_manager()); | 395 EXPECT_EQ(&network_manager_, allocator().network_manager()); |
394 EXPECT_EQ(kStunAddr, *allocator().stun_servers().begin()); | 396 EXPECT_EQ(kStunAddr, *allocator().stun_servers().begin()); |
395 ASSERT_EQ(1u, allocator().turn_servers().size()); | 397 ASSERT_EQ(1u, allocator().turn_servers().size()); |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1403 |
1402 // After clearing getting ports, adding a new interface will start getting | 1404 // After clearing getting ports, adding a new interface will start getting |
1403 // ports again. | 1405 // ports again. |
1404 candidates_.clear(); | 1406 candidates_.clear(); |
1405 ports_.clear(); | 1407 ports_.clear(); |
1406 candidate_allocation_done_ = false; | 1408 candidate_allocation_done_ = false; |
1407 network_manager_.AddInterface(kClientAddr2); | 1409 network_manager_.AddInterface(kClientAddr2); |
1408 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1410 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
1409 EXPECT_EQ(2U, ports_.size()); | 1411 EXPECT_EQ(2U, ports_.size()); |
1410 } | 1412 } |
OLD | NEW |