Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1760 TransportChannel* rtp = channel1_->transport_channel(); | 1760 TransportChannel* rtp = channel1_->transport_channel(); |
| 1761 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1761 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1762 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel | 1762 // In the case of rtcp mux, the SignalReadyToSend() from rtp channel |
| 1763 // should trigger the MediaChannel's OnReadyToSend. | 1763 // should trigger the MediaChannel's OnReadyToSend. |
| 1764 rtp->SignalReadyToSend(rtp); | 1764 rtp->SignalReadyToSend(rtp); |
| 1765 EXPECT_TRUE(media_channel1_->ready_to_send()); | 1765 EXPECT_TRUE(media_channel1_->ready_to_send()); |
| 1766 channel1_->SetReadyToSend(false, false); | 1766 channel1_->SetReadyToSend(false, false); |
| 1767 EXPECT_FALSE(media_channel1_->ready_to_send()); | 1767 EXPECT_FALSE(media_channel1_->ready_to_send()); |
| 1768 } | 1768 } |
| 1769 | 1769 |
| 1770 bool SetRemoteContentWithBitrateLimit(int remote_limit) { | |
| 1771 typename T::Content content; | |
| 1772 CreateContent(0, kPcmuCodec, kH264Codec, &content); | |
| 1773 content.set_bandwidth(remote_limit); | |
| 1774 return channel1_->SetRemoteContent(&content, CA_OFFER, NULL); | |
| 1775 } | |
| 1776 | |
| 1777 webrtc::RTCRtpParameters BitrateLimitedParameters(int limit) { | |
| 1778 webrtc::RTCRtpParameters parameters; | |
| 1779 webrtc::RTCRtpEncodingParameters encoding; | |
| 1780 encoding.max_bitrate_bps = limit; | |
| 1781 parameters.encodings.push_back(encoding); | |
| 1782 return parameters; | |
| 1783 } | |
| 1784 | |
| 1785 void VerifyMaxBitrate(const webrtc::RTCRtpParameters& parameters, | |
| 1786 int expected_bitrate) { | |
| 1787 EXPECT_EQ(1UL, parameters.encodings.size()); | |
| 1788 EXPECT_EQ(expected_bitrate, parameters.encodings[0].max_bitrate_bps); | |
| 1789 } | |
| 1790 | |
| 1791 void DefaultMaxBitrateIsUnlimited() { | |
| 1792 CreateChannels(0, 0); | |
| 1793 EXPECT_EQ(media_channel1_->max_bps(), -1); | |
| 1794 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); | |
| 1795 } | |
| 1796 | |
| 1797 void CanChangeMaxBitrate() { | |
| 1798 CreateChannels(0, 0); | |
| 1799 | |
| 1800 EXPECT_TRUE( | |
| 1801 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000))); | |
| 1802 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000); | |
| 1803 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000); | |
| 1804 EXPECT_EQ(-1, media_channel1_->max_bps()); | |
| 1805 | |
| 1806 EXPECT_TRUE( | |
| 1807 channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1))); | |
| 1808 VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1); | |
| 1809 VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1); | |
| 1810 EXPECT_EQ(-1, media_channel1_->max_bps()); | |
| 1811 } | |
|
Taylor Brandstetter
2016/03/12 01:57:06
Very thorough unit tests, I'm impressed. :)
| |
| 1812 | |
| 1770 protected: | 1813 protected: |
| 1771 // TODO(pbos): Remove playout from all media channels and let renderers mute | 1814 // TODO(pbos): Remove playout from all media channels and let renderers mute |
| 1772 // themselves. | 1815 // themselves. |
| 1773 const bool verify_playout_; | 1816 const bool verify_playout_; |
| 1774 cricket::FakeTransportController transport_controller1_; | 1817 cricket::FakeTransportController transport_controller1_; |
| 1775 cricket::FakeTransportController transport_controller2_; | 1818 cricket::FakeTransportController transport_controller2_; |
| 1776 cricket::FakeMediaEngine media_engine_; | 1819 cricket::FakeMediaEngine media_engine_; |
| 1777 // The media channels are owned by the voice channel objects below. | 1820 // The media channels are owned by the voice channel objects below. |
| 1778 typename T::MediaChannel* media_channel1_; | 1821 typename T::MediaChannel* media_channel1_; |
| 1779 typename T::MediaChannel* media_channel2_; | 1822 typename T::MediaChannel* media_channel2_; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2220 } | 2263 } |
| 2221 | 2264 |
| 2222 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { | 2265 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) { |
| 2223 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); | 2266 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false); |
| 2224 } | 2267 } |
| 2225 | 2268 |
| 2226 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { | 2269 TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) { |
| 2227 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); | 2270 Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true); |
| 2228 } | 2271 } |
| 2229 | 2272 |
| 2273 TEST_F(VoiceChannelTest, DefaultMaxBitrateIsUnlimited) { | |
| 2274 Base::DefaultMaxBitrateIsUnlimited(); | |
| 2275 } | |
| 2276 | |
| 2277 TEST_F(VoiceChannelTest, CanChangeMaxBitrate) { | |
| 2278 Base::CanChangeMaxBitrate(); | |
| 2279 } | |
| 2280 | |
| 2230 // VideoChannelTest | 2281 // VideoChannelTest |
| 2231 TEST_F(VideoChannelTest, TestInit) { | 2282 TEST_F(VideoChannelTest, TestInit) { |
| 2232 Base::TestInit(); | 2283 Base::TestInit(); |
| 2233 } | 2284 } |
| 2234 | 2285 |
| 2235 TEST_F(VideoChannelTest, TestSetContents) { | 2286 TEST_F(VideoChannelTest, TestSetContents) { |
| 2236 Base::TestSetContents(); | 2287 Base::TestSetContents(); |
| 2237 } | 2288 } |
| 2238 | 2289 |
| 2239 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { | 2290 TEST_F(VideoChannelTest, TestSetContentsNullOffer) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2478 } | 2529 } |
| 2479 | 2530 |
| 2480 TEST_F(VideoChannelTest, TestOnReadyToSend) { | 2531 TEST_F(VideoChannelTest, TestOnReadyToSend) { |
| 2481 Base::TestOnReadyToSend(); | 2532 Base::TestOnReadyToSend(); |
| 2482 } | 2533 } |
| 2483 | 2534 |
| 2484 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { | 2535 TEST_F(VideoChannelTest, TestOnReadyToSendWithRtcpMux) { |
| 2485 Base::TestOnReadyToSendWithRtcpMux(); | 2536 Base::TestOnReadyToSendWithRtcpMux(); |
| 2486 } | 2537 } |
| 2487 | 2538 |
| 2539 TEST_F(VideoChannelTest, DefaultMaxBitrateIsUnlimited) { | |
| 2540 Base::DefaultMaxBitrateIsUnlimited(); | |
| 2541 } | |
| 2542 | |
| 2543 TEST_F(VideoChannelTest, CanChangeMaxBitrate) { | |
| 2544 Base::CanChangeMaxBitrate(); | |
| 2545 } | |
| 2546 | |
| 2488 // DataChannelTest | 2547 // DataChannelTest |
| 2489 | 2548 |
| 2490 class DataChannelTest | 2549 class DataChannelTest |
| 2491 : public ChannelTest<DataTraits> { | 2550 : public ChannelTest<DataTraits> { |
| 2492 public: | 2551 public: |
| 2493 typedef ChannelTest<DataTraits> | 2552 typedef ChannelTest<DataTraits> |
| 2494 Base; | 2553 Base; |
| 2495 DataChannelTest() | 2554 DataChannelTest() |
| 2496 : Base(true, | 2555 : Base(true, |
| 2497 kDataPacket, | 2556 kDataPacket, |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2690 }; | 2749 }; |
| 2691 rtc::Buffer payload(data, 3); | 2750 rtc::Buffer payload(data, 3); |
| 2692 cricket::SendDataResult result; | 2751 cricket::SendDataResult result; |
| 2693 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); | 2752 ASSERT_TRUE(media_channel1_->SendData(params, payload, &result)); |
| 2694 EXPECT_EQ(params.ssrc, | 2753 EXPECT_EQ(params.ssrc, |
| 2695 media_channel1_->last_sent_data_params().ssrc); | 2754 media_channel1_->last_sent_data_params().ssrc); |
| 2696 EXPECT_EQ("foo", media_channel1_->last_sent_data()); | 2755 EXPECT_EQ("foo", media_channel1_->last_sent_data()); |
| 2697 } | 2756 } |
| 2698 | 2757 |
| 2699 // TODO(pthatcher): TestSetReceiver? | 2758 // TODO(pthatcher): TestSetReceiver? |
| OLD | NEW |