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; | |
| 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 | |
|
perkj_webrtc
2016/02/11 12:32:08
nit add . Write complete sentences.
nisse-webrtc
2016/02/11 13:45:08
Done.
| |
| 2363 scoped_refptr<PeerConnectionInterface> pc; | |
|
perkj_webrtc
2016/02/11 12:32:07
nit: move to where it is used. ie
scoped_refptr<P
nisse-webrtc
2016/02/11 13:45:08
I did it this way because I wanted both calls
pc
| |
| 2364 PeerConnectionInterface::RTCConfiguration config; | |
| 2365 FakeConstraints constraints; | |
| 2366 MockPeerConnectionObserver observer; | |
| 2367 | |
| 2368 pc = pcf->CreatePeerConnection(config, &constraints, nullptr, nullptr, | |
| 2369 &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(webrtc::MediaConstraintsInterface::kEnableDscp, true); | |
| 2378 | |
| 2379 pc = pcf->CreatePeerConnection(config, &constraints, nullptr, nullptr, | |
| 2380 &observer); | |
| 2381 EXPECT_TRUE(pc.get() != nullptr); | |
|
perkj_webrtc
2016/02/11 12:32:08
ASSERT_TRUE
nisse-webrtc
2016/02/11 13:45:08
Done.
| |
| 2382 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2383 EXPECT_TRUE(pcf->create_media_controller_config_.enable_dscp); | |
| 2384 } | |
| 2385 | |
| 2386 // This test verifies the cpu overuse detection constraint is | |
| 2387 // recognized and passed to the CreateMediaController. | |
| 2388 TEST(PeerConnectionMediaConfig, TestCpuOveruseConstraint) { | |
| 2389 scoped_refptr<PeerConnectionFactoryForTest> pcf( | |
| 2390 new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); | |
| 2391 pcf->Initialize(); | |
| 2392 | |
| 2393 EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); | |
| 2394 | |
| 2395 // Without constraint, default value is true | |
| 2396 PeerConnectionInterface::RTCConfiguration config; | |
| 2397 FakeConstraints constraints; | |
| 2398 MockPeerConnectionObserver observer; | |
| 2399 scoped_refptr<PeerConnectionInterface> pc; | |
| 2400 | |
| 2401 pc = pcf->CreatePeerConnection(config, &constraints, nullptr, nullptr, | |
| 2402 &observer); | |
| 2403 ASSERT_TRUE(pc.get() != nullptr); | |
| 2404 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2405 EXPECT_TRUE( | |
| 2406 pcf->create_media_controller_config_.enable_cpu_overuse_detection); | |
| 2407 | |
| 2408 // With constraint set to false | |
| 2409 pcf->create_media_controller_called_ = false; | |
| 2410 | |
| 2411 constraints.AddOptional( | |
| 2412 webrtc::MediaConstraintsInterface::kCpuOveruseDetection, false); | |
| 2413 | |
| 2414 pc = pcf->CreatePeerConnection(config, &constraints, nullptr, nullptr, | |
| 2415 &observer); | |
| 2416 ASSERT_TRUE(pc.get() != nullptr); | |
| 2417 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2418 EXPECT_FALSE( | |
| 2419 pcf->create_media_controller_config_.enable_cpu_overuse_detection); | |
| 2420 } | |
| 2421 | |
| 2422 // This test verifies the disable_prerenderer_smoothing flag is | |
| 2423 // propagated from RTCConfiguration to the CreateMediaController call. | |
| 2424 TEST(PeerConnectionMediaConfig, TestDisablePrerenderFlag) { | |
| 2425 scoped_refptr<PeerConnectionFactoryForTest> pcf( | |
| 2426 new rtc::RefCountedObject<PeerConnectionFactoryForTest>()); | |
| 2427 pcf->Initialize(); | |
| 2428 | |
| 2429 EXPECT_FALSE(pcf->create_media_controller_config_.enable_dscp); | |
| 2430 | |
| 2431 // Default value, false | |
| 2432 PeerConnectionInterface::RTCConfiguration config; | |
| 2433 FakeConstraints constraints; | |
| 2434 MockPeerConnectionObserver observer; | |
| 2435 scoped_refptr<PeerConnectionInterface> pc; | |
| 2436 | |
| 2437 pc = pcf->CreatePeerConnection(config, &constraints, nullptr, nullptr, | |
| 2438 &observer); | |
| 2439 ASSERT_TRUE(pc.get() != nullptr); | |
| 2440 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2441 EXPECT_FALSE( | |
| 2442 pcf->create_media_controller_config_.disable_prerenderer_smoothing); | |
| 2443 | |
| 2444 // Flag set | |
| 2445 pcf->create_media_controller_called_ = false; | |
|
perkj_webrtc
2016/02/11 12:32:07
right - this should actually be 6 tests instead to
nisse-webrtc
2016/02/11 13:45:08
I'll do. I guess we'll need a few iterations more.
| |
| 2446 | |
| 2447 config.disable_prerenderer_smoothing = true; | |
| 2448 pc = pcf->CreatePeerConnection(config, &constraints, nullptr, nullptr, | |
| 2449 &observer); | |
| 2450 EXPECT_TRUE(pc.get() != nullptr); | |
| 2451 EXPECT_TRUE(pcf->create_media_controller_called_); | |
| 2452 EXPECT_TRUE( | |
| 2453 pcf->create_media_controller_config_.disable_prerenderer_smoothing); | |
| 2454 } | |
| 2455 | |
| 2331 // The following tests verify that session options are created correctly. | 2456 // The following tests verify that session options are created correctly. |
| 2332 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of | 2457 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of |
| 2333 // "verify options are converted correctly", should be "pass options into | 2458 // "verify options are converted correctly", should be "pass options into |
| 2334 // CreateOffer and verify the correct offer is produced." | 2459 // CreateOffer and verify the correct offer is produced." |
| 2335 | 2460 |
| 2336 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { | 2461 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { |
| 2337 RTCOfferAnswerOptions rtc_options; | 2462 RTCOfferAnswerOptions rtc_options; |
| 2338 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; | 2463 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; |
| 2339 | 2464 |
| 2340 cricket::MediaSessionOptions options; | 2465 cricket::MediaSessionOptions options; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2489 FakeConstraints updated_answer_c; | 2614 FakeConstraints updated_answer_c; |
| 2490 answer_c.SetMandatoryReceiveAudio(false); | 2615 answer_c.SetMandatoryReceiveAudio(false); |
| 2491 answer_c.SetMandatoryReceiveVideo(false); | 2616 answer_c.SetMandatoryReceiveVideo(false); |
| 2492 | 2617 |
| 2493 cricket::MediaSessionOptions updated_answer_options; | 2618 cricket::MediaSessionOptions updated_answer_options; |
| 2494 EXPECT_TRUE( | 2619 EXPECT_TRUE( |
| 2495 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2620 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
| 2496 EXPECT_TRUE(updated_answer_options.has_audio()); | 2621 EXPECT_TRUE(updated_answer_options.has_audio()); |
| 2497 EXPECT_TRUE(updated_answer_options.has_video()); | 2622 EXPECT_TRUE(updated_answer_options.has_video()); |
| 2498 } | 2623 } |
| OLD | NEW |