Commit 029e9b25 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/2115833002
Cr-Commit-Position: refs/heads/master@{#403434}
parent b392dd07
Test 'controls' attribute
EXPECTED (video.controls != 'null') OK
EVENT(canplaythrough)
EXPECTED (video.controls != 'null') OK
RUN(video.removeAttribute('controls'))
EXPECTED (video.controls == 'false') OK
RUN(video.controls = true)
EXPECTED (video.getAttribute('controls') == '') OK
RUN(video.controls = false)
EXPECTED (video.controls == 'false') OK
RUN(video.setAttribute('controls','controls'))
EXPECTED (video.controls != 'null') OK
END OF TEST
Test controls on transformed video.
This test only runs in DRT!
EXPECTED (video.controls != 'null') OK
EVENT(canplaythrough)
EXPECTED (video.paused == 'false') OK
END OF TEST
<html>
<head>
<title>Test controls on transformed video</title>
<style type="text/css" media="screen">
video {
margin: 50px;
transform: rotate(20deg);
}
</style>
</head>
<body>
<video controls></video>
<p>Test controls on transformed video.</p>
<p>This test only runs in DRT!</p>
<script src=media-file.js></script>
<!-- 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-controls.js></script>
<script>
testExpected("video.controls", null, '!=');
waitForEvent('canplaythrough', function () {
if (window.eventSender) {
// Find the play button and click the middle of its bounding box.
var playCoords;
try {
playCoords = mediaControlsButtonCoordinates(video, "play-button");
} catch (exception) {
failTest(exception.description);
return;
}
var clickX = playCoords[0];
var clickY = playCoords[1];
eventSender.mouseMoveTo(clickX, clickY);
eventSender.mouseDown();
eventSender.mouseUp();
}
testExpected("video.paused", false);
endTest();
} );
video.src = findMediaFile("video", "content/test");
</script>
</body>
</html>
<!DOCTYPE html>
<title>Test "controls" on transformed video.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
<script src="media-controls.js"></script>
<style>
video {
margin: 50px;
transform: rotate(20deg);
}
</style>
<video controls></video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
assert_true(video.controls);
video.oncanplaythrough = t.step_func_done(function() {
// Find the play button and click the middle of its bounding box.
var playCoords = mediaControlsButtonCoordinates(video, "play-button");
eventSender.mouseMoveTo(playCoords[0], playCoords[1]);
eventSender.mouseDown();
eventSender.mouseUp();
assert_false(video.paused);
});
video.src = findMediaFile("video", "content/test");
});
</script>
\ No newline at end of file
Test controls on zoomed video.
This test only runs in DRT!
EXPECTED (video.controls != 'null') OK
EVENT(canplaythrough)
EXPECTED (video.paused == 'false') OK
END OF TEST
<html>
<head>
<title>Test controls with zooming</title>
<style type="text/css" media="screen">
video {
margin: 50px;
}
</style>
<script src=media-file.js></script>
<script src=media-controls.js></script>
<script type="text/javascript" charset="utf-8">
function runTest()
{
window.setTimeout(function() {
document.documentElement.style.zoom = '150%';
video.addEventListener("playing", function() {
testExpected("video.paused", false);
endTest();
});
<!DOCTYPE html>
<title>Test controls with zooming.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
<script src="media-controls.js"></script>
<style>
video {
margin: 50px;
}
</style>
<video controls></video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
assert_true(video.controls);
if (window.eventSender)
{
// Find the play button and click the middle of its bounding box.
var playCoords;
try {
playCoords = mediaControlsButtonCoordinates(video, "play-button");
} catch (exception) {
failTest(exception.description);
return;
}
var clickX = playCoords[0];
var clickY = playCoords[1];
video.oncanplaythrough = t.step_func(function() {
setTimeout(function() {
document.documentElement.style.zoom = "150%";
video.onplaying = t.step_func_done(function() {
assert_false(video.paused);
});
// Find the play button and click the middle of its bounding box.
var playCoords = mediaControlsButtonCoordinates(video, "play-button");
// Apply the page zoom value to the coordinates because
// getBoundingClientRect() used in
// mediaControlsButtonCoordinates() doesn't do it.
clickX = clickX * 1.5;
clickY = clickY * 1.5;
// getBoundingClientRect() used in mediaControlsButtonCoordinates() doesn't do it.
var clickX = playCoords[0] * 1.5;
var clickY = playCoords[1] * 1.5;
eventSender.mouseMoveTo(clickX, clickY);
eventSender.mouseDown();
eventSender.mouseUp();
}
}, 50);
}
</script>
</head>
<body>
<video controls></video>
<p>Test controls on zoomed video.</p>
<p>This test only runs in DRT!</p>
<!-- 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>
testExpected("video.controls", null, '!=');
waitForEvent('canplaythrough', function() {
runTest();
} );
video.src = findMediaFile("video", "content/test");
</script>
</body>
</html>
}, 50);
});
video.src = findMediaFile("video", "content/test");
});
</script>
\ No newline at end of file
<!DOCTYPE html>
<title>Test "controls" attribute.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
<video controls></video>
<p>Test 'controls' attribute<p>
<script src=media-file.js></script>
<!-- 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>
testExpected("video.controls", null, '!=');
waitForEvent('canplaythrough', function () {
testExpected("video.controls", null, '!=');
run("video.removeAttribute('controls')");
testExpected("video.controls", false, '==');
run("video.controls = true");
testExpected("video.getAttribute('controls')", "");
run("video.controls = false");
testExpected("video.controls", false, '==');
run("video.setAttribute('controls','controls')");
testExpected("video.controls", null, '!=');
endTest();
} );
async_test(function(t) {
var video = document.querySelector("video");
assert_true(video.controls);
video.oncanplaythrough = t.step_func_done(function() {
assert_true(video.controls);
video.removeAttribute("controls");
assert_false(video.controls);
video.controls = true;
assert_equals(video.getAttribute("controls"), "");
video.controls = false;
assert_false(video.controls);
video.setAttribute("controls", "controls");
assert_true(video.controls);
});
video.src = findMediaFile("video", "content/test");
</script>
});
</script>
\ No newline at end of file
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