Commit 5e00a66b authored by eric@webkit.org's avatar eric@webkit.org

2009-09-17 Alpha Lam <hclam@chromium.org>

        Reviewed by Eric Carlson.

        Media layout tests should have a way to provide test files in different formats
        https://bugs.webkit.org/show_bug.cgi?id=28327

        Updating 19 media layout tests to use media files based on supported codecs.

        * media/media-file.js: Prefer .wav over other formats as this is used the most in tests for mac port.
        Most of audio tests use media/content/test.wav as test file for mac, so this change would make sure
        findMediaFile() will return test.wav but not test.mp3 or other formats.
        (setSrcById): Fixing bug in code.
        * media/video-canvas-source.html: Use findMediaFile() to locate a media file based on supported types.
        * media/video-click-dblckick-standalone.html: ditto.
        * media/video-controls-transformed.html: ditto.
        * media/video-controls-visible-audio-only.html: ditto.
        * media/video-controls-zoomed.html: ditto.
        * media/video-controls.html: ditto.
        * media/video-currentTime-set.html: ditto.
        * media/video-currentTime-set2.html: ditto.
        * media/video-currentTime.html: ditto.
        * media/video-display-none-crash.html: ditto.
        * media/video-display-toggle.html: ditto.
        * media/video-dom-autoplay.html: ditto.
        * media/video-dom-src.html: ditto.
        * media/video-error-abort.html: ditto.
        * media/video-load-networkState.html: ditto.
        * media/video-load-readyState.html: ditto.
        * media/video-loop.html: ditto.
        * media/video-muted.html: ditto.
        * media/video-no-autoplay.html: ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48494 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9363f63c
2009-09-17 Alpha Lam <hclam@chromium.org>
Reviewed by Eric Carlson.
Media layout tests should have a way to provide test files in different formats
https://bugs.webkit.org/show_bug.cgi?id=28327
Updating 19 media layout tests to use media files based on supported codecs.
* media/media-file.js: Prefer .wav over other formats as this is used the most in tests for mac port.
Most of audio tests use media/content/test.wav as test file for mac, so this change would make sure
findMediaFile() will return test.wav but not test.mp3 or other formats.
(setSrcById): Fixing bug in code.
* media/video-canvas-source.html: Use findMediaFile() to locate a media file based on supported types.
* media/video-click-dblckick-standalone.html: ditto.
* media/video-controls-transformed.html: ditto.
* media/video-controls-visible-audio-only.html: ditto.
* media/video-controls-zoomed.html: ditto.
* media/video-controls.html: ditto.
* media/video-currentTime-set.html: ditto.
* media/video-currentTime-set2.html: ditto.
* media/video-currentTime.html: ditto.
* media/video-display-none-crash.html: ditto.
* media/video-display-toggle.html: ditto.
* media/video-dom-autoplay.html: ditto.
* media/video-dom-src.html: ditto.
* media/video-error-abort.html: ditto.
* media/video-load-networkState.html: ditto.
* media/video-load-readyState.html: ditto.
* media/video-loop.html: ditto.
* media/video-muted.html: ditto.
* media/video-no-autoplay.html: ditto.
2009-09-17 Simon Fraser <simon.fraser@apple.com>
Reviewed by Dave Hyatt.
......
var audioCodecs = [
["audio/wav", "wav"],
["audio/aac", "m4a"],
["audio/mpeg", "mp3"],
["audio/wav", "wav"],
["audio/ogg", "ogg"]
["audio/ogg", "oga"]
];
var videoCodecs = [
["video/mp4", "mp4"],
["video/mpeg", "mpg"],
["video/quicktime", "mov"],
["video/ogg", "ogg"]
["video/ogg", "ogv"]
];
function findMediaFile(tagName, name) {
......@@ -19,12 +19,9 @@ function findMediaFile(tagName, name) {
else
codecs = videoCodecs;
var element;
try {
element = document.getElementsByTagName(tagName)[0];
} catch (ex) {
var element = document.getElementsByTagName(tagName)[0];
if (!element)
element = document.createElement(tagName);
}
for (var i = 0; i < codecs.length; ++i) {
if (element.canPlayType(codecs[i][0]))
......@@ -45,5 +42,5 @@ function setSrcByTagName(tagName, src) {
function setSrcById(id, src) {
var element = document.getElementById(id);
if (element)
id.src = src;
element.src = src;
}
......@@ -2,6 +2,7 @@
<head>
<title>Drawing to canvas using video with source element does not taint canvas</title>
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
<script src=media-file.js></script>
<script src=video-test.js></script>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script>
......@@ -27,7 +28,8 @@
findMediaElement();
canvas = document.getElementsByTagName('canvas')[0];
waitForEvent('load', videoLoaded);
run("var source = document.createElement('source'); source.src = 'content/counting.mp4'; video.appendChild(source)");
var mediaFile = findMediaFile("video", "content/counting");
run("var source = document.createElement('source'); source.src = '" + mediaFile + "'; video.appendChild(source)");
}
</script>
</head>
......
<html>
<head>
<script src=media-file.js></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
var video;
function log(msg)
{
......@@ -9,10 +15,6 @@
function test()
{
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
video = document.getElementById('fr').contentDocument.getElementsByTagName('video')[0];
video.addEventListener('canplaythrough', test2);
}
......@@ -38,8 +40,13 @@
}
</script>
</head>
<body onload="test()">
<iframe src="content/test.mp4" id="fr"></iframe>
<body>
<iframe id="fr"></iframe>
<script>
var frame = document.getElementById("fr");
frame.src = findMediaFile("video", "content/test");
frame.addEventListener("load", test);
</script>
<p>This tests that clicking on a standalone video will pause and double-clicking will play.</p>
<pre id="console"></pre>
</body>
......
......@@ -12,6 +12,7 @@
<video controls></video>
<p>Test controls on transformed video.</p>
<p>This test only runs in DRT!</p>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.controls", null, '!=');
......@@ -25,9 +26,7 @@
testExpected("video.paused", false);
endTest();
} );
video.src = 'content/test.mp4';
video.src = findMediaFile("video", "content/test");
</script>
</body>
</html>
......@@ -4,7 +4,12 @@
#no-video-media { background-color: yellow; width: 320px; height: 100px;}
#mouse-parking:hover { padding:8; background-color: blue; }
</style>
<script src=media-file.js></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
var video;
......@@ -47,8 +52,6 @@
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
setTimeout(function() {
document.body.appendChild(document.createTextNode('FAIL'));
if (window.layoutTestController)
......@@ -65,7 +68,10 @@
<p><span id="mouse-parking">mouse parks here, am I blue?</span></p>
<video id="no-video-media" controls loop src="content/test.wav" onload="start()"></video>
<video id="no-video-media" controls loop onload="start()"></video>
<br><br><div id="console"></div>
<script>
setSrcById("no-video-media", findMediaFile("audio", "content/test"));
</script>
</body>
</html>
......@@ -6,6 +6,7 @@
margin: 50px;
}
</style>
<script src=media-file.js></script>
<script type="text/javascript" charset="utf-8">
function runTest()
{
......@@ -33,7 +34,7 @@
waitForEvent('load', function() {
runTest();
} );
video.src = 'content/test.mp4';
video.src = findMediaFile("video", "content/test");
</script>
</body>
</html>
......
<video controls></video>
<p>Test 'controls' attribute<p>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.controls", null, '!=');
......@@ -20,5 +21,5 @@
testExpected("video.controls", null, '!=');
endTest();
} );
video.src = 'content/test.mp4';
video.src = findMediaFile("video", "content/test");
</script>
......@@ -5,6 +5,7 @@
<p>Test that setting currentTime changes the time, and that 'ended' event is fired in a reasonable amount of time</p>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
waitForEvent('load',
......@@ -20,7 +21,7 @@
var timeout = 800;
setTimeout(function () { logResult("No 'ended' event in " + timeout/1000 + "seconds", false); }, timeout);
});
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
</body>
......
<video controls></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
waitForEvent('load',
......@@ -10,5 +11,5 @@
testExpected("video.currentTime.toFixed(1)", 3.1);
endTest();
});
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
<video controls></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.currentTime", 0)
......@@ -10,5 +11,5 @@
testExpected("video.currentTime", 0, '>')
endTest();
}
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
<video controls></video>
<p>Test that pause() after changing display to "none" doesn't cause a crash.</p>
<script src="media-file.js"></script>
<script src="video-test.js"></script>
<script>
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
video.play();
video.style.display = "none";
video.pause();
......
<html>
<head>
<script src=media-file.js></script>
<script>
function toggleDisplay()
{
......@@ -14,6 +15,7 @@
{
if (window.layoutTestController)
layoutTestController.waitUntilDone();
setSrcById('vid', findMediaFile('video', 'content/test'));
document.getElementById('vid').addEventListener("canplaythrough", test2);
}
function test2()
......@@ -28,6 +30,6 @@
</head>
<body onload="test()">
This tests that toggling the display property won't make the controls disappear.<br>
<video id="vid" controls src="content/test.mp4"></video>
<video id="vid" controls></video>
</body>
</html>
<video controls></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.autoplay", false);
......@@ -10,5 +11,5 @@
endTest();
} );
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
<video controls></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.currentSrc", "");
video.src = "content/test.mp4";
var mediaFile = findMediaFile("video", "content/test");
video.src = mediaFile;
testExpected("video.currentSrc", "");
waitForEvent('load', function () {
testExpected("relativeURL(video.currentSrc)", "content/test.mp4");
testExpected("relativeURL(video.currentSrc)", mediaFile);
endTest();
} );
......
<video controls></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.error", null);
......@@ -13,5 +14,5 @@
endTest();
} );
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
......@@ -8,6 +8,7 @@
events and end up with networkState >= NETWORK_LOADING.
</p>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
function testNetworkState(expected, endit, op)
......@@ -31,7 +32,8 @@
consoleWrite("");
// now set a valid url
run("video.src = 'content/test.mp4'");
var mediaFile = findMediaFile("video", "content/test");
run("video.src = '" + mediaFile + "'");
}
// first set the src to a bogus url, it should attempt a load
......
<video controls></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
function testReadyState(expected, endit, op)
......@@ -17,5 +18,5 @@
waitForEventAndFail("playing");
waitForEvent("canplaythrough", function () { testReadyState(HTMLMediaElement.HAVE_ENOUGH_DATA, true ); } );
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
......@@ -2,6 +2,7 @@
<video controls autoplay ></video>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
......@@ -55,10 +56,11 @@
consoleWrite("");
run("video.loop = true");
run("video.src = 'content/test.mp4'");
var mediaFile = findMediaFile("video", "content/test");
run("video.src = '" + mediaFile + "'");
consoleWrite("");
</script>
</head>
</html>
\ No newline at end of file
</html>
<video controls></video>
<p>Test 'muted' attribute<p>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.muted", false);
run("video.muted = true");
testExpected("video.muted", true);
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
run("video.load()");
waitForEvent("load", function () {
testExpected("video.muted", true);
......
<video controls></video>
<p>Test that play event does not fire when "src" set with no autoplay attribute.</p>
<script src=media-file.js></script>
<script src=video-test.js></script>
<script>
testExpected("video.paused", true);
......@@ -16,5 +17,5 @@
}
waitForEvent('load', function () { setTimeout(testPaused, 500);} );
video.src = "content/test.mp4";
video.src = findMediaFile("video", "content/test");
</script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment