Commit 458cd0b2 authored by Max Morin's avatar Max Morin Committed by Commit Bot

Force audio service to be in process in muting tests.

Bug: 843103
Change-Id: I1040b014620079865b1141c52ac8ec90fec26ab7
Reviewed-on: https://chromium-review.googlesource.com/1061293Reviewed-by: default avatarPatrik Höglund <phoglund@chromium.org>
Commit-Queue: Max Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559077}
parent 1f4fc1f7
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/webrtc/webrtc_content_browsertest_base.h" #include "content/browser/webrtc/webrtc_content_browsertest_base.h"
#include "content/browser/webrtc/webrtc_internals.h" #include "content/browser/webrtc/webrtc_internals.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h" #include "content/public/test/content_browser_test_utils.h"
...@@ -160,6 +162,24 @@ class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase { ...@@ -160,6 +162,24 @@ class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase {
} }
}; };
// Muting tests doesn't work with the out of process audio service, so we need
// another test fixture to force the audio service to be in process.
// TODO(https://crbug.com/843490): Figure out a nicer way to do this.
class WebRtcGetUserMediaBrowserTestWithAudioServiceForcedIntoBrowserProcess
: public WebRtcGetUserMediaBrowserTest {
public:
WebRtcGetUserMediaBrowserTestWithAudioServiceForcedIntoBrowserProcess() {
disable_out_of_process_audio.InitAndDisableFeature(
features::kAudioServiceOutOfProcess);
}
~WebRtcGetUserMediaBrowserTestWithAudioServiceForcedIntoBrowserProcess()
override {}
private:
base::test::ScopedFeatureList disable_out_of_process_audio;
};
// These tests will all make a getUserMedia call with different constraints and // These tests will all make a getUserMedia call with different constraints and
// see that the success callback is called. If the error callback is called or // see that the success callback is called. If the error callback is called or
// none of the callbacks are called the tests will simply time out and fail. // none of the callbacks are called the tests will simply time out and fail.
...@@ -666,56 +686,6 @@ IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, ...@@ -666,56 +686,6 @@ IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
ExecuteJavascriptAndWaitForOk("getAudioSettingsDeviceId()"); ExecuteJavascriptAndWaitForOk("getAudioSettingsDeviceId()");
} }
IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
GetAudioStreamAndCheckMutingInitiallyUnmuted) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
NavigateToURL(shell(), url);
// Expect stream to initially not be muted
media::FakeAudioInputStream::SetGlobalMutedState(false);
ExecuteJavascriptAndWaitForOk(
base::StringPrintf("%s(false);", kGetUserMediaForAudioMutingTest));
// Mute
media::FakeAudioInputStream::SetGlobalMutedState(true);
EXPECT_EQ("onmute: muted=true, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no mute event', 1500);"));
// Unmute
media::FakeAudioInputStream::SetGlobalMutedState(false);
EXPECT_EQ("onunmute: muted=false, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no unmute event', 1500);"));
}
IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
GetAudioStreamAndCheckMutingInitiallyMuted) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
NavigateToURL(shell(), url);
// Expect stream to initially be muted
media::FakeAudioInputStream::SetGlobalMutedState(true);
ExecuteJavascriptAndWaitForOk(
base::StringPrintf("%s(true);", kGetUserMediaForAudioMutingTest));
// Unmute
media::FakeAudioInputStream::SetGlobalMutedState(false);
EXPECT_EQ("onunmute: muted=false, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no unmute event', 1500);"));
// Mute
media::FakeAudioInputStream::SetGlobalMutedState(true);
EXPECT_EQ("onmute: muted=true, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no mute event', 1500);"));
}
IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, SrcObjectAddVideoTrack) { IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, SrcObjectAddVideoTrack) {
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
...@@ -807,4 +777,55 @@ IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, ...@@ -807,4 +777,55 @@ IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest,
ExecuteJavascriptAndWaitForOk("getUserMediaEchoCancellationOnAndOff()"); ExecuteJavascriptAndWaitForOk("getUserMediaEchoCancellationOnAndOff()");
} }
IN_PROC_BROWSER_TEST_F(
WebRtcGetUserMediaBrowserTestWithAudioServiceForcedIntoBrowserProcess,
GetAudioStreamAndCheckMutingInitiallyUnmuted) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
NavigateToURL(shell(), url);
// Expect stream to initially not be muted
media::FakeAudioInputStream::SetGlobalMutedState(false);
ExecuteJavascriptAndWaitForOk(
base::StringPrintf("%s(false);", kGetUserMediaForAudioMutingTest));
// Mute
media::FakeAudioInputStream::SetGlobalMutedState(true);
EXPECT_EQ("onmute: muted=true, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no mute event', 1500);"));
// Unmute
media::FakeAudioInputStream::SetGlobalMutedState(false);
EXPECT_EQ("onunmute: muted=false, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no unmute event', 1500);"));
}
IN_PROC_BROWSER_TEST_F(
WebRtcGetUserMediaBrowserTestWithAudioServiceForcedIntoBrowserProcess,
GetAudioStreamAndCheckMutingInitiallyMuted) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
NavigateToURL(shell(), url);
// Expect stream to initially be muted
media::FakeAudioInputStream::SetGlobalMutedState(true);
ExecuteJavascriptAndWaitForOk(
base::StringPrintf("%s(true);", kGetUserMediaForAudioMutingTest));
// Unmute
media::FakeAudioInputStream::SetGlobalMutedState(false);
EXPECT_EQ("onunmute: muted=false, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no unmute event', 1500);"));
// Mute
media::FakeAudioInputStream::SetGlobalMutedState(true);
EXPECT_EQ("onmute: muted=true, readyState=live",
ExecuteJavascriptAndReturnResult(
"failTestAfterTimeout('Got no mute event', 1500);"));
}
} // namespace content } // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment