blob: 56c3d13a00e07478a81f3b7286050563ed95d845 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "voice_engine/include/voe_base.h"
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000012
Karl Wibergf3850f62017-11-02 13:04:41 +010013#include "api/audio_codecs/builtin_audio_decoder_factory.h"
solenberg35dee812017-09-18 01:57:01 -070014#include "modules/audio_device/include/fake_audio_device.h"
15#include "modules/audio_processing/include/mock_audio_processing.h"
Niels Möller84255bb2017-10-06 13:43:23 +020016#include "rtc_base/refcountedobject.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "test/gtest.h"
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000018
19namespace webrtc {
20
solenberg35dee812017-09-18 01:57:01 -070021class VoEBaseTest : public ::testing::Test {
22 protected:
23 VoEBaseTest()
24 : voe_(VoiceEngine::Create()),
25 base_(VoEBase::GetInterface(voe_)) {
26 EXPECT_NE(nullptr, base_);
27 apm_ = new rtc::RefCountedObject<test::MockAudioProcessing>();
28 }
29
30 ~VoEBaseTest() {
Fredrik Solenberg55900fd2017-11-23 20:22:55 +010031 base_->Terminate();
solenberg35dee812017-09-18 01:57:01 -070032 EXPECT_EQ(1, base_->Release());
33 EXPECT_TRUE(VoiceEngine::Delete(voe_));
34 }
35
36 VoiceEngine* voe_;
37 VoEBase* base_;
38 FakeAudioDeviceModule adm_;
39 rtc::scoped_refptr<AudioProcessing> apm_;
40};
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000041
Jelena Marusic0b154452015-05-04 09:55:59 +020042TEST_F(VoEBaseTest, InitWithExternalAudioDevice) {
Karl Wibergf3850f62017-11-02 13:04:41 +010043 EXPECT_EQ(0,
44 base_->Init(&adm_, apm_.get(), CreateBuiltinAudioDecoderFactory()));
Jelena Marusic06b08af2015-04-21 11:39:57 +020045}
46
Jelena Marusic0b154452015-05-04 09:55:59 +020047TEST_F(VoEBaseTest, CreateChannelAfterInit) {
Karl Wibergf3850f62017-11-02 13:04:41 +010048 EXPECT_EQ(0,
49 base_->Init(&adm_, apm_.get(), CreateBuiltinAudioDecoderFactory()));
Jelena Marusic06b08af2015-04-21 11:39:57 +020050 int channelID = base_->CreateChannel();
Jelena Marusic46bd31b2015-04-30 10:57:10 +020051 EXPECT_NE(channelID, -1);
Jelena Marusic06b08af2015-04-21 11:39:57 +020052 EXPECT_EQ(0, base_->DeleteChannel(channelID));
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000053}
54
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000055} // namespace webrtc