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

Side by Side Diff: talk/app/webrtc/peerconnectioninterface_unittest.cc

Issue 1344143002: Catching more errors when parsing ICE server URLs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing tests that didn't expect PC creation to fail due to ICE parse errors. 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 pc_ = pc_factory_->CreatePeerConnection(servers, constraints, 275 pc_ = pc_factory_->CreatePeerConnection(servers, constraints,
276 port_allocator_factory_.get(), 276 port_allocator_factory_.get(),
277 dtls_identity_store.Pass(), 277 dtls_identity_store.Pass(),
278 &observer_); 278 &observer_);
279 ASSERT_TRUE(pc_.get() != NULL); 279 ASSERT_TRUE(pc_.get() != NULL);
280 observer_.SetPeerConnectionInterface(pc_.get()); 280 observer_.SetPeerConnectionInterface(pc_.get());
281 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); 281 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
282 } 282 }
283 283
284 void CreatePeerConnectionExpectFail(const std::string& uri) {
285 PeerConnectionInterface::IceServer server;
286 PeerConnectionInterface::IceServers servers;
287 server.uri = uri;
288 servers.push_back(server);
289
290 scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store;
291 port_allocator_factory_ = FakePortAllocatorFactory::Create();
292 scoped_refptr<PeerConnectionInterface> pc;
293 pc = pc_factory_->CreatePeerConnection(
294 servers, nullptr, port_allocator_factory_.get(),
295 dtls_identity_store.Pass(), &observer_);
296 ASSERT_EQ(nullptr, pc);
297 }
298
284 void CreatePeerConnectionWithDifferentConfigurations() { 299 void CreatePeerConnectionWithDifferentConfigurations() {
285 CreatePeerConnection(kStunAddressOnly, "", NULL); 300 CreatePeerConnection(kStunAddressOnly, "", NULL);
286 EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); 301 EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size());
287 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); 302 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size());
288 EXPECT_EQ("address", 303 EXPECT_EQ("address",
289 port_allocator_factory_->stun_configs()[0].server.hostname()); 304 port_allocator_factory_->stun_configs()[0].server.hostname());
290 EXPECT_EQ(kDefaultStunPort, 305 EXPECT_EQ(kDefaultStunPort,
291 port_allocator_factory_->stun_configs()[0].server.port()); 306 port_allocator_factory_->stun_configs()[0].server.port());
292 307
293 CreatePeerConnection(kStunInvalidPort, "", NULL); 308 CreatePeerConnectionExpectFail(kStunInvalidPort);
294 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); 309 CreatePeerConnectionExpectFail(kStunAddressPortAndMore1);
295 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); 310 CreatePeerConnectionExpectFail(kStunAddressPortAndMore2);
296
297 CreatePeerConnection(kStunAddressPortAndMore1, "", NULL);
298 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size());
299 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size());
300
301 CreatePeerConnection(kStunAddressPortAndMore2, "", NULL);
302 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size());
303 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size());
304 311
305 CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL); 312 CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL);
306 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); 313 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size());
307 EXPECT_EQ(1u, port_allocator_factory_->turn_configs().size()); 314 EXPECT_EQ(1u, port_allocator_factory_->turn_configs().size());
308 EXPECT_EQ(kTurnUsername, 315 EXPECT_EQ(kTurnUsername,
309 port_allocator_factory_->turn_configs()[0].username); 316 port_allocator_factory_->turn_configs()[0].username);
310 EXPECT_EQ(kTurnPassword, 317 EXPECT_EQ(kTurnPassword,
311 port_allocator_factory_->turn_configs()[0].password); 318 port_allocator_factory_->turn_configs()[0].password);
312 EXPECT_EQ(kTurnHostname, 319 EXPECT_EQ(kTurnHostname,
313 port_allocator_factory_->turn_configs()[0].server.hostname()); 320 port_allocator_factory_->turn_configs()[0].server.hostname());
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 sdp, NULL); 1225 sdp, NULL);
1219 EXPECT_FALSE(DoSetLocalDescription(local_offer)); 1226 EXPECT_FALSE(DoSetLocalDescription(local_offer));
1220 } 1227 }
1221 1228
1222 // Test that GetStats can still be called after PeerConnection::Close. 1229 // Test that GetStats can still be called after PeerConnection::Close.
1223 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { 1230 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) {
1224 InitiateCall(); 1231 InitiateCall();
1225 pc_->Close(); 1232 pc_->Close();
1226 DoGetStats(NULL); 1233 DoGetStats(NULL);
1227 } 1234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698