summaryrefslogtreecommitdiff
path: root/voice_engine/voe_audio_processing_unittest.cc
blob: 8916ef1cd5d43edd5974687997a544a27b200006 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "webrtc/voice_engine/include/voe_audio_processing.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/voice_engine/include/voe_base.h"

namespace webrtc {
namespace voe {
namespace {

class VoEAudioProcessingTest : public ::testing::Test {
 protected:
  VoEAudioProcessingTest()
      : voe_(VoiceEngine::Create()),
        base_(VoEBase::GetInterface(voe_)),
        audioproc_(VoEAudioProcessing::GetInterface(voe_)) {
  }

  virtual ~VoEAudioProcessingTest() {
    base_->Terminate();
    audioproc_->Release();
    base_->Release();
    VoiceEngine::Delete(voe_);
  }

  VoiceEngine* voe_;
  VoEBase* base_;
  VoEAudioProcessing* audioproc_;
};

TEST_F(VoEAudioProcessingTest, FailureIfNotInitialized) {
  EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true));
  EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false));
  EXPECT_FALSE(audioproc_->DriftCompensationEnabled());
}

// TODO(andrew): Investigate race conditions triggered by this test:
// https://code.google.com/p/webrtc/issues/detail?id=788
TEST_F(VoEAudioProcessingTest, DISABLED_DriftCompensationIsEnabledIfSupported) {
  ASSERT_EQ(0, base_->Init());
  // TODO(andrew): Ideally, DriftCompensationSupported() would be mocked.
  bool supported = VoEAudioProcessing::DriftCompensationSupported();
  if (supported) {
    EXPECT_EQ(0, audioproc_->EnableDriftCompensation(true));
    EXPECT_TRUE(audioproc_->DriftCompensationEnabled());
    EXPECT_EQ(0, audioproc_->EnableDriftCompensation(false));
    EXPECT_FALSE(audioproc_->DriftCompensationEnabled());
  } else {
    EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(true));
    EXPECT_FALSE(audioproc_->DriftCompensationEnabled());
    EXPECT_EQ(-1, audioproc_->EnableDriftCompensation(false));
    EXPECT_FALSE(audioproc_->DriftCompensationEnabled());
  }
}

}  // namespace
}  // namespace voe
}  // namespace webrtc