| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // internal libjingle threads. | 152 // internal libjingle threads. |
| 153 TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) { | 153 TEST(PeerConnectionFactoryTestInternal, CreatePCUsingInternalModules) { |
| 154 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 154 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
| 155 webrtc::CreatePeerConnectionFactory()); | 155 webrtc::CreatePeerConnectionFactory()); |
| 156 | 156 |
| 157 NullPeerConnectionObserver observer; | 157 NullPeerConnectionObserver observer; |
| 158 webrtc::PeerConnectionInterface::IceServers servers; | 158 webrtc::PeerConnectionInterface::IceServers servers; |
| 159 | 159 |
| 160 rtc::scoped_refptr<PeerConnectionInterface> pc( | 160 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 161 factory->CreatePeerConnection( | 161 factory->CreatePeerConnection( |
| 162 servers, NULL, NULL, new FakeIdentityService(), &observer)); | 162 servers, NULL, NULL, new FakeIdentityService(), rtc::KT_DEFAULT, |
| 163 &observer)); |
| 163 | 164 |
| 164 EXPECT_TRUE(pc.get() != NULL); | 165 EXPECT_TRUE(pc.get() != NULL); |
| 165 } | 166 } |
| 166 | 167 |
| 167 // This test verifies creation of PeerConnection with valid STUN and TURN | 168 // This test verifies creation of PeerConnection with valid STUN and TURN |
| 168 // configuration. Also verifies the URL's parsed correctly as expected. | 169 // configuration. Also verifies the URL's parsed correctly as expected. |
| 169 TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) { | 170 TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) { |
| 170 PeerConnectionInterface::RTCConfiguration config; | 171 PeerConnectionInterface::RTCConfiguration config; |
| 171 webrtc::PeerConnectionInterface::IceServer ice_server; | 172 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 172 ice_server.uri = kStunIceServer; | 173 ice_server.uri = kStunIceServer; |
| 173 config.servers.push_back(ice_server); | 174 config.servers.push_back(ice_server); |
| 174 ice_server.uri = kTurnIceServer; | 175 ice_server.uri = kTurnIceServer; |
| 175 ice_server.password = kTurnPassword; | 176 ice_server.password = kTurnPassword; |
| 176 config.servers.push_back(ice_server); | 177 config.servers.push_back(ice_server); |
| 177 ice_server.uri = kTurnIceServerWithTransport; | 178 ice_server.uri = kTurnIceServerWithTransport; |
| 178 ice_server.password = kTurnPassword; | 179 ice_server.password = kTurnPassword; |
| 179 config.servers.push_back(ice_server); | 180 config.servers.push_back(ice_server); |
| 180 rtc::scoped_refptr<PeerConnectionInterface> pc( | 181 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 181 factory_->CreatePeerConnection(config, NULL, | 182 factory_->CreatePeerConnection(config, NULL, |
| 182 allocator_factory_.get(), | 183 allocator_factory_.get(), |
| 183 new FakeIdentityService(), | 184 new FakeIdentityService(), |
| 185 rtc::KT_DEFAULT, |
| 184 &observer_)); | 186 &observer_)); |
| 185 EXPECT_TRUE(pc.get() != NULL); | 187 EXPECT_TRUE(pc.get() != NULL); |
| 186 StunConfigurations stun_configs; | 188 StunConfigurations stun_configs; |
| 187 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( | 189 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( |
| 188 "stun.l.google.com", 19302); | 190 "stun.l.google.com", 19302); |
| 189 stun_configs.push_back(stun1); | 191 stun_configs.push_back(stun1); |
| 190 VerifyStunConfigurations(stun_configs); | 192 VerifyStunConfigurations(stun_configs); |
| 191 TurnConfigurations turn_configs; | 193 TurnConfigurations turn_configs; |
| 192 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( | 194 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( |
| 193 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false); | 195 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 206 ice_server.urls.push_back(""); // Empty URLs should be ignored. | 208 ice_server.urls.push_back(""); // Empty URLs should be ignored. |
| 207 ice_server.urls.push_back(kStunIceServer); | 209 ice_server.urls.push_back(kStunIceServer); |
| 208 ice_server.urls.push_back(kTurnIceServer); | 210 ice_server.urls.push_back(kTurnIceServer); |
| 209 ice_server.urls.push_back(kTurnIceServerWithTransport); | 211 ice_server.urls.push_back(kTurnIceServerWithTransport); |
| 210 ice_server.password = kTurnPassword; | 212 ice_server.password = kTurnPassword; |
| 211 config.servers.push_back(ice_server); | 213 config.servers.push_back(ice_server); |
| 212 rtc::scoped_refptr<PeerConnectionInterface> pc( | 214 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 213 factory_->CreatePeerConnection(config, NULL, | 215 factory_->CreatePeerConnection(config, NULL, |
| 214 allocator_factory_.get(), | 216 allocator_factory_.get(), |
| 215 new FakeIdentityService(), | 217 new FakeIdentityService(), |
| 218 rtc::KT_DEFAULT, |
| 216 &observer_)); | 219 &observer_)); |
| 217 EXPECT_TRUE(pc.get() != NULL); | 220 EXPECT_TRUE(pc.get() != NULL); |
| 218 StunConfigurations stun_configs; | 221 StunConfigurations stun_configs; |
| 219 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( | 222 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( |
| 220 "stun.l.google.com", 19302); | 223 "stun.l.google.com", 19302); |
| 221 stun_configs.push_back(stun1); | 224 stun_configs.push_back(stun1); |
| 222 VerifyStunConfigurations(stun_configs); | 225 VerifyStunConfigurations(stun_configs); |
| 223 TurnConfigurations turn_configs; | 226 TurnConfigurations turn_configs; |
| 224 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( | 227 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( |
| 225 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false); | 228 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 242 ice_server.uri = kTurnIceServer; | 245 ice_server.uri = kTurnIceServer; |
| 243 ice_server.password = kTurnPassword; | 246 ice_server.password = kTurnPassword; |
| 244 ice_servers.push_back(ice_server); | 247 ice_servers.push_back(ice_server); |
| 245 ice_server.uri = kTurnIceServerWithTransport; | 248 ice_server.uri = kTurnIceServerWithTransport; |
| 246 ice_server.password = kTurnPassword; | 249 ice_server.password = kTurnPassword; |
| 247 ice_servers.push_back(ice_server); | 250 ice_servers.push_back(ice_server); |
| 248 rtc::scoped_refptr<PeerConnectionInterface> pc( | 251 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 249 factory_->CreatePeerConnection(ice_servers, NULL, | 252 factory_->CreatePeerConnection(ice_servers, NULL, |
| 250 allocator_factory_.get(), | 253 allocator_factory_.get(), |
| 251 new FakeIdentityService(), | 254 new FakeIdentityService(), |
| 255 rtc::KT_DEFAULT, |
| 252 &observer_)); | 256 &observer_)); |
| 253 EXPECT_TRUE(pc.get() != NULL); | 257 EXPECT_TRUE(pc.get() != NULL); |
| 254 StunConfigurations stun_configs; | 258 StunConfigurations stun_configs; |
| 255 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( | 259 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( |
| 256 "stun.l.google.com", 19302); | 260 "stun.l.google.com", 19302); |
| 257 stun_configs.push_back(stun1); | 261 stun_configs.push_back(stun1); |
| 258 VerifyStunConfigurations(stun_configs); | 262 VerifyStunConfigurations(stun_configs); |
| 259 TurnConfigurations turn_configs; | 263 TurnConfigurations turn_configs; |
| 260 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( | 264 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( |
| 261 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false); | 265 "test.com", 1234, "test@hello.com", kTurnPassword, "udp", false); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 272 ice_server.uri = kStunIceServer; | 276 ice_server.uri = kStunIceServer; |
| 273 config.servers.push_back(ice_server); | 277 config.servers.push_back(ice_server); |
| 274 ice_server.uri = kTurnIceServerWithNoUsernameInUri; | 278 ice_server.uri = kTurnIceServerWithNoUsernameInUri; |
| 275 ice_server.username = kTurnUsername; | 279 ice_server.username = kTurnUsername; |
| 276 ice_server.password = kTurnPassword; | 280 ice_server.password = kTurnPassword; |
| 277 config.servers.push_back(ice_server); | 281 config.servers.push_back(ice_server); |
| 278 rtc::scoped_refptr<PeerConnectionInterface> pc( | 282 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 279 factory_->CreatePeerConnection(config, NULL, | 283 factory_->CreatePeerConnection(config, NULL, |
| 280 allocator_factory_.get(), | 284 allocator_factory_.get(), |
| 281 new FakeIdentityService(), | 285 new FakeIdentityService(), |
| 286 rtc::KT_DEFAULT, |
| 282 &observer_)); | 287 &observer_)); |
| 283 EXPECT_TRUE(pc.get() != NULL); | 288 EXPECT_TRUE(pc.get() != NULL); |
| 284 TurnConfigurations turn_configs; | 289 TurnConfigurations turn_configs; |
| 285 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn( | 290 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn( |
| 286 "test.com", 1234, kTurnUsername, kTurnPassword, "udp", false); | 291 "test.com", 1234, kTurnUsername, kTurnPassword, "udp", false); |
| 287 turn_configs.push_back(turn); | 292 turn_configs.push_back(turn); |
| 288 VerifyTurnConfigurations(turn_configs); | 293 VerifyTurnConfigurations(turn_configs); |
| 289 } | 294 } |
| 290 | 295 |
| 291 // This test verifies the PeerConnection created properly with TURN url which | 296 // This test verifies the PeerConnection created properly with TURN url which |
| 292 // has transport parameter in it. | 297 // has transport parameter in it. |
| 293 TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) { | 298 TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) { |
| 294 PeerConnectionInterface::RTCConfiguration config; | 299 PeerConnectionInterface::RTCConfiguration config; |
| 295 webrtc::PeerConnectionInterface::IceServer ice_server; | 300 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 296 ice_server.uri = kTurnIceServerWithTransport; | 301 ice_server.uri = kTurnIceServerWithTransport; |
| 297 ice_server.password = kTurnPassword; | 302 ice_server.password = kTurnPassword; |
| 298 config.servers.push_back(ice_server); | 303 config.servers.push_back(ice_server); |
| 299 rtc::scoped_refptr<PeerConnectionInterface> pc( | 304 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 300 factory_->CreatePeerConnection(config, NULL, | 305 factory_->CreatePeerConnection(config, NULL, |
| 301 allocator_factory_.get(), | 306 allocator_factory_.get(), |
| 302 new FakeIdentityService(), | 307 new FakeIdentityService(), |
| 308 rtc::KT_DEFAULT, |
| 303 &observer_)); | 309 &observer_)); |
| 304 EXPECT_TRUE(pc.get() != NULL); | 310 EXPECT_TRUE(pc.get() != NULL); |
| 305 TurnConfigurations turn_configs; | 311 TurnConfigurations turn_configs; |
| 306 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn( | 312 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn( |
| 307 "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false); | 313 "hello.com", kDefaultStunPort, "test", kTurnPassword, "tcp", false); |
| 308 turn_configs.push_back(turn); | 314 turn_configs.push_back(turn); |
| 309 VerifyTurnConfigurations(turn_configs); | 315 VerifyTurnConfigurations(turn_configs); |
| 310 } | 316 } |
| 311 | 317 |
| 312 TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) { | 318 TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) { |
| 313 PeerConnectionInterface::RTCConfiguration config; | 319 PeerConnectionInterface::RTCConfiguration config; |
| 314 webrtc::PeerConnectionInterface::IceServer ice_server; | 320 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 315 ice_server.uri = kSecureTurnIceServer; | 321 ice_server.uri = kSecureTurnIceServer; |
| 316 ice_server.password = kTurnPassword; | 322 ice_server.password = kTurnPassword; |
| 317 config.servers.push_back(ice_server); | 323 config.servers.push_back(ice_server); |
| 318 ice_server.uri = kSecureTurnIceServerWithoutTransportParam; | 324 ice_server.uri = kSecureTurnIceServerWithoutTransportParam; |
| 319 ice_server.password = kTurnPassword; | 325 ice_server.password = kTurnPassword; |
| 320 config.servers.push_back(ice_server); | 326 config.servers.push_back(ice_server); |
| 321 ice_server.uri = kSecureTurnIceServerWithoutTransportAndPortParam; | 327 ice_server.uri = kSecureTurnIceServerWithoutTransportAndPortParam; |
| 322 ice_server.password = kTurnPassword; | 328 ice_server.password = kTurnPassword; |
| 323 config.servers.push_back(ice_server); | 329 config.servers.push_back(ice_server); |
| 324 rtc::scoped_refptr<PeerConnectionInterface> pc( | 330 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 325 factory_->CreatePeerConnection(config, NULL, | 331 factory_->CreatePeerConnection(config, NULL, |
| 326 allocator_factory_.get(), | 332 allocator_factory_.get(), |
| 327 new FakeIdentityService(), | 333 new FakeIdentityService(), |
| 334 rtc::KT_DEFAULT, |
| 328 &observer_)); | 335 &observer_)); |
| 329 EXPECT_TRUE(pc.get() != NULL); | 336 EXPECT_TRUE(pc.get() != NULL); |
| 330 TurnConfigurations turn_configs; | 337 TurnConfigurations turn_configs; |
| 331 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( | 338 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn1( |
| 332 "hello.com", kDefaultStunTlsPort, "test", kTurnPassword, "tcp", true); | 339 "hello.com", kDefaultStunTlsPort, "test", kTurnPassword, "tcp", true); |
| 333 turn_configs.push_back(turn1); | 340 turn_configs.push_back(turn1); |
| 334 // TURNS with transport param should be default to tcp. | 341 // TURNS with transport param should be default to tcp. |
| 335 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2( | 342 webrtc::PortAllocatorFactoryInterface::TurnConfiguration turn2( |
| 336 "hello.com", 443, "test_no_transport", kTurnPassword, "tcp", true); | 343 "hello.com", 443, "test_no_transport", kTurnPassword, "tcp", true); |
| 337 turn_configs.push_back(turn2); | 344 turn_configs.push_back(turn2); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 355 config.servers.push_back(ice_server); | 362 config.servers.push_back(ice_server); |
| 356 ice_server.uri = kStunIceServerWithInvalidIPv6Address; | 363 ice_server.uri = kStunIceServerWithInvalidIPv6Address; |
| 357 config.servers.push_back(ice_server); | 364 config.servers.push_back(ice_server); |
| 358 ice_server.uri = kTurnIceServerWithIPv6Address; | 365 ice_server.uri = kTurnIceServerWithIPv6Address; |
| 359 ice_server.password = kTurnPassword; | 366 ice_server.password = kTurnPassword; |
| 360 config.servers.push_back(ice_server); | 367 config.servers.push_back(ice_server); |
| 361 rtc::scoped_refptr<PeerConnectionInterface> pc( | 368 rtc::scoped_refptr<PeerConnectionInterface> pc( |
| 362 factory_->CreatePeerConnection(config, NULL, | 369 factory_->CreatePeerConnection(config, NULL, |
| 363 allocator_factory_.get(), | 370 allocator_factory_.get(), |
| 364 new FakeIdentityService(), | 371 new FakeIdentityService(), |
| 372 rtc::KT_DEFAULT, |
| 365 &observer_)); | 373 &observer_)); |
| 366 EXPECT_TRUE(pc.get() != NULL); | 374 EXPECT_TRUE(pc.get() != NULL); |
| 367 StunConfigurations stun_configs; | 375 StunConfigurations stun_configs; |
| 368 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( | 376 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun1( |
| 369 "1.2.3.4", 1234); | 377 "1.2.3.4", 1234); |
| 370 stun_configs.push_back(stun1); | 378 stun_configs.push_back(stun1); |
| 371 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun2( | 379 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun2( |
| 372 "1.2.3.4", 3478); | 380 "1.2.3.4", 3478); |
| 373 stun_configs.push_back(stun2); // Default port | 381 stun_configs.push_back(stun2); // Default port |
| 374 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun3( | 382 webrtc::PortAllocatorFactoryInterface::StunConfiguration stun3( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 405 | 413 |
| 406 track->set_enabled(false); | 414 track->set_enabled(false); |
| 407 EXPECT_TRUE(capturer->CaptureFrame()); | 415 EXPECT_TRUE(capturer->CaptureFrame()); |
| 408 EXPECT_EQ(1, local_renderer.num_rendered_frames()); | 416 EXPECT_EQ(1, local_renderer.num_rendered_frames()); |
| 409 | 417 |
| 410 track->set_enabled(true); | 418 track->set_enabled(true); |
| 411 EXPECT_TRUE(capturer->CaptureFrame()); | 419 EXPECT_TRUE(capturer->CaptureFrame()); |
| 412 EXPECT_EQ(2, local_renderer.num_rendered_frames()); | 420 EXPECT_EQ(2, local_renderer.num_rendered_frames()); |
| 413 } | 421 } |
| 414 | 422 |
| OLD | NEW |