OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 19 matching lines...) Expand all Loading... |
30 namespace test { | 30 namespace test { |
31 | 31 |
32 class CongestionControllerTest : public ::testing::Test { | 32 class CongestionControllerTest : public ::testing::Test { |
33 protected: | 33 protected: |
34 CongestionControllerTest() : clock_(123456) {} | 34 CongestionControllerTest() : clock_(123456) {} |
35 ~CongestionControllerTest() override {} | 35 ~CongestionControllerTest() override {} |
36 | 36 |
37 void SetUp() override { | 37 void SetUp() override { |
38 pacer_ = new NiceMock<MockPacedSender>(); | 38 pacer_ = new NiceMock<MockPacedSender>(); |
39 std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership. | 39 std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership. |
40 std::unique_ptr<PacketRouter> packet_router(new PacketRouter()); | |
41 controller_.reset(new CongestionController( | 40 controller_.reset(new CongestionController( |
42 &clock_, &observer_, &remote_bitrate_observer_, &event_log_, | 41 &clock_, &observer_, &remote_bitrate_observer_, &event_log_, |
43 std::move(packet_router), std::move(pacer))); | 42 &packet_router_, std::move(pacer))); |
44 bandwidth_observer_.reset( | 43 bandwidth_observer_.reset( |
45 controller_->GetBitrateController()->CreateRtcpBandwidthObserver()); | 44 controller_->GetBitrateController()->CreateRtcpBandwidthObserver()); |
46 | 45 |
47 // Set the initial bitrate estimate and expect the |observer| and |pacer_| | 46 // Set the initial bitrate estimate and expect the |observer| and |pacer_| |
48 // to be updated. | 47 // to be updated. |
49 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _)); | 48 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _)); |
50 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); | 49 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); |
51 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); | 50 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); |
52 } | 51 } |
53 | 52 |
54 SimulatedClock clock_; | 53 SimulatedClock clock_; |
55 StrictMock<MockCongestionObserver> observer_; | 54 StrictMock<MockCongestionObserver> observer_; |
56 NiceMock<MockPacedSender>* pacer_; | 55 NiceMock<MockPacedSender>* pacer_; |
57 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; | 56 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
58 NiceMock<MockRtcEventLog> event_log_; | 57 NiceMock<MockRtcEventLog> event_log_; |
59 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; | 58 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; |
| 59 PacketRouter packet_router_; |
60 std::unique_ptr<CongestionController> controller_; | 60 std::unique_ptr<CongestionController> controller_; |
61 const uint32_t kInitialBitrateBps = 60000; | 61 const uint32_t kInitialBitrateBps = 60000; |
62 }; | 62 }; |
63 | 63 |
64 TEST_F(CongestionControllerTest, OnNetworkChanged) { | 64 TEST_F(CongestionControllerTest, OnNetworkChanged) { |
65 // Test no change. | 65 // Test no change. |
66 clock_.AdvanceTimeMilliseconds(25); | 66 clock_.AdvanceTimeMilliseconds(25); |
67 controller_->Process(); | 67 controller_->Process(); |
68 | 68 |
69 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _)); | 69 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _)); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 controller_->SignalNetworkState(kNetworkDown); | 184 controller_->SignalNetworkState(kNetworkDown); |
185 EXPECT_EQ(0, controller_->GetPacerQueuingDelayMs()); | 185 EXPECT_EQ(0, controller_->GetPacerQueuingDelayMs()); |
186 | 186 |
187 // Network is up, pacer delay should be reported. | 187 // Network is up, pacer delay should be reported. |
188 controller_->SignalNetworkState(kNetworkUp); | 188 controller_->SignalNetworkState(kNetworkUp); |
189 EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs()); | 189 EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs()); |
190 } | 190 } |
191 | 191 |
192 } // namespace test | 192 } // namespace test |
193 } // namespace webrtc | 193 } // namespace webrtc |
OLD | NEW |