summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/webrtc/voice_engine/voe_base_unittest.cc
blob: 56c3d13a00e07478a81f3b7286050563ed95d845 (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
/*
 *  Copyright (c) 2013 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 "voice_engine/include/voe_base.h"

#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "modules/audio_device/include/fake_audio_device.h"
#include "modules/audio_processing/include/mock_audio_processing.h"
#include "rtc_base/refcountedobject.h"
#include "test/gtest.h"

namespace webrtc {

class VoEBaseTest : public ::testing::Test {
 protected:
  VoEBaseTest()
      : voe_(VoiceEngine::Create()),
        base_(VoEBase::GetInterface(voe_)) {
    EXPECT_NE(nullptr, base_);
    apm_ = new rtc::RefCountedObject<test::MockAudioProcessing>();
  }

  ~VoEBaseTest() {
    base_->Terminate();
    EXPECT_EQ(1, base_->Release());
    EXPECT_TRUE(VoiceEngine::Delete(voe_));
  }

  VoiceEngine* voe_;
  VoEBase* base_;
  FakeAudioDeviceModule adm_;
  rtc::scoped_refptr<AudioProcessing> apm_;
};

TEST_F(VoEBaseTest, InitWithExternalAudioDevice) {
  EXPECT_EQ(0,
            base_->Init(&adm_, apm_.get(), CreateBuiltinAudioDecoderFactory()));
}

TEST_F(VoEBaseTest, CreateChannelAfterInit) {
  EXPECT_EQ(0,
            base_->Init(&adm_, apm_.get(), CreateBuiltinAudioDecoderFactory()));
  int channelID = base_->CreateChannel();
  EXPECT_NE(channelID, -1);
  EXPECT_EQ(0, base_->DeleteChannel(channelID));
}

}  // namespace webrtc