Skip to content

Commit

Permalink
Convert media-captions-* and media-constants-* tests to testharness.js
Browse files Browse the repository at this point in the history
Cleaning up media-captions-* and media-constants-* 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/2031503002
Cr-Commit-Position: refs/heads/master@{#397377}
  • Loading branch information
srirama179 authored and Commit bot committed Jun 2, 2016
1 parent 30c929f commit 7e922c0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 123 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,51 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<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>

function canplaythrough()
{
consoleWrite("<br>** Initial state: no text tracks, controls should not be visible **");
testExpected("video.textTracks.length", 0);
testExpected("video.controls", false, '==');

consoleWrite("<br>** Add a text track, controls should not become visible **");
run("video.addTextTrack('captions')");
testExpected("video.textTracks.length", 1);
testExpected("video.controls", false);

consoleWrite("<br>** Enable controls **");
run("video.setAttribute('controls','controls')");
testExpected("video.textTracks.length", 1);
testExpected("video.controls", true);
panel = mediaControlsButton(video, "panel");
testExpected("internals.shadowRoot(video).firstChild", null, "!=");
testExpected("panel.style['display']", 'none', "!=");

consoleWrite("");
endTest();
}

function start()
{
findMediaElement();

waitForEvent('canplaythrough', canplaythrough);
video.src = findMediaFile("video", "content/test");
}

</script>
</head>
<body onload="start()">
<video>
</video>
<p>Tests that adding a text track does not make controls visible.</p>
</body>
</html>
<title>Tests that adding a text track does not make controls visible.</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>
<video></video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.src = findMediaFile("video", "content/test");

video.oncanplaythrough = t.step_func_done(function() {
// Initial state: no text tracks, controls should not be visible.
assert_equals(video.textTracks.length, 0);
assert_false(video.controls);

// Add a text track, controls should not become visible.
video.addTextTrack("captions");
assert_equals(video.textTracks.length, 1);
assert_false(video.controls);

// Enable controls.
video.setAttribute("controls","controls");
assert_equals(video.textTracks.length, 1);
assert_true(video.controls);
assert_not_equals(internals.shadowRoot(video).firstChild, null);
var panel = mediaControlsButton(video, "panel");
assert_not_equals(panel.style["display"], "none");
});
});
</script>
19 changes: 0 additions & 19 deletions third_party/WebKit/LayoutTests/media/media-constants-expected.txt

This file was deleted.

52 changes: 20 additions & 32 deletions third_party/WebKit/LayoutTests/media/media-constants.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<!-- 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 type="text/javascript">
function doTest ()
{
testExpected("HTMLMediaElement.NETWORK_EMPTY", 0);
testExpected("HTMLMediaElement.NETWORK_IDLE", 1);
testExpected("HTMLMediaElement.NETWORK_LOADING", 2);
testExpected("HTMLMediaElement.NETWORK_NO_SOURCE", 3);
consoleWrite("");
<title>Test HTMLMediaElement and MediaError constants.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(HTMLMediaElement.NETWORK_EMPTY, 0);
assert_equals(HTMLMediaElement.NETWORK_IDLE, 1);
assert_equals(HTMLMediaElement.NETWORK_LOADING, 2);
assert_equals(HTMLMediaElement.NETWORK_NO_SOURCE, 3);

testExpected("HTMLMediaElement.HAVE_NOTHING", 0);
testExpected("HTMLMediaElement.HAVE_METADATA", 1);
testExpected("HTMLMediaElement.HAVE_CURRENT_DATA", 2);
testExpected("HTMLMediaElement.HAVE_FUTURE_DATA", 3);
testExpected("HTMLMediaElement.HAVE_ENOUGH_DATA", 4);
consoleWrite("");
assert_equals(HTMLMediaElement.HAVE_NOTHING, 0);
assert_equals(HTMLMediaElement.HAVE_METADATA, 1);
assert_equals(HTMLMediaElement.HAVE_CURRENT_DATA, 2);
assert_equals(HTMLMediaElement.HAVE_FUTURE_DATA, 3);
assert_equals(HTMLMediaElement.HAVE_ENOUGH_DATA, 4);

testExpected("MediaError.MEDIA_ERR_ABORTED", 1);
testExpected("MediaError.MEDIA_ERR_NETWORK", 2);
testExpected("MediaError.MEDIA_ERR_DECODE", 3);
testExpected("MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED", 4);

endTest();
}
</script>
</head>
<body onload="doTest()">
<p>Test HTMLMediaElement and MediaError constants.</p>
</body>
</html>
assert_equals(MediaError.MEDIA_ERR_ABORTED, 1);
assert_equals(MediaError.MEDIA_ERR_NETWORK, 2);
assert_equals(MediaError.MEDIA_ERR_DECODE, 3);
assert_equals(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, 4);
});
</script>

0 comments on commit 7e922c0

Please sign in to comment.