Stop using ScopedFakeClock in screenshare_layers_unittest Bug: webrtc:42223992 Change-Id: I65322689cf768529206f1ce3474175656a6a6964 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/462242 Auto-Submit: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47362}
diff --git a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc index 87839e0..cf54448 100644 --- a/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc +++ b/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc
@@ -28,11 +28,11 @@ #include "modules/video_coding/codecs/vp8/libvpx_vp8_encoder.h" #include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/checks.h" -#include "rtc_base/fake_clock.h" #include "system_wrappers/include/metrics.h" #include "test/create_test_environment.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/time_controller/simulated_time_controller.h" #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" using ::testing::_; @@ -120,7 +120,11 @@ Vp8FrameConfig NextFrameConfig(size_t stream_index, uint32_t timestamp) { int64_t timestamp_ms = timestamp / 90; - clock_.SetTime(Timestamp::Millis(timestamp_ms)); + TimeDelta delta = Timestamp::Millis(timestamp_ms) - + time_controller_.GetClock()->CurrentTime(); + if (delta > TimeDelta::Zero()) { + time_controller_.AdvanceTime(delta); + } return layers_->NextFrameConfig(stream_index, timestamp); } @@ -196,11 +200,11 @@ return -1; } - const Environment env_ = CreateTestEnvironment(); + GlobalSimulatedTimeController time_controller_{Timestamp::Zero()}; + const Environment env_ = CreateTestEnvironment({.time = &time_controller_}); int min_qp_; uint32_t max_qp_; int frame_size_; - ScopedFakeClock clock_; std::unique_ptr<ScreenshareLayers> layers_; uint32_t timestamp_; @@ -573,7 +577,7 @@ } else { RTC_DCHECK_NOTREACHED() << "Unexpected flags"; } - clock_.AdvanceTime(TimeDelta::Millis(1000 / 5)); + time_controller_.AdvanceTime(TimeDelta::Millis(1000 / 5)); } EXPECT_TRUE(overshoot); @@ -638,7 +642,7 @@ IgnoredCodecSpecificInfo()); } timestamp += kFrameIntervalsMs * 90; - clock_.AdvanceTime(TimeDelta::Millis(kFrameIntervalsMs)); + time_controller_.AdvanceTime(TimeDelta::Millis(kFrameIntervalsMs)); ++num_input_frames; } @@ -656,7 +660,7 @@ IgnoredCodecSpecificInfo()); } timestamp += kFrameIntervalsMs * 90 / 2; - clock_.AdvanceTime(TimeDelta::Millis(kFrameIntervalsMs)); + time_controller_.AdvanceTime(TimeDelta::Millis(kFrameIntervalsMs / 2)); ++num_input_frames; }