Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: webrtc/common_audio/smoothing_filter_unittest.cc

Issue 2546493002: Update smoothed bitrate. (Closed)
Patch Set: Fix thread safety problem and changed smoothing filter. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c80ffb672cb71b3286e3408d3aaec38fe77b6006..3a6d4260ec595d474668bd747716a96e85adc840 100644
--- a/webrtc/common_audio/smoothing_filter_unittest.cc
+++ b/webrtc/common_audio/smoothing_filter_unittest.cc
@@ -105,4 +105,23 @@ TEST(SmoothingFilterTest, CheckBehaviorAfterInitialized) {
CheckOutput(&states, kTimeIntervalMs, 1.0, 0.64136f);
}
+TEST(SmoothingFilterTest, CheckBehaviorAfterInitializeConvertToLastSample) {
+ auto states = CreateSmoothingFilter();
+ states.smoothing_filter->AddSample(0.0);
+ states.simulated_clock->AdvanceTimeMilliseconds(100 * kTimeConstantMs);
+ states.smoothing_filter->AddSample(2.0); // test filter value to 2.
+
+ states.smoothing_filter->AddSample(1.0);
+ auto output = states.smoothing_filter->GetAverage();
+ EXPECT_TRUE(output);
+ EXPECT_NEAR(2, *output, kMaxAbsError);
+ states.simulated_clock->AdvanceTimeMilliseconds(kTimeConstantMs);
+ output = states.smoothing_filter->GetAverage();
+ EXPECT_TRUE(output);
+ EXPECT_NEAR(1.36787f, *output, kMaxAbsError);
+ states.simulated_clock->AdvanceTimeMilliseconds(kTimeConstantMs);
+ output = states.smoothing_filter->GetAverage();
+ EXPECT_TRUE(output);
+ EXPECT_NEAR(1.13533f, *output, kMaxAbsError);
+}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698