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 | |
| 11 | #include "webrtc/voice_engine/include/voe_base.h" |
| 12 | |
| 13 | #include "testing/gtest/include/gtest/gtest.h" |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 14 | #include "webrtc/modules/audio_device/include/fake_audio_device.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 15 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 16 | #include "webrtc/voice_engine/mock/mock_voe_observer.h" |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | class VoEBaseTest : public ::testing::Test { |
| 21 | protected: |
| 22 | VoEBaseTest() : |
| 23 | voe_(VoiceEngine::Create()), |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 24 | base_(VoEBase::GetInterface(voe_)) { |
| 25 | EXPECT_NE(nullptr, base_); |
| 26 | EXPECT_EQ(0, base_->RegisterVoiceEngineObserver(observer_)); |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | ~VoEBaseTest() { |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 30 | 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.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | VoiceEngine* voe_; |
| 37 | VoEBase* base_; |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 38 | MockVoEObserver observer_; |
| 39 | FakeAudioDeviceModule adm_; |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 42 | TEST_F(VoEBaseTest, InitWithExternalAudioDeviceAndAudioProcessing) { |
andrew@webrtc.org | 46323b3 | 2015-01-13 06:48:06 +0000 | [diff] [blame] | 43 | AudioProcessing* audioproc = AudioProcessing::Create(); |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 44 | EXPECT_EQ(0, base_->Init(&adm_, audioproc)); |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 45 | EXPECT_EQ(audioproc, base_->audio_processing()); |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 46 | EXPECT_EQ(0, base_->LastError()); |
andrew@webrtc.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Jelena Marusic | 06b08af | 2015-04-21 11:39:57 +0200 | [diff] [blame^] | 49 | TEST_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 | |
| 56 | TEST_F(VoEBaseTest, CreateChannelBeforeInitShouldFail) { |
| 57 | int channelID = base_->CreateChannel(); |
| 58 | EXPECT_EQ(-1, channelID); |
| 59 | } |
| 60 | |
| 61 | TEST_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.org | f0a90c3 | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | } // namespace webrtc |