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

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

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

Powered by Google App Engine
This is Rietveld 408576698