Index: webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc |
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc |
index 6d1434a80fe06ce96b4d58d00ea812597b440587..fc1017281286692f16ad77f0ffea58d309440162 100644 |
--- a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc |
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc |
@@ -10,11 +10,11 @@ |
#include <utility> |
+#include "webrtc/base/fakeclock.h" |
#include "webrtc/base/ignore_wundef.h" |
#include "webrtc/base/protobuf_utils.h" |
#include "webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h" |
#include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h" |
-#include "webrtc/system_wrappers/include/clock.h" |
#include "webrtc/test/gtest.h" |
#ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
@@ -47,12 +47,10 @@ constexpr int kMaxUplinkBandwidthBps = 120000; |
constexpr int kMinBandwithChangeBps = |
(kMaxUplinkBandwidthBps - kMinUplinkBandwidthBps) / kFactor; |
-constexpr int64_t kClockInitialTime = 123456789; |
- |
struct ControllerManagerStates { |
std::unique_ptr<ControllerManager> controller_manager; |
std::vector<MockController*> mock_controllers; |
- std::unique_ptr<SimulatedClock> simulated_clock; |
+ std::unique_ptr<rtc::ScopedFakeClock> fake_clock; |
}; |
ControllerManagerStates CreateControllerManager() { |
@@ -75,11 +73,10 @@ ControllerManagerStates CreateControllerManager() { |
std::make_pair(kChracteristicBandwithBps[1], |
kChracteristicPacketLossFraction[1]); |
- states.simulated_clock.reset(new SimulatedClock(kClockInitialTime)); |
+ states.fake_clock.reset(new rtc::ScopedFakeClock()); |
states.controller_manager.reset(new ControllerManagerImpl( |
ControllerManagerImpl::Config(kMinReorderingTimeMs, |
- kMinReorderingSquareDistance, |
- states.simulated_clock.get()), |
+ kMinReorderingSquareDistance), |
std::move(controllers), chracteristic_points)); |
return states; |
} |
@@ -152,7 +149,8 @@ TEST(ControllerManagerTest, DoNotReorderBeforeMinReordingTime) { |
&states, rtc::Optional<int>(kChracteristicBandwithBps[0]), |
rtc::Optional<float>(kChracteristicPacketLossFraction[0]), |
{kNumControllers - 2, kNumControllers - 1, 0, 1}); |
- states.simulated_clock->AdvanceTimeMilliseconds(kMinReorderingTimeMs - 1); |
+ states.fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(kMinReorderingTimeMs - 1)); |
// Move uplink bandwidth and packet loss fraction to the other controller's |
// characteristic point, which would cause controller manager to reorder the |
// controllers if time had reached min reordering time. |
@@ -174,7 +172,8 @@ TEST(ControllerManagerTest, ReorderBeyondMinReordingTimeAndMinDistance) { |
CheckControllersOrder(&states, rtc::Optional<int>(kBandwidthBps), |
rtc::Optional<float>(kPacketLossFraction), |
{kNumControllers - 2, kNumControllers - 1, 0, 1}); |
- states.simulated_clock->AdvanceTimeMilliseconds(kMinReorderingTimeMs); |
+ states.fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(kMinReorderingTimeMs)); |
// Then let network metrics move a little towards the other controller. |
CheckControllersOrder( |
&states, rtc::Optional<int>(kBandwidthBps - kMinBandwithChangeBps - 1), |
@@ -194,7 +193,8 @@ TEST(ControllerManagerTest, DoNotReorderIfNetworkMetricsChangeTooSmall) { |
CheckControllersOrder(&states, rtc::Optional<int>(kBandwidthBps), |
rtc::Optional<float>(kPacketLossFraction), |
{kNumControllers - 2, kNumControllers - 1, 0, 1}); |
- states.simulated_clock->AdvanceTimeMilliseconds(kMinReorderingTimeMs); |
+ states.fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(kMinReorderingTimeMs)); |
// Then let network metrics move a little towards the other controller. |
CheckControllersOrder( |
&states, rtc::Optional<int>(kBandwidthBps - kMinBandwithChangeBps + 1), |
@@ -276,14 +276,13 @@ constexpr int kMinBitrateBps = 6000; |
ControllerManagerStates CreateControllerManager( |
const ProtoString& config_string) { |
ControllerManagerStates states; |
- states.simulated_clock.reset(new SimulatedClock(kClockInitialTime)); |
+ states.fake_clock.reset(new rtc::ScopedFakeClock()); |
constexpr size_t kNumEncoderChannels = 2; |
const std::vector<int> encoder_frame_lengths_ms = {20, 60}; |
states.controller_manager = ControllerManagerImpl::Create( |
config_string, kNumEncoderChannels, encoder_frame_lengths_ms, |
kMinBitrateBps, kIntialChannelsToEncode, kInitialFrameLengthMs, |
- kInitialBitrateBps, kInitialFecEnabled, kInitialDtxEnabled, |
- states.simulated_clock.get()); |
+ kInitialBitrateBps, kInitialFecEnabled, kInitialDtxEnabled); |
return states; |
} |
@@ -399,7 +398,8 @@ TEST(ControllerManagerTest, CreateFromConfigStringAndCheckReordering) { |
rtc::Optional<int>(kChracteristicBandwithBps[1]); |
metrics.uplink_packet_loss_fraction = |
rtc::Optional<float>(kChracteristicPacketLossFraction[1]); |
- states.simulated_clock->AdvanceTimeMilliseconds(kMinReorderingTimeMs - 1); |
+ states.fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(kMinReorderingTimeMs - 1)); |
controllers = states.controller_manager->GetSortedControllers(metrics); |
// Should not reorder since min reordering time is not met. |
CheckControllersOrder(controllers, |
@@ -408,7 +408,7 @@ TEST(ControllerManagerTest, CreateFromConfigStringAndCheckReordering) { |
ControllerType::CHANNEL, ControllerType::DTX, |
ControllerType::BIT_RATE}); |
- states.simulated_clock->AdvanceTimeMilliseconds(1); |
+ states.fake_clock->AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); |
controllers = states.controller_manager->GetSortedControllers(metrics); |
// Reorder now. |
CheckControllersOrder(controllers, |