summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/media_browsertest.cc185
-rw-r--r--chrome/browser/media_uitest.cc129
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/test/data/media/player_fullscreen.html56
-rw-r--r--chrome/test/interactive_ui/interactive_ui_tests.gypi1
5 files changed, 242 insertions, 130 deletions
diff --git a/chrome/browser/media_browsertest.cc b/chrome/browser/media_browsertest.cc
new file mode 100644
index 0000000..ca17800
--- /dev/null
+++ b/chrome/browser/media_browsertest.cc
@@ -0,0 +1,185 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "base/utf_string_conversions.h"
+#include "base/string_util.h"
+#include "chrome/browser/view_ids.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_type.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+#include "chrome/test/ui/ui_layout_test.h"
+#include "net/base/net_util.h"
+
+namespace {
+
+const wchar_t kPlaying[] = L"PLAYING";
+const wchar_t kReady[] = L"READY";
+const wchar_t kFullScreen[] = L"FULLSCREEN";
+
+} // namespace
+
+class MediaBrowserTest : public InProcessBrowserTest {
+ protected:
+ MediaBrowserTest() {
+ set_show_window(true);
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) {
+ command_line->AppendSwitch(switches::kEnableVideoFullscreen);
+ }
+
+ void PlayMedia(const char* tag, const char* media_file) {
+ FilePath test_file;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file));
+ test_file = test_file.AppendASCII("media/player.html");
+
+ GURL player_gurl = net::FilePathToFileURL(test_file);
+ std::string url = StringPrintf("%s?%s=%s",
+ player_gurl.spec().c_str(),
+ tag,
+ media_file);
+
+ TabContents* tab_contents = browser()->GetSelectedTabContents();
+
+ ui_test_utils::WindowedNotificationObserver<TabContents>
+ observer(NotificationType::TAB_CONTENTS_TITLE_UPDATED, tab_contents);
+ ui_test_utils::NavigateToURL(browser(), GURL(url));
+ observer.Wait();
+
+ string16 title;
+ ui_test_utils::GetCurrentTabTitle(browser(), &title);
+ EXPECT_EQ(WideToUTF16(kPlaying), title);
+ }
+
+ void PlayAudio(const char* url) {
+ PlayMedia("audio", url);
+ }
+
+ void PlayVideo(const char* url) {
+ PlayMedia("video", url);
+ }
+
+ void PlayVideoFullScreen(const char* media_file) {
+ FilePath test_file;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file));
+ test_file = test_file.AppendASCII("media/player_fullscreen.html");
+
+ GURL player_gurl = net::FilePathToFileURL(test_file);
+ std::string url = StringPrintf("%s?%s",
+ player_gurl.spec().c_str(),
+ media_file);
+
+ TabContents* tab_contents = browser()->GetSelectedTabContents();
+
+ ui_test_utils::WindowedNotificationObserver<TabContents>
+ observer(NotificationType::TAB_CONTENTS_TITLE_UPDATED, tab_contents);
+ ui_test_utils::NavigateToURL(browser(), GURL(url));
+ observer.Wait();
+
+ string16 title;
+ ui_test_utils::GetCurrentTabTitle(browser(), &title);
+ EXPECT_EQ(WideToUTF16(kReady), title);
+
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ ui_test_utils::WaitForNotification(
+ NotificationType::TAB_CONTENTS_TITLE_UPDATED);
+ ui_test_utils::GetCurrentTabTitle(browser(), &title);
+ EXPECT_EQ(WideToUTF16(kFullScreen), title);
+ }
+};
+
+#if defined(OS_WIN)
+
+// Tests may fail on windows: http://crbug.com/55477
+#define MAYBE_VideoBearTheora FLAKY_VideoBearTheora
+#define MAYBE_VideoBearSilentTheora FLAKY_VideoBearSilentTheora
+#define MAYBE_VideoBearWebm FLAKY_VideoBearWebm
+#define MAYBE_VideoBearSilentWebm FLAKY_VideoBearSilentWebm
+#define MAYBE_VideoBearMp4 FLAKY_VideoBearMp4
+#define MAYBE_VideoBearSilentMp4 FLAKY_VideoBearSilentMp4
+#define MAYBE_MediaUILayoutTest FLAKY_MediaUILayoutTest
+
+#else
+
+#define MAYBE_VideoBearTheora VideoBearTheora
+#define MAYBE_VideoBearSilentTheora VideoBearSilentTheora
+#define MAYBE_VideoBearWebm VideoBearWebm
+#define MAYBE_VideoBearSilentWebm VideoBearSilentWebm
+#define MAYBE_VideoBearMp4 VideoBearMp4
+#define MAYBE_VideoBearSilentMp4 VideoBearSilentMp4
+#define MAYBE_MediaUILayoutTest MediaUILayoutTest
+
+#endif
+
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_VideoBearTheora) {
+ PlayVideo("bear.ogv");
+}
+
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_VideoBearSilentTheora) {
+ PlayVideo("bear_silent.ogv");
+}
+
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_VideoBearWebm) {
+ PlayVideo("bear.webm");
+}
+
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_VideoBearSilentWebm) {
+ PlayVideo("bear_silent.webm");
+}
+
+#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_VideoBearMp4) {
+ PlayVideo("bear.mp4");
+}
+
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, MAYBE_VideoBearSilentMp4) {
+ PlayVideo("bear_silent.mp4");
+}
+#endif
+
+// TODO(imcheng): Disabled until fullscreen Webkit patch is here - See
+// http://crbug.com/54838.
+// (Does Mac have fullscreen?)
+#if defined(OS_WIN) || defined(OS_LINUX)
+IN_PROC_BROWSER_TEST_F(MediaBrowserTest, DISABLED_VideoBearFullScreen) {
+ PlayVideoFullScreen("bear.ogv");
+}
+#endif // defined(OS_WIN) || defined(OS_LINUX)
+
+TEST_F(UILayoutTest, MAYBE_MediaUILayoutTest) {
+ static const char* kResources[] = {
+ "content",
+ "media-file.js",
+ "media-fullscreen.js",
+ "video-paint-test.js",
+ "video-played.js",
+ "video-test.js",
+ };
+
+ static const char* kMediaTests[] = {
+ "video-autoplay.html",
+ // "video-loop.html", disabled due to 52887.
+ "video-no-autoplay.html",
+ // TODO(sergeyu): Add more tests here.
+ };
+
+ FilePath test_dir;
+ FilePath media_test_dir;
+ media_test_dir = media_test_dir.AppendASCII("media");
+ InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort);
+
+ // Copy resources first.
+ for (size_t i = 0; i < arraysize(kResources); ++i)
+ AddResourceForLayoutTest(
+ test_dir, media_test_dir.AppendASCII(kResources[i]));
+
+ for (size_t i = 0; i < arraysize(kMediaTests); ++i)
+ RunLayoutTest(kMediaTests[i], kNoHttpPort);
+}
diff --git a/chrome/browser/media_uitest.cc b/chrome/browser/media_uitest.cc
index 8f62a2a..e69de29 100644
--- a/chrome/browser/media_uitest.cc
+++ b/chrome/browser/media_uitest.cc
@@ -1,129 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/basictypes.h"
-#include "base/file_path.h"
-#include "base/platform_thread.h"
-#include "base/string_util.h"
-#include "chrome/test/ui/ui_layout_test.h"
-#include "chrome/test/ui/ui_test.h"
-#include "net/base/net_util.h"
-
-class MediaTest : public UITest {
- protected:
- void PlayMedia(const char* tag, const char* media_file) {
- FilePath test_file(test_data_directory_);
- test_file = test_file.AppendASCII("media/player.html");
-
- GURL player_gurl = net::FilePathToFileURL(test_file);
- std::string url = StringPrintf("%s?%s=%s",
- player_gurl.spec().c_str(),
- tag,
- media_file);
-
- NavigateToURL(GURL(url));
-
- // Allow the media file to be loaded.
- const std::wstring kPlaying = L"PLAYING";
- const std::wstring kFailed = L"FAILED";
- const std::wstring kError = L"ERROR";
- for (int i = 0; i < 10; ++i) {
- PlatformThread::Sleep(sleep_timeout_ms());
- const std::wstring& title = GetActiveTabTitle();
- if (title == kPlaying || title == kFailed ||
- StartsWith(title, kError, true))
- break;
- }
-
- EXPECT_EQ(kPlaying, GetActiveTabTitle());
- }
-
- void PlayAudio(const char* url) {
- PlayMedia("audio", url);
- }
-
- void PlayVideo(const char* url) {
- PlayMedia("video", url);
- }
-};
-
-#if defined(OS_WIN)
-
-// Tests may fail on windows: http://crbug.com/55477
-#define MAYBE_VideoBearTheora FLAKY_VideoBearTheora
-#define MAYBE_VideoBearSilentTheora FLAKY_VideoBearSilentTheora
-#define MAYBE_VideoBearWebm FLAKY_VideoBearWebm
-#define MAYBE_VideoBearSilentWebm FLAKY_VideoBearSilentWebm
-#define MAYBE_VideoBearMp4 FLAKY_VideoBearMp4
-#define MAYBE_VideoBearSilentMp4 FLAKY_VideoBearSilentMp4
-#define MAYBE_MediaUILayoutTest FLAKY_MediaUILayoutTest
-
-#else
-
-#define MAYBE_VideoBearTheora VideoBearTheora
-#define MAYBE_VideoBearSilentTheora VideoBearSilentTheora
-#define MAYBE_VideoBearWebm VideoBearWebm
-#define MAYBE_VideoBearSilentWebm VideoBearSilentWebm
-#define MAYBE_VideoBearMp4 VideoBearMp4
-#define MAYBE_VideoBearSilentMp4 VideoBearSilentMp4
-#define MAYBE_MediaUILayoutTest MediaUILayoutTest
-
-#endif
-
-TEST_F(MediaTest, MAYBE_VideoBearTheora) {
- PlayVideo("bear.ogv");
-}
-
-TEST_F(MediaTest, MAYBE_VideoBearSilentTheora) {
- PlayVideo("bear_silent.ogv");
-}
-
-TEST_F(MediaTest, MAYBE_VideoBearWebm) {
- PlayVideo("bear.webm");
-}
-
-TEST_F(MediaTest, MAYBE_VideoBearSilentWebm) {
- PlayVideo("bear_silent.webm");
-}
-
-#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
-TEST_F(MediaTest, MAYBE_VideoBearMp4) {
- PlayVideo("bear.mp4");
-}
-
-TEST_F(MediaTest, MAYBE_VideoBearSilentMp4) {
- PlayVideo("bear_silent.mp4");
-}
-#endif
-
-TEST_F(UILayoutTest, MAYBE_MediaUILayoutTest) {
- static const char* kResources[] = {
- "content",
- "media-file.js",
- "media-fullscreen.js",
- "video-paint-test.js",
- "video-played.js",
- "video-test.js",
- };
-
- static const char* kMediaTests[] = {
- "video-autoplay.html",
- // "video-loop.html", disabled due to 52887.
- "video-no-autoplay.html",
- // TODO(sergeyu): Add more tests here.
- };
-
- FilePath test_dir;
- FilePath media_test_dir;
- media_test_dir = media_test_dir.AppendASCII("media");
- InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort);
-
- // Copy resources first.
- for (size_t i = 0; i < arraysize(kResources); ++i)
- AddResourceForLayoutTest(
- test_dir, media_test_dir.AppendASCII(kResources[i]));
-
- for (size_t i = 0; i < arraysize(kMediaTests); ++i)
- RunLayoutTest(kMediaTests[i], kNoHttpPort);
-}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 725d730..94e1665 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -311,7 +311,6 @@
'browser/in_process_webkit/dom_storage_uitest.cc',
'browser/locale_tests_uitest.cc',
'browser/login_prompt_uitest.cc',
- 'browser/media_uitest.cc',
'browser/metrics/metrics_service_uitest.cc',
'browser/prefs/pref_service_uitest.cc',
'browser/printing/printing_layout_uitest.cc',
diff --git a/chrome/test/data/media/player_fullscreen.html b/chrome/test/data/media/player_fullscreen.html
new file mode 100644
index 0000000..d31579c
--- /dev/null
+++ b/chrome/test/data/media/player_fullscreen.html
@@ -0,0 +1,56 @@
+<html>
+<body>
+<div id="player_container"></div>
+<script>
+var player = null;
+var ready = false;
+
+// Parse the location and load the media file accordingly.
+var url = window.location.href;
+var url_parts = url.split('?');
+
+// Make sure the URL is of the form "player.html?media_url".
+var ok = false;
+if (url_parts.length > 1) {
+ var media_url = url_parts[1];
+ ok = true;
+ var container = document.getElementById('player_container');
+ container.innerHTML = '<video id="player"></video>';
+ player = document.getElementById('player');
+
+ // Install event handlers.
+ player.addEventListener('error',
+ function() {
+ document.title = "ERROR = " + player.error.code;
+ },
+ false);
+ player.addEventListener('canplay',
+ function() {
+ if (!player.webkitSupportsFullscreen) {
+ document.title = "ERROR fullscreen unsupported";
+ } else {
+ document.title = "READY";
+ }
+ },
+ false);
+
+ // Starts the player.
+ player.src = media_url;
+ player.play();
+ document.onclick = function () {
+ try {
+ player.webkitEnterFullScreen();
+ } catch (err) {}
+ if (!player.webkitDisplayingFullscreen) {
+ document.title = "ERROR entering to fullscreen";
+ } else {
+ document.title = "FULLSCREEN";
+ }
+ };
+}
+if (!ok) {
+ document.title = 'FAILED';
+}
+</script>
+</body>
+</html>
diff --git a/chrome/test/interactive_ui/interactive_ui_tests.gypi b/chrome/test/interactive_ui/interactive_ui_tests.gypi
index 2c9be8e..af784be 100644
--- a/chrome/test/interactive_ui/interactive_ui_tests.gypi
+++ b/chrome/test/interactive_ui/interactive_ui_tests.gypi
@@ -34,6 +34,7 @@
'<(DEPTH)/chrome/browser/collected_cookies_uitest.cc',
'<(DEPTH)/chrome/browser/debugger/devtools_sanity_unittest.cc',
'<(DEPTH)/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc',
+ '<(DEPTH)/chrome/browser/media_browsertest.cc',
'<(DEPTH)/chrome/browser/notifications/notifications_interactive_uitest.cc',
'<(DEPTH)/chrome/browser/views/bookmark_bar_view_test.cc',
'<(DEPTH)/chrome/browser/views/browser_keyboard_accessibility_test_win.cc',