Chromium Code Reviews| 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 | 10 |
| (...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2321 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp, | 2321 webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, sdp, |
| 2322 nullptr)); | 2322 nullptr)); |
| 2323 | 2323 |
| 2324 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release())); | 2324 EXPECT_TRUE(DoSetLocalDescription(updated_desc.release())); |
| 2325 senders = pc_->GetSenders(); | 2325 senders = pc_->GetSenders(); |
| 2326 EXPECT_EQ(2u, senders.size()); | 2326 EXPECT_EQ(2u, senders.size()); |
| 2327 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); | 2327 EXPECT_TRUE(ContainsSender(senders, kAudioTracks[0])); |
| 2328 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); | 2328 EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0])); |
| 2329 } | 2329 } |
| 2330 | 2330 |
| 2331 // The PeerConnectionMediaConfig tests below verify that configuration | |
| 2332 // and constraints are propagated into the MediaConfig passed to | |
| 2333 // CreateMediaController. These settings are intended for MediaChannel | |
| 2334 // constructors, but that is not exercised by these unittest. | |
| 2335 class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { | |
| 2336 public: | |
| 2337 webrtc::MediaControllerInterface* CreateMediaController( | |
| 2338 const cricket::MediaConfig& config) const override { | |
| 2339 create_media_controller_called_ = true; | |
| 2340 create_media_controller_config_ = config; | |
| 2341 | |
| 2342 webrtc::MediaControllerInterface* mc = | |
| 2343 PeerConnectionFactory::CreateMediaController(config); | |
| 2344 EXPECT_TRUE(mc != nullptr); | |
| 2345 return mc; | |
| 2346 } | |
| 2347 | |
| 2348 // Mutable, so they can be modified in the above const-declared method. | |
| 2349 mutable bool create_media_controller_called_ = false; | |
|
pbos-webrtc
2016/02/11 09:22:16
If these aren't race prone then I think you can ac
nisse-webrtc
2016/02/11 09:31:32
To get a SetUp method, I'd need to define a "test
pbos-webrtc
2016/02/11 11:34:10
I think that's fine, you can also use rtc::AtomicO
| |
| 2350 mutable cricket::MediaConfig create_media_controller_config_; | |
| 2351 }; | |
| 2352 | |
| 2353 // This test verifies the DSCP constraint is recognized and passed to | |
| 2354 // the CreateMediaController. | |
| 2355 TEST(PeerConnectionMediaConfig, TestDscpConstraint) { | |
| 2356 scoped_refptr<PeerConnectionFactoryForTest> pcf( | |
| 2357 new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); | |
| 2358 pcf->Initialize(); | |
| 2359 | |
| 2360 EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); | |
| 2361 | |
| 2362 // Without constraint, default value is false | |
| 2363 scoped_refptr<PeerConnectionInterface> pc; | |
| 2364 PeerConnectionInterface::RTCConfiguration config; | |
| 2365 FakeConstraints constraints; | |
| 2366 MockPeerConnectionObserver observer; | |
| 2367 | |
| 2368 pc = pcf->CreatePeerConnection(config, &constraints, | |
| 2369 nullptr, nullptr, &observer); | |
| 2370 ASSERT_TRUE(pc.get() != nullptr); | |
| 2371 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2372 EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); | |
| 2373 | |
| 2374 // With constraint set to true | |
| 2375 pcf->create_media_controller_called_ = false; | |
| 2376 | |
| 2377 constraints.AddOptional( | |
| 2378 webrtc::MediaConstraintsInterface::kEnableDscp, true); | |
| 2379 | |
| 2380 pc = pcf->CreatePeerConnection(config, &constraints, | |
| 2381 nullptr, nullptr, &observer); | |
| 2382 EXPECT_TRUE(pc.get() != nullptr); | |
| 2383 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2384 EXPECT_TRUE(pcf->create_media_controller_config_.enable_dscp); | |
| 2385 } | |
| 2386 | |
| 2387 // This test verifies the cpu overuse detection constraint is | |
| 2388 // recognized and passed to the CreateMediaController. | |
| 2389 TEST(PeerConnectionMediaConfig, TestCpuOveruseConstraint) { | |
| 2390 scoped_refptr<PeerConnectionFactoryForTest> pcf( | |
| 2391 new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); | |
| 2392 pcf->Initialize(); | |
| 2393 | |
| 2394 EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); | |
| 2395 | |
| 2396 // Without constraint, default value is true | |
| 2397 PeerConnectionInterface::RTCConfiguration config; | |
| 2398 FakeConstraints constraints; | |
| 2399 MockPeerConnectionObserver observer; | |
| 2400 scoped_refptr<PeerConnectionInterface> pc; | |
| 2401 | |
| 2402 pc = pcf->CreatePeerConnection(config, &constraints, | |
| 2403 nullptr, nullptr, &observer); | |
| 2404 ASSERT_TRUE(pc.get() != nullptr); | |
| 2405 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2406 EXPECT_TRUE( | |
| 2407 pcf->create_media_controller_config_.enable_cpu_overuse_detection); | |
| 2408 | |
| 2409 // With constraint set to false | |
| 2410 pcf->create_media_controller_called_ = false; | |
| 2411 | |
| 2412 constraints.AddOptional( | |
| 2413 webrtc::MediaConstraintsInterface::kCpuOveruseDetection, false); | |
| 2414 | |
| 2415 pc = pcf->CreatePeerConnection(config, &constraints, | |
| 2416 nullptr, nullptr, &observer); | |
| 2417 ASSERT_TRUE(pc.get() != nullptr); | |
| 2418 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2419 EXPECT_FALSE( | |
| 2420 pcf->create_media_controller_config_.enable_cpu_overuse_detection); | |
| 2421 } | |
| 2422 | |
| 2423 // This test verifies the disable_prerenderer_smoothing flag is | |
| 2424 // propagated from RTCConfiguration to the CreateMediaController call. | |
| 2425 TEST(PeerConnectionMediaConfig, TestDisablePrerenderFlag) { | |
| 2426 scoped_refptr<PeerConnectionFactoryForTest> pcf( | |
| 2427 new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); | |
| 2428 pcf->Initialize(); | |
| 2429 | |
| 2430 EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); | |
| 2431 | |
| 2432 // Default value, false | |
| 2433 PeerConnectionInterface::RTCConfiguration config; | |
| 2434 FakeConstraints constraints; | |
| 2435 MockPeerConnectionObserver observer; | |
| 2436 scoped_refptr<PeerConnectionInterface> pc; | |
| 2437 | |
| 2438 pc = pcf->CreatePeerConnection(config, &constraints, | |
| 2439 nullptr, nullptr, &observer); | |
| 2440 ASSERT_TRUE(pc.get() != nullptr); | |
| 2441 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2442 EXPECT_FALSE( | |
| 2443 pcf->create_media_controller_config_.disable_prerenderer_smoothing); | |
| 2444 | |
| 2445 // Flag set | |
| 2446 pcf->create_media_controller_called_ = false; | |
| 2447 | |
| 2448 config.disable_prerenderer_smoothing = true; | |
| 2449 pc = pcf->CreatePeerConnection(config, &constraints, | |
| 2450 nullptr, nullptr, &observer); | |
| 2451 EXPECT_TRUE(pc.get() != nullptr); | |
| 2452 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2453 EXPECT_TRUE( | |
| 2454 pcf->create_media_controller_config_.disable_prerenderer_smoothing); | |
| 2455 } | |
| 2456 | |
| 2331 // The following tests verify that session options are created correctly. | 2457 // The following tests verify that session options are created correctly. |
| 2332 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of | 2458 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of |
| 2333 // "verify options are converted correctly", should be "pass options into | 2459 // "verify options are converted correctly", should be "pass options into |
| 2334 // CreateOffer and verify the correct offer is produced." | 2460 // CreateOffer and verify the correct offer is produced." |
| 2335 | 2461 |
| 2336 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { | 2462 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { |
| 2337 RTCOfferAnswerOptions rtc_options; | 2463 RTCOfferAnswerOptions rtc_options; |
| 2338 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; | 2464 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; |
| 2339 | 2465 |
| 2340 cricket::MediaSessionOptions options; | 2466 cricket::MediaSessionOptions options; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2489 FakeConstraints updated_answer_c; | 2615 FakeConstraints updated_answer_c; |
| 2490 answer_c.SetMandatoryReceiveAudio(false); | 2616 answer_c.SetMandatoryReceiveAudio(false); |
| 2491 answer_c.SetMandatoryReceiveVideo(false); | 2617 answer_c.SetMandatoryReceiveVideo(false); |
| 2492 | 2618 |
| 2493 cricket::MediaSessionOptions updated_answer_options; | 2619 cricket::MediaSessionOptions updated_answer_options; |
| 2494 EXPECT_TRUE( | 2620 EXPECT_TRUE( |
| 2495 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2621 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
| 2496 EXPECT_TRUE(updated_answer_options.has_audio()); | 2622 EXPECT_TRUE(updated_answer_options.has_audio()); |
| 2497 EXPECT_TRUE(updated_answer_options.has_video()); | 2623 EXPECT_TRUE(updated_answer_options.has_video()); |
| 2498 } | 2624 } |
| OLD | NEW |