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.
5 #include "base/command_line.h"
6 #include "base/debug/trace_event_impl.h"
7 #include "base/json/json_reader.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/test/trace_event_analyzer.h"
10 #include "base/values.h"
11 #include "content/browser/media/webrtc_internals.h"
12 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/public/common/content_switches.h"
14 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/content_browser_test_utils.h"
16 #include "content/public/test/test_utils.h"
17 #include "content/shell/browser/shell.h"
18 #include "content/test/webrtc_content_browsertest_base.h"
19 #include "net/test/embedded_test_server/embedded_test_server.h"
20 #include "testing/perf/perf_test.h"
23 #include "base/win/windows_version.h"
26 using trace_analyzer::TraceAnalyzer
;
27 using trace_analyzer::Query
;
28 using trace_analyzer::TraceEventVector
;
32 static const char kGetUserMediaAndStop
[] = "getUserMediaAndStop";
33 static const char kGetUserMediaAndGetStreamUp
[] = "getUserMediaAndGetStreamUp";
34 static const char kGetUserMediaAndAnalyseAndStop
[] =
35 "getUserMediaAndAnalyseAndStop";
36 static const char kGetUserMediaAndExpectFailure
[] =
37 "getUserMediaAndExpectFailure";
38 static const char kRenderSameTrackMediastreamAndStop
[] =
39 "renderSameTrackMediastreamAndStop";
40 static const char kRenderClonedMediastreamAndStop
[] =
41 "renderClonedMediastreamAndStop";
42 static const char kRenderClonedTrackMediastreamAndStop
[] =
43 "renderClonedTrackMediastreamAndStop";
44 static const char kRenderDuplicatedMediastreamAndStop
[] =
45 "renderDuplicatedMediastreamAndStop";
47 // Results returned by JS.
48 static const char kOK
[] = "OK";
50 std::string
GenerateGetUserMediaWithMandatorySourceID(
51 const std::string
& function_name
,
52 const std::string
& audio_source_id
,
53 const std::string
& video_source_id
) {
54 const std::string audio_constraint
=
55 "audio: {mandatory: { sourceId:\"" + audio_source_id
+ "\"}}, ";
57 const std::string video_constraint
=
58 "video: {mandatory: { sourceId:\"" + video_source_id
+ "\"}}";
59 return function_name
+ "({" + audio_constraint
+ video_constraint
+ "});";
62 std::string
GenerateGetUserMediaWithOptionalSourceID(
63 const std::string
& function_name
,
64 const std::string
& audio_source_id
,
65 const std::string
& video_source_id
) {
66 const std::string audio_constraint
=
67 "audio: {optional: [{sourceId:\"" + audio_source_id
+ "\"}]}, ";
69 const std::string video_constraint
=
70 "video: {optional: [{ sourceId:\"" + video_source_id
+ "\"}]}";
71 return function_name
+ "({" + audio_constraint
+ video_constraint
+ "});";
78 class WebRtcGetUserMediaBrowserTest
: public WebRtcContentBrowserTest
{
80 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL
) {}
81 virtual ~WebRtcGetUserMediaBrowserTest() {}
84 CHECK(trace_log_
== NULL
) << "Can only can start tracing once";
85 trace_log_
= base::debug::TraceLog::GetInstance();
86 base::debug::TraceOptions
trace_options(base::debug::RECORD_UNTIL_FULL
);
87 trace_options
.enable_sampling
= true;
88 trace_log_
->SetEnabled(base::debug::CategoryFilter("video"),
89 base::debug::TraceLog::RECORDING_MODE
,
91 // Check that we are indeed recording.
92 EXPECT_EQ(trace_log_
->GetNumTracesRecorded(), 1);
96 CHECK(message_loop_runner_
.get() == NULL
)
97 << "Calling StopTracing more than once";
98 trace_log_
->SetDisabled();
99 message_loop_runner_
= new MessageLoopRunner
;
100 trace_log_
->Flush(base::Bind(
101 &WebRtcGetUserMediaBrowserTest::OnTraceDataCollected
,
102 base::Unretained(this)));
103 message_loop_runner_
->Run();
106 void OnTraceDataCollected(
107 const scoped_refptr
<base::RefCountedString
>& events_str_ptr
,
108 bool has_more_events
) {
109 CHECK(!has_more_events
);
110 recorded_trace_data_
= events_str_ptr
;
111 message_loop_runner_
->Quit();
114 TraceAnalyzer
* CreateTraceAnalyzer() {
115 return TraceAnalyzer::Create("[" + recorded_trace_data_
->data() + "]");
118 void RunGetUserMediaAndCollectMeasures(const int time_to_sample_secs
,
119 const std::string
& measure_filter
,
120 const std::string
& graph_name
) {
121 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
123 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
124 NavigateToURL(shell(), url
);
126 // Put getUserMedia to work and let it run for a couple of seconds.
127 DCHECK(time_to_sample_secs
);
128 ExecuteJavascriptAndWaitForOk(
129 base::StringPrintf("%s({video: true});",
130 kGetUserMediaAndGetStreamUp
));
132 // Now the stream is up and running, start collecting traces.
135 // Let the stream run for a while in javascript.
136 ExecuteJavascriptAndWaitForOk(
137 base::StringPrintf("waitAndStopVideoTrack(%d);", time_to_sample_secs
));
139 // Wait until the page title changes to "OK". Do not sleep() here since that
140 // would stop both this code and the browser underneath.
143 scoped_ptr
<TraceAnalyzer
> analyzer(CreateTraceAnalyzer());
144 analyzer
->AssociateBeginEndEvents();
145 trace_analyzer::TraceEventVector events
;
146 DCHECK(measure_filter
.size());
147 analyzer
->FindEvents(
148 Query::EventNameIs(measure_filter
),
150 ASSERT_GT(events
.size(), 0u)
151 << "Could not collect any samples during test, this is bad";
153 std::string duration_us
;
154 std::string interarrival_us
;
155 for (size_t i
= 0; i
!= events
.size(); ++i
) {
157 base::StringPrintf("%d,", static_cast<int>(events
[i
]->duration
)));
160 for (size_t i
= 1; i
< events
.size(); ++i
) {
161 // The event |timestamp| comes in ns, divide to get us like |duration|.
162 interarrival_us
.append(base::StringPrintf("%d,",
163 static_cast<int>((events
[i
]->timestamp
- events
[i
- 1]->timestamp
) /
164 base::Time::kNanosecondsPerMicrosecond
)));
167 perf_test::PrintResultList(
168 graph_name
, "", "sample_duration", duration_us
, "us", true);
170 perf_test::PrintResultList(
171 graph_name
, "", "interarrival_time", interarrival_us
, "us", true);
174 // Runs the JavaScript twoGetUserMedia with |constraints1| and |constraint2|.
175 void RunTwoGetTwoGetUserMediaWithDifferentContraints(
176 const std::string
& constraints1
,
177 const std::string
& constraints2
,
178 const std::string
& expected_result
) {
179 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
181 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
182 NavigateToURL(shell(), url
);
184 std::string command
= "twoGetUserMedia(" + constraints1
+ ',' +
187 EXPECT_EQ(expected_result
, ExecuteJavascriptAndReturnResult(command
));
190 void GetInputDevices(std::vector
<std::string
>* audio_ids
,
191 std::vector
<std::string
>* video_ids
) {
192 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
193 NavigateToURL(shell(), url
);
195 std::string devices_as_json
= ExecuteJavascriptAndReturnResult(
197 EXPECT_FALSE(devices_as_json
.empty());
200 std::string error_message
;
201 scoped_ptr
<base::Value
> value(
202 base::JSONReader::ReadAndReturnError(devices_as_json
,
203 base::JSON_ALLOW_TRAILING_COMMAS
,
207 ASSERT_TRUE(value
.get() != NULL
) << error_message
;
208 EXPECT_EQ(value
->GetType(), base::Value::TYPE_LIST
);
210 base::ListValue
* values
;
211 ASSERT_TRUE(value
->GetAsList(&values
));
213 for (base::ListValue::iterator it
= values
->begin();
214 it
!= values
->end(); ++it
) {
215 const base::DictionaryValue
* dict
;
217 std::string device_id
;
218 ASSERT_TRUE((*it
)->GetAsDictionary(&dict
));
219 ASSERT_TRUE(dict
->GetString("kind", &kind
));
220 ASSERT_TRUE(dict
->GetString("id", &device_id
));
221 ASSERT_FALSE(device_id
.empty());
222 EXPECT_TRUE(kind
== "audio" || kind
== "video");
223 if (kind
== "audio") {
224 audio_ids
->push_back(device_id
);
225 } else if (kind
== "video") {
226 video_ids
->push_back(device_id
);
229 ASSERT_FALSE(audio_ids
->empty());
230 ASSERT_FALSE(video_ids
->empty());
234 base::debug::TraceLog
* trace_log_
;
235 scoped_refptr
<base::RefCountedString
> recorded_trace_data_
;
236 scoped_refptr
<MessageLoopRunner
> message_loop_runner_
;
239 // These tests will all make a getUserMedia call with different constraints and
240 // see that the success callback is called. If the error callback is called or
241 // none of the callbacks are called the tests will simply time out and fail.
242 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
, GetVideoStreamAndStop
) {
243 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
245 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
246 NavigateToURL(shell(), url
);
248 ExecuteJavascriptAndWaitForOk(
249 base::StringPrintf("%s({video: true});", kGetUserMediaAndStop
));
252 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
253 RenderSameTrackMediastreamAndStop
) {
254 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
256 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
257 NavigateToURL(shell(), url
);
259 ExecuteJavascriptAndWaitForOk(
260 base::StringPrintf("%s({video: true});",
261 kRenderSameTrackMediastreamAndStop
));
264 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
265 RenderClonedMediastreamAndStop
) {
266 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
268 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
269 NavigateToURL(shell(), url
);
272 ExecuteJavascriptAndWaitForOk(
273 base::StringPrintf("%s({video: true});",
274 kRenderClonedMediastreamAndStop
));
277 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
278 kRenderClonedTrackMediastreamAndStop
) {
279 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
281 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
282 NavigateToURL(shell(), url
);
284 ExecuteJavascriptAndWaitForOk(
285 base::StringPrintf("%s({video: true});",
286 kRenderClonedTrackMediastreamAndStop
));
289 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
290 kRenderDuplicatedMediastreamAndStop
) {
291 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
293 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
294 NavigateToURL(shell(), url
);
296 ExecuteJavascriptAndWaitForOk(
297 base::StringPrintf("%s({video: true});",
298 kRenderDuplicatedMediastreamAndStop
));
301 // Flaky on Android. http://crbug.com/387895
302 #if defined(OS_ANDROID)
303 #define MAYBE_GetAudioAndVideoStreamAndStop DISABLED_GetAudioAndVideoStreamAndStop
305 #define MAYBE_GetAudioAndVideoStreamAndStop GetAudioAndVideoStreamAndStop
308 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
309 MAYBE_GetAudioAndVideoStreamAndStop
) {
310 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
312 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
313 NavigateToURL(shell(), url
);
315 ExecuteJavascriptAndWaitForOk(base::StringPrintf(
316 "%s({video: true, audio: true});", kGetUserMediaAndStop
));
319 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
320 GetAudioAndVideoStreamAndClone
) {
321 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
323 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
324 NavigateToURL(shell(), url
);
326 ExecuteJavascriptAndWaitForOk("getUserMediaAndClone();");
329 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
330 RenderVideoTrackInMultipleTagsAndPause
) {
331 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
333 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
334 NavigateToURL(shell(), url
);
336 ExecuteJavascriptAndWaitForOk("getUserMediaAndRenderInSeveralVideoTags();");
341 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
342 GetUserMediaWithMandatorySourceID
) {
343 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
345 std::vector
<std::string
> audio_ids
;
346 std::vector
<std::string
> video_ids
;
347 GetInputDevices(&audio_ids
, &video_ids
);
349 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
351 // Test all combinations of mandatory sourceID;
352 for (std::vector
<std::string
>::const_iterator video_it
= video_ids
.begin();
353 video_it
!= video_ids
.end(); ++video_it
) {
354 for (std::vector
<std::string
>::const_iterator audio_it
= audio_ids
.begin();
355 audio_it
!= audio_ids
.end(); ++audio_it
) {
356 NavigateToURL(shell(), url
);
357 EXPECT_EQ(kOK
, ExecuteJavascriptAndReturnResult(
358 GenerateGetUserMediaWithMandatorySourceID(
359 kGetUserMediaAndStop
,
366 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
367 GetUserMediaWithInvalidMandatorySourceID
) {
368 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
370 std::vector
<std::string
> audio_ids
;
371 std::vector
<std::string
> video_ids
;
372 GetInputDevices(&audio_ids
, &video_ids
);
374 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
376 // Test with invalid mandatory audio sourceID.
377 NavigateToURL(shell(), url
);
378 EXPECT_EQ("DevicesNotFoundError", ExecuteJavascriptAndReturnResult(
379 GenerateGetUserMediaWithMandatorySourceID(
380 kGetUserMediaAndExpectFailure
,
384 // Test with invalid mandatory video sourceID.
385 EXPECT_EQ("DevicesNotFoundError", ExecuteJavascriptAndReturnResult(
386 GenerateGetUserMediaWithMandatorySourceID(
387 kGetUserMediaAndExpectFailure
,
389 "something invalid")));
391 // Test with empty mandatory audio sourceID.
392 EXPECT_EQ("DevicesNotFoundError", ExecuteJavascriptAndReturnResult(
393 GenerateGetUserMediaWithMandatorySourceID(
394 kGetUserMediaAndExpectFailure
,
399 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
400 GetUserMediaWithInvalidOptionalSourceID
) {
401 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
403 std::vector
<std::string
> audio_ids
;
404 std::vector
<std::string
> video_ids
;
405 GetInputDevices(&audio_ids
, &video_ids
);
407 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
409 // Test with invalid optional audio sourceID.
410 NavigateToURL(shell(), url
);
411 EXPECT_EQ(kOK
, ExecuteJavascriptAndReturnResult(
412 GenerateGetUserMediaWithOptionalSourceID(
413 kGetUserMediaAndStop
,
417 // Test with invalid optional video sourceID.
418 EXPECT_EQ(kOK
, ExecuteJavascriptAndReturnResult(
419 GenerateGetUserMediaWithOptionalSourceID(
420 kGetUserMediaAndStop
,
422 "something invalid")));
424 // Test with empty optional audio sourceID.
425 EXPECT_EQ(kOK
, ExecuteJavascriptAndReturnResult(
426 GenerateGetUserMediaWithOptionalSourceID(
427 kGetUserMediaAndStop
,
432 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
, TwoGetUserMediaAndStop
) {
433 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
435 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
436 NavigateToURL(shell(), url
);
438 ExecuteJavascriptAndWaitForOk(
439 "twoGetUserMediaAndStop({video: true, audio: true});");
442 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
443 TwoGetUserMediaWithEqualConstraints
) {
444 std::string constraints1
= "{video: true, audio: true}";
445 const std::string
& constraints2
= constraints1
;
446 std::string expected_result
= "w=640:h=480-w=640:h=480";
448 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1
, constraints2
,
452 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
453 TwoGetUserMediaWithSecondVideoCropped
) {
454 std::string constraints1
= "{video: true}";
455 std::string constraints2
= "{video: {mandatory: {maxHeight: 360}}}";
456 std::string expected_result
= "w=640:h=480-w=640:h=360";
457 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1
, constraints2
,
461 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
462 TwoGetUserMediaWithFirstHdSecondVga
) {
463 std::string constraints1
=
464 "{video: {mandatory: {minWidth:1280 , minHeight: 720}}}";
465 std::string constraints2
=
466 "{video: {mandatory: {maxWidth:640 , maxHeight: 480}}}";
467 std::string expected_result
= "w=1280:h=720-w=640:h=480";
468 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1
, constraints2
,
472 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
473 TwoGetUserMediaAndVerifyFrameRate
) {
474 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
476 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
477 NavigateToURL(shell(), url
);
479 std::string constraints1
=
480 "{video: {mandatory: {minWidth:640 , minHeight: 480, "
481 "minFrameRate : 15, maxFrameRate : 15}}}";
482 std::string constraints2
=
483 "{video: {mandatory: {maxWidth:320 , maxHeight: 240,"
484 "minFrameRate : 7, maxFrameRate : 7}}}";
486 std::string command
= "twoGetUserMediaAndVerifyFrameRate(" +
487 constraints1
+ ',' + constraints2
+ ", 15, 7)";
488 ExecuteJavascriptAndWaitForOk(command
);
491 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
492 GetUserMediaWithTooHighVideoConstraintsValues
) {
493 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
495 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
497 int large_value
= 99999;
498 std::string call
= GenerateGetUserMediaCall(kGetUserMediaAndExpectFailure
,
505 NavigateToURL(shell(), url
);
507 EXPECT_EQ("ConstraintNotSatisfiedError",
508 ExecuteJavascriptAndReturnResult(call
));
511 // This test will make a simple getUserMedia page, verify that video is playing
512 // in a simple local <video>, and for a couple of seconds, collect some
513 // performance traces from VideoCaptureController colorspace conversion and
514 // potential resizing.
515 IN_PROC_BROWSER_TEST_F(
516 WebRtcGetUserMediaBrowserTest
,
517 TraceVideoCaptureControllerPerformanceDuringGetUserMedia
) {
518 RunGetUserMediaAndCollectMeasures(
520 "VideoCaptureController::OnIncomingCapturedData",
521 "VideoCaptureController");
524 // This test calls getUserMedia and checks for aspect ratio behavior.
525 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
526 TestGetUserMediaAspectRatio4To3
) {
527 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
529 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
531 std::string constraints_4_3
= GenerateGetUserMediaCall(
532 kGetUserMediaAndAnalyseAndStop
, 640, 640, 480, 480, 10, 30);
534 NavigateToURL(shell(), url
);
535 ASSERT_EQ("w=640:h=480",
536 ExecuteJavascriptAndReturnResult(constraints_4_3
));
539 // This test calls getUserMedia and checks for aspect ratio behavior.
540 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
541 TestGetUserMediaAspectRatio16To9
) {
542 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
544 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
546 std::string constraints_16_9
= GenerateGetUserMediaCall(
547 kGetUserMediaAndAnalyseAndStop
, 640, 640, 360, 360, 10, 30);
549 NavigateToURL(shell(), url
);
550 ASSERT_EQ("w=640:h=360",
551 ExecuteJavascriptAndReturnResult(constraints_16_9
));
554 // This test calls getUserMedia and checks for aspect ratio behavior.
555 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest
,
556 TestGetUserMediaAspectRatio1To1
) {
557 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
559 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
561 std::string constraints_1_1
= GenerateGetUserMediaCall(
562 kGetUserMediaAndAnalyseAndStop
, 320, 320, 320, 320, 10, 30);
564 NavigateToURL(shell(), url
);
565 ASSERT_EQ("w=320:h=320",
566 ExecuteJavascriptAndReturnResult(constraints_1_1
));
571 struct UserMediaSizes
{
582 class WebRtcConstraintsBrowserTest
583 : public WebRtcContentBrowserTest
,
584 public testing::WithParamInterface
<UserMediaSizes
> {
586 WebRtcConstraintsBrowserTest() : user_media_(GetParam()) {}
587 const UserMediaSizes
& user_media() const { return user_media_
; }
590 UserMediaSizes user_media_
;
593 // This test calls getUserMedia in sequence with different constraints.
594 IN_PROC_BROWSER_TEST_P(WebRtcConstraintsBrowserTest
, GetUserMediaConstraints
) {
595 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
597 GURL
url(embedded_test_server()->GetURL("/media/getusermedia.html"));
599 std::string call
= GenerateGetUserMediaCall(kGetUserMediaAndStop
,
600 user_media().min_width
,
601 user_media().max_width
,
602 user_media().min_height
,
603 user_media().max_height
,
604 user_media().min_frame_rate
,
605 user_media().max_frame_rate
);
606 DVLOG(1) << "Calling getUserMedia: " << call
;
607 NavigateToURL(shell(), url
);
608 ExecuteJavascriptAndWaitForOk(call
);
611 static const UserMediaSizes kAllUserMediaSizes
[] = {
612 {320, 320, 180, 180, 10, 30},
613 {320, 320, 240, 240, 10, 30},
614 {640, 640, 360, 360, 10, 30},
615 {640, 640, 480, 480, 10, 30},
616 {960, 960, 720, 720, 10, 30},
617 {1280, 1280, 720, 720, 10, 30}};
619 INSTANTIATE_TEST_CASE_P(UserMedia
,
620 WebRtcConstraintsBrowserTest
,
621 testing::ValuesIn(kAllUserMediaSizes
));
623 } // namespace content