OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2015 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 "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 #include "webrtc/audio/audio_state.h" |
| 14 #include "webrtc/base/scoped_ptr.h" |
| 15 #include "webrtc/test/fake_voice_engine.h" |
| 16 |
| 17 namespace webrtc { |
| 18 namespace test { |
| 19 namespace { |
| 20 |
| 21 struct ConfigHelper { |
| 22 ConfigHelper() { |
| 23 config_.voice_engine = &fake_voice_engine_; |
| 24 } |
| 25 AudioState::Config& config() { |
| 26 return config_; |
| 27 } |
| 28 FakeVoiceEngine& fake_voice_engine() { |
| 29 return fake_voice_engine_; |
| 30 } |
| 31 private: |
| 32 FakeVoiceEngine fake_voice_engine_; |
| 33 AudioState::Config config_; |
| 34 }; |
| 35 } // namespace |
| 36 |
| 37 TEST(AudioStateTest, Create) { |
| 38 ConfigHelper helper; |
| 39 rtc::linked_ptr<AudioState> audio_state = |
| 40 AudioState::Create(helper.config()); |
| 41 EXPECT_TRUE(audio_state.get()); |
| 42 } |
| 43 |
| 44 TEST(AudioStateTest, ConstructDestruct) { |
| 45 ConfigHelper helper; |
| 46 { |
| 47 rtc::scoped_ptr<internal::AudioState> audio_state( |
| 48 new internal::AudioState(helper.config())); |
| 49 EXPECT_TRUE(audio_state.get()); |
| 50 // TODO(solenberg): Add these once FakeVoiceEngine has been turned into a |
| 51 // proper mock. |
| 52 // EXPECT_CALL(helper.fake_voice_engine(), |
| 53 // RegisterVoiceEngineObserver(audio_state.get())).Times(1); |
| 54 } |
| 55 // EXPECT_CALL(helper.fake_voice_engine(), |
| 56 // DeRegisterVoiceEngineObserver()).Times(1); |
| 57 } |
| 58 |
| 59 TEST(AudioStateTest, GetVoiceEngine) { |
| 60 ConfigHelper helper; |
| 61 rtc::scoped_ptr<internal::AudioState> audio_state( |
| 62 new internal::AudioState(helper.config())); |
| 63 EXPECT_EQ(audio_state->voice_engine(), &helper.fake_voice_engine()); |
| 64 } |
| 65 |
| 66 TEST(AudioStateTest, TypingNoiseDetected) { |
| 67 ConfigHelper helper; |
| 68 rtc::scoped_ptr<internal::AudioState> audio_state( |
| 69 new internal::AudioState(helper.config())); |
| 70 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 71 |
| 72 audio_state->CallbackOnError(-1, VE_NOT_INITED); |
| 73 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 74 |
| 75 audio_state->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); |
| 76 EXPECT_TRUE(audio_state->typing_noise_detected()); |
| 77 audio_state->CallbackOnError(-1, VE_NOT_INITED); |
| 78 EXPECT_TRUE(audio_state->typing_noise_detected()); |
| 79 |
| 80 audio_state->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
| 81 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 82 audio_state->CallbackOnError(-1, VE_NOT_INITED); |
| 83 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 84 } |
| 85 } // namespace test |
| 86 } // namespace webrtc |
OLD | NEW |