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

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1430433004: Replace rtc::cricket::Settable with rtc::Maybe (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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 | « talk/app/webrtc/webrtcsession.cc ('k') | talk/media/base/mediachannel.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 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 SendAudioVideoStream1(); 782 SendAudioVideoStream1();
783 SessionDescriptionInterface* offer = CreateOffer(); 783 SessionDescriptionInterface* offer = CreateOffer();
784 784
785 SetLocalDescriptionWithoutError(offer); 785 SetLocalDescriptionWithoutError(offer);
786 786
787 video_channel_ = media_engine_->GetVideoChannel(0); 787 video_channel_ = media_engine_->GetVideoChannel(0);
788 788
789 ASSERT_TRUE(video_channel_ != NULL); 789 ASSERT_TRUE(video_channel_ != NULL);
790 const cricket::VideoOptions& video_options = video_channel_->options(); 790 const cricket::VideoOptions& video_options = video_channel_->options();
791 EXPECT_EQ(value_expected, 791 EXPECT_EQ(value_expected,
792 video_options.unsignalled_recv_stream_limit.GetWithDefaultIfUnset(-1)); 792 video_options.unsignalled_recv_stream_limit.value_or(-1));
793 } 793 }
794 794
795 void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1, 795 void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1,
796 const cricket::SessionDescription* desc2, 796 const cricket::SessionDescription* desc2,
797 bool expect_equal) { 797 bool expect_equal) {
798 if (desc1->contents().size() != desc2->contents().size()) { 798 if (desc1->contents().size() != desc2->contents().size()) {
799 EXPECT_FALSE(expect_equal); 799 EXPECT_FALSE(expect_equal);
800 return; 800 return;
801 } 801 }
802 802
(...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after
3290 Init(); 3290 Init();
3291 SendAudioVideoStream1(); 3291 SendAudioVideoStream1();
3292 CreateAndSetRemoteOfferAndLocalAnswer(); 3292 CreateAndSetRemoteOfferAndLocalAnswer();
3293 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3293 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3294 ASSERT_TRUE(channel != NULL); 3294 ASSERT_TRUE(channel != NULL);
3295 ASSERT_EQ(1u, channel->send_streams().size()); 3295 ASSERT_EQ(1u, channel->send_streams().size());
3296 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); 3296 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3297 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3297 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3298 3298
3299 cricket::AudioOptions options; 3299 cricket::AudioOptions options;
3300 options.echo_cancellation.Set(true); 3300 options.echo_cancellation = rtc::Maybe<bool>(true);
3301 3301
3302 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); 3302 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
3303 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); 3303 session_->SetAudioSend(send_ssrc, false, options, renderer.get());
3304 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); 3304 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3305 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); 3305 EXPECT_EQ(rtc::Maybe<bool>(), channel->options().echo_cancellation);
3306 EXPECT_TRUE(renderer->sink() != NULL); 3306 EXPECT_TRUE(renderer->sink() != NULL);
3307 3307
3308 // This will trigger SetSink(NULL) to the |renderer|. 3308 // This will trigger SetSink(NULL) to the |renderer|.
3309 session_->SetAudioSend(send_ssrc, true, options, NULL); 3309 session_->SetAudioSend(send_ssrc, true, options, NULL);
3310 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); 3310 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3311 bool value; 3311 EXPECT_EQ(rtc::Maybe<bool>(true), channel->options().echo_cancellation);
3312 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value));
3313 EXPECT_TRUE(value);
3314 EXPECT_TRUE(renderer->sink() == NULL); 3312 EXPECT_TRUE(renderer->sink() == NULL);
3315 } 3313 }
3316 3314
3317 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { 3315 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) {
3318 Init(); 3316 Init();
3319 SendAudioVideoStream1(); 3317 SendAudioVideoStream1();
3320 CreateAndSetRemoteOfferAndLocalAnswer(); 3318 CreateAndSetRemoteOfferAndLocalAnswer();
3321 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); 3319 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3322 ASSERT_TRUE(channel != NULL); 3320 ASSERT_TRUE(channel != NULL);
3323 ASSERT_EQ(1u, channel->send_streams().size()); 3321 ASSERT_EQ(1u, channel->send_streams().size());
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
3986 3984
3987 SetLocalDescriptionWithoutError(offer); 3985 SetLocalDescriptionWithoutError(offer);
3988 3986
3989 video_channel_ = media_engine_->GetVideoChannel(0); 3987 video_channel_ = media_engine_->GetVideoChannel(0);
3990 voice_channel_ = media_engine_->GetVoiceChannel(0); 3988 voice_channel_ = media_engine_->GetVoiceChannel(0);
3991 3989
3992 ASSERT_TRUE(video_channel_ != NULL); 3990 ASSERT_TRUE(video_channel_ != NULL);
3993 ASSERT_TRUE(voice_channel_ != NULL); 3991 ASSERT_TRUE(voice_channel_ != NULL);
3994 const cricket::AudioOptions& audio_options = voice_channel_->options(); 3992 const cricket::AudioOptions& audio_options = voice_channel_->options();
3995 const cricket::VideoOptions& video_options = video_channel_->options(); 3993 const cricket::VideoOptions& video_options = video_channel_->options();
3996 EXPECT_TRUE(audio_options.dscp.IsSet()); 3994 EXPECT_EQ(rtc::Maybe<bool>(true), audio_options.dscp);
3997 EXPECT_TRUE(audio_options.dscp.GetWithDefaultIfUnset(false)); 3995 EXPECT_EQ(rtc::Maybe<bool>(true), video_options.dscp);
3998 EXPECT_TRUE(video_options.dscp.IsSet());
3999 EXPECT_TRUE(video_options.dscp.GetWithDefaultIfUnset(false));
4000 } 3996 }
4001 3997
4002 TEST_F(WebRtcSessionTest, TestSuspendBelowMinBitrateConstraint) { 3998 TEST_F(WebRtcSessionTest, TestSuspendBelowMinBitrateConstraint) {
4003 constraints_.reset(new FakeConstraints()); 3999 constraints_.reset(new FakeConstraints());
4004 constraints_->AddOptional( 4000 constraints_->AddOptional(
4005 webrtc::MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate, 4001 webrtc::MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate,
4006 true); 4002 true);
4007 Init(); 4003 Init();
4008 SendAudioVideoStream1(); 4004 SendAudioVideoStream1();
4009 SessionDescriptionInterface* offer = CreateOffer(); 4005 SessionDescriptionInterface* offer = CreateOffer();
4010 4006
4011 SetLocalDescriptionWithoutError(offer); 4007 SetLocalDescriptionWithoutError(offer);
4012 4008
4013 video_channel_ = media_engine_->GetVideoChannel(0); 4009 video_channel_ = media_engine_->GetVideoChannel(0);
4014 4010
4015 ASSERT_TRUE(video_channel_ != NULL); 4011 ASSERT_TRUE(video_channel_ != NULL);
4016 const cricket::VideoOptions& video_options = video_channel_->options(); 4012 const cricket::VideoOptions& video_options = video_channel_->options();
4017 EXPECT_TRUE( 4013 EXPECT_EQ(rtc::Maybe<bool>(true), video_options.suspend_below_min_bitrate);
4018 video_options.suspend_below_min_bitrate.GetWithDefaultIfUnset(false));
4019 } 4014 }
4020 4015
4021 TEST_F(WebRtcSessionTest, TestNumUnsignalledRecvStreamsConstraint) { 4016 TEST_F(WebRtcSessionTest, TestNumUnsignalledRecvStreamsConstraint) {
4022 // Number of unsignalled receiving streams should be between 0 and 4017 // Number of unsignalled receiving streams should be between 0 and
4023 // kMaxUnsignalledRecvStreams. 4018 // kMaxUnsignalledRecvStreams.
4024 SetAndVerifyNumUnsignalledRecvStreams(10, 10); 4019 SetAndVerifyNumUnsignalledRecvStreams(10, 10);
4025 SetAndVerifyNumUnsignalledRecvStreams(kMaxUnsignalledRecvStreams + 1, 4020 SetAndVerifyNumUnsignalledRecvStreams(kMaxUnsignalledRecvStreams + 1,
4026 kMaxUnsignalledRecvStreams); 4021 kMaxUnsignalledRecvStreams);
4027 SetAndVerifyNumUnsignalledRecvStreams(-1, 0); 4022 SetAndVerifyNumUnsignalledRecvStreams(-1, 0);
4028 } 4023 }
4029 4024
4030 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) { 4025 TEST_F(WebRtcSessionTest, TestCombinedAudioVideoBweConstraint) {
4031 constraints_.reset(new FakeConstraints()); 4026 constraints_.reset(new FakeConstraints());
4032 constraints_->AddOptional( 4027 constraints_->AddOptional(
4033 webrtc::MediaConstraintsInterface::kCombinedAudioVideoBwe, 4028 webrtc::MediaConstraintsInterface::kCombinedAudioVideoBwe,
4034 true); 4029 true);
4035 Init(); 4030 Init();
4036 SendAudioVideoStream1(); 4031 SendAudioVideoStream1();
4037 SessionDescriptionInterface* offer = CreateOffer(); 4032 SessionDescriptionInterface* offer = CreateOffer();
4038 4033
4039 SetLocalDescriptionWithoutError(offer); 4034 SetLocalDescriptionWithoutError(offer);
4040 4035
4041 voice_channel_ = media_engine_->GetVoiceChannel(0); 4036 voice_channel_ = media_engine_->GetVoiceChannel(0);
4042 4037
4043 ASSERT_TRUE(voice_channel_ != NULL); 4038 ASSERT_TRUE(voice_channel_ != NULL);
4044 const cricket::AudioOptions& audio_options = voice_channel_->options(); 4039 const cricket::AudioOptions& audio_options = voice_channel_->options();
4045 EXPECT_TRUE( 4040 EXPECT_EQ(rtc::Maybe<bool>(true), audio_options.combined_audio_video_bwe);
4046 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false));
4047 } 4041 }
4048 4042
4049 // Tests that we can renegotiate new media content with ICE candidates in the 4043 // Tests that we can renegotiate new media content with ICE candidates in the
4050 // new remote SDP. 4044 // new remote SDP.
4051 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { 4045 TEST_P(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) {
4052 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 4046 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
4053 InitWithDtls(GetParam()); 4047 InitWithDtls(GetParam());
4054 SetFactoryDtlsSrtp(); 4048 SetFactoryDtlsSrtp();
4055 4049
4056 SendAudioOnlyStream2(); 4050 SendAudioOnlyStream2();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
4210 } 4204 }
4211 4205
4212 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4206 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4213 // currently fails because upon disconnection and reconnection OnIceComplete is 4207 // currently fails because upon disconnection and reconnection OnIceComplete is
4214 // called more than once without returning to IceGatheringGathering. 4208 // called more than once without returning to IceGatheringGathering.
4215 4209
4216 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4210 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4217 WebRtcSessionTest, 4211 WebRtcSessionTest,
4218 testing::Values(ALREADY_GENERATED, 4212 testing::Values(ALREADY_GENERATED,
4219 DTLS_IDENTITY_STORE)); 4213 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | talk/media/base/mediachannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698