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 ON_CALL(voice_engine_, audio_device_module()) |
| 32 .WillByDefault(Return(&mock_audio_device_)); |
27 config_.voice_engine = &voice_engine_; | 33 config_.voice_engine = &voice_engine_; |
28 } | 34 } |
29 AudioState::Config& config() { return config_; } | 35 AudioState::Config& config() { return config_; } |
30 MockVoiceEngine& voice_engine() { return voice_engine_; } | 36 MockVoiceEngine& voice_engine() { return voice_engine_; } |
31 | 37 |
32 private: | 38 private: |
33 testing::StrictMock<MockVoiceEngine> voice_engine_; | 39 testing::StrictMock<MockVoiceEngine> voice_engine_; |
| 40 testing::NiceMock<webrtc::test::MockAudioDeviceModule> mock_audio_device_; |
34 AudioState::Config config_; | 41 AudioState::Config config_; |
35 }; | 42 }; |
36 } // namespace | 43 } // namespace |
37 | 44 |
38 TEST(AudioStateTest, Create) { | 45 TEST(AudioStateTest, Create) { |
39 ConfigHelper helper; | 46 ConfigHelper helper; |
40 rtc::scoped_refptr<AudioState> audio_state = | 47 rtc::scoped_refptr<AudioState> audio_state = |
41 AudioState::Create(helper.config()); | 48 AudioState::Create(helper.config()); |
42 EXPECT_TRUE(audio_state.get()); | 49 EXPECT_TRUE(audio_state.get()); |
43 } | 50 } |
(...skipping 27 matching lines...) Expand all Loading... |
71 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 78 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
72 EXPECT_TRUE(audio_state->typing_noise_detected()); | 79 EXPECT_TRUE(audio_state->typing_noise_detected()); |
73 | 80 |
74 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 81 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
75 EXPECT_FALSE(audio_state->typing_noise_detected()); | 82 EXPECT_FALSE(audio_state->typing_noise_detected()); |
76 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 83 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
77 EXPECT_FALSE(audio_state->typing_noise_detected()); | 84 EXPECT_FALSE(audio_state->typing_noise_detected()); |
78 } | 85 } |
79 } // namespace test | 86 } // namespace test |
80 } // namespace webrtc | 87 } // namespace webrtc |
OLD | NEW |