OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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/arraysize.h" | 13 #include "webrtc/base/arraysize.h" |
14 #include "webrtc/base/buffer.h" | 14 #include "webrtc/base/buffer.h" |
15 #include "webrtc/base/crc32.h" | 15 #include "webrtc/base/crc32.h" |
16 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
17 #include "webrtc/base/helpers.h" | 17 #include "webrtc/base/helpers.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/natserver.h" | 19 #include "webrtc/base/natserver.h" |
20 #include "webrtc/base/natsocketfactory.h" | 20 #include "webrtc/base/natsocketfactory.h" |
21 #include "webrtc/base/physicalsocketserver.h" | |
22 #include "webrtc/base/ptr_util.h" | 21 #include "webrtc/base/ptr_util.h" |
23 #include "webrtc/base/socketaddress.h" | 22 #include "webrtc/base/socketaddress.h" |
24 #include "webrtc/base/ssladapter.h" | 23 #include "webrtc/base/ssladapter.h" |
25 #include "webrtc/base/stringutils.h" | 24 #include "webrtc/base/stringutils.h" |
26 #include "webrtc/base/thread.h" | 25 #include "webrtc/base/thread.h" |
27 #include "webrtc/base/virtualsocketserver.h" | 26 #include "webrtc/base/virtualsocketserver.h" |
28 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 27 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
29 #include "webrtc/p2p/base/jseptransport.h" | 28 #include "webrtc/p2p/base/jseptransport.h" |
30 #include "webrtc/p2p/base/relayport.h" | 29 #include "webrtc/p2p/base/relayport.h" |
31 #include "webrtc/p2p/base/stunport.h" | 30 #include "webrtc/p2p/base/stunport.h" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 SocketAddress remote_address_; | 373 SocketAddress remote_address_; |
375 std::unique_ptr<StunMessage> remote_request_; | 374 std::unique_ptr<StunMessage> remote_request_; |
376 std::string remote_frag_; | 375 std::string remote_frag_; |
377 bool nominated_; | 376 bool nominated_; |
378 bool connection_ready_to_send_ = false; | 377 bool connection_ready_to_send_ = false; |
379 }; | 378 }; |
380 | 379 |
381 class PortTest : public testing::Test, public sigslot::has_slots<> { | 380 class PortTest : public testing::Test, public sigslot::has_slots<> { |
382 public: | 381 public: |
383 PortTest() | 382 PortTest() |
384 : pss_(new rtc::PhysicalSocketServer), | 383 : ss_(new rtc::VirtualSocketServer()), |
385 ss_(new rtc::VirtualSocketServer(pss_.get())), | |
386 main_(ss_.get()), | 384 main_(ss_.get()), |
387 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32), | 385 network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32), |
388 socket_factory_(rtc::Thread::Current()), | 386 socket_factory_(rtc::Thread::Current()), |
389 nat_factory1_(ss_.get(), kNatAddr1, SocketAddress()), | 387 nat_factory1_(ss_.get(), kNatAddr1, SocketAddress()), |
390 nat_factory2_(ss_.get(), kNatAddr2, SocketAddress()), | 388 nat_factory2_(ss_.get(), kNatAddr2, SocketAddress()), |
391 nat_socket_factory1_(&nat_factory1_), | 389 nat_socket_factory1_(&nat_factory1_), |
392 nat_socket_factory2_(&nat_factory2_), | 390 nat_socket_factory2_(&nat_factory2_), |
393 stun_server_(TestStunServer::Create(&main_, kStunAddr)), | 391 stun_server_(TestStunServer::Create(&main_, kStunAddr)), |
394 turn_server_(&main_, kTurnUdpIntAddr, kTurnUdpExtAddr), | 392 turn_server_(&main_, kTurnUdpIntAddr, kTurnUdpExtAddr), |
395 relay_server_(&main_, | 393 relay_server_(&main_, |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 void OnDestroyed(PortInterface* port) { ++ports_destroyed_; } | 792 void OnDestroyed(PortInterface* port) { ++ports_destroyed_; } |
795 int ports_destroyed() const { return ports_destroyed_; } | 793 int ports_destroyed() const { return ports_destroyed_; } |
796 | 794 |
797 rtc::BasicPacketSocketFactory* nat_socket_factory1() { | 795 rtc::BasicPacketSocketFactory* nat_socket_factory1() { |
798 return &nat_socket_factory1_; | 796 return &nat_socket_factory1_; |
799 } | 797 } |
800 | 798 |
801 rtc::VirtualSocketServer* vss() { return ss_.get(); } | 799 rtc::VirtualSocketServer* vss() { return ss_.get(); } |
802 | 800 |
803 private: | 801 private: |
804 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | |
805 std::unique_ptr<rtc::VirtualSocketServer> ss_; | 802 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
806 rtc::AutoSocketServerThread main_; | 803 rtc::AutoSocketServerThread main_; |
807 rtc::Network network_; | 804 rtc::Network network_; |
808 rtc::BasicPacketSocketFactory socket_factory_; | 805 rtc::BasicPacketSocketFactory socket_factory_; |
809 std::unique_ptr<rtc::NATServer> nat_server1_; | 806 std::unique_ptr<rtc::NATServer> nat_server1_; |
810 std::unique_ptr<rtc::NATServer> nat_server2_; | 807 std::unique_ptr<rtc::NATServer> nat_server2_; |
811 rtc::NATSocketFactory nat_factory1_; | 808 rtc::NATSocketFactory nat_factory1_; |
812 rtc::NATSocketFactory nat_factory2_; | 809 rtc::NATSocketFactory nat_factory2_; |
813 rtc::BasicPacketSocketFactory nat_socket_factory1_; | 810 rtc::BasicPacketSocketFactory nat_socket_factory1_; |
814 rtc::BasicPacketSocketFactory nat_socket_factory2_; | 811 rtc::BasicPacketSocketFactory nat_socket_factory2_; |
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); | 2876 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); |
2880 EXPECT_NE(conn1, conn2); | 2877 EXPECT_NE(conn1, conn2); |
2881 conn_in_use = port->GetConnection(address); | 2878 conn_in_use = port->GetConnection(address); |
2882 EXPECT_EQ(conn2, conn_in_use); | 2879 EXPECT_EQ(conn2, conn_in_use); |
2883 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); | 2880 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); |
2884 | 2881 |
2885 // Make sure the new connection was not deleted. | 2882 // Make sure the new connection was not deleted. |
2886 rtc::Thread::Current()->ProcessMessages(300); | 2883 rtc::Thread::Current()->ProcessMessages(300); |
2887 EXPECT_TRUE(port->GetConnection(address) != nullptr); | 2884 EXPECT_TRUE(port->GetConnection(address) != nullptr); |
2888 } | 2885 } |
OLD | NEW |