| OLD | NEW |
| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { | 241 void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) { |
| 242 CreatePeerConnection("", "", constraints); | 242 CreatePeerConnection("", "", constraints); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void CreatePeerConnection(const std::string& uri, | 245 void CreatePeerConnection(const std::string& uri, |
| 246 const std::string& password, | 246 const std::string& password, |
| 247 webrtc::MediaConstraintsInterface* constraints) { | 247 webrtc::MediaConstraintsInterface* constraints) { |
| 248 PeerConnectionInterface::IceServer server; | 248 PeerConnectionInterface::IceServer server; |
| 249 PeerConnectionInterface::IceServers servers; | 249 PeerConnectionInterface::IceServers servers; |
| 250 server.uri = uri; | 250 if (!uri.empty()) { |
| 251 server.password = password; | 251 server.uri = uri; |
| 252 servers.push_back(server); | 252 server.password = password; |
| 253 servers.push_back(server); |
| 254 } |
| 253 | 255 |
| 254 port_allocator_factory_ = FakePortAllocatorFactory::Create(); | 256 port_allocator_factory_ = FakePortAllocatorFactory::Create(); |
| 255 | 257 |
| 256 // DTLS does not work in a loopback call, so is disabled for most of the | 258 // DTLS does not work in a loopback call, so is disabled for most of the |
| 257 // tests in this file. We only create a FakeIdentityService if the test | 259 // tests in this file. We only create a FakeIdentityService if the test |
| 258 // explicitly sets the constraint. | 260 // explicitly sets the constraint. |
| 259 FakeConstraints default_constraints; | 261 FakeConstraints default_constraints; |
| 260 if (!constraints) { | 262 if (!constraints) { |
| 261 constraints = &default_constraints; | 263 constraints = &default_constraints; |
| 262 | 264 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 274 } | 276 } |
| 275 pc_ = pc_factory_->CreatePeerConnection(servers, constraints, | 277 pc_ = pc_factory_->CreatePeerConnection(servers, constraints, |
| 276 port_allocator_factory_.get(), | 278 port_allocator_factory_.get(), |
| 277 dtls_identity_store.Pass(), | 279 dtls_identity_store.Pass(), |
| 278 &observer_); | 280 &observer_); |
| 279 ASSERT_TRUE(pc_.get() != NULL); | 281 ASSERT_TRUE(pc_.get() != NULL); |
| 280 observer_.SetPeerConnectionInterface(pc_.get()); | 282 observer_.SetPeerConnectionInterface(pc_.get()); |
| 281 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); | 283 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); |
| 282 } | 284 } |
| 283 | 285 |
| 286 void CreatePeerConnectionExpectFail(const std::string& uri) { |
| 287 PeerConnectionInterface::IceServer server; |
| 288 PeerConnectionInterface::IceServers servers; |
| 289 server.uri = uri; |
| 290 servers.push_back(server); |
| 291 |
| 292 scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store; |
| 293 port_allocator_factory_ = FakePortAllocatorFactory::Create(); |
| 294 scoped_refptr<PeerConnectionInterface> pc; |
| 295 pc = pc_factory_->CreatePeerConnection( |
| 296 servers, nullptr, port_allocator_factory_.get(), |
| 297 dtls_identity_store.Pass(), &observer_); |
| 298 ASSERT_EQ(nullptr, pc); |
| 299 } |
| 300 |
| 284 void CreatePeerConnectionWithDifferentConfigurations() { | 301 void CreatePeerConnectionWithDifferentConfigurations() { |
| 285 CreatePeerConnection(kStunAddressOnly, "", NULL); | 302 CreatePeerConnection(kStunAddressOnly, "", NULL); |
| 286 EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); | 303 EXPECT_EQ(1u, port_allocator_factory_->stun_configs().size()); |
| 287 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); | 304 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); |
| 288 EXPECT_EQ("address", | 305 EXPECT_EQ("address", |
| 289 port_allocator_factory_->stun_configs()[0].server.hostname()); | 306 port_allocator_factory_->stun_configs()[0].server.hostname()); |
| 290 EXPECT_EQ(kDefaultStunPort, | 307 EXPECT_EQ(kDefaultStunPort, |
| 291 port_allocator_factory_->stun_configs()[0].server.port()); | 308 port_allocator_factory_->stun_configs()[0].server.port()); |
| 292 | 309 |
| 293 CreatePeerConnection(kStunInvalidPort, "", NULL); | 310 CreatePeerConnectionExpectFail(kStunInvalidPort); |
| 294 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); | 311 CreatePeerConnectionExpectFail(kStunAddressPortAndMore1); |
| 295 EXPECT_EQ(0u, port_allocator_factory_->turn_configs().size()); | 312 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 | 313 |
| 305 CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL); | 314 CreatePeerConnection(kTurnIceServerUri, kTurnPassword, NULL); |
| 306 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); | 315 EXPECT_EQ(0u, port_allocator_factory_->stun_configs().size()); |
| 307 EXPECT_EQ(1u, port_allocator_factory_->turn_configs().size()); | 316 EXPECT_EQ(1u, port_allocator_factory_->turn_configs().size()); |
| 308 EXPECT_EQ(kTurnUsername, | 317 EXPECT_EQ(kTurnUsername, |
| 309 port_allocator_factory_->turn_configs()[0].username); | 318 port_allocator_factory_->turn_configs()[0].username); |
| 310 EXPECT_EQ(kTurnPassword, | 319 EXPECT_EQ(kTurnPassword, |
| 311 port_allocator_factory_->turn_configs()[0].password); | 320 port_allocator_factory_->turn_configs()[0].password); |
| 312 EXPECT_EQ(kTurnHostname, | 321 EXPECT_EQ(kTurnHostname, |
| 313 port_allocator_factory_->turn_configs()[0].server.hostname()); | 322 port_allocator_factory_->turn_configs()[0].server.hostname()); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 sdp, NULL); | 1227 sdp, NULL); |
| 1219 EXPECT_FALSE(DoSetLocalDescription(local_offer)); | 1228 EXPECT_FALSE(DoSetLocalDescription(local_offer)); |
| 1220 } | 1229 } |
| 1221 | 1230 |
| 1222 // Test that GetStats can still be called after PeerConnection::Close. | 1231 // Test that GetStats can still be called after PeerConnection::Close. |
| 1223 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { | 1232 TEST_F(PeerConnectionInterfaceTest, CloseAndGetStats) { |
| 1224 InitiateCall(); | 1233 InitiateCall(); |
| 1225 pc_->Close(); | 1234 pc_->Close(); |
| 1226 DoGetStats(NULL); | 1235 DoGetStats(NULL); |
| 1227 } | 1236 } |
| OLD | NEW |