Chromium Code Reviews| Index: webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| diff --git a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..79fd6741022078f61a1a98c609de3145d6d564a6 |
| --- /dev/null |
| +++ b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| @@ -0,0 +1,71 @@ |
| +/* |
| + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "testing/gmock/include/gmock/gmock.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "webrtc/modules/pacing/mock/mock_paced_sender.h" |
| +#include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| +#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h" |
| +#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h" |
| +#include "webrtc/system_wrappers/include/clock.h" |
| + |
| +using testing::_; |
| +using testing::NiceMock; |
| +using testing::Return; |
| +using testing::SaveArg; |
| + |
| +namespace webrtc { |
| +namespace test { |
| + |
| +class CongestionControllerTest : public ::testing::Test { |
| + protected: |
| + CongestionControllerTest() : clock_(123456) {} |
| + ~CongestionControllerTest() override {} |
| + |
| + void SetUp() override { |
| + EXPECT_CALL(observer_, OnNetworkChanged(_, _, _)) |
| + .WillOnce(SaveArg<0>(&initial_bitrate_bps_)); |
| + |
| + pacer_ = new NiceMock<MockPacedSender>(); |
| + std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership. |
| + std::unique_ptr<PacketRouter> packet_router(new PacketRouter()); |
| + controller_.reset( |
| + new CongestionController(&clock_, &observer_, &remote_bitrate_observer_, |
| + std::move(packet_router), std::move(pacer))); |
| + EXPECT_GT(initial_bitrate_bps_, 0u); |
| + } |
| + |
| + SimulatedClock clock_; |
| + MockCongestionObserver observer_; |
| + NiceMock<MockPacedSender>* pacer_; |
| + NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
| + std::unique_ptr<CongestionController> controller_; |
| + uint32_t initial_bitrate_bps_ = 0; |
| +}; |
| + |
| +TEST_F(CongestionControllerTest, OnSendQueueFull) { |
|
stefan-webrtc
2016/05/02 12:56:47
Would be good with a test for the cases where the
perkj_webrtc
2016/05/02 14:45:35
added more tests.
|
| + EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
| + .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); |
| + clock_.AdvanceTimeMilliseconds(25); |
| + |
| + EXPECT_CALL(observer_, OnNetworkChanged(0, _, _)); |
| + controller_->Process(); |
| + |
| + // Let the pacer not be full next time the controller checks. |
| + EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
| + .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); |
| + clock_.AdvanceTimeMilliseconds(25); |
| + |
| + EXPECT_CALL(observer_, OnNetworkChanged(initial_bitrate_bps_, _, _)); |
| + controller_->Process(); |
| +} |
| + |
| +} // namespace test |
| +} // namespace webrtc |