Index: third_party/WebKit/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html |
diff --git a/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html b/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html |
index 784292b112347b1d8a5b4b7bdfb22eded75347a4..32da1a3a57339e35eb5019e75af1897e60271117 100644 |
--- a/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html |
+++ b/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc018-align-text-line-position.html |
@@ -1,94 +1,103 @@ |
<!DOCTYPE html> |
-<html> |
- <head> |
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
+<title>Tests cue alignment, line and text position from settings.</title> |
+<script src="track-helpers.js"></script> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<video> |
+ <track src="captions-webvtt/tc018-align-text-line-position.vtt"> |
+ <track src="captions-webvtt/tc018-align-text-line-position-bad.vtt"> |
+</video> |
+<script> |
+async_test(function(t) { |
+ var video = document.querySelector("video"); |
- <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> |
+ var trackElements = document.querySelectorAll("track"); |
+ for (var i = 0; i < video.textTracks.length; i++) |
fs
2016/05/25 19:49:56
Same.
Srirama
2016/05/26 10:47:18
Done.
|
+ trackElements[i].onload = t.step_func(trackLoaded); |
- var numberOfTrackTests = 2; |
+ enableAllTextTracks(video.textTracks); |
- function trackLoaded() |
+ var numberOfTracksLoaded = 0; |
+ function trackLoaded() { |
fs
2016/05/25 19:49:56
Getting a feeling that turning this pattern into a
Srirama
2016/05/26 10:47:18
ok, but how can we call these testTrack and testTr
|
+ numberOfTracksLoaded++; |
+ if (numberOfTracksLoaded != 2) |
+ return; |
+ |
+ testTrack(0); |
+ testTrackError(1); |
+ t.done(); |
+ } |
+ |
+ function testTrack(index) { |
+ var expected = [ |
+ { |
+ align : "start", |
+ position : 10, |
+ line : 0, |
+ snapToLines : false |
+ }, |
+ { |
+ align : "start", |
+ position : "auto", |
+ line : 0, |
+ snapToLines : true |
+ }, |
+ { |
+ align : "middle", |
+ position : 80, |
+ line : 80, |
+ snapToLines : false |
+ }, |
+ { |
+ align : "end", |
+ position : 30, |
+ line : 5, |
+ snapToLines : true |
+ }, |
{ |
- numberOfTracksLoaded++; |
- if (numberOfTracksLoaded == numberOfTrackTests) { |
- testTrack(0); |
- testTrackError(1); |
- } |
+ align : "middle", |
+ position : 60, |
+ line : -3, |
+ snapToLines : true |
} |
+ ]; |
+ testCues(video.textTracks[index].cues, expected); |
+ } |
- function testTrack(i) |
+ function testTrackError(index) { |
+ var expected = [ |
{ |
- findMediaElement(); |
- var expected = |
- { |
- length : 5, |
- tests: |
- [ |
- { |
- property : "align", |
- values : ["start", "start", "middle", "end", "middle"], |
- }, |
- { |
- property : "position", |
- values : [10, "auto", 80, 30, 60], |
- }, |
- { |
- property : "line", |
- values : [0, 0, 80, 5, -3], |
- }, |
- { |
- property : "snapToLines", |
- values : [false, true, false, true, true], |
- }, |
- ], |
- }; |
- testCues(i, expected); |
- |
- allTestsEnded(); |
+ align : "middle", |
+ position : "auto", |
+ line : "auto", |
+ snapToLines : true |
+ }, |
+ { |
+ align : "end", |
+ position : 0, |
+ line : "auto", |
+ snapToLines : true |
+ }, |
+ { |
+ align : "middle", |
+ position : 60, |
+ line : -3, |
+ snapToLines : true |
} |
+ ]; |
- function testTrackError(i) |
- { |
- findMediaElement(); |
- var expected = |
- { |
- length : 3, |
- tests: |
- [ |
- { |
- property : "align", |
- values : ["middle", "end", "middle"], |
- }, |
- { |
- property : "position", |
- values : ["auto", 0, 60], |
- }, |
- { |
- property : "line", |
- values : ["auto", "auto", -3], |
- }, |
- { |
- property : "snapToLines", |
- values : [true, true, true], |
- }, |
- ], |
- }; |
- testCues(i, expected); |
+ testCues(video.textTracks[index].cues, expected); |
+ } |
- allTestsEnded(); |
- } |
- </script> |
- </head> |
- <body onload="enableAllTextTracks()"> |
- <p>Tests cue alignment, line and text position from settings.</p> |
- <video> |
- <track src="captions-webvtt/tc018-align-text-line-position.vtt" onload="trackLoaded()"> |
- <track src="captions-webvtt/tc018-align-text-line-position-bad.vtt" onload="trackLoaded()"> |
- </video> |
- </body> |
-</html> |
+ function testCues(cues, expected) { |
+ assert_equals(cues.length, expected.length); |
+ for (var i = 0; i < cues.length; i++) { |
+ assert_equals(cues[i].align, expected[i].align); |
+ assert_equals(cues[i].position, expected[i].position); |
+ assert_equals(cues[i].line, expected[i].line); |
+ assert_equals(cues[i].snapToLines, expected[i].snapToLines); |
+ } |
+ } |
+}); |
+</script> |