OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 <memory> | 11 #include <memory> |
12 | 12 |
13 #include "webrtc/audio/audio_state.h" | 13 #include "webrtc/audio/audio_state.h" |
| 14 #include "webrtc/modules/audio_device/include/mock_audio_device.h" |
14 #include "webrtc/test/gtest.h" | 15 #include "webrtc/test/gtest.h" |
15 #include "webrtc/test/mock_voice_engine.h" | 16 #include "webrtc/test/mock_voice_engine.h" |
16 | 17 |
17 namespace webrtc { | 18 namespace webrtc { |
18 namespace test { | 19 namespace test { |
19 namespace { | 20 namespace { |
20 | 21 |
21 struct ConfigHelper { | 22 struct ConfigHelper { |
22 ConfigHelper() { | 23 ConfigHelper() { |
23 EXPECT_CALL(voice_engine_, | 24 EXPECT_CALL(voice_engine_, |
24 RegisterVoiceEngineObserver(testing::_)).WillOnce(testing::Return(0)); | 25 RegisterVoiceEngineObserver(testing::_)).WillOnce(testing::Return(0)); |
25 EXPECT_CALL(voice_engine_, | 26 EXPECT_CALL(voice_engine_, DeRegisterVoiceEngineObserver()) |
26 DeRegisterVoiceEngineObserver()).WillOnce(testing::Return(0)); | 27 .WillOnce(testing::Return(0)); |
| 28 EXPECT_CALL(voice_engine_, audio_transport()); |
| 29 EXPECT_CALL(voice_engine_, audio_processing()); |
| 30 EXPECT_CALL(voice_engine_, audio_device_module()) |
| 31 .WillOnce(testing::Return(&mock_audio_device_)); |
27 config_.voice_engine = &voice_engine_; | 32 config_.voice_engine = &voice_engine_; |
28 } | 33 } |
29 AudioState::Config& config() { return config_; } | 34 AudioState::Config& config() { return config_; } |
30 MockVoiceEngine& voice_engine() { return voice_engine_; } | 35 MockVoiceEngine& voice_engine() { return voice_engine_; } |
31 | 36 |
32 private: | 37 private: |
33 testing::StrictMock<MockVoiceEngine> voice_engine_; | 38 testing::StrictMock<MockVoiceEngine> voice_engine_; |
| 39 MockAudioDeviceModule mock_audio_device_; |
34 AudioState::Config config_; | 40 AudioState::Config config_; |
35 }; | 41 }; |
36 } // namespace | 42 } // namespace |
37 | 43 |
38 TEST(AudioStateTest, Create) { | 44 TEST(AudioStateTest, Create) { |
39 ConfigHelper helper; | 45 ConfigHelper helper; |
40 rtc::scoped_refptr<AudioState> audio_state = | 46 rtc::scoped_refptr<AudioState> audio_state = |
41 AudioState::Create(helper.config()); | 47 AudioState::Create(helper.config()); |
42 EXPECT_TRUE(audio_state.get()); | 48 EXPECT_TRUE(audio_state.get()); |
43 } | 49 } |
(...skipping 27 matching lines...) Expand all Loading... |
71 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 77 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
72 EXPECT_TRUE(audio_state->typing_noise_detected()); | 78 EXPECT_TRUE(audio_state->typing_noise_detected()); |
73 | 79 |
74 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 80 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
75 EXPECT_FALSE(audio_state->typing_noise_detected()); | 81 EXPECT_FALSE(audio_state->typing_noise_detected()); |
76 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 82 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
77 EXPECT_FALSE(audio_state->typing_noise_detected()); | 83 EXPECT_FALSE(audio_state->typing_noise_detected()); |
78 } | 84 } |
79 } // namespace test | 85 } // namespace test |
80 } // namespace webrtc | 86 } // namespace webrtc |
OLD | NEW |