2013-04-29 17:27:29 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "common_audio/resampler/include/push_resampler.h"
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h" // RTC_DCHECK_IS_ON
|
|
|
|
|
#include "test/gtest.h"
|
2019-11-28 17:09:30 +01:00
|
|
|
#include "test/testsupport/rtc_expect_death.h"
|
2013-04-29 17:27:29 +00:00
|
|
|
|
2022-08-03 14:37:00 +02:00
|
|
|
// Quality testing of PushResampler is done in audio/remix_resample_unittest.cc.
|
2013-04-29 17:27:29 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2013-06-03 19:00:29 +00:00
|
|
|
TEST(PushResamplerTest, VerifiesInputParameters) {
|
2014-04-19 00:32:07 +00:00
|
|
|
PushResampler<int16_t> resampler;
|
2013-06-03 19:00:29 +00:00
|
|
|
EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1));
|
|
|
|
|
EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2));
|
2018-10-02 14:09:46 +02:00
|
|
|
EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 8));
|
2013-04-29 17:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-26 23:07:40 +02:00
|
|
|
#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
|
2020-05-18 16:47:56 +02:00
|
|
|
TEST(PushResamplerDeathTest, VerifiesBadInputParameters1) {
|
2016-05-26 22:21:31 +02:00
|
|
|
PushResampler<int16_t> resampler;
|
2019-11-28 17:09:30 +01:00
|
|
|
RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1),
|
|
|
|
|
"src_sample_rate_hz");
|
2016-05-26 22:21:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-18 16:47:56 +02:00
|
|
|
TEST(PushResamplerDeathTest, VerifiesBadInputParameters2) {
|
2016-05-26 22:21:31 +02:00
|
|
|
PushResampler<int16_t> resampler;
|
2019-11-28 17:09:30 +01:00
|
|
|
RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1),
|
|
|
|
|
"dst_sample_rate_hz");
|
2016-05-26 22:21:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-18 16:47:56 +02:00
|
|
|
TEST(PushResamplerDeathTest, VerifiesBadInputParameters3) {
|
2016-05-26 22:21:31 +02:00
|
|
|
PushResampler<int16_t> resampler;
|
2019-11-28 17:09:30 +01:00
|
|
|
RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0),
|
|
|
|
|
"num_channels");
|
2016-05-26 22:21:31 +02:00
|
|
|
}
|
2016-05-26 23:07:40 +02:00
|
|
|
#endif
|
2016-05-26 22:21:31 +02:00
|
|
|
|
2013-04-29 17:27:29 +00:00
|
|
|
} // namespace webrtc
|