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

Side by Side Diff: content/renderer/media/media_stream_constraints_util_unittest.cc

Issue 227743004: Added a kEchoCancellation constraint to turn off the audio processing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "content/renderer/media/media_stream_audio_processor_options.h"
8 #include "content/renderer/media/media_stream_constraints_util.h"
9 #include "content/renderer/media/media_stream_video_source.h"
10 #include "content/renderer/media/mock_media_constraint_factory.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace content {
14
15 class MediaStreamConstraintsUtilTest : public testing::Test {
16 };
17
18 TEST_F(MediaStreamConstraintsUtilTest, BooleanConstraints) {
19 static const std::string kValueTrue = "true";
20 static const std::string kValueFalse = "false";
21
22 MockMediaConstraintFactory constraint_factory;
23 // Mandatory constraints.
24 constraint_factory.AddMandatory(MediaAudioConstraints::kEchoCancellation,
25 kValueTrue);
26 constraint_factory.AddMandatory(MediaAudioConstraints::kGoogEchoCancellation,
27 kValueFalse);
28 blink::WebMediaConstraints constraints =
29 constraint_factory.CreateWebMediaConstraints();
30 bool value_true = false;
31 bool value_false = false;
32 EXPECT_TRUE(GetMandatoryConstraintValueAsBoolean(
33 constraints, MediaAudioConstraints::kEchoCancellation, &value_true));
34 EXPECT_TRUE(GetMandatoryConstraintValueAsBoolean(
35 constraints, MediaAudioConstraints::kGoogEchoCancellation, &value_false));
36 EXPECT_TRUE(value_true);
37 EXPECT_FALSE(value_false);
38
39 // Optional constraints.
40 constraint_factory.AddOptional(MediaAudioConstraints::kEchoCancellation,
41 kValueFalse);
42 constraint_factory.AddOptional(MediaAudioConstraints::kGoogEchoCancellation,
43 kValueTrue);
44 constraints = constraint_factory.CreateWebMediaConstraints();
45 EXPECT_TRUE(GetOptionalConstraintValueAsBoolean(
46 constraints, MediaAudioConstraints::kEchoCancellation, &value_false));
47 EXPECT_TRUE(GetOptionalConstraintValueAsBoolean(
48 constraints, MediaAudioConstraints::kGoogEchoCancellation,
49 &value_true));
50 EXPECT_TRUE(value_true);
51 EXPECT_FALSE(value_false);
52 }
53
54 TEST_F(MediaStreamConstraintsUtilTest, IntConstraints) {
55 MockMediaConstraintFactory constraint_factory;
56 int width = 600;
57 int height = 480;
58 constraint_factory.AddMandatory(MediaStreamVideoSource::kMaxWidth, width);
59 constraint_factory.AddMandatory(MediaStreamVideoSource::kMaxHeight, height);
60 blink::WebMediaConstraints constraints =
61 constraint_factory.CreateWebMediaConstraints();
62 int value_width = 0;
63 int value_height = 0;
64 EXPECT_TRUE(GetMandatoryConstraintValueAsInteger(
65 constraints, MediaStreamVideoSource::kMaxWidth, &value_width));
66 EXPECT_TRUE(GetMandatoryConstraintValueAsInteger(
67 constraints, MediaStreamVideoSource::kMaxHeight, &value_height));
68 EXPECT_EQ(width, value_width);
69 EXPECT_EQ(height, value_height);
70
71 width = 720;
72 height = 600;
73 constraint_factory.AddOptional(MediaStreamVideoSource::kMaxWidth, width);
74 constraint_factory.AddOptional(MediaStreamVideoSource::kMaxHeight, height);
75 constraints = constraint_factory.CreateWebMediaConstraints();
76 EXPECT_TRUE(GetOptionalConstraintValueAsInteger(
77 constraints, MediaStreamVideoSource::kMaxWidth, &value_width));
78 EXPECT_TRUE(GetOptionalConstraintValueAsInteger(
79 constraints, MediaStreamVideoSource::kMaxHeight, &value_height));
80 EXPECT_EQ(width, value_width);
81 EXPECT_EQ(height, value_height);
82 }
83
84 TEST_F(MediaStreamConstraintsUtilTest, WrongBooleanConstraints) {
85 static const std::string kWrongValueTrue = "True";
86 static const std::string kWrongValueFalse = "False";
87 MockMediaConstraintFactory constraint_factory;
88 constraint_factory.AddMandatory(MediaAudioConstraints::kEchoCancellation,
89 kWrongValueTrue);
90 constraint_factory.AddMandatory(MediaAudioConstraints::kGoogEchoCancellation,
91 kWrongValueFalse);
92 blink::WebMediaConstraints constraints =
93 constraint_factory.CreateWebMediaConstraints();
94 bool value_false = false;
95 EXPECT_FALSE(GetMandatoryConstraintValueAsBoolean(
96 constraints, MediaAudioConstraints::kEchoCancellation, &value_false));
97 EXPECT_FALSE(value_false);
98 EXPECT_FALSE(GetMandatoryConstraintValueAsBoolean(
99 constraints, MediaAudioConstraints::kGoogEchoCancellation, &value_false));
100 EXPECT_FALSE(value_false);
101 }
102
103 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_constraints_util.cc ('k') | content/renderer/media/media_stream_dependency_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698