Commit de30ce28 authored by dino@apple.com's avatar dino@apple.com
Browse files

Cleanup some captions menu tests

https://bugs.webkit.org/show_bug.cgi?id=105500

Reviewed by Eric Carlson.

Use the helper library where possible. Dynamically add
video.src so that we always get the 'canplaythrough' event.

* media/video-controls-captions-trackmenu-expected.txt:
* media/video-controls-captions-trackmenu-localized.html:
* media/video-controls-captions-trackmenu-sorted.html:
* media/video-controls-captions-trackmenu.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138283 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9ba18d8c
2012-12-19 Dean Jackson <dino@apple.com>
Cleanup some captions menu tests
https://bugs.webkit.org/show_bug.cgi?id=105500
Reviewed by Eric Carlson.
Use the helper library where possible. Dynamically add
video.src so that we always get the 'canplaythrough' event.
* media/video-controls-captions-trackmenu-expected.txt:
* media/video-controls-captions-trackmenu-localized.html:
* media/video-controls-captions-trackmenu-sorted.html:
* media/video-controls-captions-trackmenu.html:
2012-12-19 Dean Jackson <dino@apple.com>
 
Follow WebVTT line breaking rules
......@@ -2,15 +2,14 @@ Test that we are able to trigger the list of captions, and select from the list.
EVENT(canplaythrough)
*** Add another text track.
RUN(video.addTextTrack("captions", "Commentary", "ru"))
*** Set the user language preference.
RUN(internals.setUserPreferredLanguages(['en']))
*** Click the CC button.
*** Add another text track.
RUN(video.addTextTrack("captions", "Commentary", "ru"))
*** Turning captions on
Found 5 menu items OK
There should be 5 items in the menu.
EXPECTED (5 == '5') OK
EXPECTED (video.textTracks.length == '4') OK
Track 0 should be showing
EXPECTED (video.textTracks[0].mode == 'showing') OK
......@@ -24,10 +23,9 @@ EXPECTED (textTrackDisplayElement(video, 'display').innerText == 'Lorem') OK
*** Remove a track.
RUN(video.removeChild(document.querySelectorAll("track")[0]))
*** Click the CC button.
*** Turning captions off
Found 4 menu items OK
There should be 4 items in the menu.
EXPECTED (4 == '4') OK
EXPECTED (video.textTracks.length == '3') OK
Track 0 should be disabled
EXPECTED (video.textTracks[0].mode == 'disabled') OK
......
......@@ -52,6 +52,7 @@
function start()
{
findMediaElement();
video.src = findMediaFile('video', 'content/test');
waitForEvent('canplaythrough', function () { startTrackMenuTest(testMenuHeaders); });
}
</script>
......@@ -60,8 +61,6 @@
<body onload="start()">
<p>Test that captions and subtitles menu items are localized.</p>
<video width="500" height="300" controls>
<source src="content/test.mp4" type="video/mp4">
<source src="content/test.ogv" type="video/ogg">
<track kind="captions" src="track/captions-webvtt/captions-fast.vtt">
<track kind="subtitles" src="track/captions-webvtt/captions-fast.vtt">
</video>
......
......@@ -49,6 +49,7 @@
function start()
{
findMediaElement();
video.src = findMediaFile('video', 'content/test');
waitForEvent('canplaythrough', function () { startTrackMenuTest(testSortedMenu); });
}
</script>
......@@ -57,8 +58,6 @@
<body onload="start()">
<p>Test that captions and subtitles are sorted in the menu.</p>
<video width="500" height="300" controls>
<source src="content/test.mp4" type="video/mp4">
<source src="content/test.ogv" type="video/ogg">
<track label="c" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
<track label="b" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">
<track label="a" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en">
......
......@@ -5,48 +5,23 @@
<script src="media-controls.js"></script>
<script src="media-file.js"></script>
<script src="video-test.js"></script>
<script src="trackmenu-test.js"></script>
<script>
var captionsButtonCoordinates;
if (window.testRunner)
testRunner.dumpAsText();
function clickCCButton()
{
consoleWrite("<br>*** Click the CC button.");
eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
eventSender.mouseDown();
eventSender.mouseUp();
}
function startTest()
{
consoleWrite("<br>*** Add another text track.");
run('video.addTextTrack("captions", "Commentary", "ru")');
if (window.eventSender) {
consoleWrite("<br>*** Set the user language preference.");
run("internals.setUserPreferredLanguages(['en'])");
try {
captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
} catch (exception) {
failTest(exception.description);
return;
}
clickCCButton();
window.setTimeout(turnCaptionsOn, 100);
}
window.setTimeout(turnCaptionsOn, 100);
}
function trackMenuList()
{
var trackListElement;
try {
trackListElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-closed-captions-track-list");
} catch (exception) {
failTest(exception.description);
var trackListElement = getTrackListElement();
if (!trackListElement)
return;
}
// Track list should have a <ul> with five <li> children (One of them is "Off").
var trackList = trackListElement.querySelector("ul");
if (!trackList) {
......@@ -55,7 +30,7 @@
}
var trackListItems = trackList.querySelectorAll("li");
if (!trackListItems) {
failTest("Could not find a child li elements in track list menu");
failTest("Could not find child li elements in track list menu");
return;
}
......@@ -66,11 +41,8 @@
{
var trackListItems = trackMenuList();
var expectedItemCount = video.textTracks.length + 1;
if (trackListItems.length != expectedItemCount) {
failTest("Expected " + expectedItemCount + " items in menu but found " + trackListItems.length);
return;
}
logResult(true, "Found " + expectedItemCount + " menu items");
consoleWrite("There should be " + expectedItemCount + " items in the menu.");
testExpected(trackListItems.length, expectedItemCount);
}
function selectCaptionMenuItem(index, nextStep)
......@@ -136,7 +108,8 @@
function start()
{
findMediaElement();
waitForEvent('canplaythrough', startTest);
video.src = findMediaFile('video', 'content/test');
waitForEvent('canplaythrough', function () { startTrackMenuTest(startTest); });
}
</script>
</head>
......@@ -144,8 +117,6 @@
<body onload="start()">
<p>Test that we are able to trigger the list of captions, and select from the list.</p>
<video width="500" height="300" controls>
<source src="content/test.mp4" type="video/mp4">
<source src="content/test.ogv" type="video/ogg">
<track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en">
<track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">
<track kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
......
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