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/relayport.h" | 14 #include "webrtc/p2p/base/relayport.h" |
13 #include "webrtc/p2p/base/relayserver.h" | 15 #include "webrtc/p2p/base/relayserver.h" |
14 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
15 #include "webrtc/base/helpers.h" | 17 #include "webrtc/base/helpers.h" |
16 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
17 #include "webrtc/base/physicalsocketserver.h" | 19 #include "webrtc/base/physicalsocketserver.h" |
18 #include "webrtc/base/scoped_ptr.h" | |
19 #include "webrtc/base/socketadapters.h" | 20 #include "webrtc/base/socketadapters.h" |
20 #include "webrtc/base/socketaddress.h" | 21 #include "webrtc/base/socketaddress.h" |
21 #include "webrtc/base/ssladapter.h" | 22 #include "webrtc/base/ssladapter.h" |
22 #include "webrtc/base/thread.h" | 23 #include "webrtc/base/thread.h" |
23 #include "webrtc/base/virtualsocketserver.h" | 24 #include "webrtc/base/virtualsocketserver.h" |
24 | 25 |
25 using rtc::SocketAddress; | 26 using rtc::SocketAddress; |
26 | 27 |
27 static const SocketAddress kLocalAddress = SocketAddress("192.168.1.2", 0); | 28 static const SocketAddress kLocalAddress = SocketAddress("192.168.1.2", 0); |
28 static const SocketAddress kRelayUdpAddr = SocketAddress("99.99.99.1", 5000); | 29 static const SocketAddress kRelayUdpAddr = SocketAddress("99.99.99.1", 5000); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 cricket::ProtocolAddress(kRelayTcpAddr, cricket::PROTO_TCP); | 173 cricket::ProtocolAddress(kRelayTcpAddr, cricket::PROTO_TCP); |
173 | 174 |
174 // Create a ssl server socket for the RelayServer. | 175 // Create a ssl server socket for the RelayServer. |
175 rtc::AsyncSocket* ssl_server_socket = | 176 rtc::AsyncSocket* ssl_server_socket = |
176 CreateServerSocket(kRelaySslAddr); | 177 CreateServerSocket(kRelaySslAddr); |
177 relay_server_->AddInternalServerSocket(ssl_server_socket, | 178 relay_server_->AddInternalServerSocket(ssl_server_socket, |
178 cricket::PROTO_SSLTCP); | 179 cricket::PROTO_SSLTCP); |
179 | 180 |
180 // Create a tcp server socket that listens on the fake address so | 181 // Create a tcp server socket that listens on the fake address so |
181 // the relay port can attempt to connect to it. | 182 // the relay port can attempt to connect to it. |
182 rtc::scoped_ptr<rtc::AsyncSocket> tcp_server_socket( | 183 std::unique_ptr<rtc::AsyncSocket> tcp_server_socket( |
183 CreateServerSocket(kRelayTcpAddr)); | 184 CreateServerSocket(kRelayTcpAddr)); |
184 | 185 |
185 // Add server addresses to the relay port and let it start. | 186 // Add server addresses to the relay port and let it start. |
186 relay_port_->AddServerAddress(fake_protocol_address); | 187 relay_port_->AddServerAddress(fake_protocol_address); |
187 relay_port_->AddServerAddress( | 188 relay_port_->AddServerAddress( |
188 cricket::ProtocolAddress(kRelaySslAddr, cricket::PROTO_SSLTCP)); | 189 cricket::ProtocolAddress(kRelaySslAddr, cricket::PROTO_SSLTCP)); |
189 relay_port_->PrepareAddress(); | 190 relay_port_->PrepareAddress(); |
190 EXPECT_FALSE(relay_port_->IsReady()); | 191 EXPECT_FALSE(relay_port_->IsReady()); |
191 | 192 |
192 // Should have timed out in 3000 ms(relayport.cc, kSoftConnectTimeoutMs). | 193 // Should have timed out in 3000 ms(relayport.cc, kSoftConnectTimeoutMs). |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 soft_timedout_connections_[i].proto == addr->proto) { | 238 soft_timedout_connections_[i].proto == addr->proto) { |
238 return true; | 239 return true; |
239 } | 240 } |
240 } | 241 } |
241 return false; | 242 return false; |
242 } | 243 } |
243 | 244 |
244 typedef std::map<rtc::AsyncPacketSocket*, int> PacketMap; | 245 typedef std::map<rtc::AsyncPacketSocket*, int> PacketMap; |
245 | 246 |
246 rtc::Thread* main_; | 247 rtc::Thread* main_; |
247 rtc::scoped_ptr<rtc::PhysicalSocketServer> | 248 std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_; |
248 physical_socket_server_; | 249 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_; |
249 rtc::scoped_ptr<rtc::VirtualSocketServer> virtual_socket_server_; | |
250 rtc::SocketServerScope ss_scope_; | 250 rtc::SocketServerScope ss_scope_; |
251 rtc::Network network_; | 251 rtc::Network network_; |
252 rtc::BasicPacketSocketFactory socket_factory_; | 252 rtc::BasicPacketSocketFactory socket_factory_; |
253 std::string username_; | 253 std::string username_; |
254 std::string password_; | 254 std::string password_; |
255 rtc::scoped_ptr<cricket::RelayPort> relay_port_; | 255 std::unique_ptr<cricket::RelayPort> relay_port_; |
256 rtc::scoped_ptr<cricket::RelayServer> relay_server_; | 256 std::unique_ptr<cricket::RelayServer> relay_server_; |
257 std::vector<cricket::ProtocolAddress> failed_connections_; | 257 std::vector<cricket::ProtocolAddress> failed_connections_; |
258 std::vector<cricket::ProtocolAddress> soft_timedout_connections_; | 258 std::vector<cricket::ProtocolAddress> soft_timedout_connections_; |
259 PacketMap received_packet_count_; | 259 PacketMap received_packet_count_; |
260 }; | 260 }; |
261 | 261 |
262 TEST_F(RelayPortTest, ConnectUdp) { | 262 TEST_F(RelayPortTest, ConnectUdp) { |
263 TestConnectUdp(); | 263 TestConnectUdp(); |
264 } | 264 } |
265 | 265 |
266 TEST_F(RelayPortTest, ConnectTcp) { | 266 TEST_F(RelayPortTest, ConnectTcp) { |
267 TestConnectTcp(); | 267 TestConnectTcp(); |
268 } | 268 } |
269 | 269 |
270 TEST_F(RelayPortTest, ConnectSslTcp) { | 270 TEST_F(RelayPortTest, ConnectSslTcp) { |
271 TestConnectSslTcp(); | 271 TestConnectSslTcp(); |
272 } | 272 } |
OLD | NEW |