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

Side by Side Diff: webrtc/api/localaudiosource_unittest.cc

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Rebase Created 3 years, 11 months 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/api/localaudiosource.cc ('k') | webrtc/api/mediaconstraintsinterface_unittest.cc » ('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 2013 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 "webrtc/api/localaudiosource.h"
12
13 #include <string>
14 #include <vector>
15
16 #include "webrtc/api/test/fakeconstraints.h"
17 #include "webrtc/base/gunit.h"
18 #include "webrtc/media/base/fakemediaengine.h"
19 #include "webrtc/media/base/fakevideorenderer.h"
20
21 using webrtc::LocalAudioSource;
22 using webrtc::MediaConstraintsInterface;
23 using webrtc::MediaSourceInterface;
24 using webrtc::PeerConnectionFactoryInterface;
25
26 TEST(LocalAudioSourceTest, SetValidOptions) {
27 webrtc::FakeConstraints constraints;
28 constraints.AddMandatory(
29 MediaConstraintsInterface::kGoogEchoCancellation, false);
30 constraints.AddOptional(
31 MediaConstraintsInterface::kExtendedFilterEchoCancellation, true);
32 constraints.AddOptional(MediaConstraintsInterface::kDAEchoCancellation, true);
33 constraints.AddOptional(MediaConstraintsInterface::kAutoGainControl, true);
34 constraints.AddOptional(
35 MediaConstraintsInterface::kExperimentalAutoGainControl, true);
36 constraints.AddMandatory(MediaConstraintsInterface::kNoiseSuppression, false);
37 constraints.AddOptional(MediaConstraintsInterface::kHighpassFilter, true);
38
39 rtc::scoped_refptr<LocalAudioSource> source =
40 LocalAudioSource::Create(PeerConnectionFactoryInterface::Options(),
41 &constraints);
42
43 EXPECT_EQ(rtc::Optional<bool>(false), source->options().echo_cancellation);
44 EXPECT_EQ(rtc::Optional<bool>(true), source->options().extended_filter_aec);
45 EXPECT_EQ(rtc::Optional<bool>(true), source->options().delay_agnostic_aec);
46 EXPECT_EQ(rtc::Optional<bool>(true), source->options().auto_gain_control);
47 EXPECT_EQ(rtc::Optional<bool>(true), source->options().experimental_agc);
48 EXPECT_EQ(rtc::Optional<bool>(false), source->options().noise_suppression);
49 EXPECT_EQ(rtc::Optional<bool>(true), source->options().highpass_filter);
50 }
51
52 TEST(LocalAudioSourceTest, OptionNotSet) {
53 webrtc::FakeConstraints constraints;
54 rtc::scoped_refptr<LocalAudioSource> source =
55 LocalAudioSource::Create(PeerConnectionFactoryInterface::Options(),
56 &constraints);
57 EXPECT_EQ(rtc::Optional<bool>(), source->options().highpass_filter);
58 }
59
60 TEST(LocalAudioSourceTest, MandatoryOverridesOptional) {
61 webrtc::FakeConstraints constraints;
62 constraints.AddMandatory(
63 MediaConstraintsInterface::kGoogEchoCancellation, false);
64 constraints.AddOptional(
65 MediaConstraintsInterface::kGoogEchoCancellation, true);
66
67 rtc::scoped_refptr<LocalAudioSource> source =
68 LocalAudioSource::Create(PeerConnectionFactoryInterface::Options(),
69 &constraints);
70
71 EXPECT_EQ(rtc::Optional<bool>(false), source->options().echo_cancellation);
72 }
73
74 TEST(LocalAudioSourceTest, InvalidOptional) {
75 webrtc::FakeConstraints constraints;
76 constraints.AddOptional(MediaConstraintsInterface::kHighpassFilter, false);
77 constraints.AddOptional("invalidKey", false);
78
79 rtc::scoped_refptr<LocalAudioSource> source =
80 LocalAudioSource::Create(PeerConnectionFactoryInterface::Options(),
81 &constraints);
82
83 EXPECT_EQ(MediaSourceInterface::kLive, source->state());
84 EXPECT_EQ(rtc::Optional<bool>(false), source->options().highpass_filter);
85 }
86
87 TEST(LocalAudioSourceTest, InvalidMandatory) {
88 webrtc::FakeConstraints constraints;
89 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false);
90 constraints.AddMandatory("invalidKey", false);
91
92 rtc::scoped_refptr<LocalAudioSource> source =
93 LocalAudioSource::Create(PeerConnectionFactoryInterface::Options(),
94 &constraints);
95
96 EXPECT_EQ(MediaSourceInterface::kLive, source->state());
97 EXPECT_EQ(rtc::Optional<bool>(false), source->options().highpass_filter);
98 }
99
100 TEST(LocalAudioSourceTest, InitWithAudioOptions) {
101 cricket::AudioOptions audio_options;
102 audio_options.highpass_filter = rtc::Optional<bool>(true);
103 rtc::scoped_refptr<LocalAudioSource> source = LocalAudioSource::Create(
104 PeerConnectionFactoryInterface::Options(), &audio_options);
105 EXPECT_EQ(rtc::Optional<bool>(true), source->options().highpass_filter);
106 }
107
108 TEST(LocalAudioSourceTest, InitWithNoOptions) {
109 rtc::scoped_refptr<LocalAudioSource> source =
110 LocalAudioSource::Create(PeerConnectionFactoryInterface::Options(),
111 (cricket::AudioOptions*)nullptr);
112 EXPECT_EQ(rtc::Optional<bool>(), source->options().highpass_filter);
113 }
OLDNEW
« no previous file with comments | « webrtc/api/localaudiosource.cc ('k') | webrtc/api/mediaconstraintsinterface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698