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 11 #include "webrtc/voice_engine/include/voe_audio_processing.h" 12 13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "webrtc/voice_engine/include/voe_base.h" 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 virtual ~VoEAudioProcessingTest() { 28 base_->Terminate(); 29 audioproc_->Release(); 30 base_->Release(); 31 VoiceEngine::Delete(voe_); 32 } 33 34 VoiceEngine* voe_; 35 VoEBase* base_; 36 VoEAudioProcessing* audioproc_; 37 }; 38 39 TEST_F(VoEAudioProcessingTest, FailureIfNotInitialized) { 40 EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true)); 41 EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false)); 42 EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); 43 } 44 45 // TODO(andrew): Investigate race conditions triggered by this test: 46 // https://code.google.com/p/webrtc/issues/detail?id=788 47 TEST_F(VoEAudioProcessingTest, DISABLED_DriftCompensationIsEnabledIfSupported) { 48 ASSERT_EQ(0, base_->Init()); 49 // TODO(andrew): Ideally, DriftCompensationSupported() would be mocked. 50 bool supported = VoEAudioProcessing::DriftCompensationSupported(); 51 if (supported) { 52 EXPECT_EQ(0, audioproc_->EnableDriftCompensation(true)); 53 EXPECT_TRUE(audioproc_->DriftCompensationEnabled()); 54 EXPECT_EQ(0, audioproc_->EnableDriftCompensation(false)); 55 EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); 56 } else { 57 EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true)); 58 EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); 59 EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false)); 60 EXPECT_FALSE(audioproc_->DriftCompensationEnabled()); 61 } 62 } 63 64 } // namespace 65 } // namespace voe 66 } // namespace webrtc 67