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/gtest/include/gtest/gtest.h" |
| 12 #include "webrtc/modules/congestion_controller/alr_detector.h" |
| 13 |
| 14 namespace { |
| 15 |
| 16 constexpr int kMeasuredIntervalMs = 110; |
| 17 constexpr int kEstimatedBitrateBps = 300000; |
| 18 constexpr int kBytesInIntervalAtEstimatedBitrate = |
| 19 (kEstimatedBitrateBps / 8) * kMeasuredIntervalMs / 1000; |
| 20 |
| 21 } // namespace |
| 22 |
| 23 namespace webrtc { |
| 24 |
| 25 TEST(AlrDetectorTest, ApplicationLimitedWhenLittleDataSent) { |
| 26 AlrDetector alr_detector; |
| 27 |
| 28 alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps); |
| 29 for (int i = 0; i < 6; i++) |
| 30 alr_detector.OnBytesSent(0, kMeasuredIntervalMs); |
| 31 EXPECT_EQ(alr_detector.InApplicationLimitedRegion(), true); |
| 32 |
| 33 for (int i = 0; i < 6; i++) |
| 34 alr_detector.OnBytesSent(100, kMeasuredIntervalMs); |
| 35 EXPECT_EQ(alr_detector.InApplicationLimitedRegion(), true); |
| 36 } |
| 37 |
| 38 TEST(AlrDetectorTest, NetworkLimitedWhenSendingCloseToEstimate) { |
| 39 AlrDetector alr_detector; |
| 40 |
| 41 alr_detector.SetEstimatedBitrate(kEstimatedBitrateBps); |
| 42 for (int i = 0; i < 6; i++) |
| 43 alr_detector.OnBytesSent(kBytesInIntervalAtEstimatedBitrate, |
| 44 kMeasuredIntervalMs); |
| 45 EXPECT_EQ(alr_detector.InApplicationLimitedRegion(), false); |
| 46 } |
| 47 |
| 48 } // namespace webrtc |
OLD | NEW |