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

Side by Side Diff: content/browser/webrtc/webrtc_getusermedia_browsertest.cc

Issue 2790823002: Spec compliant video constraints for getUserMedia behind flag. (Closed)
Patch Set: fix tests Created 3 years, 8 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/feature_list.h"
8 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
9 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/test/trace_event_analyzer.h" 12 #include "base/test/trace_event_analyzer.h"
12 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
13 #include "base/trace_event/trace_event_impl.h" 14 #include "base/trace_event/trace_event_impl.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "content/browser/browser_main_loop.h" 17 #include "content/browser/browser_main_loop.h"
17 #include "content/browser/renderer_host/media/media_stream_manager.h" 18 #include "content/browser/renderer_host/media/media_stream_manager.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" 20 #include "content/browser/webrtc/webrtc_content_browsertest_base.h"
20 #include "content/browser/webrtc/webrtc_internals.h" 21 #include "content/browser/webrtc/webrtc_internals.h"
22 #include "content/public/common/content_features.h"
21 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
22 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
23 #include "content/public/test/content_browser_test_utils.h" 25 #include "content/public/test/content_browser_test_utils.h"
24 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
25 #include "content/shell/browser/shell.h" 27 #include "content/shell/browser/shell.h"
26 #include "media/audio/audio_manager.h" 28 #include "media/audio/audio_manager.h"
27 #include "net/test/embedded_test_server/embedded_test_server.h" 29 #include "net/test/embedded_test_server/embedded_test_server.h"
28 #include "testing/perf/perf_test.h" 30 #include "testing/perf/perf_test.h"
29 31
30 #if defined(OS_WIN) 32 #if defined(OS_WIN)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const std::string video_constraint = 91 const std::string video_constraint =
90 "video: { mandatory: { chromeMediaSource:'screen' }}"; 92 "video: { mandatory: { chromeMediaSource:'screen' }}";
91 return function_name + "({" + audio_constraint + video_constraint + "});"; 93 return function_name + "({" + audio_constraint + video_constraint + "});";
92 } 94 }
93 95
94 bool VerifyDisableLocalEcho(bool expect_value, 96 bool VerifyDisableLocalEcho(bool expect_value,
95 const content::StreamControls& controls) { 97 const content::StreamControls& controls) {
96 return expect_value == controls.disable_local_echo; 98 return expect_value == controls.disable_local_echo;
97 } 99 }
98 100
101 bool IsOldVideoConstraints() {
102 return base::FeatureList::IsEnabled(
103 features::kMediaStreamOldVideoConstraints);
104 }
105
99 } // namespace 106 } // namespace
100 107
101 namespace content { 108 namespace content {
102 109
103 class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase { 110 class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase {
104 public: 111 public:
105 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) { 112 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) {
106 // Automatically grant device permission. 113 // Automatically grant device permission.
107 AppendUseFakeUIForMediaStreamFlag(); 114 AppendUseFakeUIForMediaStreamFlag();
108 } 115 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 const std::string& constraints2 = constraints1; 497 const std::string& constraints2 = constraints1;
491 std::string expected_result = "w=640:h=480-w=640:h=480"; 498 std::string expected_result = "w=640:h=480-w=640:h=480";
492 499
493 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, 500 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2,
494 expected_result); 501 expected_result);
495 } 502 }
496 503
497 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 504 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
498 TwoGetUserMediaWithSecondVideoCropped) { 505 TwoGetUserMediaWithSecondVideoCropped) {
499 std::string constraints1 = "{video: true}"; 506 std::string constraints1 = "{video: true}";
500 std::string constraints2 = "{video: {mandatory: {maxHeight: 360}}}"; 507 std::string constraints2 =
508 IsOldVideoConstraints()
509 ? "{video: {mandatory: {maxHeight: 360}}}"
510 : "{video: {width: {exact: 640}, height: {exact: 360}}}";
501 std::string expected_result = "w=640:h=480-w=640:h=360"; 511 std::string expected_result = "w=640:h=480-w=640:h=360";
502 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, 512 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2,
503 expected_result); 513 expected_result);
504 } 514 }
505 515
506 // Test fails under MSan, http://crbug.com/445745 516 // Test fails under MSan, http://crbug.com/445745
507 #if defined(MEMORY_SANITIZER) 517 #if defined(MEMORY_SANITIZER)
508 #define MAYBE_TwoGetUserMediaWithFirstHdSecondVga \ 518 #define MAYBE_TwoGetUserMediaWithFirstHdSecondVga \
509 DISABLED_TwoGetUserMediaWithFirstHdSecondVga 519 DISABLED_TwoGetUserMediaWithFirstHdSecondVga
510 #else 520 #else
511 #define MAYBE_TwoGetUserMediaWithFirstHdSecondVga \ 521 #define MAYBE_TwoGetUserMediaWithFirstHdSecondVga \
512 TwoGetUserMediaWithFirstHdSecondVga 522 TwoGetUserMediaWithFirstHdSecondVga
513 #endif 523 #endif
514 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 524 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
515 MAYBE_TwoGetUserMediaWithFirstHdSecondVga) { 525 MAYBE_TwoGetUserMediaWithFirstHdSecondVga) {
516 std::string constraints1 = 526 std::string constraints1 =
517 "{video: {mandatory: {maxWidth:1280 , minWidth:1280 , maxHeight: 720,\ 527 IsOldVideoConstraints()
518 minHeight: 720}}}"; 528 ? "{video: {mandatory: {maxWidth:1280 , minWidth:1280 , "
529 "maxHeight: 720, minHeight: 720}}}"
530 : "{video: {width : {exact: 1280}, height: {exact: 720}}}";
519 std::string constraints2 = 531 std::string constraints2 =
520 "{video: {mandatory: {maxWidth:640 , maxHeight: 480}}}"; 532 IsOldVideoConstraints()
533 ? "{video: {mandatory: {maxWidth:640 , maxHeight: 480}}}"
534 : "{video: {width : {exact: 640}, height: {exact: 480}}}";
521 std::string expected_result = "w=1280:h=720-w=640:h=480"; 535 std::string expected_result = "w=1280:h=720-w=640:h=480";
522 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, 536 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2,
523 expected_result); 537 expected_result);
hbos_chromium 2017/04/05 12:37:27 ScopedFeature thingy to test both old and new with
Guido Urdaneta 2017/04/05 16:17:16 Done.
524 } 538 }
525 539
526 // Timing out on Windows 7 bot: http://crbug.com/443294 540 // Timing out on Windows 7 bot: http://crbug.com/443294
527 // Flaky: http://crbug.com/660656; possible the test is too perf sensitive. 541 // Flaky: http://crbug.com/660656; possible the test is too perf sensitive.
528 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 542 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
529 DISABLED_TwoGetUserMediaWithFirst1080pSecondVga) { 543 DISABLED_TwoGetUserMediaWithFirst1080pSecondVga) {
530 std::string constraints1 = 544 std::string constraints1 =
531 "{video: {mandatory: {maxWidth:1920 , minWidth:1920 , maxHeight: 1080,\ 545 "{video: {mandatory: {maxWidth:1920 , minWidth:1920 , maxHeight: 1080, "
532 minHeight: 1080}}}"; 546 "minHeight: 1080}}}";
533 std::string constraints2 = 547 std::string constraints2 =
534 "{video: {mandatory: {maxWidth:640 , maxHeight: 480}}}"; 548 "{video: {mandatory: {maxWidth:640 , maxHeight: 480}}}";
535 std::string expected_result = "w=1920:h=1080-w=640:h=480"; 549 std::string expected_result = "w=1920:h=1080-w=640:h=480";
536 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2, 550 RunTwoGetTwoGetUserMediaWithDifferentContraints(constraints1, constraints2,
537 expected_result); 551 expected_result);
538 } 552 }
539 553
540 // Test fails under MSan, http://crbug.com/445745 554 // Test fails under MSan, http://crbug.com/445745
541 #if defined(MEMORY_SANITIZER) 555 #if defined(MEMORY_SANITIZER)
542 #define MAYBE_TwoGetUserMediaAndVerifyFrameRate \ 556 #define MAYBE_TwoGetUserMediaAndVerifyFrameRate \
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 base::Bind(&VerifyDisableLocalEcho, true)); 793 base::Bind(&VerifyDisableLocalEcho, true));
780 call = GenerateGetUserMediaWithDisableLocalEcho( 794 call = GenerateGetUserMediaWithDisableLocalEcho(
781 "getUserMediaAndExpectSuccess", "true"); 795 "getUserMediaAndExpectSuccess", "true");
782 ExecuteJavascriptAndWaitForOk(call); 796 ExecuteJavascriptAndWaitForOk(call);
783 797
784 manager->SetGenerateStreamCallbackForTesting( 798 manager->SetGenerateStreamCallbackForTesting(
785 MediaStreamManager::GenerateStreamTestCallback()); 799 MediaStreamManager::GenerateStreamTestCallback());
786 } 800 }
787 801
788 } // namespace content 802 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/common/content_features.h » ('j') | content/renderer/media/media_stream_video_capturer_source.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698