summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 22:47:06 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 22:47:06 +0000
commit4b87e474248a7d635df9b48983c89f61f7f6d570 (patch)
tree081f3b749cd7d5cb6b9187eb3fe90380bc688134 /chrome
parentdbcda9bb32b1753395ebd40e0a3df9f47c0c8998 (diff)
downloadchromium_src-4b87e474248a7d635df9b48983c89f61f7f6d570.zip
chromium_src-4b87e474248a7d635df9b48983c89f61f7f6d570.tar.gz
chromium_src-4b87e474248a7d635df9b48983c89f61f7f6d570.tar.bz2
UI test for <video>
Simple ui test that goes through some test clips. TEST=MediaTest.* Review URL: http://codereview.chromium.org/125173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/media_uitest.cc52
-rw-r--r--chrome/chrome.gyp2
-rw-r--r--chrome/test/data/media/bear.mp4bin0 -> 134641 bytes
-rw-r--r--chrome/test/data/media/player.html46
4 files changed, 100 insertions, 0 deletions
diff --git a/chrome/browser/media_uitest.cc b/chrome/browser/media_uitest.cc
new file mode 100644
index 0000000..faa8d15
--- /dev/null
+++ b/chrome/browser/media_uitest.cc
@@ -0,0 +1,52 @@
+// 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_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);
+ }
+};
+
+TEST_F(MediaTest, VideoBearH264) {
+ PlayVideo("bear.mp4");
+}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index ef48b56..a407299 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -3098,6 +3098,7 @@
'browser/images_uitest.cc',
'browser/locale_tests_uitest.cc',
'browser/login_prompt_uitest.cc',
+ 'browser/media_uitest.cc',
'browser/metrics/metrics_service_uitest.cc',
'browser/printing/printing_layout_uitest.cc',
'browser/printing/printing_test.h',
@@ -3210,6 +3211,7 @@
'sources!': [
# TODO(port)? (Most of these include windows.h or similar.)
'browser/extensions/extension_uitest.cc',
+ 'browser/media_uitest.cc',
'browser/printing/printing_layout_uitest.cc',
'browser/ssl/ssl_uitest.cc',
'browser/views/find_bar_win_uitest.cc',
diff --git a/chrome/test/data/media/bear.mp4 b/chrome/test/data/media/bear.mp4
new file mode 100644
index 0000000..f0b4707
--- /dev/null
+++ b/chrome/test/data/media/bear.mp4
Binary files differ
diff --git a/chrome/test/data/media/player.html b/chrome/test/data/media/player.html
new file mode 100644
index 0000000..3b8fd9b
--- /dev/null
+++ b/chrome/test/data/media/player.html
@@ -0,0 +1,46 @@
+<html>
+<body>
+<div id="player_container"></div>
+<script>
+var player = null;
+function InstallEventHandler(event, action) {
+ player.addEventListener(event, function(e) {
+ eval(action);
+ }, 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?query".
+var ok = false;
+if (url_parts.length > 1) {
+ var query = url_parts[1];
+ var query_parts = query.split('=');
+ if (query_parts.length == 2) {
+ var tag = query_parts[0];
+ var media_url = query_parts[1];
+ if (tag == 'audio' || tag == 'video') {
+ ok = true;
+ var container = document.getElementById('player_container');
+ container.innerHTML = '<' + tag + ' controls id="player"></' + tag + '>';
+ player = document.getElementById('player');
+
+ // Install event handlers.
+ InstallEventHandler('error',
+ 'document.title = "ERROR = " + player.error.code');
+ InstallEventHandler('playing', 'document.title = "PLAYING"');
+
+ // Starts the player.
+ player.src = media_url;
+ player.play();
+ }
+ }
+}
+if (!ok) {
+ document.title = 'FAILED';
+}
+</script>
+</body>
+</html>