OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 #if defined(WEBRTC_POSIX) | 10 #if defined(WEBRTC_POSIX) |
11 #include <dirent.h> | 11 #include <dirent.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 16 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
17 #include "webrtc/p2p/base/p2pconstants.h" | 17 #include "webrtc/p2p/base/p2pconstants.h" |
18 #include "webrtc/p2p/base/portallocator.h" | 18 #include "webrtc/p2p/base/portallocator.h" |
19 #include "webrtc/p2p/base/tcpport.h" | 19 #include "webrtc/p2p/base/tcpport.h" |
20 #include "webrtc/p2p/base/testturnserver.h" | 20 #include "webrtc/p2p/base/testturnserver.h" |
21 #include "webrtc/p2p/base/turnport.h" | 21 #include "webrtc/p2p/base/turnport.h" |
22 #include "webrtc/p2p/base/udpport.h" | 22 #include "webrtc/p2p/base/udpport.h" |
23 #include "webrtc/base/asynctcpsocket.h" | 23 #include "webrtc/base/asynctcpsocket.h" |
24 #include "webrtc/base/buffer.h" | 24 #include "webrtc/base/buffer.h" |
| 25 #include "webrtc/base/checks.h" |
25 #include "webrtc/base/dscp.h" | 26 #include "webrtc/base/dscp.h" |
26 #include "webrtc/base/fakeclock.h" | 27 #include "webrtc/base/fakeclock.h" |
27 #include "webrtc/base/firewallsocketserver.h" | 28 #include "webrtc/base/firewallsocketserver.h" |
28 #include "webrtc/base/gunit.h" | 29 #include "webrtc/base/gunit.h" |
29 #include "webrtc/base/helpers.h" | 30 #include "webrtc/base/helpers.h" |
30 #include "webrtc/base/logging.h" | 31 #include "webrtc/base/logging.h" |
31 #include "webrtc/base/physicalsocketserver.h" | 32 #include "webrtc/base/physicalsocketserver.h" |
32 #include "webrtc/base/socketadapters.h" | 33 #include "webrtc/base/socketadapters.h" |
33 #include "webrtc/base/socketaddress.h" | 34 #include "webrtc/base/socketaddress.h" |
34 #include "webrtc/base/ssladapter.h" | 35 #include "webrtc/base/ssladapter.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 udp_ready_(false), | 157 udp_ready_(false), |
157 test_finish_(false) { | 158 test_finish_(false) { |
158 // Some code uses "last received time == 0" to represent "nothing received | 159 // Some code uses "last received time == 0" to represent "nothing received |
159 // so far", so we need to start the fake clock at a nonzero time... | 160 // so far", so we need to start the fake clock at a nonzero time... |
160 // TODO(deadbeef): Fix this. | 161 // TODO(deadbeef): Fix this. |
161 fake_clock_.AdvanceTime(rtc::TimeDelta::FromSeconds(1)); | 162 fake_clock_.AdvanceTime(rtc::TimeDelta::FromSeconds(1)); |
162 network_.AddIP(rtc::IPAddress(INADDR_ANY)); | 163 network_.AddIP(rtc::IPAddress(INADDR_ANY)); |
163 } | 164 } |
164 | 165 |
165 virtual void OnMessage(rtc::Message* msg) { | 166 virtual void OnMessage(rtc::Message* msg) { |
166 ASSERT(msg->message_id == MSG_TESTFINISH); | 167 RTC_CHECK(msg->message_id == MSG_TESTFINISH); |
167 if (msg->message_id == MSG_TESTFINISH) | 168 if (msg->message_id == MSG_TESTFINISH) |
168 test_finish_ = true; | 169 test_finish_ = true; |
169 } | 170 } |
170 | 171 |
171 void ConnectSignalAddressReadyToSetLocalhostAsAltenertativeLocalAddress() { | 172 void ConnectSignalAddressReadyToSetLocalhostAsAltenertativeLocalAddress() { |
172 rtc::AsyncPacketSocket* socket = turn_port_->socket(); | 173 rtc::AsyncPacketSocket* socket = turn_port_->socket(); |
173 rtc::VirtualSocket* virtual_socket = | 174 rtc::VirtualSocket* virtual_socket = |
174 ss_->LookupBinding(socket->GetLocalAddress()); | 175 ss_->LookupBinding(socket->GetLocalAddress()); |
175 virtual_socket->SignalAddressReady.connect( | 176 virtual_socket->SignalAddressReady.connect( |
176 this, &TurnPortTest::SetLocalhostAsAltenertativeLocalAddress); | 177 this, &TurnPortTest::SetLocalhostAsAltenertativeLocalAddress); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 server_address, credentials, 0, | 267 server_address, credentials, 0, |
267 origin)); | 268 origin)); |
268 // This TURN port will be the controlling. | 269 // This TURN port will be the controlling. |
269 turn_port_->SetIceRole(ICEROLE_CONTROLLING); | 270 turn_port_->SetIceRole(ICEROLE_CONTROLLING); |
270 ConnectSignals(); | 271 ConnectSignals(); |
271 } | 272 } |
272 | 273 |
273 void CreateSharedTurnPort(const std::string& username, | 274 void CreateSharedTurnPort(const std::string& username, |
274 const std::string& password, | 275 const std::string& password, |
275 const ProtocolAddress& server_address) { | 276 const ProtocolAddress& server_address) { |
276 ASSERT(server_address.proto == PROTO_UDP); | 277 RTC_CHECK(server_address.proto == PROTO_UDP); |
277 | 278 |
278 if (!socket_) { | 279 if (!socket_) { |
279 socket_.reset(socket_factory_.CreateUdpSocket( | 280 socket_.reset(socket_factory_.CreateUdpSocket( |
280 rtc::SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0)); | 281 rtc::SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0)); |
281 ASSERT_TRUE(socket_ != NULL); | 282 ASSERT_TRUE(socket_ != NULL); |
282 socket_->SignalReadPacket.connect( | 283 socket_->SignalReadPacket.connect( |
283 this, &TurnPortTest::OnSocketReadPacket); | 284 this, &TurnPortTest::OnSocketReadPacket); |
284 } | 285 } |
285 | 286 |
286 RelayCredentials credentials(username, password); | 287 RelayCredentials credentials(username, password); |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 EXPECT_TRUE(turn_port_->Candidates().empty()); | 1259 EXPECT_TRUE(turn_port_->Candidates().empty()); |
1259 turn_port_.reset(); | 1260 turn_port_.reset(); |
1260 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); | 1261 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); |
1261 // Waiting for above message to be processed. | 1262 // Waiting for above message to be processed. |
1262 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); | 1263 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); |
1263 EXPECT_EQ(last_fd_count, GetFDCount()); | 1264 EXPECT_EQ(last_fd_count, GetFDCount()); |
1264 } | 1265 } |
1265 #endif | 1266 #endif |
1266 | 1267 |
1267 } // namespace cricket | 1268 } // namespace cricket |
OLD | NEW |