OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "testing/gmock/include/gmock/gmock.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 #include "webrtc/modules/pacing/mock/mock_paced_sender.h" | |
14 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | |
15 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont roller.h" | |
16 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_observer.h" | |
17 #include "webrtc/system_wrappers/include/clock.h" | |
18 | |
19 using testing::_; | |
20 using testing::NiceMock; | |
21 using testing::Return; | |
22 using testing::SaveArg; | |
23 | |
24 namespace webrtc { | |
25 namespace test { | |
26 | |
27 class CongestionControllerTest : public ::testing::Test { | |
28 protected: | |
29 CongestionControllerTest() : clock_(123456) {} | |
30 ~CongestionControllerTest() override {} | |
31 | |
32 void SetUp() override { | |
33 EXPECT_CALL(observer_, OnNetworkChanged(_, _, _)) | |
34 .WillOnce(SaveArg<0>(&initial_bitrate_bps_)); | |
35 | |
36 pacer_ = new NiceMock<MockPacedSender>(); | |
37 std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership. | |
38 std::unique_ptr<PacketRouter> packet_router(new PacketRouter()); | |
39 controller_.reset( | |
40 new CongestionController(&clock_, &observer_, &remote_bitrate_observer_, | |
41 std::move(packet_router), std::move(pacer))); | |
42 EXPECT_GT(initial_bitrate_bps_, 0u); | |
43 } | |
44 | |
45 SimulatedClock clock_; | |
46 MockCongestionObserver observer_; | |
47 NiceMock<MockPacedSender>* pacer_; | |
48 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; | |
49 std::unique_ptr<CongestionController> controller_; | |
50 uint32_t initial_bitrate_bps_ = 0; | |
51 }; | |
52 | |
53 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.
| |
54 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) | |
55 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); | |
56 clock_.AdvanceTimeMilliseconds(25); | |
57 | |
58 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _)); | |
59 controller_->Process(); | |
60 | |
61 // Let the pacer not be full next time the controller checks. | |
62 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) | |
63 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); | |
64 clock_.AdvanceTimeMilliseconds(25); | |
65 | |
66 EXPECT_CALL(observer_, OnNetworkChanged(initial_bitrate_bps_, _, _)); | |
67 controller_->Process(); | |
68 } | |
69 | |
70 } // namespace test | |
71 } // namespace webrtc | |
OLD | NEW |