blob: ea90bbae1d9edeaa799cd293dc5658f36cde22f0 [file] [log] [blame]
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +00001/*
2 * Copyright (c) 2013 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_base.h"
12
13#include "testing/gtest/include/gtest/gtest.h"
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000014#include "webrtc/modules/audio_device/include/fake_audio_device.h"
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000015#include "webrtc/modules/audio_processing/include/audio_processing.h"
Jelena Marusic06b08af2015-04-21 11:39:57 +020016#include "webrtc/voice_engine/mock/mock_voe_observer.h"
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000017
18namespace webrtc {
19
20class VoEBaseTest : public ::testing::Test {
21 protected:
22 VoEBaseTest() :
23 voe_(VoiceEngine::Create()),
Jelena Marusic06b08af2015-04-21 11:39:57 +020024 base_(VoEBase::GetInterface(voe_)) {
25 EXPECT_NE(nullptr, base_);
26 EXPECT_EQ(0, base_->RegisterVoiceEngineObserver(observer_));
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000027 }
28
29 ~VoEBaseTest() {
Jelena Marusic06b08af2015-04-21 11:39:57 +020030 EXPECT_EQ(0, base_->DeRegisterVoiceEngineObserver());
31 EXPECT_EQ(0, base_->Terminate());
32 EXPECT_EQ(1, base_->Release());
33 EXPECT_TRUE(VoiceEngine::Delete(voe_));
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000034 }
35
36 VoiceEngine* voe_;
37 VoEBase* base_;
Jelena Marusic06b08af2015-04-21 11:39:57 +020038 MockVoEObserver observer_;
39 FakeAudioDeviceModule adm_;
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000040};
41
Jelena Marusic06b08af2015-04-21 11:39:57 +020042TEST_F(VoEBaseTest, InitWithExternalAudioDeviceAndAudioProcessing) {
andrew@webrtc.org46323b32015-01-13 06:48:06 +000043 AudioProcessing* audioproc = AudioProcessing::Create();
Jelena Marusic06b08af2015-04-21 11:39:57 +020044 EXPECT_EQ(0, base_->Init(&adm_, audioproc));
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000045 EXPECT_EQ(audioproc, base_->audio_processing());
Jelena Marusic06b08af2015-04-21 11:39:57 +020046 EXPECT_EQ(0, base_->LastError());
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000047}
48
Jelena Marusic06b08af2015-04-21 11:39:57 +020049TEST_F(VoEBaseTest, InitWithExternalAudioDevice) {
50 EXPECT_EQ(nullptr, base_->audio_processing());
51 EXPECT_EQ(0, base_->Init(&adm_, nullptr));
52 EXPECT_NE(nullptr, base_->audio_processing());
53 EXPECT_EQ(0, base_->LastError());
54}
55
56TEST_F(VoEBaseTest, CreateChannelBeforeInitShouldFail) {
57 int channelID = base_->CreateChannel();
58 EXPECT_EQ(-1, channelID);
59}
60
61TEST_F(VoEBaseTest, CreateChannelAfterInitShouldPass) {
62 EXPECT_EQ(0, base_->Init(&adm_, nullptr));
63 int channelID = base_->CreateChannel();
64 EXPECT_NE(-1, channelID);
65 EXPECT_EQ(0, base_->DeleteChannel(channelID));
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000066}
67
68} // namespace webrtc