Chromium Code Reviews| Index: content/browser/media/media_browsertest.cc |
| diff --git a/content/browser/media/media_browsertest.cc b/content/browser/media/media_browsertest.cc |
| index bdd77096bc3ba2a24cd1eb3c8543f9025e9d9c1b..68570fd8a263d0e9c09183db676844eaad82ce86 100644 |
| --- a/content/browser/media/media_browsertest.cc |
| +++ b/content/browser/media/media_browsertest.cc |
| @@ -4,13 +4,14 @@ |
| #include "content/browser/media/media_browsertest.h" |
| -#include "base/strings/stringprintf.h" |
| +#include "base/path_service.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/url_constants.h" |
| #include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/content_browser_test_utils.h" |
| #include "content/shell/browser/shell.h" |
| +#include "media/base/test_data_util.h" |
| // TODO(wolenetz): Fix Media.YUV* tests on MSVS 2012 x64. crbug.com/180074 |
| #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) && _MSC_VER == 1700 |
| @@ -27,38 +28,44 @@ const char MediaBrowserTest::kError[] = "ERROR"; |
| const char MediaBrowserTest::kFailed[] = "FAILED"; |
| void MediaBrowserTest::RunMediaTestPage( |
| - const char* html_page, std::vector<StringPair>* query_params, |
| - const char* expected, bool http) { |
| + const std::string& html_page, |
| + std::vector<StringPair>* query_params, |
| + const std::string& expected_title, |
| + bool http) { |
| GURL gurl; |
| std::string query = ""; |
| if (query_params != NULL && !query_params->empty()) { |
|
jrummell
2014/07/02 00:33:40
Should query_params -> query be a helper function?
shadi
2014/07/02 19:23:36
Done.
|
| std::vector<StringPair>::const_iterator itr = query_params->begin(); |
| - query = base::StringPrintf("%s=%s", itr->first, itr->second); |
| + query = itr->first + "=" + itr->second; |
| ++itr; |
| for (; itr != query_params->end(); ++itr) { |
| - query.append(base::StringPrintf("&%s=%s", itr->first, itr->second)); |
| + query.append("&" + itr->first + "=" + itr->second); |
| } |
| } |
| + scoped_ptr<net::SpawnedTestServer> http_test_server_; |
|
jrummell
2014/07/02 00:33:40
local variables shouldn't end in _.
shadi
2014/07/02 19:23:36
Done.
|
| if (http) { |
| - ASSERT_TRUE(test_server()->Start()); |
| - gurl = test_server()->GetURL( |
| - base::StringPrintf("files/media/%s?%s", html_page, query.c_str())); |
| + http_test_server_.reset(new net::SpawnedTestServer( |
| + net::SpawnedTestServer::TYPE_HTTP, |
| + net::SpawnedTestServer::kLocalhost, |
| + media::GetTestDataPath())); |
| + ASSERT_TRUE(http_test_server_.get()->Start()); |
|
jrummell
2014/07/02 00:33:40
ditto on .get(). Could this be refactored out into
shadi
2014/07/02 19:23:36
Done.
|
| + gurl = http_test_server_.get()->GetURL("files/" + html_page + "?" + query); |
| } else { |
| - base::FilePath test_file_path = GetTestFilePath("media", html_page); |
| - gurl = GetFileUrlWithQuery(test_file_path, query); |
| + gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), |
| + query); |
| } |
| - RunTest(gurl, expected); |
| + base::string16 final_title = RunTest(gurl, expected_title); |
| + EXPECT_EQ(base::ASCIIToUTF16(expected_title), final_title); |
| } |
| -void MediaBrowserTest::RunTest(const GURL& gurl, const char* expected) { |
| - const base::string16 expected_title = base::ASCIIToUTF16(expected); |
| - DVLOG(1) << "Running test URL: " << gurl; |
| - TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| +base::string16 MediaBrowserTest::RunTest(const GURL& gurl, |
| + const std::string& expected_title) { |
| + VLOG(0) << "Running test URL: " << gurl; |
| + TitleWatcher title_watcher(shell()->web_contents(), |
| + base::ASCIIToUTF16(expected_title)); |
| AddWaitForTitles(&title_watcher); |
| NavigateToURL(shell(), gurl); |
| - |
| - base::string16 final_title = title_watcher.WaitAndGetTitle(); |
| - EXPECT_EQ(expected_title, final_title); |
| + return title_watcher.WaitAndGetTitle(); |
| } |
| void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) { |
| @@ -75,22 +82,26 @@ class MediaTest : public testing::WithParamInterface<bool>, |
| public MediaBrowserTest { |
| public: |
| // Play specified audio over http:// or file:// depending on |http| setting. |
| - void PlayAudio(const char* media_file, bool http) { |
| + void PlayAudio(const std::string& media_file, bool http) { |
| PlayMedia("audio", media_file, http); |
| } |
| // Play specified video over http:// or file:// depending on |http| setting. |
| - void PlayVideo(const char* media_file, bool http) { |
| + void PlayVideo(const std::string& media_file, bool http) { |
| PlayMedia("video", media_file, http); |
| } |
| // Run specified color format test with the expected result. |
| - void RunColorFormatTest(const char* media_file, const char* expected) { |
| - base::FilePath test_file_path = GetTestFilePath("media", "blackwhite.html"); |
| + void RunColorFormatTest(const std::string& media_file, |
| + const std::string& expected) { |
| + base::FilePath test_file_path = |
| + media::GetTestDataFilePath("blackwhite.html"); |
| RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected); |
| } |
| - void PlayMedia(const char* tag, const char* media_file, bool http) { |
| + void PlayMedia(const std::string& tag, |
| + const std::string& media_file, |
| + bool http) { |
| std::vector<StringPair> query_params; |
| query_params.push_back(std::make_pair(tag, media_file)); |
| RunMediaTestPage("player.html", &query_params, kEnded, http); |
| @@ -140,7 +151,7 @@ IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS16be) { |
| IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS24be) { |
| PlayVideo("bear_pcm_s24be.mov", GetParam()); |
| } |
| -#endif |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| #if defined(OS_CHROMEOS) |
| #if defined(USE_PROPRIETARY_CODECS) |
| @@ -171,8 +182,9 @@ IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavGsmms) { |
| IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearFlac) { |
| PlayAudio("bear.flac", GetParam()); |
| } |
| -#endif |
| -#endif |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| +#endif // defined(OS_CHROMEOS) |
| + |
| IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavAlaw) { |
| PlayAudio("bear_alaw.wav", GetParam()); |