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

Unified Diff: webrtc/modules/audio_processing/test/analog_volume_mapper_unittest.cc

Issue 2837553002: First try on a fake analog volume control interface for use in audioproc_f. (Closed)
Patch Set: Comments addressed: smaller range, simpler checks, working test. Created 3 years, 8 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: webrtc/modules/audio_processing/test/analog_volume_mapper_unittest.cc
diff --git a/webrtc/modules/audio_processing/test/analog_volume_mapper_unittest.cc b/webrtc/modules/audio_processing/test/analog_volume_mapper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e564153c78e4db639156597c4d3483b8b3563069
--- /dev/null
+++ b/webrtc/modules/audio_processing/test/analog_volume_mapper_unittest.cc
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_processing/test/analog_volume_mapper.h"
+#include "webrtc/test/gtest.h"
+
+TEST(AnalogVolumeMapper, GainCurveShouldBeMonotone) {
+ using MappingKind = webrtc::AnalogLevelMapper::LevelToScalingMappingKind;
+
+ for (auto kind : {MappingKind::kIdentity, MappingKind::kLinear}) {
+ webrtc::AnalogLevelMapper level_mapper(kind);
+ float last_level = level_mapper.GetScalingFactor();
+ RTC_DCHECK_LE(0.f, last_level);
+
+ for (int i = 0; i < 255; ++i) {
+ level_mapper.set_analog_level(i);
+ const float current_level = level_mapper.GetScalingFactor();
+ RTC_DCHECK_LE(last_level, current_level);
+
+ last_level = current_level;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698