blob: 0d725bcc9ab4795baec8deeca6cc6ffee293b51c [file] [log] [blame]
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +00001/*
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.org956aa7e2013-05-21 13:52:32 +000011#include "webrtc/voice_engine/include/voe_audio_processing.h"
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +000012
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000013#include "testing/gtest/include/gtest/gtest.h"
14#include "webrtc/voice_engine/include/voe_base.h"
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +000015
16namespace webrtc {
17namespace voe {
18namespace {
19
20class VoEAudioProcessingTest : public ::testing::Test {
21 protected:
22 VoEAudioProcessingTest()
23 : voe_(VoiceEngine::Create()),
24 base_(VoEBase::GetInterface(voe_)),
Jelena Marusic0d266052015-05-04 14:15:32 +020025 audioproc_(VoEAudioProcessing::GetInterface(voe_)) {}
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +000026
27 virtual ~VoEAudioProcessingTest() {
andrew@webrtc.orgb9352282012-08-29 04:23:14 +000028 base_->Terminate();
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +000029 audioproc_->Release();
30 base_->Release();
31 VoiceEngine::Delete(voe_);
32 }
33
34 VoiceEngine* voe_;
35 VoEBase* base_;
36 VoEAudioProcessing* audioproc_;
37};
38
39TEST_F(VoEAudioProcessingTest, FailureIfNotInitialized) {
40 EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true));
41 EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false));
42 EXPECT_FALSE(audioproc_->DriftCompensationEnabled());
43}
44
andrew@webrtc.orgcc53b7c2012-08-29 06:55:21 +000045// TODO(andrew): Investigate race conditions triggered by this test:
46// https://code.google.com/p/webrtc/issues/detail?id=788
47TEST_F(VoEAudioProcessingTest, DISABLED_DriftCompensationIsEnabledIfSupported) {
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +000048 ASSERT_EQ(0, base_->Init());
andrew@webrtc.orgcc53b7c2012-08-29 06:55:21 +000049 // TODO(andrew): Ideally, DriftCompensationSupported() would be mocked.
andrew@webrtc.org55c0d4a2012-08-29 02:13:12 +000050 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