Index: webrtc/common_audio/smoothing_filter_unittest.cc |
diff --git a/webrtc/common_audio/smoothing_filter_unittest.cc b/webrtc/common_audio/smoothing_filter_unittest.cc |
index 9ffbf3c5f5aa9921439e7e372efb5e8a9e736c41..96e73da1e901a759a07f120d238ad328e07321a1 100644 |
--- a/webrtc/common_audio/smoothing_filter_unittest.cc |
+++ b/webrtc/common_audio/smoothing_filter_unittest.cc |
@@ -11,6 +11,7 @@ |
#include <cmath> |
#include <memory> |
+#include "webrtc/base/fakeclock.h" |
#include "webrtc/common_audio/smoothing_filter.h" |
#include "webrtc/test/gtest.h" |
@@ -22,15 +23,16 @@ constexpr float kMaxAbsError = 1e-5f; |
constexpr int64_t kClockInitialTime = 123456; |
struct SmoothingFilterStates { |
- std::unique_ptr<SimulatedClock> simulated_clock; |
+ std::unique_ptr<rtc::ScopedFakeClock> fake_clock; |
kwiberg-webrtc
2017/04/11 12:18:38
This doesn't look quite right. IIUC the intention
michaelt
2017/04/11 14:11:13
I think you are right that this class was meant to
kwiberg-webrtc
2017/04/11 16:46:57
OK. But could you at least get rid of the unique_p
michaelt
2017/04/12 07:17:57
Done
|
std::unique_ptr<SmoothingFilterImpl> smoothing_filter; |
}; |
SmoothingFilterStates CreateSmoothingFilter(int init_time_ms) { |
SmoothingFilterStates states; |
- states.simulated_clock.reset(new SimulatedClock(kClockInitialTime)); |
- states.smoothing_filter.reset( |
- new SmoothingFilterImpl(init_time_ms, states.simulated_clock.get())); |
+ states.fake_clock.reset(new rtc::ScopedFakeClock()); |
+ states.fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(kClockInitialTime)); |
+ states.smoothing_filter.reset(new SmoothingFilterImpl(init_time_ms)); |
return states; |
} |
@@ -44,7 +46,8 @@ void CheckOutput(SmoothingFilterStates* states, |
int advance_time_ms, |
float expected_ouput) { |
states->smoothing_filter->AddSample(sample); |
- states->simulated_clock->AdvanceTimeMilliseconds(advance_time_ms); |
+ states->fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(advance_time_ms)); |
auto output = states->smoothing_filter->GetAverage(); |
EXPECT_TRUE(output); |
EXPECT_NEAR(expected_ouput, *output, kMaxAbsError); |
@@ -144,13 +147,14 @@ TEST(SmoothingFilterTest, CannotChangeTimeConstantDuringInitialization) { |
states.smoothing_filter->AddSample(0.0); |
// During initialization, |SetTimeConstantMs| does not take effect. |
- states.simulated_clock->AdvanceTimeMilliseconds(kInitTimeMs - 1); |
+ states.fake_clock->AdvanceTime( |
+ rtc::TimeDelta::FromMilliseconds(kInitTimeMs - 1)); |
states.smoothing_filter->AddSample(0.0); |
EXPECT_FALSE(states.smoothing_filter->SetTimeConstantMs(kInitTimeMs * 2)); |
EXPECT_NE(exp(-1.0f / (kInitTimeMs * 2)), states.smoothing_filter->alpha()); |
- states.simulated_clock->AdvanceTimeMilliseconds(1); |
+ states.fake_clock->AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); |
states.smoothing_filter->AddSample(0.0); |
// When initialization finishes, the time constant should be come |
// |kInitTimeConstantMs|. |