Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: webrtc/api/peerconnectioninterface_unittest.cc

Issue 1717583002: Non-constraint interfaces for all constrainable interfaces (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Review comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/peerconnectionproxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 // The following tests verify that session options are created correctly. 2447 // The following tests verify that session options are created correctly.
2448 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of 2448 // TODO(deadbeef): Convert these tests to be more end-to-end. Instead of
2449 // "verify options are converted correctly", should be "pass options into 2449 // "verify options are converted correctly", should be "pass options into
2450 // CreateOffer and verify the correct offer is produced." 2450 // CreateOffer and verify the correct offer is produced."
2451 2451
2452 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { 2452 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) {
2453 RTCOfferAnswerOptions rtc_options; 2453 RTCOfferAnswerOptions rtc_options;
2454 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; 2454 rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1;
2455 2455
2456 cricket::MediaSessionOptions options; 2456 cricket::MediaSessionOptions options;
2457 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2457 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, &options));
2458 2458
2459 rtc_options.offer_to_receive_audio = 2459 rtc_options.offer_to_receive_audio =
2460 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; 2460 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1;
2461 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2461 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, &options));
2462 } 2462 }
2463 2463
2464 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) { 2464 TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) {
2465 RTCOfferAnswerOptions rtc_options; 2465 RTCOfferAnswerOptions rtc_options;
2466 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; 2466 rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1;
2467 2467
2468 cricket::MediaSessionOptions options; 2468 cricket::MediaSessionOptions options;
2469 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2469 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, &options));
2470 2470
2471 rtc_options.offer_to_receive_video = 2471 rtc_options.offer_to_receive_video =
2472 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; 2472 RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1;
2473 EXPECT_FALSE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2473 EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, &options));
2474 } 2474 }
2475 2475
2476 // Test that a MediaSessionOptions is created for an offer if 2476 // Test that a MediaSessionOptions is created for an offer if
2477 // OfferToReceiveAudio and OfferToReceiveVideo options are set. 2477 // OfferToReceiveAudio and OfferToReceiveVideo options are set.
2478 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) { 2478 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) {
2479 RTCOfferAnswerOptions rtc_options; 2479 RTCOfferAnswerOptions rtc_options;
2480 rtc_options.offer_to_receive_audio = 1; 2480 rtc_options.offer_to_receive_audio = 1;
2481 rtc_options.offer_to_receive_video = 1; 2481 rtc_options.offer_to_receive_video = 1;
2482 2482
2483 cricket::MediaSessionOptions options; 2483 cricket::MediaSessionOptions options;
2484 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2484 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2485 EXPECT_TRUE(options.has_audio()); 2485 EXPECT_TRUE(options.has_audio());
2486 EXPECT_TRUE(options.has_video()); 2486 EXPECT_TRUE(options.has_video());
2487 EXPECT_TRUE(options.bundle_enabled); 2487 EXPECT_TRUE(options.bundle_enabled);
2488 } 2488 }
2489 2489
2490 // Test that a correct MediaSessionOptions is created for an offer if 2490 // Test that a correct MediaSessionOptions is created for an offer if
2491 // OfferToReceiveAudio is set. 2491 // OfferToReceiveAudio is set.
2492 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) { 2492 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) {
2493 RTCOfferAnswerOptions rtc_options; 2493 RTCOfferAnswerOptions rtc_options;
2494 rtc_options.offer_to_receive_audio = 1; 2494 rtc_options.offer_to_receive_audio = 1;
2495 2495
2496 cricket::MediaSessionOptions options; 2496 cricket::MediaSessionOptions options;
2497 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2497 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2498 EXPECT_TRUE(options.has_audio()); 2498 EXPECT_TRUE(options.has_audio());
2499 EXPECT_FALSE(options.has_video()); 2499 EXPECT_FALSE(options.has_video());
2500 EXPECT_TRUE(options.bundle_enabled); 2500 EXPECT_TRUE(options.bundle_enabled);
2501 } 2501 }
2502 2502
2503 // Test that a correct MediaSessionOptions is created for an offer if 2503 // Test that a correct MediaSessionOptions is created for an offer if
2504 // the default OfferOptions are used. 2504 // the default OfferOptions are used.
2505 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) { 2505 TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) {
2506 RTCOfferAnswerOptions rtc_options; 2506 RTCOfferAnswerOptions rtc_options;
2507 2507
2508 cricket::MediaSessionOptions options; 2508 cricket::MediaSessionOptions options;
2509 options.transport_options["audio"] = cricket::TransportOptions(); 2509 options.transport_options["audio"] = cricket::TransportOptions();
2510 options.transport_options["video"] = cricket::TransportOptions(); 2510 options.transport_options["video"] = cricket::TransportOptions();
2511 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2511 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2512 EXPECT_TRUE(options.has_audio()); 2512 EXPECT_TRUE(options.has_audio());
2513 EXPECT_FALSE(options.has_video()); 2513 EXPECT_FALSE(options.has_video());
2514 EXPECT_TRUE(options.bundle_enabled); 2514 EXPECT_TRUE(options.bundle_enabled);
2515 EXPECT_TRUE(options.vad_enabled); 2515 EXPECT_TRUE(options.vad_enabled);
2516 EXPECT_FALSE(options.transport_options["audio"].ice_restart); 2516 EXPECT_FALSE(options.transport_options["audio"].ice_restart);
2517 EXPECT_FALSE(options.transport_options["video"].ice_restart); 2517 EXPECT_FALSE(options.transport_options["video"].ice_restart);
2518 } 2518 }
2519 2519
2520 // Test that a correct MediaSessionOptions is created for an offer if 2520 // Test that a correct MediaSessionOptions is created for an offer if
2521 // OfferToReceiveVideo is set. 2521 // OfferToReceiveVideo is set.
2522 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) { 2522 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) {
2523 RTCOfferAnswerOptions rtc_options; 2523 RTCOfferAnswerOptions rtc_options;
2524 rtc_options.offer_to_receive_audio = 0; 2524 rtc_options.offer_to_receive_audio = 0;
2525 rtc_options.offer_to_receive_video = 1; 2525 rtc_options.offer_to_receive_video = 1;
2526 2526
2527 cricket::MediaSessionOptions options; 2527 cricket::MediaSessionOptions options;
2528 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2528 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2529 EXPECT_FALSE(options.has_audio()); 2529 EXPECT_FALSE(options.has_audio());
2530 EXPECT_TRUE(options.has_video()); 2530 EXPECT_TRUE(options.has_video());
2531 EXPECT_TRUE(options.bundle_enabled); 2531 EXPECT_TRUE(options.bundle_enabled);
2532 } 2532 }
2533 2533
2534 // Test that a correct MediaSessionOptions is created for an offer if 2534 // Test that a correct MediaSessionOptions is created for an offer if
2535 // UseRtpMux is set to false. 2535 // UseRtpMux is set to false.
2536 TEST(CreateSessionOptionsTest, 2536 TEST(CreateSessionOptionsTest,
2537 GetMediaSessionOptionsForOfferWithBundleDisabled) { 2537 GetMediaSessionOptionsForOfferWithBundleDisabled) {
2538 RTCOfferAnswerOptions rtc_options; 2538 RTCOfferAnswerOptions rtc_options;
2539 rtc_options.offer_to_receive_audio = 1; 2539 rtc_options.offer_to_receive_audio = 1;
2540 rtc_options.offer_to_receive_video = 1; 2540 rtc_options.offer_to_receive_video = 1;
2541 rtc_options.use_rtp_mux = false; 2541 rtc_options.use_rtp_mux = false;
2542 2542
2543 cricket::MediaSessionOptions options; 2543 cricket::MediaSessionOptions options;
2544 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2544 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2545 EXPECT_TRUE(options.has_audio()); 2545 EXPECT_TRUE(options.has_audio());
2546 EXPECT_TRUE(options.has_video()); 2546 EXPECT_TRUE(options.has_video());
2547 EXPECT_FALSE(options.bundle_enabled); 2547 EXPECT_FALSE(options.bundle_enabled);
2548 } 2548 }
2549 2549
2550 // Test that a correct MediaSessionOptions is created to restart ice if 2550 // Test that a correct MediaSessionOptions is created to restart ice if
2551 // IceRestart is set. It also tests that subsequent MediaSessionOptions don't 2551 // IceRestart is set. It also tests that subsequent MediaSessionOptions don't
2552 // have |audio_transport_options.ice_restart| etc. set. 2552 // have |audio_transport_options.ice_restart| etc. set.
2553 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) { 2553 TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) {
2554 RTCOfferAnswerOptions rtc_options; 2554 RTCOfferAnswerOptions rtc_options;
2555 rtc_options.ice_restart = true; 2555 rtc_options.ice_restart = true;
2556 2556
2557 cricket::MediaSessionOptions options; 2557 cricket::MediaSessionOptions options;
2558 options.transport_options["audio"] = cricket::TransportOptions(); 2558 options.transport_options["audio"] = cricket::TransportOptions();
2559 options.transport_options["video"] = cricket::TransportOptions(); 2559 options.transport_options["video"] = cricket::TransportOptions();
2560 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2560 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2561 EXPECT_TRUE(options.transport_options["audio"].ice_restart); 2561 EXPECT_TRUE(options.transport_options["audio"].ice_restart);
2562 EXPECT_TRUE(options.transport_options["video"].ice_restart); 2562 EXPECT_TRUE(options.transport_options["video"].ice_restart);
2563 2563
2564 rtc_options = RTCOfferAnswerOptions(); 2564 rtc_options = RTCOfferAnswerOptions();
2565 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_options, &options)); 2565 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, &options));
2566 EXPECT_FALSE(options.transport_options["audio"].ice_restart); 2566 EXPECT_FALSE(options.transport_options["audio"].ice_restart);
2567 EXPECT_FALSE(options.transport_options["video"].ice_restart); 2567 EXPECT_FALSE(options.transport_options["video"].ice_restart);
2568 } 2568 }
2569 2569
2570 // Test that the MediaConstraints in an answer don't affect if audio and video 2570 // Test that the MediaConstraints in an answer don't affect if audio and video
2571 // is offered in an offer but that if kOfferToReceiveAudio or 2571 // is offered in an offer but that if kOfferToReceiveAudio or
2572 // kOfferToReceiveVideo constraints are true in an offer, the media type will be 2572 // kOfferToReceiveVideo constraints are true in an offer, the media type will be
2573 // included in subsequent answers. 2573 // included in subsequent answers.
2574 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) { 2574 TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) {
2575 FakeConstraints answer_c; 2575 FakeConstraints answer_c;
2576 answer_c.SetMandatoryReceiveAudio(true); 2576 answer_c.SetMandatoryReceiveAudio(true);
2577 answer_c.SetMandatoryReceiveVideo(true); 2577 answer_c.SetMandatoryReceiveVideo(true);
2578 2578
2579 cricket::MediaSessionOptions answer_options; 2579 cricket::MediaSessionOptions answer_options;
2580 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options)); 2580 EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options));
2581 EXPECT_TRUE(answer_options.has_audio()); 2581 EXPECT_TRUE(answer_options.has_audio());
2582 EXPECT_TRUE(answer_options.has_video()); 2582 EXPECT_TRUE(answer_options.has_video());
2583 2583
2584 RTCOfferAnswerOptions rtc_offer_options; 2584 RTCOfferAnswerOptions rtc_offer_options;
2585 2585
2586 cricket::MediaSessionOptions offer_options; 2586 cricket::MediaSessionOptions offer_options;
2587 EXPECT_TRUE(ConvertRtcOptionsForOffer(rtc_offer_options, &offer_options)); 2587 EXPECT_TRUE(ExtractMediaSessionOptions(rtc_offer_options, &offer_options));
2588 EXPECT_TRUE(offer_options.has_audio()); 2588 EXPECT_TRUE(offer_options.has_audio());
2589 EXPECT_FALSE(offer_options.has_video()); 2589 EXPECT_FALSE(offer_options.has_video());
2590 2590
2591 RTCOfferAnswerOptions updated_rtc_offer_options; 2591 RTCOfferAnswerOptions updated_rtc_offer_options;
2592 updated_rtc_offer_options.offer_to_receive_audio = 1; 2592 updated_rtc_offer_options.offer_to_receive_audio = 1;
2593 updated_rtc_offer_options.offer_to_receive_video = 1; 2593 updated_rtc_offer_options.offer_to_receive_video = 1;
2594 2594
2595 cricket::MediaSessionOptions updated_offer_options; 2595 cricket::MediaSessionOptions updated_offer_options;
2596 EXPECT_TRUE(ConvertRtcOptionsForOffer(updated_rtc_offer_options, 2596 EXPECT_TRUE(ExtractMediaSessionOptions(updated_rtc_offer_options,
2597 &updated_offer_options)); 2597 &updated_offer_options));
2598 EXPECT_TRUE(updated_offer_options.has_audio()); 2598 EXPECT_TRUE(updated_offer_options.has_audio());
2599 EXPECT_TRUE(updated_offer_options.has_video()); 2599 EXPECT_TRUE(updated_offer_options.has_video());
2600 2600
2601 // Since an offer has been created with both audio and video, subsequent 2601 // Since an offer has been created with both audio and video, subsequent
2602 // offers and answers should contain both audio and video. 2602 // offers and answers should contain both audio and video.
2603 // Answers will only contain the media types that exist in the offer 2603 // Answers will only contain the media types that exist in the offer
2604 // regardless of the value of |updated_answer_options.has_audio| and 2604 // regardless of the value of |updated_answer_options.has_audio| and
2605 // |updated_answer_options.has_video|. 2605 // |updated_answer_options.has_video|.
2606 FakeConstraints updated_answer_c; 2606 FakeConstraints updated_answer_c;
2607 answer_c.SetMandatoryReceiveAudio(false); 2607 answer_c.SetMandatoryReceiveAudio(false);
2608 answer_c.SetMandatoryReceiveVideo(false); 2608 answer_c.SetMandatoryReceiveVideo(false);
2609 2609
2610 cricket::MediaSessionOptions updated_answer_options; 2610 cricket::MediaSessionOptions updated_answer_options;
2611 EXPECT_TRUE( 2611 EXPECT_TRUE(
2612 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2612 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2613 EXPECT_TRUE(updated_answer_options.has_audio()); 2613 EXPECT_TRUE(updated_answer_options.has_audio());
2614 EXPECT_TRUE(updated_answer_options.has_video()); 2614 EXPECT_TRUE(updated_answer_options.has_video());
2615 } 2615 }
OLDNEW
« no previous file with comments | « webrtc/api/peerconnectioninterface.h ('k') | webrtc/api/peerconnectionproxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698