| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 uint8_t last_fraction_loss_; | 59 uint8_t last_fraction_loss_; |
| 60 int64_t last_rtt_; | 60 int64_t last_rtt_; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class BitrateControllerTest : public ::testing::Test { | 63 class BitrateControllerTest : public ::testing::Test { |
| 64 protected: | 64 protected: |
| 65 BitrateControllerTest() : clock_(0) {} | 65 BitrateControllerTest() : clock_(0) {} |
| 66 ~BitrateControllerTest() {} | 66 ~BitrateControllerTest() {} |
| 67 | 67 |
| 68 virtual void SetUp() { | 68 virtual void SetUp() { |
| 69 ON_CALL(pacer_, CanSendMorePackets()).WillByDefault(Return(true)); |
| 69 controller_ = BitrateController::CreateBitrateController( | 70 controller_ = BitrateController::CreateBitrateController( |
| 70 &clock_, &bitrate_observer_, &pacer_); | 71 &clock_, &bitrate_observer_, &pacer_); |
| 71 controller_->SetStartBitrate(kStartBitrateBps); | 72 controller_->SetStartBitrate(kStartBitrateBps); |
| 72 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); | 73 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); |
| 73 controller_->SetMinMaxBitrate(kMinBitrateBps, kMaxBitrateBps); | 74 controller_->SetMinMaxBitrate(kMinBitrateBps, kMaxBitrateBps); |
| 74 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); | 75 EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_); |
| 75 bandwidth_observer_ = controller_->CreateRtcpBandwidthObserver(); | 76 bandwidth_observer_ = controller_->CreateRtcpBandwidthObserver(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 virtual void TearDown() { | 79 virtual void TearDown() { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); | 403 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); |
| 403 | 404 |
| 404 controller_->SetReservedBitrate(10000); | 405 controller_->SetReservedBitrate(10000); |
| 405 bandwidth_observer_->OnReceivedEstimatedBitrate(1); | 406 bandwidth_observer_->OnReceivedEstimatedBitrate(1); |
| 406 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); | 407 EXPECT_EQ(100000, bitrate_observer_.last_bitrate_); |
| 407 } | 408 } |
| 408 | 409 |
| 409 TEST_F(BitrateControllerTest, OnSendQueueFull) { | 410 TEST_F(BitrateControllerTest, OnSendQueueFull) { |
| 410 bandwidth_observer_->OnReceivedEstimatedBitrate(200000); | 411 bandwidth_observer_->OnReceivedEstimatedBitrate(200000); |
| 411 EXPECT_EQ(200000, bitrate_observer_.last_bitrate_); | 412 EXPECT_EQ(200000, bitrate_observer_.last_bitrate_); |
| 412 // Let the pacer be full next time the controller checks. | 413 // Let the pacer return not ready next time the controller checks. |
| 413 EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) | 414 EXPECT_CALL(pacer_, CanSendMorePackets()).WillOnce(Return(false)); |
| 414 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); | |
| 415 clock_.AdvanceTimeMilliseconds(25); | 415 clock_.AdvanceTimeMilliseconds(25); |
| 416 controller_->Process(); | 416 controller_->Process(); |
| 417 EXPECT_EQ(0, bitrate_observer_.last_bitrate_); | 417 EXPECT_EQ(0, bitrate_observer_.last_bitrate_); |
| 418 // Let the pacer not be full next time the controller checks. | 418 // Let the pacer not be full next time the controller checks. |
| 419 EXPECT_CALL(pacer_, ExpectedQueueTimeMs()) | 419 EXPECT_CALL(pacer_, CanSendMorePackets()).WillOnce(Return(true)); |
| 420 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); | |
| 421 clock_.AdvanceTimeMilliseconds(25); | 420 clock_.AdvanceTimeMilliseconds(25); |
| 422 controller_->Process(); | 421 controller_->Process(); |
| 423 EXPECT_EQ(200000, bitrate_observer_.last_bitrate_); | 422 EXPECT_EQ(200000, bitrate_observer_.last_bitrate_); |
| 424 } | 423 } |
| OLD | NEW |