Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: webrtc/audio/audio_state_unittest.cc

Issue 1403363003: Move VoiceEngineObserver into AudioSendStream so that we detect typing noises and return properly i… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: that's all folks! (incl rebase), or is it? Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/audio/audio_state.cc ('k') | webrtc/audio/webrtc_audio.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/mock_voice_engine.h"
16
17 namespace webrtc {
18 namespace test {
19 namespace {
20
21 struct ConfigHelper {
22 ConfigHelper() {
23 EXPECT_CALL(voice_engine_,
24 RegisterVoiceEngineObserver(testing::_)).WillOnce(testing::Return(0));
25 EXPECT_CALL(voice_engine_,
26 DeRegisterVoiceEngineObserver()).WillOnce(testing::Return(0));
27 config_.voice_engine = &voice_engine_;
28 }
29 AudioState::Config& config() { return config_; }
30 MockVoiceEngine& voice_engine() { return voice_engine_; }
31
32 private:
33 MockVoiceEngine voice_engine_;
34 AudioState::Config config_;
35 };
36 } // namespace
37
38 TEST(AudioStateTest, Create) {
39 ConfigHelper helper;
40 rtc::scoped_refptr<AudioState> audio_state =
41 AudioState::Create(helper.config());
42 EXPECT_TRUE(audio_state.get());
43 }
44
45 TEST(AudioStateTest, ConstructDestruct) {
46 ConfigHelper helper;
47 rtc::scoped_ptr<internal::AudioState> audio_state(
48 new internal::AudioState(helper.config()));
49 }
50
51 TEST(AudioStateTest, GetVoiceEngine) {
52 ConfigHelper helper;
53 rtc::scoped_ptr<internal::AudioState> audio_state(
54 new internal::AudioState(helper.config()));
55 EXPECT_EQ(audio_state->voice_engine(), &helper.voice_engine());
56 }
57
58 TEST(AudioStateTest, TypingNoiseDetected) {
59 ConfigHelper helper;
60 rtc::scoped_ptr<internal::AudioState> audio_state(
61 new internal::AudioState(helper.config()));
62 VoiceEngineObserver* voe_observer =
63 static_cast<VoiceEngineObserver*>(audio_state.get());
64 EXPECT_FALSE(audio_state->typing_noise_detected());
65
66 voe_observer->CallbackOnError(-1, VE_NOT_INITED);
67 EXPECT_FALSE(audio_state->typing_noise_detected());
68
69 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_WARNING);
70 EXPECT_TRUE(audio_state->typing_noise_detected());
71 voe_observer->CallbackOnError(-1, VE_NOT_INITED);
72 EXPECT_TRUE(audio_state->typing_noise_detected());
73
74 voe_observer->CallbackOnError(-1, VE_TYPING_NOISE_OFF_WARNING);
75 EXPECT_FALSE(audio_state->typing_noise_detected());
76 voe_observer->CallbackOnError(-1, VE_NOT_INITED);
77 EXPECT_FALSE(audio_state->typing_noise_detected());
78 }
79 } // namespace test
80 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_state.cc ('k') | webrtc/audio/webrtc_audio.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698