andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 11 | #include "webrtc/voice_engine/include/voe_audio_processing.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 13 | #include "testing/gtest/include/gtest/gtest.h" |
| 14 | #include "webrtc/voice_engine/include/voe_base.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
| 17 | namespace voe { |
| 18 | namespace { |
| 19 | |
| 20 | class VoEAudioProcessingTest : public ::testing::Test { |
| 21 | protected: |
| 22 | VoEAudioProcessingTest() |
| 23 | : voe_(VoiceEngine::Create()), |
| 24 | base_(VoEBase::GetInterface(voe_)), |
| 25 | audioproc_(VoEAudioProcessing::GetInterface(voe_)) { |
| 26 | } |
| 27 | |
| 28 | virtual ~VoEAudioProcessingTest() { |
| 29 | base_->Terminate(); |
| 30 | audioproc_->Release(); |
| 31 | base_->Release(); |
| 32 | VoiceEngine::Delete(voe_); |
| 33 | } |
| 34 | |
| 35 | VoiceEngine* voe_; |
| 36 | VoEBase* base_; |
| 37 | VoEAudioProcessing* audioproc_; |
| 38 | }; |
| 39 | |
| 40 | TEST_F(VoEAudioProcessingTest, FailureIfNotInitialized) { |
| 41 | EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true)); |
| 42 | EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false)); |
| 43 | EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); |
| 44 | } |
| 45 | |
| 46 | // TODO(andrew): Investigate race conditions triggered by this test: |
| 47 | // https://code.google.com/p/webrtc/issues/detail?id=788 |
| 48 | TEST_F(VoEAudioProcessingTest, DISABLED_DriftCompensationIsEnabledIfSupported) { |
| 49 | ASSERT_EQ(0, base_->Init()); |
| 50 | // TODO(andrew): Ideally, DriftCompensationSupported() would be mocked. |
| 51 | bool supported = VoEAudioProcessing::DriftCompensationSupported(); |
| 52 | if (supported) { |
| 53 | EXPECT_EQ(0, audioproc_->EnableDriftCompensation(true)); |
| 54 | EXPECT_TRUE(audioproc_->DriftCompensationEnabled()); |
| 55 | EXPECT_EQ(0, audioproc_->EnableDriftCompensation(false)); |
| 56 | EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); |
| 57 | } else { |
| 58 | EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true)); |
| 59 | EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); |
| 60 | EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false)); |
| 61 | EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | } // namespace |
| 66 | } // namespace voe |
| 67 | } // namespace webrtc |