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 0e6650bde4b1a9f49dd8ab979868b345125a30eb..382a94396491bf835700ff0070b9926f9fb0e716 100644 |
| --- a/content/browser/media/media_browsertest.cc |
| +++ b/content/browser/media/media_browsertest.cc |
| @@ -17,6 +17,7 @@ |
| #include "media/base/test_data_util.h" |
| #include "media/media_features.h" |
| #include "net/test/embedded_test_server/embedded_test_server.h" |
| +#include "url/url_util.h" |
| namespace content { |
| @@ -70,6 +71,14 @@ std::string MediaBrowserTest::RunTest(const GURL& gurl, |
| return base::UTF16ToASCII(result); |
| } |
| +std::string MediaBrowserTest::EncodeErrorMessage( |
| + const std::string& original_message) { |
| + url::RawCanonOutputT<char> buffer; |
| + url::EncodeURIComponent(original_message.data(), original_message.size(), |
| + &buffer); |
| + return std::string(buffer.data(), buffer.length()); |
| +} |
| + |
| void MediaBrowserTest::AddTitlesToAwait(content::TitleWatcher* title_watcher) { |
| title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kEnded)); |
| title_watcher->AlsoWaitForTitle(base::ASCIIToUTF16(kError)); |
| @@ -102,6 +111,17 @@ class MediaTest : public testing::WithParamInterface<bool>, |
| RunMediaTestPage("player.html", query_params, kEnded, http); |
| } |
| + void RunErrorMessageTest(const std::string& tag, |
| + const std::string& media_file, |
| + const std::string& expected_error_substring, |
| + bool http) { |
| + base::StringPairs query_params; |
| + query_params.push_back(std::make_pair(tag, media_file)); |
| + query_params.push_back(std::make_pair( |
| + "error_substr", EncodeErrorMessage(expected_error_substring))); |
| + RunMediaTestPage("player.html", query_params, kErrorEvent, http); |
| + } |
| + |
| void RunVideoSizeTest(const char* media_file, int width, int height) { |
| std::string expected; |
| expected += base::IntToString(width); |
| @@ -259,6 +279,23 @@ IN_PROC_BROWSER_TEST_P(MediaTest, VideoTulipWebm) { |
| PlayVideo("tulip2.webm", GetParam()); |
| } |
| +IN_PROC_BROWSER_TEST_P(MediaTest, VideoErrorMissingResource) { |
| + RunErrorMessageTest("video", "nonexistent_file.webm", |
| + "Media element error: Format error", GetParam()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_P(MediaTest, VideoErrorEmptySrcAttribute) { |
| + RunErrorMessageTest("video", "", "Media element error: Empty src attribute", |
| + GetParam()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_P(MediaTest, VideoErrorNoSupportedStreams) { |
| + RunErrorMessageTest( |
| + "video", "no_streams.webm", |
| + "demuxer: no supported streams: FFmpegDemuxer: no supported streams", |
| + GetParam()); |
|
mlamouri (slow - plz ping)
2017/04/18 12:37:58
Should there be a test for multi-lines errors?
wolenetz
2017/04/18 17:53:06
The spec discussion (and this patch set) leans tow
|
| +} |
| + |
| // Covers tear-down when navigating away as opposed to browser exiting. |
| IN_PROC_BROWSER_TEST_F(MediaTest, Navigate) { |
| PlayVideo("bear.webm", false); |