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

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

Issue 2291893002: Let Contraints Controll Mute/Unmute Audio Local Playback For Desktop Sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 2 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/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/test/trace_event_analyzer.h" 11 #include "base/test/trace_event_analyzer.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "base/trace_event/trace_event_impl.h" 13 #include "base/trace_event/trace_event_impl.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "content/browser/browser_main_loop.h"
17 #include "content/browser/renderer_host/media/media_stream_manager.h"
16 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
17 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" 19 #include "content/browser/webrtc/webrtc_content_browsertest_base.h"
18 #include "content/browser/webrtc/webrtc_internals.h" 20 #include "content/browser/webrtc/webrtc_internals.h"
19 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
20 #include "content/public/test/browser_test_utils.h" 22 #include "content/public/test/browser_test_utils.h"
21 #include "content/public/test/content_browser_test_utils.h" 23 #include "content/public/test/content_browser_test_utils.h"
22 #include "content/public/test/test_utils.h" 24 #include "content/public/test/test_utils.h"
23 #include "content/shell/browser/shell.h" 25 #include "content/shell/browser/shell.h"
24 #include "net/test/embedded_test_server/embedded_test_server.h" 26 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "testing/perf/perf_test.h" 27 #include "testing/perf/perf_test.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const std::string& audio_source_id, 71 const std::string& audio_source_id,
70 const std::string& video_source_id) { 72 const std::string& video_source_id) {
71 const std::string audio_constraint = 73 const std::string audio_constraint =
72 "audio: {optional: [{sourceId:\"" + audio_source_id + "\"}]}, "; 74 "audio: {optional: [{sourceId:\"" + audio_source_id + "\"}]}, ";
73 75
74 const std::string video_constraint = 76 const std::string video_constraint =
75 "video: {optional: [{ sourceId:\"" + video_source_id + "\"}]}"; 77 "video: {optional: [{ sourceId:\"" + video_source_id + "\"}]}";
76 return function_name + "({" + audio_constraint + video_constraint + "});"; 78 return function_name + "({" + audio_constraint + video_constraint + "});";
77 } 79 }
78 80
81 std::string GenerateGetUserMediaWithDisableLocalEcho(
82 const std::string& function_name,
83 const std::string& disable_local_echo) {
84 const std::string audio_constraint =
85 "audio:{mandatory: { chromeMediaSource : 'system', disableLocalEcho : " +
86 disable_local_echo + " }},";
87
88 const std::string video_constraint =
89 "video: { mandatory: { chromeMediaSource:'screen' }}";
90 return function_name + "({" + audio_constraint + video_constraint + "});";
91 }
92
93 bool VerifyDisableLocalEcho(bool expect_value,
94 const content::StreamControls& controls) {
95 return expect_value == controls.disable_local_echo;
96 }
97
79 } // namespace 98 } // namespace
80 99
81 namespace content { 100 namespace content {
82 101
83 class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase { 102 class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase {
84 public: 103 public:
85 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) { 104 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) {
86 // Automatically grant device permission. 105 // Automatically grant device permission.
87 AppendUseFakeUIForMediaStreamFlag(); 106 AppendUseFakeUIForMediaStreamFlag();
88 } 107 }
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 735 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
717 736
718 std::string call = 737 std::string call =
719 GenerateGetUserMediaWithMandatorySourceID( 738 GenerateGetUserMediaWithMandatorySourceID(
720 "getUserMediaInIframeAndCloseInFailureCb", "invalid", "invalid"); 739 "getUserMediaInIframeAndCloseInFailureCb", "invalid", "invalid");
721 NavigateToURL(shell(), url); 740 NavigateToURL(shell(), url);
722 741
723 ExecuteJavascriptAndWaitForOk(call); 742 ExecuteJavascriptAndWaitForOk(call);
724 } 743 }
725 744
745 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
746 DisableLocalEchoParameter) {
747 base::CommandLine::ForCurrentProcess()->AppendSwitch(
748 switches::kEnableExperimentalWebPlatformFeatures);
749 ASSERT_TRUE(embedded_test_server()->Start());
750
751 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
752 NavigateToURL(shell(), url);
753
754 MediaStreamManager* manager =
755 BrowserMainLoop::GetInstance()->media_stream_manager();
756
757 manager->SetGenerateStreamCallbackForTesting(
758 base::Bind(&VerifyDisableLocalEcho, false));
759 std::string call = GenerateGetUserMediaWithDisableLocalEcho(
760 "getUserMediaAndExpectSuccess", "false");
761 ExecuteJavascriptAndWaitForOk(call);
762
763 manager->SetGenerateStreamCallbackForTesting(
764 base::Bind(&VerifyDisableLocalEcho, true));
765 call = GenerateGetUserMediaWithDisableLocalEcho(
766 "getUserMediaAndExpectSuccess", "true");
767 ExecuteJavascriptAndWaitForOk(call);
768
769 manager->SetGenerateStreamCallbackForTesting(
770 MediaStreamManager::GenerateStreamTestCallback());
771 }
772
726 } // namespace content 773 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | content/common/media/media_stream_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698