Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
| diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
| index 998408c798f95631842fe1a4894e42083fdca56e..1a644f00bebf36b85c8cdf9f8beba83ec736a586 100644 |
| --- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
| +++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
| @@ -1,86 +1,53 @@ |
| <!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 testCueDisplayBox; |
| - var seekedCount = 0; |
| - var info = [ "Lorem", "ipsum", "dolor", "sit" ]; |
| - |
| - function testFontSize(width, height) |
| - { |
| - run("video.width = " + width); |
| - run("video.height = " + height); |
| - document.body.offsetTop; |
| - testExpected("getComputedStyle(textTrackDisplayElement(video)).fontSize", parseInt(height * 0.05) + "px"); |
| - consoleWrite(""); |
| - } |
| - |
| - function testCueStyle() |
| - { |
| - consoleWrite("<br>Test the cue display colors and font."); |
| +<title>Test that default positioned TextTrack's cues are rendered correctly.</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.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"); |
| + |
| + var cueTextIndex = 0; |
| + var cueText = [ "Lorem", "ipsum", "dolor", "sit" ]; |
| + video.onseeked = t.step_func(function() { |
| + assert_equals(video.currentTime, cueTextIndex + 0.5); |
| + assert_equals(testTrack.track.activeCues.length, 1); |
| + assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex]); |
| + |
| + var testCueDisplayBox = textTrackDisplayElement(video, "display"); |
| + assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]); |
| + assert_true(2 * testCueDisplayBox.offsetLeft == video.videoWidth - testCueDisplayBox.offsetWidth) |
| + |
| + if (++cueTextIndex == cueText.length) { |
| + // Test the cue display colors and font. |
| testFontSize(320, 240); |
| testFontSize(640, 480); |
| testFontSize(1280, 960); |
| testFontSize(2560, 1440); |
| - testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif"); |
| - testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgb(255, 255, 255)"); |
| - testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.796875)"); |
| + assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontFamily, "sans-serif"); |
| + assert_equals(getComputedStyle(textTrackDisplayElement(video)).color, "rgb(255, 255, 255)"); |
| + assert_equals(getComputedStyle(textTrackDisplayElement(video, "display").firstChild).backgroundColor, "rgba(0, 0, 0, 0.8)"); |
|
Srirama
2016/04/25 11:13:23
mediacontrols.css specifies, background-color: rgb
|
| - endTest(); |
| - |
| - // Resize the video so it is easier to interact with it manually, if necessary. |
| - video.width = 320; |
| - video.height = 240; |
| + t.done(); |
| + } else { |
| + video.currentTime = video.currentTime + 1; |
| } |
| - |
| - function seeked() |
| - { |
| - if (testEnded) |
| - return; |
| - |
| - testExpected("video.currentTime", seekedCount + .5); |
| - testExpected("testTrack.track.activeCues.length", 1); |
| - testExpected("testTrack.track.activeCues[0].text", info[seekedCount]); |
| - |
| - testCueDisplayBox = textTrackDisplayElement(video, 'display'); |
| - testExpected("testCueDisplayBox.innerText", info[seekedCount]); |
| - testExpected("2 * testCueDisplayBox.offsetLeft == video.videoWidth - testCueDisplayBox.offsetWidth", true) |
| - |
| - if (++seekedCount == info.length) |
| - testCueStyle(); |
| - else { |
| - consoleWrite(""); |
| - run("video.currentTime = " + (video.currentTime + 1)); |
| - return; |
| - } |
| - } |
| - |
| - function loaded() |
| - { |
| - consoleWrite("Test that default positioned TextTrack's cues are rendered correctly."); |
| - findMediaElement(); |
| - testTrack = document.querySelector('track'); |
| - video.src = findMediaFile('video', '../content/test'); |
| - waitForEvent('seeked', seeked); |
| - waitForEventOnce('canplaythrough', function() { video.currentTime = .5; }); |
| - } |
| - |
| - </script> |
| - </head> |
| - <body onload="loaded()"> |
| - <video controls > |
| - <track src="captions-webvtt/captions.vtt" kind="captions" default> |
| - </video> |
| - </body> |
| -</html> |
| + }); |
| + |
| + function testFontSize(width, height) { |
| + video.width = width; |
| + video.height = height; |
| + document.body.offsetTop; |
|
mlamouri (slow - plz ping)
2016/04/25 15:53:26
nit: add a comment explaining this line is for for
Srirama
2016/04/26 07:00:16
Done.
|
| + assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontSize, parseInt(height * 0.05) + "px"); |
| + } |
| + |
| + video.currentTime = 0.5; |
| +}); |
| +</script> |