andrew@webrtc.org | 50b2efe | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "common_audio/resampler/include/push_resampler.h" |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "rtc_base/checks.h" // RTC_DCHECK_IS_ON |
| 14 | #include "test/gtest.h" |
Artem Titov | 9dc209a | 2019-11-28 17:09:30 +0100 | [diff] [blame] | 15 | #include "test/testsupport/rtc_expect_death.h" |
andrew@webrtc.org | 50b2efe | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 16 | |
| 17 | // Quality testing of PushResampler is handled through output_mixer_unittest.cc. |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
Tommi | 0ad72ea | 2016-05-26 23:07:40 +0200 | [diff] [blame] | 21 | // The below tests are temporarily disabled on WEBRTC_WIN due to problems |
| 22 | // with clang debug builds. |
Tommi | 90edc65 | 2016-05-26 23:48:16 +0200 | [diff] [blame] | 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) |
andrew@webrtc.org | c1eb560 | 2013-06-03 19:00:29 +0000 | [diff] [blame] | 26 | TEST(PushResamplerTest, VerifiesInputParameters) { |
andrew@webrtc.org | f5a33f1 | 2014-04-19 00:32:07 +0000 | [diff] [blame] | 27 | PushResampler<int16_t> resampler; |
andrew@webrtc.org | c1eb560 | 2013-06-03 19:00:29 +0000 | [diff] [blame] | 28 | EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1)); |
| 29 | EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2)); |
Alex Loiko | 3fc5a20 | 2018-10-02 14:09:46 +0200 | [diff] [blame] | 30 | EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 8)); |
andrew@webrtc.org | 50b2efe | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 31 | } |
| 32 | |
Tommi | 0ad72ea | 2016-05-26 23:07:40 +0200 | [diff] [blame] | 33 | #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
Tommi | 909f3a5 | 2020-05-18 16:47:56 +0200 | [diff] [blame] | 34 | TEST(PushResamplerDeathTest, VerifiesBadInputParameters1) { |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 35 | PushResampler<int16_t> resampler; |
Artem Titov | 9dc209a | 2019-11-28 17:09:30 +0100 | [diff] [blame] | 36 | RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1), |
| 37 | "src_sample_rate_hz"); |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 38 | } |
| 39 | |
Tommi | 909f3a5 | 2020-05-18 16:47:56 +0200 | [diff] [blame] | 40 | TEST(PushResamplerDeathTest, VerifiesBadInputParameters2) { |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 41 | PushResampler<int16_t> resampler; |
Artem Titov | 9dc209a | 2019-11-28 17:09:30 +0100 | [diff] [blame] | 42 | RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1), |
| 43 | "dst_sample_rate_hz"); |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 44 | } |
| 45 | |
Tommi | 909f3a5 | 2020-05-18 16:47:56 +0200 | [diff] [blame] | 46 | TEST(PushResamplerDeathTest, VerifiesBadInputParameters3) { |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 47 | PushResampler<int16_t> resampler; |
Artem Titov | 9dc209a | 2019-11-28 17:09:30 +0100 | [diff] [blame] | 48 | RTC_EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0), |
| 49 | "num_channels"); |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 52 | #endif |
Tommi | 0ad72ea | 2016-05-26 23:07:40 +0200 | [diff] [blame] | 53 | #endif |
Tommi | f9d2fe9 | 2016-05-26 22:21:31 +0200 | [diff] [blame] | 54 | |
andrew@webrtc.org | 50b2efe | 2013-04-29 17:27:29 +0000 | [diff] [blame] | 55 | } // namespace webrtc |