summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhalliwell <halliwell@chromium.org>2015-11-11 16:19:27 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-12 00:20:07 +0000
commit7c3a5f4bd5583a7be9cd8064c8a0323cbc95ad33 (patch)
tree91f960d314be747ddc01185945bec7f7ca2c59db
parent8561f30fdbc43ef7d729afcb186c0bc28e470f14 (diff)
downloadchromium_src-7c3a5f4bd5583a7be9cd8064c8a0323cbc95ad33.zip
chromium_src-7c3a5f4bd5583a7be9cd8064c8a0323cbc95ad33.tar.gz
chromium_src-7c3a5f4bd5583a7be9cd8064c8a0323cbc95ad33.tar.bz2
[Chromecast] Adds Browser test for media playback
This is the best mechanism I can find for testing overlay video frame creation and usage (something which can easily be broken right now). It also makes up for the recent loss of the cma end to end test. The overlay frames are still broken (fixing in a separate CL), so this includes a couple of tweaks to handle the breakage more gracefully and fall back to black frames. Once overlays are fixed, that can be replaced with some stronger assertions. BUG=internal b/25230251 Review URL: https://codereview.chromium.org/1431193005 Cr-Commit-Position: refs/heads/master@{#359191}
-rw-r--r--chromecast/browser/BUILD.gn2
-rw-r--r--chromecast/browser/test/chromecast_shell_browser_test.cc49
-rw-r--r--chromecast/chromecast_tests.gypi11
-rw-r--r--chromecast/renderer/media/hole_frame_factory.cc18
-rw-r--r--testing/buildbot/chromium.linux.json6
5 files changed, 79 insertions, 7 deletions
diff --git a/chromecast/browser/BUILD.gn b/chromecast/browser/BUILD.gn
index 1223add..730ffe5 100644
--- a/chromecast/browser/BUILD.gn
+++ b/chromecast/browser/BUILD.gn
@@ -162,6 +162,8 @@ test("cast_shell_browser_test") {
deps = [
":test_support",
"//base",
+ "//content/test:test_support",
+ "//media/base:test_support",
"//testing/gtest",
"//url",
]
diff --git a/chromecast/browser/test/chromecast_shell_browser_test.cc b/chromecast/browser/test/chromecast_shell_browser_test.cc
index bc83b4c..d617f25 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
diff --git a/chromecast/chromecast_tests.gypi b/chromecast/chromecast_tests.gypi
index f3c6249..53316ba 100644
--- a/chromecast/chromecast_tests.gypi
+++ b/chromecast/chromecast_tests.gypi
@@ -348,6 +348,8 @@
'type': '<(gtest_target_type)',
'dependencies': [
'cast_shell_test_support',
+ '../content/content_shell_and_tests.gyp:test_support_content',
+ '../media/media.gyp:media_test_support',
'../testing/gtest.gyp:gtest',
],
'defines': [
@@ -356,6 +358,15 @@
'sources': [
'browser/test/chromecast_shell_browser_test.cc',
],
+ 'conditions': [
+ ['chromecast_branding=="public"', {
+ 'dependencies': [
+ # Link default libcast_media_1.0 statically to prevent
+ # linking dynamically against dummy implementation.
+ 'media/media.gyp:libcast_media_1.0_default_core',
+ ],
+ }],
+ ],
},
# GN target: //chromecast/app:cast_shell_unittests
{
diff --git a/chromecast/renderer/media/hole_frame_factory.cc b/chromecast/renderer/media/hole_frame_factory.cc
index 62dad08..5d9adda 100644
--- a/chromecast/renderer/media/hole_frame_factory.cc
+++ b/chromecast/renderer/media/hole_frame_factory.cc
@@ -27,12 +27,14 @@ HoleFrameFactory::HoleFrameFactory(
gl->BindTexture(GL_TEXTURE_2D, texture_);
image_id_ = gl->CreateGpuMemoryBufferImageCHROMIUM(1, 1, GL_RGBA,
GL_READ_WRITE_CHROMIUM);
- gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
+ if (image_id_) {
+ gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
- gl->GenMailboxCHROMIUM(mailbox_.name);
- gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name);
+ gl->GenMailboxCHROMIUM(mailbox_.name);
+ gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name);
- sync_token_ = gpu::SyncToken(gl->InsertSyncPointCHROMIUM());
+ sync_token_ = gpu::SyncToken(gl->InsertSyncPointCHROMIUM());
+ }
}
}
@@ -43,15 +45,17 @@ HoleFrameFactory::~HoleFrameFactory() {
CHECK(lock);
gpu::gles2::GLES2Interface* gl = lock->ContextGL();
gl->BindTexture(GL_TEXTURE_2D, texture_);
- gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
+ if (image_id_)
+ gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
gl->DeleteTextures(1, &texture_);
- gl->DestroyImageCHROMIUM(image_id_);
+ if (image_id_)
+ gl->DestroyImageCHROMIUM(image_id_);
}
}
scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame(
const gfx::Size& size) {
- if (texture_) {
+ if (texture_ && image_id_) {
scoped_refptr<::media::VideoFrame> frame =
::media::VideoFrame::WrapNativeTexture(
::media::PIXEL_FORMAT_XRGB,
diff --git a/testing/buildbot/chromium.linux.json b/testing/buildbot/chromium.linux.json
index 8922182..b5a7ade 100644
--- a/testing/buildbot/chromium.linux.json
+++ b/testing/buildbot/chromium.linux.json
@@ -193,6 +193,12 @@
"test": "cast_media_unittests"
},
{
+ "args": [
+ "--enable-local-file-accesses",
+ "--enable-cma-media-pipeline",
+ "--ozone-platform=cast",
+ "--no-sandbox"
+ ],
"test": "cast_shell_browser_test"
},
{