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

Unified Diff: chromecast/media/cma/backend/alsa/post_processors/saturated_gain_unittest.cc

Issue 2958393002: Add a simple, safe gain PostProcessor. (Closed)
Patch Set: Move cast_audio.json filepath string to a separate file Created 3 years, 6 months 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: chromecast/media/cma/backend/alsa/post_processors/saturated_gain_unittest.cc
diff --git a/chromecast/media/cma/backend/alsa/post_processors/saturated_gain_unittest.cc b/chromecast/media/cma/backend/alsa/post_processors/saturated_gain_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5fc630ff345df3b1d25ffdf99e73db4503351401
--- /dev/null
+++ b/chromecast/media/cma/backend/alsa/post_processors/saturated_gain_unittest.cc
@@ -0,0 +1,53 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+#include <vector>
+
+#include "base/memory/ptr_util.h"
+#include "base/strings/stringprintf.h"
+#include "chromecast/media/cma/backend/alsa/post_processors/post_processor_unittest.h"
+#include "chromecast/media/cma/backend/alsa/post_processors/saturated_gain.h"
+
+namespace chromecast {
+namespace media {
+namespace post_processor_test {
+
+namespace {
+
+const char* kConfigTemplate =
+ R"config({"gain_db": %f})config";
+
+std::string MakeConfigString(float gain_db) {
+ return base::StringPrintf(kConfigTemplate, gain_db);
+}
+
+} // namespace
+
+// Default tests from post_processor_test
+TEST_P(PostProcessorTest, TestDelay) {
+ std::string config = MakeConfigString(0.0);
+ auto pp =
+ base::WrapUnique(AudioPostProcessorShlib_Create(config, kNumChannels));
+ TestDelay(pp.get(), sample_rate_);
+}
+
+TEST_P(PostProcessorTest, TestRinging) {
+ std::string config = MakeConfigString(0.0);
+ auto pp =
+ base::WrapUnique(AudioPostProcessorShlib_Create(config, kNumChannels));
+ TestRingingTime(pp.get(), sample_rate_);
+}
+
+// Also tests clipping (by attempting to set gain way too high).
+TEST_P(PostProcessorTest, TestPassthrough) {
+ std::string config = MakeConfigString(100.0);
+ auto pp =
+ base::WrapUnique(AudioPostProcessorShlib_Create(config, kNumChannels));
+ TestPassthrough(pp.get(), sample_rate_);
+}
+
+} // namespace post_processor_test
+} // namespace media
+} // namespace chromecast

Powered by Google App Engine
This is Rietveld 408576698