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 class PeerConnectionMediaConfigTest : public testing::Test { |
| 2354 protected: |
| 2355 void SetUp() override { |
| 2356 pcf_= new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); |
| 2357 pcf_->Initialize(); |
| 2358 } |
| 2359 const cricket::MediaConfig& TestCreatePeerConnection( |
| 2360 const PeerConnectionInterface::RTCConfiguration& config, |
| 2361 const MediaConstraintsInterface *constraints) { |
| 2362 pcf_->create_media_controller_called_ = false; |
| 2363 |
| 2364 scoped_refptr<PeerConnectionInterface> pc( |
| 2365 pcf_->CreatePeerConnection(config, constraints, nullptr, nullptr, |
| 2366 &observer_)); |
| 2367 EXPECT_TRUE(pc.get()); |
| 2368 EXPECT_TRUE(pcf_->create_media_controller_called_); |
| 2369 return pcf_->create_media_controller_config_; |
| 2370 } |
| 2371 |
| 2372 scoped_refptr<PeerConnectionFactoryForTest> pcf_; |
| 2373 MockPeerConnectionObserver observer_; |
| 2374 }; |
| 2375 |
| 2376 // This test verifies the default behaviour with no constraints and a |
| 2377 // default RTCConfiguration. |
| 2378 TEST_F(PeerConnectionMediaConfigTest, TestDefaults) { |
| 2379 PeerConnectionInterface::RTCConfiguration config; |
| 2380 FakeConstraints constraints; |
| 2381 |
| 2382 const cricket::MediaConfig& media_config = |
| 2383 TestCreatePeerConnection(config, &constraints); |
| 2384 |
| 2385 EXPECT_FALSE(media_config.enable_dscp); |
| 2386 EXPECT_TRUE(media_config.enable_cpu_overuse_detection); |
| 2387 EXPECT_FALSE(media_config.disable_prerenderer_smoothing); |
| 2388 } |
| 2389 |
| 2390 // This test verifies the DSCP constraint is recognized and passed to |
| 2391 // the CreateMediaController call. |
| 2392 TEST_F(PeerConnectionMediaConfigTest, TestDscpConstraintTrue) { |
| 2393 PeerConnectionInterface::RTCConfiguration config; |
| 2394 FakeConstraints constraints; |
| 2395 |
| 2396 constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDscp, true); |
| 2397 const cricket::MediaConfig& media_config = |
| 2398 TestCreatePeerConnection(config, &constraints); |
| 2399 |
| 2400 EXPECT_TRUE(media_config.enable_dscp); |
| 2401 } |
| 2402 |
| 2403 // This test verifies the cpu overuse detection constraint is |
| 2404 // recognized and passed to the CreateMediaController call. |
| 2405 TEST_F(PeerConnectionMediaConfigTest, TestCpuOveruseConstraintFalse) { |
| 2406 PeerConnectionInterface::RTCConfiguration config; |
| 2407 FakeConstraints constraints; |
| 2408 |
| 2409 constraints.AddOptional( |
| 2410 webrtc::MediaConstraintsInterface::kCpuOveruseDetection, false); |
| 2411 const cricket::MediaConfig media_config = |
| 2412 TestCreatePeerConnection(config, &constraints); |
| 2413 |
| 2414 EXPECT_FALSE(media_config.enable_cpu_overuse_detection); |
| 2415 } |
| 2416 |
| 2417 // This test verifies that the disable_prerenderer_smoothing flag is |
| 2418 // propagated from RTCConfiguration to the CreateMediaController call. |
| 2419 TEST_F(PeerConnectionMediaConfigTest, TestDisablePrerendererSmoothingTrue) { |
| 2420 PeerConnectionInterface::RTCConfiguration config; |
| 2421 FakeConstraints constraints; |
| 2422 |
| 2423 config.disable_prerenderer_smoothing = true; |
| 2424 const cricket::MediaConfig& media_config = |
| 2425 TestCreatePeerConnection(config, &constraints); |
| 2426 |
| 2427 EXPECT_TRUE(media_config.disable_prerenderer_smoothing); |
| 2428 } |
| 2429 |
2331 // The following tests verify that session options are created correctly. | 2430 // The following tests verify that session options are created correctly. |
2332 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of | 2431 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of |
2333 // "verify options are converted correctly", should be "pass options into | 2432 // "verify options are converted correctly", should be "pass options into |
2334 // CreateOffer and verify the correct offer is produced." | 2433 // CreateOffer and verify the correct offer is produced." |
2335 | 2434 |
2336 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { | 2435 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { |
2337 RTCOfferAnswerOptions rtc_options; | 2436 RTCOfferAnswerOptions rtc_options; |
2338 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; | 2437 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; |
2339 | 2438 |
2340 cricket::MediaSessionOptions options; | 2439 cricket::MediaSessionOptions options; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 FakeConstraints updated_answer_c; | 2588 FakeConstraints updated_answer_c; |
2490 answer_c.SetMandatoryReceiveAudio(false); | 2589 answer_c.SetMandatoryReceiveAudio(false); |
2491 answer_c.SetMandatoryReceiveVideo(false); | 2590 answer_c.SetMandatoryReceiveVideo(false); |
2492 | 2591 |
2493 cricket::MediaSessionOptions updated_answer_options; | 2592 cricket::MediaSessionOptions updated_answer_options; |
2494 EXPECT_TRUE( | 2593 EXPECT_TRUE( |
2495 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2594 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
2496 EXPECT_TRUE(updated_answer_options.has_audio()); | 2595 EXPECT_TRUE(updated_answer_options.has_audio()); |
2497 EXPECT_TRUE(updated_answer_options.has_video()); | 2596 EXPECT_TRUE(updated_answer_options.has_video()); |
2498 } | 2597 } |
OLD | NEW |