| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webrtc/base/checks.h" // force defintion of RTC_DCHECK_IS_ON | |
| 13 #include "webrtc/common_audio/resampler/include/push_resampler.h" | 12 #include "webrtc/common_audio/resampler/include/push_resampler.h" |
| 14 | 13 |
| 15 // Quality testing of PushResampler is handled through output_mixer_unittest.cc. | 14 // Quality testing of PushResampler is handled through output_mixer_unittest.cc. |
| 16 | 15 |
| 17 namespace webrtc { | 16 namespace webrtc { |
| 18 | 17 |
| 19 TEST(PushResamplerTest, VerifiesInputParameters) { | 18 TEST(PushResamplerTest, VerifiesInputParameters) { |
| 20 PushResampler<int16_t> resampler; | 19 PushResampler<int16_t> resampler; |
| 20 EXPECT_EQ(-1, resampler.InitializeIfNeeded(-1, 16000, 1)); |
| 21 EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, -1, 1)); |
| 22 EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, 16000, 0)); |
| 23 EXPECT_EQ(-1, resampler.InitializeIfNeeded(16000, 16000, 3)); |
| 21 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1)); | 24 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 1)); |
| 22 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2)); | 25 EXPECT_EQ(0, resampler.InitializeIfNeeded(16000, 16000, 2)); |
| 23 } | 26 } |
| 24 | 27 |
| 25 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | |
| 26 TEST(PushResamplerTest, VerifiesBadInputParameters1) { | |
| 27 PushResampler<int16_t> resampler; | |
| 28 EXPECT_DEATH(resampler.InitializeIfNeeded(-1, 16000, 1), | |
| 29 "src_sample_rate_hz"); | |
| 30 } | |
| 31 | |
| 32 TEST(PushResamplerTest, VerifiesBadInputParameters2) { | |
| 33 PushResampler<int16_t> resampler; | |
| 34 EXPECT_DEATH(resampler.InitializeIfNeeded(16000, -1, 1), | |
| 35 "dst_sample_rate_hz"); | |
| 36 } | |
| 37 | |
| 38 TEST(PushResamplerTest, VerifiesBadInputParameters3) { | |
| 39 PushResampler<int16_t> resampler; | |
| 40 EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 0), "num_channels"); | |
| 41 } | |
| 42 | |
| 43 TEST(PushResamplerTest, VerifiesBadInputParameters4) { | |
| 44 PushResampler<int16_t> resampler; | |
| 45 EXPECT_DEATH(resampler.InitializeIfNeeded(16000, 16000, 3), "num_channels"); | |
| 46 } | |
| 47 #endif | |
| 48 | |
| 49 } // namespace webrtc | 28 } // namespace webrtc |
| OLD | NEW |