OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/debug/trace_event_impl.h" | 6 #include "base/debug/trace_event_impl.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/test/trace_event_analyzer.h" | 9 #include "base/test/trace_event_analyzer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 base::Time::kNanosecondsPerMicrosecond))); | 170 base::Time::kNanosecondsPerMicrosecond))); |
171 } | 171 } |
172 | 172 |
173 perf_test::PrintResultList( | 173 perf_test::PrintResultList( |
174 graph_name, "", "sample_duration", duration_us, "us", true); | 174 graph_name, "", "sample_duration", duration_us, "us", true); |
175 | 175 |
176 perf_test::PrintResultList( | 176 perf_test::PrintResultList( |
177 graph_name, "", "interarrival_time", interarrival_us, "us", true); | 177 graph_name, "", "interarrival_time", interarrival_us, "us", true); |
178 } | 178 } |
179 | 179 |
| 180 void RunTwoGetTwoGetUserMediaWithDifferentContraints( |
| 181 const std::string& constraints1, |
| 182 const std::string& constraints2, |
| 183 const std::string& expected_result) { |
| 184 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 185 |
| 186 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 187 NavigateToURL(shell(), url); |
| 188 |
| 189 std::string command = "twoGetUserMedia(" + constraints1 + ',' + |
| 190 constraints2 + ')'; |
| 191 |
| 192 EXPECT_EQ(expected_result, ExecuteJavascriptAndReturnResult(command)); |
| 193 } |
| 194 |
180 void GetSources(std::vector<std::string>* audio_ids, | 195 void GetSources(std::vector<std::string>* audio_ids, |
181 std::vector<std::string>* video_ids) { | 196 std::vector<std::string>* video_ids) { |
182 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 197 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
183 NavigateToURL(shell(), url); | 198 NavigateToURL(shell(), url); |
184 | 199 |
185 std::string sources_as_json = ExecuteJavascriptAndReturnResult( | 200 std::string sources_as_json = ExecuteJavascriptAndReturnResult( |
186 "getSources()"); | 201 "getSources()"); |
187 EXPECT_FALSE(sources_as_json.empty()); | 202 EXPECT_FALSE(sources_as_json.empty()); |
188 | 203 |
189 int error_code; | 204 int error_code; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 436 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
422 | 437 |
423 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 438 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
424 NavigateToURL(shell(), url); | 439 NavigateToURL(shell(), url); |
425 | 440 |
426 ExecuteJavascriptAndWaitForOk( | 441 ExecuteJavascriptAndWaitForOk( |
427 "twoGetUserMediaAndStop({video: true, audio: true});"); | 442 "twoGetUserMediaAndStop({video: true, audio: true});"); |
428 } | 443 } |
429 | 444 |
430 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, | 445 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, |
| 446 TwoGetUserMediaWithEqualConstraints) { |
| 447 std::string constraints1 = "{video: true, audio: true}"; |
| 448 const std::string& constraints2 = constraints1; |
| 449 std::string expected_result = "w=640:h=480-w=640:h=480"; |
| 450 |
| 451 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, |
| 452 expected_result); |
| 453 } |
| 454 |
| 455 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, |
| 456 TwoGetUserMediaWithSecondVideoCropped) { |
| 457 std::string constraints1 = "{video: true}"; |
| 458 std::string constraints2 = "{video: {mandatory: {maxHeight: 360}}}"; |
| 459 std::string expected_result = "w=640:h=480-w=640:h=360"; |
| 460 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, |
| 461 expected_result); |
| 462 } |
| 463 |
| 464 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, |
| 465 TwoGetUserMediaWithFirstHdSecondVga) { |
| 466 std::string constraints1 = |
| 467 "{video: {mandatory: {minWidth:1280 , minHeight: 720}}}"; |
| 468 std::string constraints2 = |
| 469 "{video: {mandatory: {maxWidth:640 , maxHeight: 480}}}"; |
| 470 std::string expected_result = "w=1280:h=720-w=640:h=480"; |
| 471 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, |
| 472 expected_result); |
| 473 } |
| 474 |
| 475 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, |
431 GetUserMediaWithTooHighVideoConstraintsValues) { | 476 GetUserMediaWithTooHighVideoConstraintsValues) { |
432 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 477 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
433 | 478 |
434 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 479 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
435 | 480 |
436 int large_value = 99999; | 481 int large_value = 99999; |
437 std::string call = GenerateGetUserMediaCall(kGetUserMediaAndExpectFailure, | 482 std::string call = GenerateGetUserMediaCall(kGetUserMediaAndExpectFailure, |
438 large_value, | 483 large_value, |
439 large_value, | 484 large_value, |
440 large_value, | 485 large_value, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 {640, 640, 360, 360, 10, 30}, | 598 {640, 640, 360, 360, 10, 30}, |
554 {640, 640, 480, 480, 10, 30}, | 599 {640, 640, 480, 480, 10, 30}, |
555 {960, 960, 720, 720, 10, 30}, | 600 {960, 960, 720, 720, 10, 30}, |
556 {1280, 1280, 720, 720, 10, 30}}; | 601 {1280, 1280, 720, 720, 10, 30}}; |
557 | 602 |
558 INSTANTIATE_TEST_CASE_P(UserMedia, | 603 INSTANTIATE_TEST_CASE_P(UserMedia, |
559 WebRtcConstraintsBrowserTest, | 604 WebRtcConstraintsBrowserTest, |
560 testing::ValuesIn(kAllUserMediaSizes)); | 605 testing::ValuesIn(kAllUserMediaSizes)); |
561 | 606 |
562 } // namespace content | 607 } // namespace content |
OLD | NEW |