Commit 0a9bf07f authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Call MediaBrowserTest::SetUpCommandLine() in subclasses

When overridding SetUpCommandLine(), subclasses of MediaBrowserTest
should always call MediaBrowserTest::SetUpCommandLine(). This also helps
remove duplicate code in setting autoplay policy in these tests.

Bug: 707128
Test: Clean up only. No functionality change.
Change-Id: Ic06ba4b48e20cf342db7f60a32565766f5d1a1d5
Reviewed-on: https://chromium-review.googlesource.com/c/1257599Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596358}
parent 5d7e5bfc
...@@ -299,9 +299,7 @@ class EncryptedMediaTestBase : public MediaBrowserTest { ...@@ -299,9 +299,7 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
} }
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitchASCII( MediaBrowserTest::SetUpCommandLine(command_line);
switches::kAutoplayPolicy,
switches::autoplay::kNoUserGestureRequiredPolicy);
command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"EncryptedMediaHdcpPolicyCheck"); "EncryptedMediaHdcpPolicyCheck");
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/media/media_browsertest.h" #include "chrome/browser/media/media_browsertest.h"
#include "base/command_line.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "media/base/media_switches.h"
#include "media/base/test_data_util.h" #include "media/base/test_data_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
...@@ -21,6 +23,12 @@ MediaBrowserTest::MediaBrowserTest() {} ...@@ -21,6 +23,12 @@ MediaBrowserTest::MediaBrowserTest() {}
MediaBrowserTest::~MediaBrowserTest() {} MediaBrowserTest::~MediaBrowserTest() {}
void MediaBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
command_line->AppendSwitchASCII(
switches::kAutoplayPolicy,
switches::autoplay::kNoUserGestureRequiredPolicy);
}
void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, void MediaBrowserTest::RunMediaTestPage(const std::string& html_page,
const base::StringPairs& query_params, const base::StringPairs& query_params,
const std::string& expected_title, const std::string& expected_title,
......
...@@ -22,6 +22,9 @@ class MediaBrowserTest : public InProcessBrowserTest { ...@@ -22,6 +22,9 @@ class MediaBrowserTest : public InProcessBrowserTest {
MediaBrowserTest(); MediaBrowserTest();
~MediaBrowserTest() override; ~MediaBrowserTest() override;
// InProcessBrowserTest implementation.
void SetUpCommandLine(base::CommandLine* command_line) override;
// Runs a html page with a list of URL query parameters. // Runs a html page with a list of URL query parameters.
// If http is true, the test starts a local http test server to load the test // If http is true, the test starts a local http test server to load the test
// page, otherwise a local file URL is loaded inside the content shell. // page, otherwise a local file URL is loaded inside the content shell.
......
...@@ -182,9 +182,7 @@ class EncryptedMediaTest ...@@ -182,9 +182,7 @@ class EncryptedMediaTest
} }
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitchASCII( MediaBrowserTest::SetUpCommandLine(command_line);
switches::kAutoplayPolicy,
switches::autoplay::kNoUserGestureRequiredPolicy);
#if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL) #if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL)
scoped_feature_list_.InitWithFeatures({media::kExternalClearKeyForTesting}, scoped_feature_list_.InitWithFeatures({media::kExternalClearKeyForTesting},
{}); {});
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/command_line.h" #include "base/command_line.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/media/media_browsertest.h" #include "content/browser/media/media_browsertest.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
...@@ -37,7 +36,7 @@ const char kMp2tAudioVideo[] = "video/mp2t; codecs=\"mp4a.40.2, avc1.42E01E\""; ...@@ -37,7 +36,7 @@ const char kMp2tAudioVideo[] = "video/mp2t; codecs=\"mp4a.40.2, avc1.42E01E\"";
namespace content { namespace content {
class MediaSourceTest : public content::MediaBrowserTest { class MediaSourceTest : public MediaBrowserTest {
public: public:
void TestSimplePlayback(const std::string& media_file, void TestSimplePlayback(const std::string& media_file,
const std::string& media_type, const std::string& media_type,
...@@ -48,15 +47,6 @@ class MediaSourceTest : public content::MediaBrowserTest { ...@@ -48,15 +47,6 @@ class MediaSourceTest : public content::MediaBrowserTest {
RunMediaTestPage("media_source_player.html", query_params, expectation, RunMediaTestPage("media_source_player.html", query_params, expectation,
false); false);
} }
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitchASCII(
switches::kAutoplayPolicy,
switches::autoplay::kNoUserGestureRequiredPolicy);
}
protected:
base::test::ScopedFeatureList scoped_feature_list_;
}; };
IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoAudio_WebM) { IN_PROC_BROWSER_TEST_F(MediaSourceTest, Playback_VideoAudio_WebM) {
......
...@@ -24,13 +24,13 @@ static void SuspendAllMediaPlayersInRenderFrame(RenderFrameHost* rfh) { ...@@ -24,13 +24,13 @@ static void SuspendAllMediaPlayersInRenderFrame(RenderFrameHost* rfh) {
// and that players suspended in this way can be resumed. Note: This does not // and that players suspended in this way can be resumed. Note: This does not
// test suspend in various ready states; those tests are handled by layout tests // test suspend in various ready states; those tests are handled by layout tests
// for ease of writing and ready state manipulation. // for ease of writing and ready state manipulation.
class MediaSuspendTest : public content::MediaBrowserTest { class MediaSuspendTest : public MediaBrowserTest {
public: public:
void RunSuspendTest(const std::string& load_until) { void RunSuspendTest(const std::string& load_until) {
base::StringPairs query_params; base::StringPairs query_params;
query_params.emplace_back("event", load_until); query_params.emplace_back("event", load_until);
GURL gurl = content::GetFileUrlWithQuery( GURL gurl = GetFileUrlWithQuery(
media::GetTestDataFilePath("media_suspend_test.html"), media::GetTestDataFilePath("media_suspend_test.html"),
media::GetURLQueryString(query_params)); media::GetURLQueryString(query_params));
...@@ -74,7 +74,7 @@ class MediaSuspendTest : public content::MediaBrowserTest { ...@@ -74,7 +74,7 @@ class MediaSuspendTest : public content::MediaBrowserTest {
protected: protected:
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
content::MediaBrowserTest::SetUpCommandLine(command_line); MediaBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kExposeInternalsForTesting); command_line->AppendSwitch(switches::kExposeInternalsForTesting);
} }
}; };
......
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