Skip to content

Commit

Permalink
Have media content and chrome browser tests load data from media/test…
Browse files Browse the repository at this point in the history
…/data

Update remaining encrypted media browser tests to use new player app.

(This is identical to r282795 which got reverted, i.e. revert of revert).

The fix was submitted separately in r283757

BUG=379314

Review URL: https://codereview.chromium.org/398823004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284489 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
shadi@chromium.org committed Jul 21, 2014
1 parent 5c5e60b commit 1bede83
Show file tree
Hide file tree
Showing 40 changed files with 286 additions and 687 deletions.
59 changes: 31 additions & 28 deletions chrome/browser/media/encrypted_media_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)

void RunEncryptedMediaTestPage(const std::string& html_page,
const std::string& key_system,
std::vector<StringPair>* query_params,
const std::string& expected_title) {
StartLicenseServerIfNeeded(key_system, query_params);
RunMediaTestPage(html_page, query_params, expected_title, true);
void RunEncryptedMediaTestPage(
const std::string& html_page,
const std::string& key_system,
const media::QueryParams& query_params,
const std::string& expected_title) {
media::QueryParams new_query_params = query_params;
StartLicenseServerIfNeeded(key_system, &new_query_params);
RunMediaTestPage(html_page, new_query_params, expected_title, true);
}

// Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
Expand All @@ -144,7 +146,7 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
VLOG(0) << "Skipping test - MSE not supported.";
return;
}
std::vector<StringPair> query_params;
media::QueryParams query_params;
query_params.push_back(std::make_pair("mediaFile", media_file));
query_params.push_back(std::make_pair("mediaType", media_type));
query_params.push_back(std::make_pair("keySystem", key_system));
Expand All @@ -156,7 +158,7 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
if (!session_to_load.empty())
query_params.push_back(std::make_pair("sessionToLoad", session_to_load));
RunEncryptedMediaTestPage(html_page, key_system, &query_params,
RunEncryptedMediaTestPage(html_page, key_system, query_params,
expected_title);
}

Expand Down Expand Up @@ -188,16 +190,17 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
EXPECT_TRUE(receivedKeyMessage);
}


// Starts a license server if available for the |key_system| and adds a
// 'licenseServerURL' query parameter to |query_params|.
void StartLicenseServerIfNeeded(const std::string& key_system,
std::vector<StringPair>* query_params) {
media::QueryParams* query_params) {
scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system);
if (!config)
return;
license_server_.reset(new TestLicenseServer(config.Pass()));
EXPECT_TRUE(license_server_->Start());
query_params->push_back(std::make_pair("licenseServerURL",
license_server_->GetServerURL()));
query_params->push_back(
std::make_pair("licenseServerURL", license_server_->GetServerURL()));
}

bool IsPlayBackPossible(const std::string& key_system) {
Expand Down Expand Up @@ -312,7 +315,7 @@ class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
// Since we do not test playback, arbitrarily choose a test file and source
// type.
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-a-enc_a.webm",
"bear-a_enc-a.webm",
kWebMAudioOnly,
key_system,
SRC,
Expand Down Expand Up @@ -379,7 +382,7 @@ class EncryptedMediaTest

void RunInvalidResponseTest() {
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-320x240-av-enc_av.webm",
"bear-320x240-av_enc-av.webm",
kWebMAudioVideo,
CurrentKeySystem(),
CurrentSourceType(),
Expand All @@ -391,7 +394,7 @@ class EncryptedMediaTest

void TestFrameSizeChange() {
RunEncryptedMediaTest("encrypted_frame_size_change.html",
"frame_size_change-av-enc-v.webm",
"frame_size_change-av_enc-v.webm",
kWebMAudioVideo,
CurrentKeySystem(),
CurrentSourceType(),
Expand All @@ -403,14 +406,14 @@ class EncryptedMediaTest

void TestConfigChange() {
DCHECK(IsMSESupported());
std::vector<StringPair> query_params;
media::QueryParams query_params;
query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
query_params.push_back(std::make_pair("runEncrypted", "1"));
if (CurrentEmeVersion() == PREFIXED)
query_params.push_back(std::make_pair("usePrefixedEME", "1"));
RunEncryptedMediaTestPage("mse_config_change.html",
CurrentKeySystem(),
&query_params,
query_params,
kEnded);
}

Expand Down Expand Up @@ -488,7 +491,7 @@ INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly,
Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
Values(MSE),
Values(UNPREFIXED)));
#endif // defined(ENABLE_PEPPER_CDMS)
#endif // defined(ENABLE_PEPPER_CDMS)

#if defined(WIDEVINE_CDM_AVAILABLE)
// This test doesn't fully test playback with Widevine. So we only run Widevine
Expand All @@ -511,27 +514,27 @@ INSTANTIATE_TEST_CASE_P(MSE_Widevine,
#endif // defined(WIDEVINE_CDM_AVAILABLE)

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly);
TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly);
}

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo);
TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo);
}

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo);
TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo);
}

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) {
TestSimplePlayback("bear-320x240-v-enc_v.webm", kWebMVideoOnly);
TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly);
}

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo);
TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo);
}

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) {
TestSimplePlayback("bear-320x240-v-vp9-enc_v.webm", kWebMVP9VideoOnly);
TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly);
}

IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
Expand Down Expand Up @@ -587,7 +590,7 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) {
// The parent key system cannot be used in generateKeyRequest.
IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-a-enc_a.webm",
"bear-a_enc-a.webm",
kWebMAudioOnly,
"com.widevine",
MSE,
Expand All @@ -601,7 +604,7 @@ IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
// The parent key system cannot be used when creating MediaKeys.
IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-a-enc_a.webm",
"bear-a_enc-a.webm",
kWebMAudioOnly,
"com.widevine",
MSE,
Expand Down Expand Up @@ -640,7 +643,7 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) {

IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-320x240-v-enc_v.webm",
"bear-320x240-v_enc-v.webm",
kWebMVideoOnly,
kExternalClearKeyKeySystem,
SRC,
Expand All @@ -653,7 +656,7 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
// TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
RunEncryptedMediaTest(kDefaultEmePlayer,
"bear-320x240-v-enc_v.webm",
"bear-320x240-v_enc-v.webm",
kWebMVideoOnly,
kExternalClearKeyKeySystem,
SRC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "media/base/test_data_util.h"
#include "url/gurl.h"

#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
Expand Down Expand Up @@ -224,9 +225,10 @@ class EncryptedMediaIsTypeSupportedTest : public InProcessBrowserTest {
// Load the test page needed. IsConcreteSupportedKeySystem() needs some
// JavaScript and a video loaded in order to work.
if (!is_test_page_loaded_) {
ASSERT_TRUE(test_server()->Start());
GURL gurl = test_server()->GetURL(
"files/media/test_key_system_instantiation.html");
scoped_ptr<net::SpawnedTestServer> http_test_server =
media::StartMediaHttpTestServer();
GURL gurl = http_test_server->GetURL(
"files/test_key_system_instantiation.html");
ui_test_utils::NavigateToURL(browser(), gurl);
is_test_page_loaded_ = true;
}
Expand Down
47 changes: 17 additions & 30 deletions chrome/browser/media/media_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

#include "chrome/browser/media/media_browsertest.h"

#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
Expand All @@ -28,46 +25,36 @@ MediaBrowserTest::MediaBrowserTest() : ignore_plugin_crash_(false) {
MediaBrowserTest::~MediaBrowserTest() {
}

void MediaBrowserTest::RunMediaTestPage(
const std::string& html_page, std::vector<StringPair>* query_params,
const std::string& expected_title, bool http) {
void MediaBrowserTest::RunMediaTestPage(const std::string& html_page,
const media::QueryParams& query_params,
const std::string& expected_title,
bool http) {
GURL gurl;
std::string query = "";
if (query_params != NULL && !query_params->empty()) {
std::vector<StringPair>::const_iterator itr = query_params->begin();
query = itr->first + "=" + itr->second;
++itr;
for (; itr != query_params->end(); ++itr) {
query.append("&" + itr->first + "=" + itr->second);
}
}
std::string query = media::GetURLQueryString(query_params);
scoped_ptr<net::SpawnedTestServer> http_test_server;
if (http) {
ASSERT_TRUE(test_server()->Start());
gurl = test_server()->GetURL("files/media/" + html_page + "?" + query);
http_test_server = media::StartMediaHttpTestServer();
gurl = http_test_server->GetURL("files/" + html_page + "?" + query);
} else {
base::FilePath test_file_path;
PathService::Get(chrome::DIR_TEST_DATA, &test_file_path);
test_file_path = test_file_path.AppendASCII("media")
.AppendASCII(html_page);
gurl = content::GetFileUrlWithQuery(test_file_path, query);
gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page),
query);
}

base::string16 final_title = RunTest(gurl, expected_title);
EXPECT_EQ(base::ASCIIToUTF16(expected_title), final_title);
std::string final_title = RunTest(gurl, expected_title);
EXPECT_EQ(expected_title, final_title);
}

base::string16 MediaBrowserTest::RunTest(const GURL& gurl,
const std::string& expected_title) {
VLOG(0) << "Running test URL: " << gurl;
std::string MediaBrowserTest::RunTest(const GURL& gurl,
const std::string& expected_title) {
DVLOG(0) << "Running test URL: " << gurl;
// Observe the web contents for plugin crashes.
Observe(browser()->tab_strip_model()->GetActiveWebContents());
content::TitleWatcher title_watcher(
browser()->tab_strip_model()->GetActiveWebContents(),
base::ASCIIToUTF16(expected_title));
AddWaitForTitles(&title_watcher);
ui_test_utils::NavigateToURL(browser(), gurl);

return title_watcher.WaitAndGetTitle();
base::string16 result = title_watcher.WaitAndGetTitle();
return base::UTF16ToASCII(result);
}

void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) {
Expand Down
15 changes: 7 additions & 8 deletions chrome/browser/media/media_browsertest.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#ifndef CHROME_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_
#define CHROME_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_

#include <utility>
#include <vector>
#include <string>

#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/web_contents_observer.h"
#include "media/base/test_data_util.h"

namespace content {
class TitleWatcher;
Expand All @@ -21,8 +21,6 @@ class TitleWatcher;
class MediaBrowserTest : public InProcessBrowserTest,
public content::WebContentsObserver {
protected:
typedef std::pair<std::string, std::string> StringPair;

// Common test results.
static const char kEnded[];
// TODO(xhwang): Report detailed errors, e.g. "ERROR-3".
Expand All @@ -38,12 +36,13 @@ class MediaBrowserTest : public InProcessBrowserTest,
// page, otherwise a local file URL is loaded inside the content shell.
// It uses RunTest() to check for expected test output.
void RunMediaTestPage(const std::string& html_page,
std::vector<StringPair>* query_params,
const std::string& expected, bool http);
const media::QueryParams& query_params,
const std::string& expected,
bool http);

// Opens a URL and waits for the document title to match either one of the
// default strings or the expected string.
base::string16 RunTest(const GURL& gurl, const std::string& expected);
// default strings or the expected string. Returns the matching title value.
std::string RunTest(const GURL& gurl, const std::string& expected);

virtual void AddWaitForTitles(content::TitleWatcher* title_watcher);

Expand Down
31 changes: 0 additions & 31 deletions chrome/test/data/media/eme_player_js/test_config.js

This file was deleted.

Binary file not shown.
Loading

0 comments on commit 1bede83

Please sign in to comment.