Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11245)

Unified Diff: chromecast/browser/test/chromecast_shell_browser_test.cc

Issue 1431193005: [Chromecast] Adds Browser test for media playback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit rm blank line Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/browser/BUILD.gn ('k') | chromecast/chromecast_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/browser/test/chromecast_shell_browser_test.cc
diff --git a/chromecast/browser/test/chromecast_shell_browser_test.cc b/chromecast/browser/test/chromecast_shell_browser_test.cc
index bc83b4ce4862d00d7574c726b8ce2c0e15daee70..d617f25e5f5de9205e8e17e10acf2a2b777897b4 100644
--- a/chromecast/browser/test/chromecast_shell_browser_test.cc
+++ b/chromecast/browser/test/chromecast_shell_browser_test.cc
@@ -3,12 +3,21 @@
// found in the LICENSE file.
#include "base/macros.h"
+#include "base/strings/string_split.h"
+#include "base/strings/utf_string_conversions.h"
#include "chromecast/browser/test/chromecast_browser_test.h"
+#include "content/public/test/browser_test_utils.h"
+#include "media/base/test_data_util.h"
#include "url/gurl.h"
#include "url/url_constants.h"
namespace chromecast {
namespace shell {
+namespace {
+const char kEnded[] = "ENDED";
+const char kError[] = "ERROR";
+const char kFailed[] = "FAILED";
+}
class ChromecastShellBrowserTest : public ChromecastBrowserTest {
public:
@@ -19,9 +28,45 @@ class ChromecastShellBrowserTest : public ChromecastBrowserTest {
NavigateToURL(web_contents(), url_);
}
+ void PlayVideo(const std::string& media_file) {
+ PlayMedia("video", media_file);
+ }
+
private:
const GURL url_;
+ void PlayMedia(const std::string& tag,
+ const std::string& media_file) {
+ base::StringPairs query_params;
+ query_params.push_back(std::make_pair(tag, media_file));
+ RunMediaTestPage("player.html", query_params, kEnded);
+ }
+
+ void RunMediaTestPage(const std::string& html_page,
+ const base::StringPairs& query_params,
+ const std::string& expected_title) {
+ std::string query = media::GetURLQueryString(query_params);
+ GURL gurl = content::GetFileUrlWithQuery(
+ media::GetTestDataFilePath(html_page),
+ query);
+
+ std::string final_title = RunTest(gurl, expected_title);
+ EXPECT_EQ(expected_title, final_title);
+ }
+
+ std::string RunTest(const GURL& gurl,
+ const std::string& expected_title) {
+ content::TitleWatcher title_watcher(web_contents(),
+ base::ASCIIToUTF16(expected_title));
+ title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kEnded));
+ title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kError));
+ title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kFailed));
+
+ NavigateToURL(web_contents(), gurl);
+ base::string16 result = title_watcher.WaitAndGetTitle();
+ return base::UTF16ToASCII(result);
+ }
+
DISALLOW_COPY_AND_ASSIGN(ChromecastShellBrowserTest);
};
@@ -32,5 +77,9 @@ IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, EmptyTest) {
EXPECT_TRUE(true);
}
+IN_PROC_BROWSER_TEST_F(ChromecastShellBrowserTest, MediaPlayback) {
+ PlayVideo("bear.mp4");
+}
+
} // namespace shell
} // namespace chromecast
« no previous file with comments | « chromecast/browser/BUILD.gn ('k') | chromecast/chromecast_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698