andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "voice_engine/include/voe_base.h" |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 12 | |
solenberg | 35dee81 | 2017-09-18 01:57:01 -0700 | [diff] [blame] | 13 | #include "modules/audio_device/include/fake_audio_device.h" |
| 14 | #include "modules/audio_processing/include/mock_audio_processing.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "test/gtest.h" |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
solenberg | 35dee81 | 2017-09-18 01:57:01 -0700 | [diff] [blame] | 19 | class VoEBaseTest : public ::testing::Test { |
| 20 | protected: |
| 21 | VoEBaseTest() |
| 22 | : voe_(VoiceEngine::Create()), |
| 23 | base_(VoEBase::GetInterface(voe_)) { |
| 24 | EXPECT_NE(nullptr, base_); |
| 25 | apm_ = new rtc::RefCountedObject<test::MockAudioProcessing>(); |
| 26 | } |
| 27 | |
| 28 | ~VoEBaseTest() { |
| 29 | EXPECT_EQ(0, base_->Terminate()); |
| 30 | EXPECT_EQ(1, base_->Release()); |
| 31 | EXPECT_TRUE(VoiceEngine::Delete(voe_)); |
| 32 | } |
| 33 | |
| 34 | VoiceEngine* voe_; |
| 35 | VoEBase* base_; |
| 36 | FakeAudioDeviceModule adm_; |
| 37 | rtc::scoped_refptr<AudioProcessing> apm_; |
| 38 | }; |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 39 | |
Jelena Marusic | 0b15445 | 2015-05-04 09:55:59 +0200 | [diff] [blame] | 40 | TEST_F(VoEBaseTest, InitWithExternalAudioDevice) { |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 41 | EXPECT_EQ(0, base_->Init(&adm_, apm_.get())); |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Jelena Marusic | 0b15445 | 2015-05-04 09:55:59 +0200 | [diff] [blame] | 44 | TEST_F(VoEBaseTest, CreateChannelAfterInit) { |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 45 | EXPECT_EQ(0, base_->Init(&adm_, apm_.get(), nullptr)); |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame] | 46 | int channelID = base_->CreateChannel(); |
Jelena Marusic | 46bd31b | 2015-04-30 10:57:10 +0200 | [diff] [blame] | 47 | EXPECT_NE(channelID, -1); |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame] | 48 | EXPECT_EQ(0, base_->DeleteChannel(channelID)); |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 49 | } |
| 50 | |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 51 | } // namespace webrtc |