Index: webrtc/pc/channel_unittest.cc |
diff --git a/webrtc/pc/channel_unittest.cc b/webrtc/pc/channel_unittest.cc |
index ad5fbaf1847e11997359b66b6846f8f4706ce43c..5cc994de76c9b3bb08cb2777593611eaeb3ac36e 100644 |
--- a/webrtc/pc/channel_unittest.cc |
+++ b/webrtc/pc/channel_unittest.cc |
@@ -1767,6 +1767,49 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { |
EXPECT_FALSE(media_channel1_->ready_to_send()); |
} |
+ bool SetRemoteContentWithBitrateLimit(int remote_limit) { |
+ typename T::Content content; |
+ CreateContent(0, kPcmuCodec, kH264Codec, &content); |
+ content.set_bandwidth(remote_limit); |
+ return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); |
+ } |
+ |
+ webrtc::RTCRtpParameters BitrateLimitedParameters(int limit) { |
+ webrtc::RTCRtpParameters parameters; |
+ webrtc::RTCRtpEncodingParameters encoding; |
+ encoding.max_bitrate_bps = limit; |
+ parameters.encodings.push_back(encoding); |
+ return parameters; |
+ } |
+ |
+ void VerifyMaxBitrate(const webrtc::RTCRtpParameters& parameters, |
+ int expected_bitrate) { |
+ EXPECT_EQ(1UL, parameters.encodings.size()); |
+ EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); |
+ } |
+ |
+ void DefaultMaxBitrateIsUnlimited() { |
+ CreateChannels(0, 0); |
+ EXPECT_EQ(media_channel1_->max_bps(), -1); |
+ VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); |
+ } |
+ |
+ void CanChangeMaxBitrate() { |
+ CreateChannels(0, 0); |
+ |
+ EXPECT_TRUE( |
+ channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); |
+ VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000); |
+ VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000); |
+ EXPECT_EQ(-1, media_channel1_->max_bps()); |
+ |
+ EXPECT_TRUE( |
+ channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); |
+ VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); |
+ VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); |
+ EXPECT_EQ(-1, media_channel1_->max_bps()); |
+ } |
Taylor Brandstetter
2016/03/12 01:57:06
Very thorough unit tests, I'm impressed. :)
|
+ |
protected: |
// TODO(pbos): Remove playout from all media channels and let renderers mute |
// themselves. |
@@ -2227,6 +2270,14 @@ TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { |
Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); |
} |
+TEST_F(VoiceChannelTest, DefaultMaxBitrateIsUnlimited) { |
+ Base::DefaultMaxBitrateIsUnlimited(); |
+} |
+ |
+TEST_F(VoiceChannelTest, CanChangeMaxBitrate) { |
+ Base::CanChangeMaxBitrate(); |
+} |
+ |
// VideoChannelTest |
TEST_F(VideoChannelTest, TestInit) { |
Base::TestInit(); |
@@ -2485,6 +2536,14 @@ TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { |
Base::TestOnReadyToSendWithRtcpMux(); |
} |
+TEST_F(VideoChannelTest, DefaultMaxBitrateIsUnlimited) { |
+ Base::DefaultMaxBitrateIsUnlimited(); |
+} |
+ |
+TEST_F(VideoChannelTest, CanChangeMaxBitrate) { |
+ Base::CanChangeMaxBitrate(); |
+} |
+ |
// DataChannelTest |
class DataChannelTest |