OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests cue line 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/tc017-line-position.vtt"> |
| 8 <track src="captions-webvtt/tc017-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 |
23 function testTrack(i) | 27 testTrack(0); |
24 { | 28 testTrackError(1); |
25 findMediaElement(); | 29 t.done(); |
26 var expected = | 30 } |
27 { | |
28 length : 7, | |
29 tests: | |
30 [ | |
31 { | |
32 property : "line", | |
33 values : [0, 0, 50, 5, 100, -1, 500], | |
34 }, | |
35 { | |
36 property : "snapToLines", | |
37 values : [false, true, false, true, false, true, tru
e], | |
38 }, | |
39 ], | |
40 }; | |
41 testCues(i, expected); | |
42 | 31 |
43 allTestsEnded(); | 32 function testTrack(index) { |
44 } | 33 var expected = [ |
| 34 { line : 0, snapToLines : false }, |
| 35 { line : 0, snapToLines : true }, |
| 36 { line : 50, snapToLines : false }, |
| 37 { line : 5, snapToLines : true }, |
| 38 { line : 100, snapToLines : false }, |
| 39 { line : -1, snapToLines : true }, |
| 40 { line : 500, snapToLines : true } |
| 41 ]; |
| 42 var properties = [ "line", "snapToLines" ]; |
45 | 43 |
46 function testTrackError(i) | 44 assert_cues_match(video.textTracks[index].cues, expected, properties); |
47 { | 45 } |
48 findMediaElement(); | |
49 var expected = | |
50 { | |
51 length : 6, | |
52 tests: | |
53 [ | |
54 { | |
55 property : "line", | |
56 values : ["auto", "auto", "auto", "auto", "auto", "a
uto", "auto"], | |
57 }, | |
58 { | |
59 property : "snapToLines", | |
60 values : [true, true, true, true, true, true, true], | |
61 }, | |
62 ], | |
63 }; | |
64 testCues(i, expected); | |
65 | 46 |
66 allTestsEnded(); | 47 function testTrackError(index) { |
67 } | 48 var expected = [ |
68 </script> | 49 { line : "auto", snapToLines : true }, |
69 </head> | 50 { line : "auto", snapToLines : true }, |
70 <body onload="enableAllTextTracks()"> | 51 { line : "auto", snapToLines : true }, |
71 <p>Tests cue line position from settings.</p> | 52 { line : "auto", snapToLines : true }, |
72 <video> | 53 { line : "auto", snapToLines : true }, |
73 <track src="captions-webvtt/tc017-line-position.vtt" onload="trackLo
aded()"> | 54 { line : "auto", snapToLines : true } |
74 <track src="captions-webvtt/tc017-line-position-bad.vtt" onload="tra
ckLoaded()"> | 55 ]; |
75 </video> | 56 var properties = [ "line", "snapToLines" ]; |
76 </body> | 57 |
77 </html> | 58 assert_cues_match(video.textTracks[index].cues, expected, properties); |
| 59 } |
| 60 }); |
| 61 </script> |
OLD | NEW |