| Index: webrtc/audio/audio_send_stream_unittest.cc
|
| diff --git a/webrtc/audio/audio_send_stream_unittest.cc b/webrtc/audio/audio_send_stream_unittest.cc
|
| index 227ec8379971f3e6c2ad73b52acf75872e27a08a..592509aebf2964ffb22edd09ddd6118c61add660 100644
|
| --- a/webrtc/audio/audio_send_stream_unittest.cc
|
| +++ b/webrtc/audio/audio_send_stream_unittest.cc
|
| @@ -11,11 +11,35 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| #include "webrtc/audio/audio_send_stream.h"
|
| +#include "webrtc/audio/audio_state.h"
|
| #include "webrtc/audio/conversion.h"
|
| +#include "webrtc/base/scoped_ptr.h"
|
| #include "webrtc/test/fake_voice_engine.h"
|
|
|
| namespace webrtc {
|
| namespace test {
|
| +namespace {
|
| +
|
| +struct ConfigHelper {
|
| + ConfigHelper() : stream_config_(nullptr) {
|
| + AudioState::Config config;
|
| + config.voice_engine = &voice_engine_;
|
| + audio_state_.reset(new internal::AudioState(config));
|
| + }
|
| +
|
| + AudioSendStream::Config& config() {
|
| + return stream_config_;
|
| + }
|
| + internal::AudioState* audio_state() {
|
| + return audio_state_.get();
|
| + }
|
| +
|
| + private:
|
| + FakeVoiceEngine voice_engine_;
|
| + rtc::scoped_ptr<internal::AudioState> audio_state_;
|
| + AudioSendStream::Config stream_config_;
|
| +};
|
| +} // namespace
|
|
|
| TEST(AudioSendStreamTest, ConfigToString) {
|
| const int kAbsSendTimeId = 3;
|
| @@ -33,18 +57,16 @@ TEST(AudioSendStreamTest, ConfigToString) {
|
| }
|
|
|
| TEST(AudioSendStreamTest, ConstructDestruct) {
|
| - FakeVoiceEngine voice_engine;
|
| - AudioSendStream::Config config(nullptr);
|
| - config.voe_channel_id = 1;
|
| - internal::AudioSendStream send_stream(config, &voice_engine);
|
| + ConfigHelper helper;
|
| + helper.config().voe_channel_id = 1;
|
| + internal::AudioSendStream send_stream(helper.config(), helper.audio_state());
|
| }
|
|
|
| TEST(AudioSendStreamTest, GetStats) {
|
| - FakeVoiceEngine voice_engine;
|
| - AudioSendStream::Config config(nullptr);
|
| - config.rtp.ssrc = FakeVoiceEngine::kSendSsrc;
|
| - config.voe_channel_id = FakeVoiceEngine::kSendChannelId;
|
| - internal::AudioSendStream send_stream(config, &voice_engine);
|
| + ConfigHelper helper;
|
| + helper.config().rtp.ssrc = FakeVoiceEngine::kSendSsrc;
|
| + helper.config().voe_channel_id = FakeVoiceEngine::kSendChannelId;
|
| + internal::AudioSendStream send_stream(helper.config(), helper.audio_state());
|
|
|
| AudioSendStream::Stats stats = send_stream.GetStats();
|
| const CallStatistics& call_stats = FakeVoiceEngine::kSendCallStats;
|
| @@ -72,5 +94,18 @@ TEST(AudioSendStreamTest, GetStats) {
|
| stats.echo_return_loss_enhancement);
|
| EXPECT_FALSE(stats.typing_noise_detected);
|
| }
|
| +
|
| +TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) {
|
| + ConfigHelper helper;
|
| + helper.config().voe_channel_id = 1;
|
| + internal::AudioSendStream send_stream(helper.config(), helper.audio_state());
|
| + EXPECT_FALSE(send_stream.GetStats().typing_noise_detected);
|
| +
|
| + internal::AudioState* audio_state = helper.audio_state();
|
| + audio_state->CallbackOnError(-1, VE_TYPING_NOISE_WARNING);
|
| + EXPECT_TRUE(send_stream.GetStats().typing_noise_detected);
|
| + audio_state->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING);
|
| + EXPECT_FALSE(send_stream.GetStats().typing_noise_detected);
|
| +}
|
| } // namespace test
|
| } // namespace webrtc
|
|
|