Index: webrtc/modules/audio_processing/audio_processing_unittest.cc |
diff --git a/webrtc/modules/audio_processing/audio_processing_unittest.cc b/webrtc/modules/audio_processing/audio_processing_unittest.cc |
index 646e8b7b874eb1c0baba34c12cb926503d3a5d1a..21a24b6c23669e5972938a73b894c2c03b874505 100644 |
--- a/webrtc/modules/audio_processing/audio_processing_unittest.cc |
+++ b/webrtc/modules/audio_processing/audio_processing_unittest.cc |
@@ -16,15 +16,18 @@ |
#include <memory> |
#include <queue> |
+#include "testing/gtest/include/gtest/gtest.h" |
#include "webrtc/base/arraysize.h" |
#include "webrtc/base/checks.h" |
#include "webrtc/common_audio/include/audio_util.h" |
#include "webrtc/common_audio/resampler/include/push_resampler.h" |
#include "webrtc/common_audio/resampler/push_sinc_resampler.h" |
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" |
+#include "webrtc/modules/audio_processing/audio_processing_impl.h" |
#include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h" |
#include "webrtc/modules/audio_processing/common.h" |
#include "webrtc/modules/audio_processing/include/audio_processing.h" |
+#include "webrtc/modules/audio_processing/level_controller/lc_constants.h" |
the sun
2016/09/30 08:51:16
please don't abbreviate file names
peah-webrtc
2016/10/03 09:52:13
Done.
|
#include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
#include "webrtc/modules/audio_processing/test/test_utils.h" |
#include "webrtc/modules/include/module_common_types.h" |
@@ -32,10 +35,8 @@ |
#include "webrtc/system_wrappers/include/trace.h" |
#include "webrtc/test/testsupport/fileutils.h" |
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
-#include "gtest/gtest.h" |
#include "external/webrtc/webrtc/modules/audio_processing/test/unittest.pb.h" |
#else |
-#include "testing/gtest/include/gtest/gtest.h" |
#include "webrtc/modules/audio_processing/unittest.pb.h" |
#endif |
@@ -2774,4 +2775,97 @@ INSTANTIATE_TEST_CASE_P( |
#endif |
} // namespace |
+ |
+TEST(ApmConfiguration, DefaultBehavior) { |
+ // Verify that the level controller is default off, it can be activated using |
+ // the config, and that the default initial level is maintained after the |
+ // config has been applied. |
+ const float kTolerance = 0.0001f; |
+ std::unique_ptr<AudioProcessingImpl> apm( |
+ new AudioProcessingImpl(webrtc::Config())); |
+ AudioProcessing::Config config; |
+ EXPECT_FALSE(apm->config_.level_controller.enabled); |
+ // TODO(peah): Add test for the existence of the level controller object once |
+ // that is created only when that is specified in the config. |
+ // TODO(peah): Remove the testing for |
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
+ // is instead used to activate the level controller. |
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
+ EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
+ apm->config_.level_controller.initial_peak_level_dbfs, |
+ kTolerance); |
+ config.level_controller.enabled = true; |
+ apm->ApplyConfig(config); |
+ EXPECT_TRUE(apm->config_.level_controller.enabled); |
the sun
2016/09/30 08:51:16
Aren't you testing this in ValidConfigBehavior? De
peah-webrtc
2016/10/03 09:52:13
No, if I understand your question correctly, I don
the sun
2016/10/06 07:21:13
Acknowledged.
|
+ // TODO(peah): Add test for the existence of the level controller object once |
+ // that is created only when the that is specified in the config. |
+ // TODO(peah): Remove the testing for |
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
+ // is instead used to activate the level controller. |
+ EXPECT_TRUE(apm->capture_nonlocked_.level_controller_enabled); |
+ EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
+ apm->config_.level_controller.initial_peak_level_dbfs, |
+ kTolerance); |
+} |
+ |
+TEST(ApmConfiguration, ValidConfigBehavior) { |
+ // Verify that the initial level can be specified and is retained after the |
+ // config has been applied. |
+ const float kTolerance = 0.0001f; |
+ std::unique_ptr<AudioProcessingImpl> apm( |
+ new AudioProcessingImpl(webrtc::Config())); |
+ AudioProcessing::Config config; |
+ config = AudioProcessing::Config(); |
+ config.level_controller.initial_peak_level_dbfs = -50.f; |
+ apm->ApplyConfig(config); |
+ EXPECT_FALSE(apm->config_.level_controller.enabled); |
+ // TODO(peah): Add test for the existence of the level controller object once |
+ // that is created only when the that is specified in the config. |
+ // TODO(peah): Remove the testing for |
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
+ // is instead used to activate the level controller. |
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
+ EXPECT_NEAR(-50.f, apm->config_.level_controller.initial_peak_level_dbfs, |
+ kTolerance); |
+} |
+ |
+TEST(ApmConfiguration, InValidConfigBehavior) { |
+ // Verify that the config is properly reset when nonproper values are applied |
+ // for the initial level. |
+ const float kTolerance = 0.0001f; |
+ std::unique_ptr<AudioProcessingImpl> apm( |
+ new AudioProcessingImpl(webrtc::Config())); |
+ AudioProcessing::Config config; |
+ config = AudioProcessing::Config(); |
+ config.level_controller.enabled = true; |
+ config.level_controller.initial_peak_level_dbfs = -101.f; |
+ apm->ApplyConfig(config); |
+ EXPECT_FALSE(apm->config_.level_controller.enabled); |
+ // TODO(peah): Add test for the existence of the level controller object once |
+ // that is created only when the that is specified in the config. |
+ // TODO(peah): Remove the testing for |
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
+ // is instead used to activate the level controller. |
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
+ EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
+ apm->config_.level_controller.initial_peak_level_dbfs, |
+ kTolerance); |
+ |
+ apm.reset(new AudioProcessingImpl(webrtc::Config())); |
the sun
2016/09/30 08:51:16
So here's either a separate test case, or a commen
peah-webrtc
2016/10/03 09:52:13
I added comments about what is being done. Ideally
the sun
2016/10/06 07:21:13
Acknowledged.
|
+ config = AudioProcessing::Config(); |
+ config.level_controller.enabled = true; |
+ config.level_controller.initial_peak_level_dbfs = 1.f; |
+ apm->ApplyConfig(config); |
+ EXPECT_FALSE(apm->config_.level_controller.enabled); |
+ // TODO(peah): Add test for the existence of the level controller object once |
+ // that is created only when that is specified in the config. |
+ // TODO(peah): Remove the testing for |
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_ |
+ // is instead used to activate the level controller. |
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); |
+ EXPECT_NEAR(kTargetLcPeakLeveldBFS, |
+ apm->config_.level_controller.initial_peak_level_dbfs, |
+ kTolerance); |
+} |
+ |
} // namespace webrtc |