| OLD | NEW |
| 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> |
| 12 |
| 11 #include "webrtc/base/gunit.h" | 13 #include "webrtc/base/gunit.h" |
| 12 #include "webrtc/base/physicalsocketserver.h" | 14 #include "webrtc/base/physicalsocketserver.h" |
| 13 #include "webrtc/base/thread.h" | 15 #include "webrtc/base/thread.h" |
| 14 #include "webrtc/base/virtualsocketserver.h" | 16 #include "webrtc/base/virtualsocketserver.h" |
| 15 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 17 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 16 #include "webrtc/p2p/base/tcpport.h" | 18 #include "webrtc/p2p/base/tcpport.h" |
| 17 | 19 |
| 18 using rtc::SocketAddress; | 20 using rtc::SocketAddress; |
| 19 using cricket::Connection; | 21 using cricket::Connection; |
| 20 using cricket::Port; | 22 using cricket::Port; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 socket->SetAlternativeLocalAddress(local_address); | 58 socket->SetAlternativeLocalAddress(local_address); |
| 57 } | 59 } |
| 58 | 60 |
| 59 TCPPort* CreateTCPPort(const SocketAddress& addr) { | 61 TCPPort* CreateTCPPort(const SocketAddress& addr) { |
| 60 return TCPPort::Create(main_, &socket_factory_, &network_, addr.ipaddr(), 0, | 62 return TCPPort::Create(main_, &socket_factory_, &network_, addr.ipaddr(), 0, |
| 61 0, username_, password_, true); | 63 0, username_, password_, true); |
| 62 } | 64 } |
| 63 | 65 |
| 64 protected: | 66 protected: |
| 65 rtc::Thread* main_; | 67 rtc::Thread* main_; |
| 66 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 68 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
| 67 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; | 69 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
| 68 rtc::SocketServerScope ss_scope_; | 70 rtc::SocketServerScope ss_scope_; |
| 69 rtc::Network network_; | 71 rtc::Network network_; |
| 70 rtc::BasicPacketSocketFactory socket_factory_; | 72 rtc::BasicPacketSocketFactory socket_factory_; |
| 71 std::string username_; | 73 std::string username_; |
| 72 std::string password_; | 74 std::string password_; |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 TEST_F(TCPPortTest, TestTCPPortWithLocalhostAddress) { | 77 TEST_F(TCPPortTest, TestTCPPortWithLocalhostAddress) { |
| 76 rtc::scoped_ptr<TCPPort> lport(CreateTCPPort(kLocalAddr)); | 78 std::unique_ptr<TCPPort> lport(CreateTCPPort(kLocalAddr)); |
| 77 rtc::scoped_ptr<TCPPort> rport(CreateTCPPort(kRemoteAddr)); | 79 std::unique_ptr<TCPPort> rport(CreateTCPPort(kRemoteAddr)); |
| 78 lport->PrepareAddress(); | 80 lport->PrepareAddress(); |
| 79 rport->PrepareAddress(); | 81 rport->PrepareAddress(); |
| 80 // Start to listen to new socket creation event. | 82 // Start to listen to new socket creation event. |
| 81 ConnectSignalSocketCreated(); | 83 ConnectSignalSocketCreated(); |
| 82 Connection* conn = | 84 Connection* conn = |
| 83 lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); | 85 lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE); |
| 84 EXPECT_TRUE_WAIT(conn->connected(), kTimeout); | 86 EXPECT_TRUE_WAIT(conn->connected(), kTimeout); |
| 85 } | 87 } |
| OLD | NEW |