| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/voice_engine/include/voe_base.h" | 11 #include "webrtc/voice_engine/include/voe_base.h" |
| 12 | 12 |
| 13 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 13 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 14 #include "webrtc/test/gtest.h" | 14 #include "webrtc/test/gtest.h" |
| 15 #include "webrtc/voice_engine/channel_manager.h" | 15 #include "webrtc/voice_engine/channel_manager.h" |
| 16 #include "webrtc/voice_engine/shared_data.h" | 16 #include "webrtc/voice_engine/shared_data.h" |
| 17 #include "webrtc/voice_engine/voice_engine_fixture.h" | 17 #include "webrtc/voice_engine/voice_engine_fixture.h" |
| 18 #include "webrtc/voice_engine/voice_engine_impl.h" | 18 #include "webrtc/voice_engine/voice_engine_impl.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 | 21 |
| 22 class VoEBaseTest : public VoiceEngineFixture {}; | 22 class VoEBaseTest : public VoiceEngineFixture {}; |
| 23 | 23 |
| 24 TEST_F(VoEBaseTest, InitWithExternalAudioDeviceAndAudioProcessing) { | 24 TEST_F(VoEBaseTest, InitWithExternalAudioDevice) { |
| 25 AudioProcessing* audioproc = AudioProcessing::Create(); | 25 EXPECT_EQ(0, base_->Init(&adm_, apm_.get())); |
| 26 EXPECT_EQ(0, base_->Init(&adm_, audioproc)); | |
| 27 EXPECT_EQ(audioproc, base_->audio_processing()); | |
| 28 EXPECT_EQ(0, base_->LastError()); | 26 EXPECT_EQ(0, base_->LastError()); |
| 29 } | 27 } |
| 30 | 28 |
| 31 TEST_F(VoEBaseTest, InitWithExternalAudioDevice) { | |
| 32 EXPECT_EQ(nullptr, base_->audio_processing()); | |
| 33 EXPECT_EQ(0, base_->Init(&adm_, nullptr)); | |
| 34 EXPECT_NE(nullptr, base_->audio_processing()); | |
| 35 EXPECT_EQ(0, base_->LastError()); | |
| 36 } | |
| 37 | |
| 38 TEST_F(VoEBaseTest, CreateChannelBeforeInitShouldFail) { | 29 TEST_F(VoEBaseTest, CreateChannelBeforeInitShouldFail) { |
| 39 int channelID = base_->CreateChannel(); | 30 int channelID = base_->CreateChannel(); |
| 40 EXPECT_EQ(channelID, -1); | 31 EXPECT_EQ(channelID, -1); |
| 41 } | 32 } |
| 42 | 33 |
| 43 TEST_F(VoEBaseTest, CreateChannelAfterInit) { | 34 TEST_F(VoEBaseTest, CreateChannelAfterInit) { |
| 44 EXPECT_EQ(0, base_->Init(&adm_, nullptr)); | 35 EXPECT_EQ(0, base_->Init(&adm_, apm_.get(), nullptr)); |
| 45 int channelID = base_->CreateChannel(); | 36 int channelID = base_->CreateChannel(); |
| 46 EXPECT_NE(channelID, -1); | 37 EXPECT_NE(channelID, -1); |
| 47 EXPECT_EQ(0, base_->DeleteChannel(channelID)); | 38 EXPECT_EQ(0, base_->DeleteChannel(channelID)); |
| 48 } | 39 } |
| 49 | 40 |
| 50 TEST_F(VoEBaseTest, AssociateSendChannel) { | 41 TEST_F(VoEBaseTest, AssociateSendChannel) { |
| 51 AudioProcessing* audioproc = AudioProcessing::Create(); | 42 EXPECT_EQ(0, base_->Init(&adm_, apm_.get())); |
| 52 EXPECT_EQ(0, base_->Init(&adm_, audioproc)); | |
| 53 | 43 |
| 54 const int channel_1 = base_->CreateChannel(); | 44 const int channel_1 = base_->CreateChannel(); |
| 55 | 45 |
| 56 // Associating with a channel that does not exist should fail. | 46 // Associating with a channel that does not exist should fail. |
| 57 EXPECT_EQ(-1, base_->AssociateSendChannel(channel_1, channel_1 + 1)); | 47 EXPECT_EQ(-1, base_->AssociateSendChannel(channel_1, channel_1 + 1)); |
| 58 | 48 |
| 59 const int channel_2 = base_->CreateChannel(); | 49 const int channel_2 = base_->CreateChannel(); |
| 60 | 50 |
| 61 // Let the two channels associate with each other. This is not a normal use | 51 // Let the two channels associate with each other. This is not a normal use |
| 62 // case. Actually, circular association should be avoided in practice. This | 52 // case. Actually, circular association should be avoided in practice. This |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 EXPECT_EQ(1, reference.use_count()); | 68 EXPECT_EQ(1, reference.use_count()); |
| 79 } | 69 } |
| 80 | 70 |
| 81 TEST_F(VoEBaseTest, GetVersion) { | 71 TEST_F(VoEBaseTest, GetVersion) { |
| 82 char v1[1024] = {75}; | 72 char v1[1024] = {75}; |
| 83 base_->GetVersion(v1); | 73 base_->GetVersion(v1); |
| 84 std::string v2 = VoiceEngine::GetVersionString() + "\n"; | 74 std::string v2 = VoiceEngine::GetVersionString() + "\n"; |
| 85 EXPECT_EQ(v2, v1); | 75 EXPECT_EQ(v2, v1); |
| 86 } | 76 } |
| 87 } // namespace webrtc | 77 } // namespace webrtc |
| OLD | NEW |