Chromium Code Reviews| 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/test/gtest.h" | 14 #include "webrtc/test/gtest.h" |
| 15 #include "webrtc/test/mock_voice_engine.h" | 15 #include "webrtc/test/mock_voice_engine.h" |
| 16 | 16 |
| 17 namespace webrtc { | 17 namespace webrtc { |
| 18 namespace test { | 18 namespace test { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 struct ConfigHelper { | 21 struct ConfigHelper { |
| 22 ConfigHelper() { | 22 ConfigHelper() { |
| 23 EXPECT_CALL(voice_engine_, | 23 EXPECT_CALL(voice_engine_, |
| 24 RegisterVoiceEngineObserver(testing::_)).WillOnce(testing::Return(0)); | 24 RegisterVoiceEngineObserver(testing::_)).WillOnce(testing::Return(0)); |
| 25 EXPECT_CALL(voice_engine_, | 25 EXPECT_CALL(voice_engine_, |
| 26 DeRegisterVoiceEngineObserver()).WillOnce(testing::Return(0)); | 26 DeRegisterVoiceEngineObserver()).WillOnce(testing::Return(0)); |
| 27 EXPECT_CALL(voice_engine_, audio_device_module()); | |
| 28 EXPECT_CALL(voice_engine_, audio_processing()); | |
| 29 EXPECT_CALL(voice_engine_, audio_transport()); | |
| 30 | |
| 27 config_.voice_engine = &voice_engine_; | 31 config_.voice_engine = &voice_engine_; |
| 28 } | 32 } |
| 29 AudioState::Config& config() { return config_; } | 33 AudioState::Config& config() { return config_; } |
| 30 MockVoiceEngine& voice_engine() { return voice_engine_; } | 34 MockVoiceEngine& voice_engine() { return voice_engine_; } |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 testing::StrictMock<MockVoiceEngine> voice_engine_; | 37 testing::StrictMock<MockVoiceEngine> voice_engine_; |
| 34 AudioState::Config config_; | 38 AudioState::Config config_; |
| 35 }; | 39 }; |
| 36 } // namespace | 40 } // namespace |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 73 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); |
| 70 EXPECT_TRUE(audio_state->typing_noise_detected()); | 74 EXPECT_TRUE(audio_state->typing_noise_detected()); |
| 71 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 75 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
| 72 EXPECT_TRUE(audio_state->typing_noise_detected()); | 76 EXPECT_TRUE(audio_state->typing_noise_detected()); |
| 73 | 77 |
| 74 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 78 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
| 75 EXPECT_FALSE(audio_state->typing_noise_detected()); | 79 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 76 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 80 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
| 77 EXPECT_FALSE(audio_state->typing_noise_detected()); | 81 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 78 } | 82 } |
| 83 | |
| 84 // Test that RecordedDataIsAvailable calls get to the original transport. | |
| 85 TEST(AudioStateTest, RecordedAudioArrivesAtOriginalTransport) { | |
| 86 using testing::_; | |
| 87 | |
| 88 ConfigHelper helper; | |
| 89 auto& voice_engine = helper.voice_engine(); | |
| 90 auto device = | |
| 91 static_cast<MockAudioDeviceModule*>(voice_engine.audio_device_module()); | |
| 92 | |
| 93 AudioTransport* audio_transport_proxy = nullptr; | |
| 94 ON_CALL(*device, RegisterAudioCallback(_)) | |
| 95 .WillByDefault( | |
| 96 testing::Invoke([&audio_transport_proxy](AudioTransport* transport) { | |
| 97 audio_transport_proxy = transport; | |
| 98 return 0; | |
| 99 })); | |
| 100 | |
| 101 MockAudioTransport original_audio_transport; | |
| 102 ON_CALL(voice_engine, audio_transport()) | |
| 103 .WillByDefault(testing::Return(&original_audio_transport)); | |
| 104 | |
| 105 EXPECT_CALL(voice_engine, audio_device_module()); | |
| 106 std::unique_ptr<internal::AudioState> audio_state( | |
| 107 new internal::AudioState(helper.config())); | |
| 108 | |
| 109 // Setup completed. Ensure call of old transport is forwarded to new. | |
| 110 uint32_t new_mic_level; | |
| 111 EXPECT_CALL(original_audio_transport, | |
| 112 RecordedDataIsAvailable(nullptr, 80, 2, 1, 8000, 0, 0, 0, false, | |
|
the sun
2016/11/14 13:50:08
Do you need to test the other forwarding calls as
aleloi
2016/11/14 14:24:42
I don't think so. The other calls are NeedMorePlay
| |
| 113 testing::Ref(new_mic_level))); | |
| 114 | |
| 115 audio_transport_proxy->RecordedDataIsAvailable(nullptr, 80, 2, 1, 8000, 0, 0, | |
| 116 0, false, new_mic_level); | |
| 117 } | |
| 79 } // namespace test | 118 } // namespace test |
| 80 } // namespace webrtc | 119 } // namespace webrtc |
| OLD | NEW |