OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests cue text position and alignment 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/tc016-align-positioning.vtt"> | |
8 <track src="captions-webvtt/tc016-align-positioning-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
It feels a bit odd to use another length for itera
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() { | |
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 position : 10, |
fs
2016/05/25 19:49:56
I think it would be ok to write these lists as one
Srirama
2016/05/26 10:47:18
Done.
| |
17 if (numberOfTracksLoaded == numberOfTrackTests) { | 35 align : "start", |
18 testTrack(0); | 36 vertical : "" |
19 testTrackError(1); | 37 }, |
20 } | 38 { |
39 position : 20, | |
40 align : "middle", | |
41 vertical : "" | |
42 }, | |
43 { | |
44 position : 80, | |
45 align : "end", | |
46 vertical : "" | |
21 } | 47 } |
48 ]; | |
22 | 49 |
23 function testTrack(i) | 50 assert_cues_equal_by_style(video.textTracks[index].cues, expected); |
51 } | |
52 | |
53 function testTrackError(index) { | |
54 var expected = [ | |
24 { | 55 { |
25 findMediaElement(); | 56 position : 10, |
26 var expected = | 57 align : "middle", |
27 { | 58 vertical : "" |
28 length : 3, | 59 }, |
29 tests: | 60 { |
30 [ | 61 position : "auto", |
31 { | 62 align : "middle", |
32 property : "position", | 63 vertical : "" |
33 values : [10, 20, 80], | 64 }, |
34 }, | 65 { |
35 { | 66 position : "auto", |
36 property : "align", | 67 align : "middle", |
37 values : ["start", "middle", "end"], | 68 vertical : "" |
38 }, | 69 } |
39 ], | 70 ]; |
40 }; | |
41 testCues(i, expected); | |
42 | 71 |
43 allTestsEnded(); | 72 assert_cues_equal_by_style(video.textTracks[index].cues, expected); |
44 } | 73 } |
45 | 74 }); |
46 function testTrackError(i) | 75 </script> |
47 { | |
48 findMediaElement(); | |
49 var expected = | |
50 { | |
51 length : 3, | |
52 tests: | |
53 [ | |
54 { | |
55 property : "position", | |
56 values : [10, "auto", "auto"], | |
57 }, | |
58 { | |
59 property : "align", | |
60 values : ["middle", "middle", "middle"], | |
61 }, | |
62 ], | |
63 }; | |
64 testCues(i, expected); | |
65 | |
66 allTestsEnded(); | |
67 } | |
68 </script> | |
69 </head> | |
70 <body onload="enableAllTextTracks()"> | |
71 <p>Tests cue text position and alignment from settings.</p> | |
72 <video> | |
73 <track src="captions-webvtt/tc016-align-positioning.vtt" onload="tra ckLoaded()"> | |
74 <track src="captions-webvtt/tc016-align-positioning-bad.vtt" onload= "trackLoaded()"> | |
75 </video> | |
76 </body> | |
77 </html> | |
OLD | NEW |