Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html |
| diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html |
| index 68e96d9a35d077a97f3fc2531e3969b10afbb94c..b299b701a7968552398c9f09eda07ee7012581b7 100644 |
| --- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html |
| +++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-snap-to-lines-not-set.html |
| @@ -1,103 +1,80 @@ |
| <!DOCTYPE html> |
| -<html> |
| - <head> |
| - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| - |
| - <script src=../media-file.js></script> |
| - <!-- TODO(philipj): 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> |
| - |
| - var testTrack; |
| - var cueDisplayElement; |
| - var cueDisplayContainer; |
| - var controlsPanelElement; |
| - var seekedCount = 0; |
| - |
| - var testCaseDescription = [ |
| - "Default", |
| - "Center", |
| - "Top left", |
| - "Top right", |
| - "Bottom right", |
| - "Bottom left", |
| - "Bottom center", |
| - "Multiple cues" |
| - ]; |
| - |
| - var testCaseSeekTime = [ |
| - 0.10, |
| - 0.60, |
| - 1.10, |
| - 1.60, |
| - 2.10, |
| - 2.60, |
| - 3.10, |
| - 4.10 |
| - ]; |
| - |
| - var currentTestCase = 0; |
| - |
| - function seeked() |
| - { |
| - consoleWrite("Active cues: " + testTrack.track.activeCues.length); |
| - for (var i = 0; i < testTrack.track.activeCues.length; ++i) { |
| - cueDisplayElement = textTrackDisplayElement(video, 'display', i); |
| - |
| - consoleWrite(""); |
| - consoleWrite("* Cue " + i + " *"); |
| - testExpected("cueDisplayElement.innerText", testTrack.track.activeCues[i].text); |
| - consoleWrite("Cue alignment (default or as specified): " + testTrack.track.activeCues[i].align); |
| - |
| - consoleWrite("Cue left position (percentage): " + Math.round(cueDisplayElement.offsetLeft / cueDisplayContainer.offsetWidth * 100)); |
| - consoleWrite("Cue top position (percentage): " + Math.round(cueDisplayElement.offsetTop / cueDisplayContainer.offsetHeight * 100)); |
| - } |
| - |
| - runNextTestCase(); |
| - }; |
| - |
| - function runNextTestCase() |
| - { |
| - if (currentTestCase == testCaseDescription.length) { |
| - endTest(); |
| - return; |
| - } |
| - |
| - consoleWrite(""); |
| - consoleWrite("** " + testCaseDescription[currentTestCase] + " **"); |
| - |
| - video.currentTime = testCaseSeekTime[currentTestCase]; |
| - waitForEvent('seeked', seeked, false, true); |
| - |
| - currentTestCase++; |
| - } |
| - |
| - function loaded() |
| - { |
| - consoleWrite("Test that TextTrack's cues are rendered correctly when the snap to lines flag is not set."); |
| - |
| - findMediaElement(); |
| - testTrack = document.querySelector('track'); |
| - video.src = findMediaFile('video', '../content/test'); |
| - |
| - // In Chromium it is the enclosure element, which provides the controls height, otherwise the panel; |
| - // both are the second child in the shadow DOM. |
| - controlsPanelElement = internals.shadowRoot(video).firstChild.firstChild; |
| - |
| - waitForEventOnce('canplaythrough', function() { |
| - cueDisplayContainer = textTrackDisplayElement(video); |
| - runNextTestCase(); |
| - }); |
| +<title>Test that TextTrack's cues are rendered correctly when the snap to lines flag is not set.</title> |
| +<script src="../media-file.js"></script> |
| +<script src="../media-controls.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<video> |
| + <track src="captions-webvtt/captions-snap-to-lines-not-set.vtt" kind="captions" default> |
| +</video> |
| +<script> |
| +async_test(function(t) { |
| + var video = document.querySelector("video"); |
| + var testTrack = document.querySelector("track"); |
| + video.src = findMediaFile("video", "../content/test"); |
| + |
| + // In Chromium it is the enclosure element, which provides the controls height, otherwise the panel; |
| + // both are the second child in the shadow DOM. |
| + var controlsPanelElement = internals.shadowRoot(video).firstChild.firstChild; |
| + |
| + var cueDisplayContainer; |
| + video.oncanplaythrough = t.step_func(function() { |
| + cueDisplayContainer = textTrackDisplayElement(video); |
| + runNextTestCase(); |
| + }); |
| + |
| + var seekTimeIndex = 0; |
| + var testCaseSeekTime = [ |
| + 0.10, |
| + 0.60, |
| + 1.10, |
| + 1.60, |
| + 2.10, |
| + 2.60, |
| + 3.10, |
| + 4.10 |
| + ]; |
| + var cueRenderingPosition = [ |
|
Srirama
2016/04/25 11:13:23
Right now these cue rendering position values are
|
| + // Number of active cues 1. |
| + [[0 ,100, "middle"]], |
| + [[0, 50, "middle"]], |
| + [[0, 0, "start"]], |
| + [[0, 0, "end"]], |
| + [[0, 100, "right"]], |
| + [[0, 100, "left"]], |
| + [[0, 50, "middle"]], |
| + [ //Number of active cues 7. |
| + [0, 50, "middle"], |
| + [0, 0, "start"], |
| + [0, 0, "end"], |
| + [0, 100, "middle"], |
| + [0, 25, "end"], |
| + [44, 33, "start"], |
| + [23, 55, "start"] |
| + ] |
| + ]; |
| + function runNextTestCase() { |
| + if (seekTimeIndex == testCaseSeekTime.length) |
| + t.done(); |
| + |
| + video.currentTime = testCaseSeekTime[seekTimeIndex]; |
| + video.onseeked = t.step_func(seeked); |
| + } |
| + |
| + function seeked() { |
| + var cuePosition = cueRenderingPosition[seekTimeIndex]; |
| + for (var i = 0; i < testTrack.track.activeCues.length; ++i) { |
| + cueDisplayElement = textTrackDisplayElement(video, "display", i); |
| + |
| + assert_equals(cueDisplayElement.innerText, testTrack.track.activeCues[i].text); |
| + assert_equals(testTrack.track.activeCues[i].align, cuePosition[i][2]); |
| + |
| + assert_equals(Math.round(cueDisplayElement.offsetLeft / cueDisplayContainer.offsetWidth * 100), cuePosition[i][0]); |
| + assert_equals(Math.round(cueDisplayElement.offsetTop / cueDisplayContainer.offsetHeight * 100), cuePosition[i][1]); |
| } |
| - </script> |
| - </head> |
| - <body onload="loaded()"> |
| - <video controls> |
| - <track src="captions-webvtt/captions-snap-to-lines-not-set.vtt" kind="captions" default> |
| - </video> |
| - </body> |
| -</html> |
| + seekTimeIndex++; |
| + runNextTestCase(); |
| + } |
| +}); |
| +</script> |