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 assert_equals(trackElements.length, video.textTracks.length); |
8 (Please avoid writing new tests using video-test.js) --> | 16 for (var i = 0; i < trackElements.length; i++) |
9 <script src=../video-test.js></script> | 17 trackElements[i].onload = t.step_func(trackLoaded); |
10 <script> | |
11 | 18 |
12 var numberOfTrackTests = 2; | 19 enableAllTextTracks(video.textTracks); |
13 | 20 |
14 function trackLoaded() | 21 var numberOfTracksLoaded = 0; |
15 { | 22 function trackLoaded() { |
16 numberOfTracksLoaded++; | 23 numberOfTracksLoaded++; |
17 if (numberOfTracksLoaded == numberOfTrackTests) { | 24 if (numberOfTracksLoaded != 2) |
18 testTrack(0); | 25 return; |
19 testTrackError(1); | |
20 } | |
21 } | |
22 | 26 |
| 27 testTrack(0); |
| 28 testTrackError(1); |
| 29 t.done(); |
| 30 } |
23 | 31 |
24 function testTrack(i) | 32 function testTrack(index) { |
25 { | 33 var expected = [ |
26 findMediaElement(); | 34 { align : "start", position : 10, line : 0, snapToLines : fals
e }, |
27 var expected = | 35 { align : "start", position : "auto", line : 0, snapToLines : true
}, |
28 { | 36 { align : "middle", position : 80, line : 80, snapToLines : fals
e }, |
29 length : 5, | 37 { align : "end", position : 30, line : 5, snapToLines : true
}, |
30 tests: | 38 { align : "middle", position : 60, line : -3, snapToLines : true
} |
31 [ | 39 ]; |
32 { | 40 var properties = [ "align", "position", "line", "snapToLines" ]; |
33 property : "align", | |
34 values : ["start", "start", "middle", "end", "middle
"], | |
35 }, | |
36 { | |
37 property : "position", | |
38 values : [10, "auto", 80, 30, 60], | |
39 }, | |
40 { | |
41 property : "line", | |
42 values : [0, 0, 80, 5, -3], | |
43 }, | |
44 { | |
45 property : "snapToLines", | |
46 values : [false, true, false, true, true], | |
47 }, | |
48 ], | |
49 }; | |
50 testCues(i, expected); | |
51 | 41 |
52 allTestsEnded(); | 42 assert_cues_match(video.textTracks[index].cues, expected, properties); |
53 } | 43 } |
54 | 44 |
55 function testTrackError(i) | 45 function testTrackError(index) { |
56 { | 46 var expected = [ |
57 findMediaElement(); | 47 { align : "middle", position : "auto", line : "auto", snapToLines :
true }, |
58 var expected = | 48 { align : "end", position : 0, line : "auto", snapToLines :
true }, |
59 { | 49 { align : "middle", position : 60, line : -3, snapToLines :
true } |
60 length : 3, | 50 ]; |
61 tests: | 51 var properties = [ "align", "position", "line", "snapToLines" ]; |
62 [ | |
63 { | |
64 property : "align", | |
65 values : ["middle", "end", "middle"], | |
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 | 52 |
83 allTestsEnded(); | 53 assert_cues_match(video.textTracks[index].cues, expected, properties); |
84 } | 54 } |
85 </script> | 55 }); |
86 </head> | 56 </script> |
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 |