Chromium Code Reviews| Index: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc |
| diff --git a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc |
| index 9821568260c0cf82e0df7c97821409f162271246..83d660ae5ab0df6728e07a7d83fda60f02b460c3 100644 |
| --- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc |
| +++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc |
| @@ -8,12 +8,17 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| +#include <memory> |
| +#include <utility> |
| + |
| +#include "webrtc/test/gmock.h" |
| +#include "webrtc/test/gtest.h" |
| + |
| +#include "webrtc/base/test/mock_ratetracker.h" |
| #include "webrtc/modules/pacing/packet_router.h" |
| #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
| #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| #include "webrtc/system_wrappers/include/clock.h" |
| -#include "webrtc/test/gmock.h" |
| -#include "webrtc/test/gtest.h" |
| using ::testing::_; |
| using ::testing::InSequence; |
| @@ -29,7 +34,12 @@ class MockPacketRouter : public PacketRouter { |
| class RemoteEstimatorProxyTest : public ::testing::Test { |
| public: |
| - RemoteEstimatorProxyTest() : clock_(0), proxy_(&clock_, &router_) {} |
| + RemoteEstimatorProxyTest() |
| + : clock_(0), |
| + received_bitrate_tracker_bps_( |
| + new testing::NiceMock<rtc::MockRateTracker>()), |
| + mock_received_bitrate_tracker_bps_(received_bitrate_tracker_bps_.get()), |
| + proxy_(&clock_, &router_, std::move(received_bitrate_tracker_bps_)) {} |
| protected: |
| void IncomingPacket(uint16_t seq, int64_t time_ms) { |
| @@ -42,12 +52,16 @@ class RemoteEstimatorProxyTest : public ::testing::Test { |
| void Process() { |
| clock_.AdvanceTimeMilliseconds( |
| - RemoteEstimatorProxy::kDefaultProcessIntervalMs); |
| + RemoteEstimatorProxy::kHighBitrateProcessIntervalMs); |
| proxy_.Process(); |
| } |
| SimulatedClock clock_; |
| testing::StrictMock<MockPacketRouter> router_; |
| + std::unique_ptr<testing::NiceMock<rtc::MockRateTracker>> |
| + received_bitrate_tracker_bps_; |
| + testing::NiceMock<rtc::MockRateTracker>* mock_received_bitrate_tracker_bps_; |
|
stefan-webrtc
2016/10/17 18:55:21
Instead of using a mock I'd suggest that we call I
|
| + |
| RemoteEstimatorProxy proxy_; |
| const size_t kDefaultPacketSize = 100; |
| @@ -350,4 +364,36 @@ TEST_F(RemoteEstimatorProxyTest, RemovesTimestampsOutOfScope) { |
| Process(); |
| } |
| +TEST_F(RemoteEstimatorProxyTest, AddPaketToIncomingBitrateTracker) { |
| + EXPECT_CALL(*mock_received_bitrate_tracker_bps_, |
| + AddSamples(kDefaultPacketSize * 8)); |
| + IncomingPacket(kBaseSeq, kBaseTimeMs); |
| +} |
| + |
| +TEST_F(RemoteEstimatorProxyTest, |
| + TimeUntilNextProcessIsHightOnLowIncomingBitrate) { |
| + EXPECT_CALL(*mock_received_bitrate_tracker_bps_, TotalSampleCount()) |
| + .WillRepeatedly( |
| + Return(RemoteEstimatorProxy::kMinPacketCountRecievedBitrate + 1)); |
| + EXPECT_CALL(*mock_received_bitrate_tracker_bps_, ComputeRate()) |
| + .WillRepeatedly( |
| + Return(RemoteEstimatorProxy::kSwitchToLowBitrateProcessIntervalBps)); |
| + Process(); |
| + EXPECT_EQ(RemoteEstimatorProxy::kLowBitrateProcessIntervalMs, |
| + proxy_.TimeUntilNextProcess()); |
| +} |
| + |
| +TEST_F(RemoteEstimatorProxyTest, |
| + TimeUntilNextProcessIsLowOnHightIncomingBitrate) { |
| + EXPECT_CALL(*mock_received_bitrate_tracker_bps_, TotalSampleCount()) |
| + .WillRepeatedly( |
| + Return(RemoteEstimatorProxy::kMinPacketCountRecievedBitrate + 1)); |
| + EXPECT_CALL(*mock_received_bitrate_tracker_bps_, ComputeRate()) |
| + .WillRepeatedly( |
| + Return(RemoteEstimatorProxy::kSwitchToHighBitrateProcessIntervalBps)); |
| + Process(); |
| + EXPECT_EQ(RemoteEstimatorProxy::kHighBitrateProcessIntervalMs, |
| + proxy_.TimeUntilNextProcess()); |
| +} |
| + |
| } // namespace webrtc |