1 /*
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
11 #include "common_audio/resampler/include/push_resampler.h"
12
13 #include "rtc_base/checks.h" // RTC_DCHECK_IS_ON
14 #include "test/gtest.h"
15 #include "test/testsupport/rtc_expect_death.h"
16
17 // Quality testing of PushResampler is handled through output_mixer_unittest.cc.
18
19 namespace webrtc {
20
21 // The below tests are temporarily disabled on WEBRTC_WIN due to problems
22 // with clang debug builds.
23 // 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)
TEST(PushResamplerTest,VerifiesInputParameters)26 TEST(PushResamplerTest, VerifiesInputParameters) {
27 PushResampler<int16_t> resampler;
28 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1));
29 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2));
30 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 8));
31 }
32
33 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
TEST(PushResamplerDeathTest,VerifiesBadInputParameters1)34 TEST(PushResamplerDeathTest, VerifiesBadInputParameters1) {
35 PushResampler<int16_t> resampler;
36 RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1),
37 "src_sample_rate_hz");
38 }
39
TEST(PushResamplerDeathTest,VerifiesBadInputParameters2)40 TEST(PushResamplerDeathTest, VerifiesBadInputParameters2) {
41 PushResampler<int16_t> resampler;
42 RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1),
43 "dst_sample_rate_hz");
44 }
45
TEST(PushResamplerDeathTest,VerifiesBadInputParameters3)46 TEST(PushResamplerDeathTest, VerifiesBadInputParameters3) {
47 PushResampler<int16_t> resampler;
48 RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0),
49 "num_channels");
50 }
51
52 #endif
53 #endif
54
55 } // namespace webrtc
56