// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cast/streaming/impl/bandwidth_estimator.h" #include <chrono> #include <limits> #include <random> #include "gmock/gmock.h" #include "gtest/gtest.h" #include "platform/api/time.h" #include "util/chrono_helpers.h" namespace openscreen::cast { namespace { operator<<; // BandwidthEstimator configuration common to all tests. constexpr int kMaxPacketsPerTimeslice = …; constexpr Clock::duration kTimesliceDuration = …; constexpr int kTimeslicesPerSecond = …; // Use a fake, fixed start time. constexpr Clock::time_point kStartTime = …; // Range of "fuzz" to add to timestamps in BandwidthEstimatorTest::AddFuzz(). constexpr Clock::duration kMaxFuzzOffset = …; constexpr int kFuzzLowerBoundClockTicks = …; constexpr int kFuzzUpperBoundClockTicks = …; class BandwidthEstimatorTest : public testing::Test { … }; // Tests that, without any data, there won't be any estimates. TEST_F(BandwidthEstimatorTest, DoesNotEstimateWithoutAnyInput) { … } // Tests the case where packets are being sent, but the Receiver hasn't provided // feedback (e.g., due to a network blackout). TEST_F(BandwidthEstimatorTest, DoesNotEstimateWithoutFeedback) { … } // Tests the case where packets are being sent, and a connection to the Receiver // has been confirmed (because RTCP packets are coming in), but the Receiver has // not successfully received anything. TEST_F(BandwidthEstimatorTest, DoesNotEstimateIfNothingSuccessfullyReceived) { … } // Tests that, when the Receiver successfully receives the payload bytes at a // fixed rate, the network bandwidth estimates are based on the amount of time // the Sender spent transmitting. TEST_F(BandwidthEstimatorTest, EstimatesAtVariousBurstSaturations) { … } // Tests that magnitude of the network round trip times, as well as random // variance in packet arrival times, do not have a significant effect on the // bandwidth estimates. TEST_F(BandwidthEstimatorTest, EstimatesIndependentOfFeedbackDelays) { … } // Tests that both the history tracking internal to BandwidthEstimator, as well // as its computation of the bandwidth estimate, are both resistant to possible // integer overflow cases. The internal implementation always clamps to the // valid range of int. TEST_F(BandwidthEstimatorTest, ClampsEstimateToMaxInt) { … } } // namespace } // namespace openscreen::cast