| 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> |
| 12 |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 #include "webrtc/audio/audio_state.h" | 15 #include "webrtc/audio/audio_state.h" |
| 14 #include "webrtc/base/scoped_ptr.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)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 TEST(AudioStateTest, Create) { | 39 TEST(AudioStateTest, Create) { |
| 39 ConfigHelper helper; | 40 ConfigHelper helper; |
| 40 rtc::scoped_refptr<AudioState> audio_state = | 41 rtc::scoped_refptr<AudioState> audio_state = |
| 41 AudioState::Create(helper.config()); | 42 AudioState::Create(helper.config()); |
| 42 EXPECT_TRUE(audio_state.get()); | 43 EXPECT_TRUE(audio_state.get()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 TEST(AudioStateTest, ConstructDestruct) { | 46 TEST(AudioStateTest, ConstructDestruct) { |
| 46 ConfigHelper helper; | 47 ConfigHelper helper; |
| 47 rtc::scoped_ptr<internal::AudioState> audio_state( | 48 std::unique_ptr<internal::AudioState> audio_state( |
| 48 new internal::AudioState(helper.config())); | 49 new internal::AudioState(helper.config())); |
| 49 } | 50 } |
| 50 | 51 |
| 51 TEST(AudioStateTest, GetVoiceEngine) { | 52 TEST(AudioStateTest, GetVoiceEngine) { |
| 52 ConfigHelper helper; | 53 ConfigHelper helper; |
| 53 rtc::scoped_ptr<internal::AudioState> audio_state( | 54 std::unique_ptr<internal::AudioState> audio_state( |
| 54 new internal::AudioState(helper.config())); | 55 new internal::AudioState(helper.config())); |
| 55 EXPECT_EQ(audio_state->voice_engine(), &helper.voice_engine()); | 56 EXPECT_EQ(audio_state->voice_engine(), &helper.voice_engine()); |
| 56 } | 57 } |
| 57 | 58 |
| 58 TEST(AudioStateTest, TypingNoiseDetected) { | 59 TEST(AudioStateTest, TypingNoiseDetected) { |
| 59 ConfigHelper helper; | 60 ConfigHelper helper; |
| 60 rtc::scoped_ptr<internal::AudioState> audio_state( | 61 std::unique_ptr<internal::AudioState> audio_state( |
| 61 new internal::AudioState(helper.config())); | 62 new internal::AudioState(helper.config())); |
| 62 VoiceEngineObserver* voe_observer = | 63 VoiceEngineObserver* voe_observer = |
| 63 static_cast<VoiceEngineObserver*>(audio_state.get()); | 64 static_cast<VoiceEngineObserver*>(audio_state.get()); |
| 64 EXPECT_FALSE(audio_state->typing_noise_detected()); | 65 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 65 | 66 |
| 66 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 67 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
| 67 EXPECT_FALSE(audio_state->typing_noise_detected()); | 68 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 68 | 69 |
| 69 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); | 70 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING); |
| 70 EXPECT_TRUE(audio_state->typing_noise_detected()); | 71 EXPECT_TRUE(audio_state->typing_noise_detected()); |
| 71 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 72 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
| 72 EXPECT_TRUE(audio_state->typing_noise_detected()); | 73 EXPECT_TRUE(audio_state->typing_noise_detected()); |
| 73 | 74 |
| 74 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); | 75 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING); |
| 75 EXPECT_FALSE(audio_state->typing_noise_detected()); | 76 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 76 voe_observer->CallbackOnError(-1, VE_NOT_INITED); | 77 voe_observer->CallbackOnError(-1, VE_NOT_INITED); |
| 77 EXPECT_FALSE(audio_state->typing_noise_detected()); | 78 EXPECT_FALSE(audio_state->typing_noise_detected()); |
| 78 } | 79 } |
| 79 } // namespace test | 80 } // namespace test |
| 80 } // namespace webrtc | 81 } // namespace webrtc |
| OLD | NEW |