Commit 4d81c69a authored by srirama.m's avatar srirama.m Committed by Commit bot

Convert video-controls* tests to testharness.js

Cleaning up video-controls* tests in media/
to use testharness.js instead of video-test.js.
This will enable to upstream these tests to web-platform-tests.

BUG=588956

Review-Url: https://codereview.chromium.org/2108993003
Cr-Commit-Position: refs/heads/master@{#403142}
parent 7aa92b14
Test video element control visibility after click on control. After the click the mouse does not move, so the control is still hovered and it should remain visible.
This test only runs in DRT!
EXPECTED (video.paused == 'true') OK
EXPECTED (video.paused == 'false') OK
EXPECTED (getComputedStyle(controls).opacity == '1') OK
END OF TEST
<!DOCTYPE html> <!DOCTYPE html>
<html> <title>Verify that media controls are always visible when hovered.</title>
<style> <script src="../resources/testharness.js"></script>
#no-video-media { <script src="../resources/testharnessreport.js"></script>
width: 320px; <script src="media-file.js"></script>
height: 240px; <script src="media-controls.js"></script>
} <video controls loop></video>
</style>
<!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
(Please avoid writing new tests using video-test.js) -->
<script src=video-test.js></script>
<script src=media-file.js></script>
<script src=media-controls.js></script>
<script> <script>
var controls; async_test(function(t) {
var video = document.querySelector("video");
function runTest() video.oncanplaythrough = t.step_func(function() {
{
video = document.getElementById("no-video-media");
testExpected("video.paused", true); assert_true(video.paused);
if (!window.testRunner)
return;
// Click the play button. // Click the play button.
var playCoords = mediaControlsButtonCoordinates(video, "play-button"); var playCoords = mediaControlsButtonCoordinates(video, "play-button");
var clickX = playCoords[0]; eventSender.mouseMoveTo(playCoords[0], playCoords[1]);
var clickY = playCoords[1]; eventSender.mouseDown();
eventSender.mouseMoveTo(clickX, clickY); eventSender.mouseUp();
eventSender.mouseDown(); assert_false(video.paused);
eventSender.mouseUp();
testExpected("video.paused", false);
runAfterHideMediaControlsTimerFired(function() runAfterHideMediaControlsTimerFired(t.step_func_done(function() {
{ var controls = mediaControlsButton(video, "panel");
controls = mediaControlsButton(video, "panel"); assert_equals(getComputedStyle(controls).opacity, "1");
testExpected("getComputedStyle(controls).opacity", 1); }), video);
});
consoleWrite(""); video.src = findMediaFile("video", "content/test");
endTest(); });
}, video); </script>
} \ No newline at end of file
</script>
<body>
<p>Test video element control visibility after click on control. After the click
the mouse does not move, so the control is still hovered and it should
remain visible.</p>
<p>This test only runs in DRT!</p>
<video id="no-video-media" controls loop oncanplaythrough="runTest()"></video>
<script>
setSrcById("no-video-media", findMediaFile("video", "content/test"));
</script>
</body>
</html>
Test that the controls attribute is not affected by fullscreen
EVENT(loadeddata)
EXPECTED (video.controls == 'false') OK
RUN(video.webkitRequestFullscreen())
EVENT(webkitfullscreenchange)
EXPECTED (video.controls == 'false') OK
END OF TEST
<!doctype html> <!doctype html>
<html> <title>Test that the controls attribute is not affected by fullscreen</title>
<head> <script src="../resources/testharness.js"></script>
<title>Test that the controls attribute is not affected by fullscreen</title> <script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script> <script src="media-file.js"></script>
<!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 <video></video>
(Please avoid writing new tests using video-test.js) --> <script>
<script src="video-test.js"></script> async_test(function(t) {
<script> var video = document.querySelector("video");
function start() video.src = findMediaFile("video", "content/test");
{ video.onloadeddata = t.step_func(function() {
findMediaElement(); assert_false(video.controls);
video.src = findMediaFile("video", "content/test"); video.onwebkitfullscreenchange = t.step_func_done(function() {
waitForEvent("loadeddata", loadeddata); assert_false(video.controls);
} });
function loadeddata() document.onclick = t.step_func(function() {
{ video.webkitRequestFullscreen();
testExpected("video.controls", false); });
waitForEventOnce("webkitfullscreenchange", fullscreenchange); eventSender.mouseDown();
document.addEventListener("click", function() eventSender.mouseUp();
{ });
run("video.webkitRequestFullscreen()"); });
}); </script>
eventSender.mouseDown(); \ No newline at end of file
eventSender.mouseUp();
}
function fullscreenchange()
{
testExpected("video.controls", false);
endTest();
}
</script>
</head>
<body onload="start()">
<p>Test that the controls attribute is not affected by fullscreen</p>
<video></video>
</body>
</html>
Test video control element visibility when play by touch.
This test only runs in DRT!
EXPECTED (video.paused == 'true') OK
EXPECTED (video.paused == 'false') OK
EXPECTED (getComputedStyle(controls).opacity == '0') OK
END OF TEST
<!DOCTYPE html> <!DOCTYPE html>
<html> <title>Test video control element visibility when play by touch.</title>
<style> <script src="../resources/testharness.js"></script>
#no-video-media { <script src="../resources/testharnessreport.js"></script>
width: 320px; <script src="media-file.js"></script>
height: 240px; <script src="media-controls.js"></script>
} <video controls loop></video>
</style>
<!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
(Please avoid writing new tests using video-test.js) -->
<script src=video-test.js></script>
<script src=media-file.js></script>
<script src=media-controls.js></script>
<script> <script>
async_test(function(t) {
var video = document.querySelector("video");
var controls; video.oncanplaythrough = t.step_func(function() {
var controls = mediaControlsButton(video, "panel");
function dispatchActivateEvent(target) { assert_true(video.paused);
// Create a DOMActivate event and dispatch it
var event = document.createEvent('UIEvents');
event.initUIEvent('DOMActivate', true, true, window, 1)
target.dispatchEvent(event);
}
// Click the play button.
var playCoords = mediaControlsButtonCoordinates(video, "play-button");
var clickX = playCoords[0];
var clickY = playCoords[1];
eventSender.gestureTap(clickX, clickY);
eventSender.gestureTapDown(clickX, clickY);
function runTest() // Create a DOMActivate event and dispatch it.
{ var event = document.createEvent("UIEvents");
video = document.getElementById("no-video-media"); event.initUIEvent("DOMActivate", true, true, window, 1);
controls = mediaControlsButton(video, "panel"); controls.dispatchEvent(event);
testExpected("video.paused", true); assert_false(video.paused);
if (!window.testRunner)
return;
// Click the play button. runAfterHideMediaControlsTimerFired(t.step_func_done(function() {
var playCoords = mediaControlsButtonCoordinates(video, "play-button"); assert_equals(getComputedStyle(controls).opacity, "0");
var clickX = playCoords[0]; }), video);
var clickY = playCoords[1]; });
eventSender.gestureTap(clickX, clickY);
eventSender.gestureTapDown(clickX, clickY);
dispatchActivateEvent(controls);
testExpected("video.paused", false); video.src = findMediaFile("video", "content/test");
});
runAfterHideMediaControlsTimerFired(function() </script>
{ \ No newline at end of file
testExpected("getComputedStyle(controls).opacity", 0);
consoleWrite("");
endTest();
}, video);
}
</script>
<body>
<p>Test video control element visibility when play by touch.</p>
<p>This test only runs in DRT!</p>
<video id="no-video-media" controls loop oncanplaythrough="runTest()"></video>
<script>
setSrcById("no-video-media", findMediaFile("video", "content/test"));
</script>
</body>
</html>
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