Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Tests cue alignment, line and text position from settings.</title> |
| 3 <head> | 3 <script src="track-helpers.js"></script> |
| 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | |
| 6 <video> | |
| 7 <track src="captions-webvtt/tc018-align-text-line-position.vtt"> | |
| 8 <track src="captions-webvtt/tc018-align-text-line-position-bad.vtt"> | |
| 9 </video> | |
| 10 <script> | |
| 11 async_test(function(t) { | |
| 12 var video = document.querySelector("video"); | |
| 5 | 13 |
| 6 <script src=../media-file.js></script> | 14 var trackElements = document.querySelectorAll("track"); |
| 7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 15 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.
| |
| 8 (Please avoid writing new tests using video-test.js) --> | 16 trackElements[i].onload = t.step_func(trackLoaded); |
| 9 <script src=../video-test.js></script> | |
| 10 <script> | |
| 11 | 17 |
| 12 var numberOfTrackTests = 2; | 18 enableAllTextTracks(video.textTracks); |
| 13 | 19 |
| 14 function trackLoaded() | 20 var numberOfTracksLoaded = 0; |
| 21 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
| |
| 22 numberOfTracksLoaded++; | |
| 23 if (numberOfTracksLoaded != 2) | |
| 24 return; | |
| 25 | |
| 26 testTrack(0); | |
| 27 testTrackError(1); | |
| 28 t.done(); | |
| 29 } | |
| 30 | |
| 31 function testTrack(index) { | |
| 32 var expected = [ | |
| 15 { | 33 { |
| 16 numberOfTracksLoaded++; | 34 align : "start", |
| 17 if (numberOfTracksLoaded == numberOfTrackTests) { | 35 position : 10, |
| 18 testTrack(0); | 36 line : 0, |
| 19 testTrackError(1); | 37 snapToLines : false |
| 20 } | 38 }, |
| 39 { | |
| 40 align : "start", | |
| 41 position : "auto", | |
| 42 line : 0, | |
| 43 snapToLines : true | |
| 44 }, | |
| 45 { | |
| 46 align : "middle", | |
| 47 position : 80, | |
| 48 line : 80, | |
| 49 snapToLines : false | |
| 50 }, | |
| 51 { | |
| 52 align : "end", | |
| 53 position : 30, | |
| 54 line : 5, | |
| 55 snapToLines : true | |
| 56 }, | |
| 57 { | |
| 58 align : "middle", | |
| 59 position : 60, | |
| 60 line : -3, | |
| 61 snapToLines : true | |
| 21 } | 62 } |
| 63 ]; | |
| 22 | 64 |
| 65 testCues(video.textTracks[index].cues, expected); | |
| 66 } | |
| 23 | 67 |
| 24 function testTrack(i) | 68 function testTrackError(index) { |
| 69 var expected = [ | |
| 25 { | 70 { |
| 26 findMediaElement(); | 71 align : "middle", |
| 27 var expected = | 72 position : "auto", |
| 28 { | 73 line : "auto", |
| 29 length : 5, | 74 snapToLines : true |
| 30 tests: | 75 }, |
| 31 [ | 76 { |
| 32 { | 77 align : "end", |
| 33 property : "align", | 78 position : 0, |
| 34 values : ["start", "start", "middle", "end", "middle "], | 79 line : "auto", |
| 35 }, | 80 snapToLines : true |
| 36 { | 81 }, |
| 37 property : "position", | 82 { |
| 38 values : [10, "auto", 80, 30, 60], | 83 align : "middle", |
| 39 }, | 84 position : 60, |
| 40 { | 85 line : -3, |
| 41 property : "line", | 86 snapToLines : true |
| 42 values : [0, 0, 80, 5, -3], | 87 } |
| 43 }, | 88 ]; |
| 44 { | |
| 45 property : "snapToLines", | |
| 46 values : [false, true, false, true, true], | |
| 47 }, | |
| 48 ], | |
| 49 }; | |
| 50 testCues(i, expected); | |
| 51 | 89 |
| 52 allTestsEnded(); | 90 testCues(video.textTracks[index].cues, expected); |
| 53 } | 91 } |
| 54 | 92 |
| 55 function testTrackError(i) | 93 function testCues(cues, expected) { |
| 56 { | 94 assert_equals(cues.length, expected.length); |
| 57 findMediaElement(); | 95 for (var i = 0; i < cues.length; i++) { |
| 58 var expected = | 96 assert_equals(cues[i].align, expected[i].align); |
| 59 { | 97 assert_equals(cues[i].position, expected[i].position); |
| 60 length : 3, | 98 assert_equals(cues[i].line, expected[i].line); |
| 61 tests: | 99 assert_equals(cues[i].snapToLines, expected[i].snapToLines); |
| 62 [ | 100 } |
| 63 { | 101 } |
| 64 property : "align", | 102 }); |
| 65 values : ["middle", "end", "middle"], | 103 </script> |
| 66 }, | |
| 67 { | |
| 68 property : "position", | |
| 69 values : ["auto", 0, 60], | |
| 70 }, | |
| 71 { | |
| 72 property : "line", | |
| 73 values : ["auto", "auto", -3], | |
| 74 }, | |
| 75 { | |
| 76 property : "snapToLines", | |
| 77 values : [true, true, true], | |
| 78 }, | |
| 79 ], | |
| 80 }; | |
| 81 testCues(i, expected); | |
| 82 | |
| 83 allTestsEnded(); | |
| 84 } | |
| 85 </script> | |
| 86 </head> | |
| 87 <body onload="enableAllTextTracks()"> | |
| 88 <p>Tests cue alignment, line and text position from settings.</p> | |
| 89 <video> | |
| 90 <track src="captions-webvtt/tc018-align-text-line-position.vtt" onlo ad="trackLoaded()"> | |
| 91 <track src="captions-webvtt/tc018-align-text-line-position-bad.vtt" onload="trackLoaded()"> | |
| 92 </video> | |
| 93 </body> | |
| 94 </html> | |
| OLD | NEW |