OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test that cues are rendered when only the track mode is changed.</title> |
3 <head> | 3 <script src="../media-file.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../media-controls.js"></script> |
| 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var video = document.createElement('video'); |
| 10 video.src = findMediaFile('video', '../content/test'); |
5 | 11 |
6 <script src=../media-file.js></script> | 12 video.oncanplaythrough = t.step_func_done(function() { |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 13 addTracks(); |
8 (Please avoid writing new tests using video-test.js) --> | 14 testCueActiveState(); |
9 <script src=../video-test.js></script> | 15 testCueVisibility(); |
10 <script src=../media-controls.js></script> | 16 }); |
11 | 17 |
12 <script> | 18 var testTrackArabic; |
| 19 var testTrackEnglish; |
| 20 var testCueDisplayBox; |
13 | 21 |
14 var testTrackArabic; | 22 function addTracks() { |
15 var testTrackEnglish; | 23 // Add 'Arabic' text track with one cue. |
16 var testCueDisplayBox; | 24 testTrackArabic = video.addTextTrack('captions', 'Arabic', 'ar'); |
| 25 testTrackArabic.addCue(new VTTCue(0, 10, 'Arabic')); |
17 | 26 |
18 function addTracks() | 27 // Add 'English' text track with one cue. |
19 { | 28 testTrackEnglish = video.addTextTrack('captions', 'English', 'en'); |
20 consoleWrite(""); | 29 testTrackEnglish.addCue(new VTTCue(0, 10, 'English')); |
21 | 30 |
22 consoleWrite("Add 'Arabic' text track with one cue"); | 31 // Set the mode of the 'Arabic' track to showing. |
23 testTrackArabic = video.addTextTrack('captions', 'Arabic', 'ar'); | 32 testTrackArabic.mode = 'showing'; |
24 testTrackArabic.addCue(new VTTCue(0.0, 10.0, 'Arabic')); | |
25 | 33 |
26 consoleWrite("Add 'English' text track with one cue"); | 34 // Set the mode of the 'English' track to hidden. |
27 testTrackEnglish = video.addTextTrack('captions', 'English', 'en'); | 35 testTrackEnglish.mode = 'hidden'; |
28 testTrackEnglish.addCue(new VTTCue(0.0, 10.0, 'English')); | 36 } |
29 | 37 |
30 consoleWrite(""); | 38 function testCueActiveState() { |
31 consoleWrite("Set the mode of the 'Arabic' track to showing"); | 39 // Both cues should be active. |
32 testTrackArabic.mode = "showing"; | 40 assert_equals(testTrackEnglish.activeCues.length, 1); |
| 41 assert_equals(testTrackEnglish.activeCues[0].text, 'English'); |
33 | 42 |
34 consoleWrite("Set the mode of the 'English' track to hidden"); | 43 assert_equals(testTrackArabic.activeCues.length, 1); |
35 testTrackEnglish.mode = "hidden"; | 44 assert_equals(testTrackArabic.activeCues[0].text, 'Arabic'); |
36 } | 45 } |
37 | 46 |
38 function testCueActiveState() | 47 function testCueVisibility() { |
39 { | 48 // Only one cue should be visible. |
40 consoleWrite(""); | 49 testCueDisplayBox = textTrackDisplayElement(video, 'display', 0); |
41 consoleWrite("** Both cues should be active **"); | 50 assert_equals(testCueDisplayBox.innerText, 'Arabic'); |
42 testExpected("testTrackEnglish.activeCues.length", 1); | 51 assert_equals(testCueDisplayBox.nextSibling, null); |
43 testExpected("testTrackEnglish.activeCues[0].text", "English"); | |
44 | 52 |
45 testExpected("testTrackArabic.activeCues.length", 1); | 53 // Set the mode of the 'English' track to showing. |
46 testExpected("testTrackArabic.activeCues[0].text", "Arabic"); | 54 testTrackEnglish.mode = 'showing'; |
47 } | |
48 | 55 |
49 function testCueVisibility() | 56 // Both cues shold be visible. |
50 { | 57 testCueDisplayBox = textTrackDisplayElement(video, 'display', 0); |
51 consoleWrite(""); | 58 assert_equals(testCueDisplayBox.innerText, 'Arabic'); |
52 consoleWrite("** Only one cue should be visible **"); | |
53 testCueDisplayBox = textTrackDisplayElement(video, 'display', 0); | |
54 testExpected("testCueDisplayBox.innerText", "Arabic"); | |
55 testExpected("testCueDisplayBox.nextSibling", null); | |
56 | 59 |
57 consoleWrite(""); | 60 testCueDisplayBox = textTrackDisplayElement(video, 'display', 1); |
58 consoleWrite("Set the mode of the 'English' track to showing"); | 61 assert_equals(testCueDisplayBox.innerText, 'English'); |
59 testTrackEnglish.mode = "showing"; | 62 } |
60 | 63 }); |
61 consoleWrite(""); | 64 </script> |
62 consoleWrite("** Both cues shold be visible. **"); | |
63 testCueDisplayBox = textTrackDisplayElement(video, 'display', 0); | |
64 testExpected("testCueDisplayBox.innerText", "Arabic"); | |
65 | |
66 testCueDisplayBox = textTrackDisplayElement(video, 'display', 1); | |
67 testExpected("testCueDisplayBox.innerText", "English"); | |
68 } | |
69 | |
70 function runTests() { | |
71 addTracks(); | |
72 testCueActiveState(); | |
73 testCueVisibility(); | |
74 endTest(); | |
75 } | |
76 | |
77 function loaded() | |
78 { | |
79 consoleWrite("Test that cues are rendered when only the track mode i
s changed"); | |
80 | |
81 findMediaElement(); | |
82 video.src = findMediaFile('video', '../content/test'); | |
83 | |
84 waitForEvent('canplaythrough', runTests); | |
85 } | |
86 | |
87 </script> | |
88 </head> | |
89 <body onload="loaded()"> | |
90 <video controls ></video> | |
91 </body> | |
92 </html> | |
OLD | NEW |