Chromium Code Reviews| Index: webrtc/pc/peerconnectioninterface_unittest.cc |
| diff --git a/webrtc/pc/peerconnectioninterface_unittest.cc b/webrtc/pc/peerconnectioninterface_unittest.cc |
| index c10324a94b7a5772733cd473a939226c074981d2..831dafce972014fbf9e32582b7ec9ef500a68169 100644 |
| --- a/webrtc/pc/peerconnectioninterface_unittest.cc |
| +++ b/webrtc/pc/peerconnectioninterface_unittest.cc |
| @@ -1171,6 +1171,57 @@ class PeerConnectionInterfaceTest : public testing::Test { |
| return audio_desc->streams()[0].cname; |
| } |
| + bool CreateOfferWithOptions( |
| + std::unique_ptr<SessionDescriptionInterface>* desc, |
| + const RTCOfferAnswerOptions& offer_answer_options) { |
|
Taylor Brandstetter
2017/07/28 19:00:25
Can this just return the unique_ptr, returning nul
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + RTC_DCHECK(pc_); |
| + rtc::scoped_refptr<MockCreateSessionDescriptionObserver> observer( |
| + new rtc::RefCountedObject<MockCreateSessionDescriptionObserver>()); |
| + pc_->CreateOffer(observer, offer_answer_options); |
| + EXPECT_EQ_WAIT(true, observer->called(), kTimeout); |
| + *desc = observer->MoveDescription(); |
| + return observer->result(); |
| + } |
| + |
| + void CreateOfferWithOptionsAsRemoteDescription( |
| + std::unique_ptr<SessionDescriptionInterface>* desc, |
| + const RTCOfferAnswerOptions& offer_answer_options) { |
| + ASSERT_TRUE(CreateOfferWithOptions(desc, offer_answer_options)); |
| + std::string sdp; |
| + EXPECT_TRUE((*desc)->ToString(&sdp)); |
| + SessionDescriptionInterface* remote_offer = |
| + webrtc::CreateSessionDescription(SessionDescriptionInterface::kOffer, |
| + sdp, NULL); |
| + EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
| + EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_); |
| + } |
| + |
| + void CreateOfferWithOptionsAsLocalDescription( |
| + std::unique_ptr<SessionDescriptionInterface>* desc, |
| + const RTCOfferAnswerOptions& offer_answer_options) { |
| + ASSERT_TRUE(CreateOfferWithOptions(desc, offer_answer_options)); |
| + std::string sdp; |
| + EXPECT_TRUE((*desc)->ToString(&sdp)); |
| + SessionDescriptionInterface* new_offer = webrtc::CreateSessionDescription( |
| + SessionDescriptionInterface::kOffer, sdp, NULL); |
| + |
| + EXPECT_TRUE(DoSetLocalDescription(new_offer)); |
| + EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_); |
| + } |
| + |
| + bool VerifyNoCNCodecs(const cricket::ContentInfo* content) { |
|
Taylor Brandstetter
2017/07/28 19:00:25
I think it would make more sense to call this "Has
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + const cricket::ContentDescription* description = content->description; |
| + RTC_DCHECK(description); |
| + const cricket::AudioContentDescription* audio_content_desc = |
| + static_cast<const cricket::AudioContentDescription*>(description); |
| + RTC_DCHECK(audio_content_desc); |
| + for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) { |
| + if (audio_content_desc->codecs()[i].name == "CN") |
| + return false; |
| + } |
| + return true; |
| + } |
| + |
| std::unique_ptr<rtc::VirtualSocketServer> vss_; |
| rtc::AutoSocketServerThread main_; |
| cricket::FakePortAllocator* port_allocator_ = nullptr; |
| @@ -3410,6 +3461,198 @@ TEST_F(PeerConnectionInterfaceTest, SetBitrateCurrentLessThanImplicitMin) { |
| EXPECT_TRUE(pc_->SetBitrate(bitrate).ok()); |
| } |
| +// The following tests verify that session options and offers are created |
| +// correctly. |
| +TEST_F(PeerConnectionInterfaceTest, GetOptionsForOfferWithInvalidAudioOption) { |
|
Taylor Brandstetter
2017/07/28 19:00:25
Since these tests are no longer calling "GetOption
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_FALSE(CreateOfferWithOptions(&offer, rtc_options)); |
|
Taylor Brandstetter
2017/07/28 19:00:25
These tests could use some comments. For example:
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + rtc_options.offer_to_receive_audio = |
| + RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; |
| + EXPECT_FALSE(CreateOfferWithOptions(&offer, rtc_options)); |
| +} |
| + |
| +TEST_F(PeerConnectionInterfaceTest, GetOptionsForOfferWithInvalidVideoOption) { |
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_FALSE(CreateOfferWithOptions(&offer, rtc_options)); |
| + |
| + rtc_options.offer_to_receive_video = |
| + RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; |
| + EXPECT_FALSE(CreateOfferWithOptions(&offer, rtc_options)); |
| +} |
| + |
| +// Test that the audio and video section will be added to an offer if |
| +// OfferToReceiveAudio and OfferToReceiveVideo options are set. |
| +TEST_F(PeerConnectionInterfaceTest, |
| + GetMediaSessionOptionsForOfferWithAudioVideo) { |
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.offer_to_receive_audio = 1; |
| + rtc_options.offer_to_receive_video = 1; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_TRUE(CreateOfferWithOptions(&offer, rtc_options)); |
| + EXPECT_TRUE(ValidateOfferAnswerOptions(rtc_options)); |
| + EXPECT_NE(nullptr, offer->description()->GetContentByName(cricket::CN_AUDIO)); |
| + EXPECT_NE(nullptr, offer->description()->GetContentByName(cricket::CN_VIDEO)); |
|
Taylor Brandstetter
2017/07/28 19:00:25
nit: To be foolproof, we shouldn't rely on "GetCon
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + EXPECT_TRUE(offer->description()->HasGroup(cricket::GROUP_TYPE_BUNDLE)); |
|
Taylor Brandstetter
2017/07/28 19:00:26
I don't think the BUNDLE group assertion is releva
Zhi Huang
2017/08/02 04:38:36
Done.
|
| +} |
| + |
| +// Test that only audio section will be added if only OfferToReceiveAudio |
| +// options is set. |
| +TEST_F(PeerConnectionInterfaceTest, GetMediaSessionOptionsForOfferWithAudio) { |
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.offer_to_receive_audio = 1; |
| + rtc_options.offer_to_receive_video = 0; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_TRUE(CreateOfferWithOptions(&offer, rtc_options)); |
| + EXPECT_NE(nullptr, offer->description()->GetContentByName(cricket::CN_AUDIO)); |
| + EXPECT_EQ(nullptr, offer->description()->GetContentByName(cricket::CN_VIDEO)); |
| + EXPECT_TRUE(offer->description()->HasGroup(cricket::GROUP_TYPE_BUNDLE)); |
| +} |
| + |
| +// Test that the |vad_enabled| can be set correctly in MediaSessionOptions. |
|
Taylor Brandstetter
2017/07/28 19:00:26
This comment should be updated since this test doe
Zhi Huang
2017/08/02 04:38:36
Done.
|
| +TEST_F(PeerConnectionInterfaceTest, GetMediaSessionOptionsWithVAD) { |
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.offer_to_receive_audio = 1; |
| + rtc_options.offer_to_receive_video = 0; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_TRUE(CreateOfferWithOptions(&offer, rtc_options)); |
| + const cricket::ContentInfo* audio_content = |
| + offer->description()->GetContentByName(cricket::CN_AUDIO); |
| + ASSERT_TRUE(audio_content); |
| + EXPECT_FALSE(VerifyNoCNCodecs(audio_content)); |
| + |
| + rtc_options.voice_activity_detection = false; |
| + EXPECT_TRUE(CreateOfferWithOptions(&offer, rtc_options)); |
| + audio_content = offer->description()->GetContentByName(cricket::CN_AUDIO); |
| + ASSERT_TRUE(audio_content); |
| + EXPECT_TRUE(VerifyNoCNCodecs(audio_content)); |
| +} |
| + |
| +// Test that no media section will be added if using default |
| +// RTCOfferAnswerOptions. |
| +TEST_F(PeerConnectionInterfaceTest, GetDefaultMediaSessionOptionsForOffer) { |
| + RTCOfferAnswerOptions rtc_options; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_TRUE(CreateOfferWithOptions(&offer, rtc_options)); |
| + // No media sections should be created. |
| + EXPECT_EQ(nullptr, offer->description()->GetContentByName(cricket::CN_AUDIO)); |
| + EXPECT_EQ(nullptr, offer->description()->GetContentByName(cricket::CN_VIDEO)); |
| +} |
| + |
| +// Test that only video section will be added if only OfferToReceiveVideo |
| +// options is set. |
| +TEST_F(PeerConnectionInterfaceTest, GetMediaSessionOptionsForOfferWithVideo) { |
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.offer_to_receive_audio = 0; |
| + rtc_options.offer_to_receive_video = 1; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + EXPECT_TRUE(CreateOfferWithOptions(&offer, rtc_options)); |
| + EXPECT_EQ(nullptr, offer->description()->GetContentByName(cricket::CN_AUDIO)); |
| + EXPECT_NE(nullptr, offer->description()->GetContentByName(cricket::CN_VIDEO)); |
| + EXPECT_TRUE(offer->description()->HasGroup(cricket::GROUP_TYPE_BUNDLE)); |
| +} |
| + |
| +// Test that a correct MediaSessionOptions is created to restart ice if |
| +// IceRestart is set. |
| +TEST_F(PeerConnectionInterfaceTest, |
| + GetMediaSessionOptionsForOfferWithIceRestart) { |
| + RTCOfferAnswerOptions rtc_options; |
| + rtc_options.ice_restart = false; |
| + rtc_options.offer_to_receive_audio = 1; |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreatePeerConnection(); |
| + CreateOfferWithOptionsAsLocalDescription(&offer, rtc_options); |
| + auto ufrag1 = offer->description() |
| + ->GetTransportInfoByName(cricket::CN_AUDIO) |
| + ->description.ice_ufrag; |
| + auto pwd1 = offer->description() |
| + ->GetTransportInfoByName(cricket::CN_AUDIO) |
| + ->description.ice_pwd; |
| + |
| + CreateOfferWithOptionsAsLocalDescription(&offer, rtc_options); |
|
Taylor Brandstetter
2017/07/28 19:00:26
So this is also testing that if ice_restart is fal
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + auto ufrag2 = offer->description() |
| + ->GetTransportInfoByName(cricket::CN_AUDIO) |
| + ->description.ice_ufrag; |
| + auto pwd2 = offer->description() |
| + ->GetTransportInfoByName(cricket::CN_AUDIO) |
| + ->description.ice_pwd; |
| + |
| + rtc_options.ice_restart = true; |
| + CreateOfferWithOptionsAsLocalDescription(&offer, rtc_options); |
| + auto ufrag3 = offer->description() |
| + ->GetTransportInfoByName(cricket::CN_AUDIO) |
| + ->description.ice_ufrag; |
| + auto pwd3 = offer->description() |
| + ->GetTransportInfoByName(cricket::CN_AUDIO) |
| + ->description.ice_pwd; |
| + |
| + EXPECT_EQ(ufrag1, ufrag2); |
| + EXPECT_EQ(pwd1, pwd2); |
| + EXPECT_NE(ufrag2, ufrag3); |
| + EXPECT_NE(pwd2, pwd3); |
| +} |
| + |
| +// Test that the MediaConstraints can be correctly translated to |
| +// RTCOfferAnswerOptions when creating an answer and the MediaConstraints don't |
| +// affect whether audio and video sections are created if they are offered from |
| +// the remote side. |
| +TEST_F(PeerConnectionInterfaceTest, MediaConstraintsInAnswer) { |
|
Taylor Brandstetter
2017/07/28 19:00:26
I think this test could be written in terms of Pee
Zhi Huang
2017/08/02 04:38:36
Done.
|
| + FakeConstraints answer_c; |
| + answer_c.SetMandatoryReceiveAudio(true); |
| + answer_c.SetMandatoryReceiveVideo(true); |
| + |
| + RTCOfferAnswerOptions rtc_answer_options; |
| + EXPECT_TRUE( |
| + ConvertConstraintsToOfferAnswerOptions(&answer_c, &rtc_answer_options)); |
| + EXPECT_EQ(1, rtc_answer_options.offer_to_receive_audio); |
| + EXPECT_EQ(1, rtc_answer_options.offer_to_receive_video); |
| + |
| + RTCOfferAnswerOptions rtc_offer_options; |
| + rtc_offer_options.offer_to_receive_audio = 1; |
| + rtc_offer_options.offer_to_receive_video = 1; |
| + |
| + CreatePeerConnection(); |
| + |
| + std::unique_ptr<SessionDescriptionInterface> offer; |
| + CreateOfferWithOptionsAsRemoteDescription(&offer, rtc_offer_options); |
| + EXPECT_NE(nullptr, offer->description()->GetContentByName(cricket::CN_AUDIO)); |
| + EXPECT_NE(nullptr, offer->description()->GetContentByName(cricket::CN_VIDEO)); |
| + |
| + // Since an offer has been created with both audio and video, subsequent |
| + // offers and answers should contain both audio and video. |
| + // Answers will only contain the media types that exist in the offer |
| + // regardless of the value of |updated_answer_options.has_audio| and |
| + // |updated_answer_options.has_video|. |
| + FakeConstraints updated_answer_c; |
| + updated_answer_c.SetMandatoryReceiveAudio(false); |
| + updated_answer_c.SetMandatoryReceiveVideo(false); |
| + |
| + std::unique_ptr<SessionDescriptionInterface> answer; |
| + ASSERT_TRUE(DoCreateAnswer(&answer, &updated_answer_c)); |
| + EXPECT_NE(nullptr, |
| + answer->description()->GetContentByName(cricket::CN_AUDIO)); |
| + EXPECT_NE(nullptr, |
| + answer->description()->GetContentByName(cricket::CN_VIDEO)); |
| +} |
| + |
| class PeerConnectionMediaConfigTest : public testing::Test { |
| protected: |
| void SetUp() override { |
| @@ -3418,8 +3661,7 @@ class PeerConnectionMediaConfigTest : public testing::Test { |
| } |
| const cricket::MediaConfig TestCreatePeerConnection( |
| const PeerConnectionInterface::RTCConfiguration& config, |
| - const MediaConstraintsInterface *constraints) { |
| - |
| + const MediaConstraintsInterface* constraints) { |
| rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection( |
| config, constraints, nullptr, nullptr, &observer_)); |
| EXPECT_TRUE(pc.get()); |
| @@ -3501,177 +3743,6 @@ TEST_F(PeerConnectionMediaConfigTest, |
| EXPECT_TRUE(media_config.video.suspend_below_min_bitrate); |
| } |
| -// The following tests verify that session options are created correctly. |
| -// TODO(deadbeef): Convert these tests to be more end-to-end. Instead of |
| -// "verify options are converted correctly", should be "pass options into |
| -// CreateOffer and verify the correct offer is produced." |
| - |
| -TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidAudioOption) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.offer_to_receive_audio = RTCOfferAnswerOptions::kUndefined - 1; |
| - |
| - cricket::MediaSessionOptions options; |
| - EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - |
| - rtc_options.offer_to_receive_audio = |
| - RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; |
| - EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| -} |
| - |
| -TEST(CreateSessionOptionsTest, GetOptionsForOfferWithInvalidVideoOption) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.offer_to_receive_video = RTCOfferAnswerOptions::kUndefined - 1; |
| - |
| - cricket::MediaSessionOptions options; |
| - EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - |
| - rtc_options.offer_to_receive_video = |
| - RTCOfferAnswerOptions::kMaxOfferToReceiveMedia + 1; |
| - EXPECT_FALSE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| -} |
| - |
| -// Test that a MediaSessionOptions is created for an offer if |
| -// OfferToReceiveAudio and OfferToReceiveVideo options are set. |
| -TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudioVideo) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.offer_to_receive_audio = 1; |
| - rtc_options.offer_to_receive_video = 1; |
| - |
| - cricket::MediaSessionOptions options; |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_TRUE(options.has_audio()); |
| - EXPECT_TRUE(options.has_video()); |
| - EXPECT_TRUE(options.bundle_enabled); |
| -} |
| - |
| -// Test that a correct MediaSessionOptions is created for an offer if |
| -// OfferToReceiveAudio is set. |
| -TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithAudio) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.offer_to_receive_audio = 1; |
| - |
| - cricket::MediaSessionOptions options; |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_TRUE(options.has_audio()); |
| - EXPECT_FALSE(options.has_video()); |
| - EXPECT_TRUE(options.bundle_enabled); |
| -} |
| - |
| -// Test that a correct MediaSessionOptions is created for an offer if |
| -// the default OfferOptions are used. |
| -TEST(CreateSessionOptionsTest, GetDefaultMediaSessionOptionsForOffer) { |
| - RTCOfferAnswerOptions rtc_options; |
| - |
| - cricket::MediaSessionOptions options; |
| - options.transport_options["audio"] = cricket::TransportOptions(); |
| - options.transport_options["video"] = cricket::TransportOptions(); |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_TRUE(options.has_audio()); |
| - EXPECT_FALSE(options.has_video()); |
| - EXPECT_TRUE(options.bundle_enabled); |
| - EXPECT_TRUE(options.vad_enabled); |
| - EXPECT_FALSE(options.transport_options["audio"].ice_restart); |
| - EXPECT_FALSE(options.transport_options["video"].ice_restart); |
| -} |
| - |
| -// Test that a correct MediaSessionOptions is created for an offer if |
| -// OfferToReceiveVideo is set. |
| -TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithVideo) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.offer_to_receive_audio = 0; |
| - rtc_options.offer_to_receive_video = 1; |
| - |
| - cricket::MediaSessionOptions options; |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_FALSE(options.has_audio()); |
| - EXPECT_TRUE(options.has_video()); |
| - EXPECT_TRUE(options.bundle_enabled); |
| -} |
| - |
| -// Test that a correct MediaSessionOptions is created for an offer if |
| -// UseRtpMux is set to false. |
| -TEST(CreateSessionOptionsTest, |
| - GetMediaSessionOptionsForOfferWithBundleDisabled) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.offer_to_receive_audio = 1; |
| - rtc_options.offer_to_receive_video = 1; |
| - rtc_options.use_rtp_mux = false; |
| - |
| - cricket::MediaSessionOptions options; |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_TRUE(options.has_audio()); |
| - EXPECT_TRUE(options.has_video()); |
| - EXPECT_FALSE(options.bundle_enabled); |
| -} |
| - |
| -// Test that a correct MediaSessionOptions is created to restart ice if |
| -// IceRestart is set. It also tests that subsequent MediaSessionOptions don't |
| -// have |audio_transport_options.ice_restart| etc. set. |
| -TEST(CreateSessionOptionsTest, GetMediaSessionOptionsForOfferWithIceRestart) { |
| - RTCOfferAnswerOptions rtc_options; |
| - rtc_options.ice_restart = true; |
| - |
| - cricket::MediaSessionOptions options; |
| - options.transport_options["audio"] = cricket::TransportOptions(); |
| - options.transport_options["video"] = cricket::TransportOptions(); |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_TRUE(options.transport_options["audio"].ice_restart); |
| - EXPECT_TRUE(options.transport_options["video"].ice_restart); |
| - |
| - rtc_options = RTCOfferAnswerOptions(); |
| - EXPECT_TRUE(ExtractMediaSessionOptions(rtc_options, true, &options)); |
| - EXPECT_FALSE(options.transport_options["audio"].ice_restart); |
| - EXPECT_FALSE(options.transport_options["video"].ice_restart); |
| -} |
| - |
| -// Test that the MediaConstraints in an answer don't affect if audio and video |
| -// is offered in an offer but that if kOfferToReceiveAudio or |
| -// kOfferToReceiveVideo constraints are true in an offer, the media type will be |
| -// included in subsequent answers. |
| -TEST(CreateSessionOptionsTest, MediaConstraintsInAnswer) { |
| - FakeConstraints answer_c; |
| - answer_c.SetMandatoryReceiveAudio(true); |
| - answer_c.SetMandatoryReceiveVideo(true); |
| - |
| - cricket::MediaSessionOptions answer_options; |
| - EXPECT_TRUE(ParseConstraintsForAnswer(&answer_c, &answer_options)); |
| - EXPECT_TRUE(answer_options.has_audio()); |
| - EXPECT_TRUE(answer_options.has_video()); |
| - |
| - RTCOfferAnswerOptions rtc_offer_options; |
| - |
| - cricket::MediaSessionOptions offer_options; |
| - EXPECT_TRUE( |
| - ExtractMediaSessionOptions(rtc_offer_options, false, &offer_options)); |
| - EXPECT_TRUE(offer_options.has_audio()); |
| - EXPECT_TRUE(offer_options.has_video()); |
| - |
| - RTCOfferAnswerOptions updated_rtc_offer_options; |
| - updated_rtc_offer_options.offer_to_receive_audio = 1; |
| - updated_rtc_offer_options.offer_to_receive_video = 1; |
| - |
| - cricket::MediaSessionOptions updated_offer_options; |
| - EXPECT_TRUE(ExtractMediaSessionOptions(updated_rtc_offer_options, false, |
| - &updated_offer_options)); |
| - EXPECT_TRUE(updated_offer_options.has_audio()); |
| - EXPECT_TRUE(updated_offer_options.has_video()); |
| - |
| - // Since an offer has been created with both audio and video, subsequent |
| - // offers and answers should contain both audio and video. |
| - // Answers will only contain the media types that exist in the offer |
| - // regardless of the value of |updated_answer_options.has_audio| and |
| - // |updated_answer_options.has_video|. |
| - FakeConstraints updated_answer_c; |
| - answer_c.SetMandatoryReceiveAudio(false); |
| - answer_c.SetMandatoryReceiveVideo(false); |
| - |
| - cricket::MediaSessionOptions updated_answer_options; |
| - EXPECT_TRUE( |
| - ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
| - EXPECT_TRUE(updated_answer_options.has_audio()); |
| - EXPECT_TRUE(updated_answer_options.has_video()); |
| -} |
| - |
| // Tests a few random fields being different. |
| TEST(RTCConfigurationTest, ComparisonOperators) { |
| PeerConnectionInterface::RTCConfiguration a; |