Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: webrtc/p2p/client/portallocator_unittest.cc

Issue 1311353011: Remove AsyncHttpRequest, AutoPortAllocator, ConnectivityChecker, and HttpPortAllocator (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: undo chromium change Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/client/httpportallocator.cc ('k') | webrtc/p2p/p2p.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", 1211 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp",
1212 kClientAddr); 1212 kClientAddr);
1213 EXPECT_PRED5(CheckCandidate, candidates_[2], 1213 EXPECT_PRED5(CheckCandidate, candidates_[2],
1214 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", 1214 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp",
1215 kClientIPv6Addr); 1215 kClientIPv6Addr);
1216 EXPECT_PRED5(CheckCandidate, candidates_[3], 1216 EXPECT_PRED5(CheckCandidate, candidates_[3],
1217 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", 1217 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp",
1218 kClientAddr); 1218 kClientAddr);
1219 EXPECT_EQ(4U, candidates_.size()); 1219 EXPECT_EQ(4U, candidates_.size());
1220 } 1220 }
1221
1222 // Test that the httpportallocator correctly maintains its lists of stun and
1223 // relay servers, by never allowing an empty list.
1224 TEST(HttpPortAllocatorTest, TestHttpPortAllocatorHostLists) {
1225 rtc::FakeNetworkManager network_manager;
1226 cricket::HttpPortAllocator alloc(&network_manager, "unit test agent");
1227 EXPECT_EQ(1U, alloc.relay_hosts().size());
1228 EXPECT_EQ(1U, alloc.stun_hosts().size());
1229
1230 std::vector<std::string> relay_servers;
1231 std::vector<rtc::SocketAddress> stun_servers;
1232
1233 alloc.SetRelayHosts(relay_servers);
1234 alloc.SetStunHosts(stun_servers);
1235 EXPECT_EQ(1U, alloc.relay_hosts().size());
1236 EXPECT_EQ(1U, alloc.stun_hosts().size());
1237
1238 relay_servers.push_back("1.unittest.corp.google.com");
1239 relay_servers.push_back("2.unittest.corp.google.com");
1240 stun_servers.push_back(
1241 rtc::SocketAddress("1.unittest.corp.google.com", 0));
1242 stun_servers.push_back(
1243 rtc::SocketAddress("2.unittest.corp.google.com", 0));
1244
1245 alloc.SetRelayHosts(relay_servers);
1246 alloc.SetStunHosts(stun_servers);
1247 EXPECT_EQ(2U, alloc.relay_hosts().size());
1248 EXPECT_EQ(2U, alloc.stun_hosts().size());
1249 }
1250
1251 // Test that the HttpPortAllocator uses correct URL to create sessions.
1252 TEST(HttpPortAllocatorTest, TestSessionRequestUrl) {
1253 rtc::FakeNetworkManager network_manager;
1254 cricket::HttpPortAllocator alloc(&network_manager, "unit test agent");
1255
1256 rtc::scoped_ptr<cricket::HttpPortAllocatorSessionBase> session(
1257 static_cast<cricket::HttpPortAllocatorSession*>(
1258 alloc.CreateSessionInternal(
1259 "test content", 0, kIceUfrag0, kIcePwd0)));
1260 std::string url = session->GetSessionRequestUrl();
1261 LOG(LS_INFO) << "url: " << url;
1262 std::vector<std::string> parts;
1263 rtc::split(url, '?', &parts);
1264 ASSERT_EQ(2U, parts.size());
1265
1266 std::vector<std::string> args_parts;
1267 rtc::split(parts[1], '&', &args_parts);
1268
1269 std::map<std::string, std::string> args;
1270 for (std::vector<std::string>::iterator it = args_parts.begin();
1271 it != args_parts.end(); ++it) {
1272 std::vector<std::string> parts;
1273 rtc::split(*it, '=', &parts);
1274 ASSERT_EQ(2U, parts.size());
1275 args[rtc::s_url_decode(parts[0])] = rtc::s_url_decode(parts[1]);
1276 }
1277
1278 EXPECT_EQ(kIceUfrag0, args["username"]);
1279 EXPECT_EQ(kIcePwd0, args["password"]);
1280 }
1281
1282 // Tests that destroying ports with non-shared sockets does not crash.
1283 // b/19074679.
1284 TEST_F(PortAllocatorTest, TestDestroyPortsNonSharedSockets) {
1285 AddInterface(kClientAddr);
1286 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1287 session_->StartGettingPorts();
1288 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
1289 EXPECT_EQ(4U, ports_.size());
1290
1291 auto it = ports_.begin();
1292 for (; it != ports_.end(); ++it) {
1293 (reinterpret_cast<cricket::Port*>(*it))->Destroy();
1294 }
1295 }
1296
1297 class AllocationSequenceForTest : public cricket::AllocationSequence {
1298 public:
1299 AllocationSequenceForTest(cricket::BasicPortAllocatorSession* session,
1300 rtc::Network* network,
1301 cricket::PortConfiguration* config,
1302 uint32 flags)
1303 : cricket::AllocationSequence(session, network, config, flags) {}
1304 using cricket::AllocationSequence::CreateTurnPort;
1305 };
1306
1307 TEST_F(PortAllocatorTest, TestCreateTurnPortWithNullSocket) {
1308 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1309 session_->StartGettingPorts();
1310
1311 cricket::ServerAddresses stun_servers;
1312 stun_servers.insert(kStunAddr);
1313 cricket::PortConfiguration config(stun_servers, kIceUfrag0, kIcePwd0);
1314 rtc::Network network1("test_eth0", "Test Network Adapter 1",
1315 rtc::IPAddress(0x12345600U), 24);
1316 uint32 flag = cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
1317 AllocationSequenceForTest alloc_sequence(
1318 static_cast<cricket::BasicPortAllocatorSession*>(session_.get()),
1319 &network1, &config, flag);
1320 // This simply tests it will not crash if udp_socket_ in the
1321 // AllocationSequence is null, which is chosen in the constructor.
1322 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
1323 relay_server.ports.push_back(
1324 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false));
1325 alloc_sequence.CreateTurnPort(relay_server);
1326 }
OLDNEW
« no previous file with comments | « webrtc/p2p/client/httpportallocator.cc ('k') | webrtc/p2p/p2p.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698