blob: 4724833fbb1351d98b738e466d055739c320b6e6 [file] [log] [blame]
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "common_audio/resampler/include/push_resampler.h"
Jonas Olssona4d87372019-07-05 19:08:33 +020012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "rtc_base/checks.h" // RTC_DCHECK_IS_ON
14#include "test/gtest.h"
Artem Titov9dc209a2019-11-28 17:09:30 +010015#include "test/testsupport/rtc_expect_death.h"
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000016
17// Quality testing of PushResampler is handled through output_mixer_unittest.cc.
18
19namespace webrtc {
20
Tommi0ad72ea2016-05-26 23:07:40 +020021// The below tests are temporarily disabled on WEBRTC_WIN due to problems
22// with clang debug builds.
Tommi90edc652016-05-26 23:48:16 +020023// TODO(tommi): Re-enable when we've figured out what the problem is.
24// http://crbug.com/615050
25#if !defined(WEBRTC_WIN) && defined(__clang__) && !defined(NDEBUG)
andrew@webrtc.orgc1eb5602013-06-03 19:00:29 +000026TEST(PushResamplerTest, VerifiesInputParameters) {
andrew@webrtc.orgf5a33f12014-04-19 00:32:07 +000027 PushResampler<int16_t> resampler;
andrew@webrtc.orgc1eb5602013-06-03 19:00:29 +000028 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1));
29 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2));
Alex Loiko3fc5a202018-10-02 14:09:46 +020030 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 8));
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000031}
32
Tommi0ad72ea2016-05-26 23:07:40 +020033#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
Tommi909f3a52020-05-18 16:47:56 +020034TEST(PushResamplerDeathTest, VerifiesBadInputParameters1) {
Tommif9d2fe92016-05-26 22:21:31 +020035 PushResampler<int16_t> resampler;
Artem Titov9dc209a2019-11-28 17:09:30 +010036 RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1),
37 "src_sample_rate_hz");
Tommif9d2fe92016-05-26 22:21:31 +020038}
39
Tommi909f3a52020-05-18 16:47:56 +020040TEST(PushResamplerDeathTest, VerifiesBadInputParameters2) {
Tommif9d2fe92016-05-26 22:21:31 +020041 PushResampler<int16_t> resampler;
Artem Titov9dc209a2019-11-28 17:09:30 +010042 RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1),
43 "dst_sample_rate_hz");
Tommif9d2fe92016-05-26 22:21:31 +020044}
45
Tommi909f3a52020-05-18 16:47:56 +020046TEST(PushResamplerDeathTest, VerifiesBadInputParameters3) {
Tommif9d2fe92016-05-26 22:21:31 +020047 PushResampler<int16_t> resampler;
Artem Titov9dc209a2019-11-28 17:09:30 +010048 RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0),
49 "num_channels");
Tommif9d2fe92016-05-26 22:21:31 +020050}
51
Tommif9d2fe92016-05-26 22:21:31 +020052#endif
Tommi0ad72ea2016-05-26 23:07:40 +020053#endif
Tommif9d2fe92016-05-26 22:21:31 +020054
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000055} // namespace webrtc