Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(996)

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-add-remove-cue.html

Issue 1873093003: Convert track tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-add-remove-cue-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests TextTrack's addCue and removeCue.</title>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script>
6 async_test(function(t) {
7 var video = document.createElement("video");
8 var trackElement = document.createElement("track");
5 9
6 <script src=../media-file.js></script> 10 trackElement.onload = t.step_func_done(function() {
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 11 var cues = trackElement.track.cues;
8 (Please avoid writing new tests using video-test.js) --> 12 // Test cues loaded from the file.
9 <script src=../video-test.js></script> 13 assert_equals(cues.length, 4);
10 <script> 14 assert_equals(cues.getCueById("1").startTime, 0);
15 assert_equals(cues[1].startTime, 31);
16 assert_equals(cues[2].startTime, 61);
17 assert_equals(cues.getCueById("4").startTime, 121);
18 assert_object_equals(cues.getCueById("junk"), undefined);
11 19
12 var cues; 20 // Create a new cue, check values.
21 var textCue = new VTTCue(33, 3.4, "Sausage?");
22 assert_equals(textCue.track, null);
23 assert_equals(textCue.id, "");
24 assert_equals(textCue.startTime, 33);
25 assert_equals(textCue.endTime, 3.4);
26 assert_equals(textCue.pauseOnExit, false);
27 assert_equals(textCue.vertical, "");
28 assert_equals(textCue.snapToLines, true);
29 assert_equals(textCue.line, "auto");
30 assert_equals(textCue.position, "auto");
31 assert_equals(textCue.size, 100);
32 assert_equals(textCue.align, "middle");
13 33
14 function trackLoaded() 34 // Remove the unadded track, make sure it throws correctly.
15 { 35 assert_throws("NotFoundError", function() { trackElement.track.removeCue (textCue); });
16 var testTrack = document.getElementById('testTrack');
17 cues = testTrack.track.cues;
18 36
19 consoleWrite("<br>*** Test cues loaded from the file."); 37 // Add the new cue to a track, make sure it is inserted correctly.
20 testExpected("cues.length", 4); 38 trackElement.track.addCue(textCue);
21 testExpected("cues.getCueById('1').startTime", 0); 39 assert_equals(textCue.track, trackElement.track);
22 testExpected("cues[1].startTime", 31); 40 assert_equals(cues[1].startTime, 31);
23 testExpected("cues[2].startTime", 61); 41 assert_equals(cues[2].startTime, 33);
24 testExpected("cues.getCueById('4').startTime", 121); 42 assert_equals(cues[3].startTime, 61);
25 testExpected("cues.getCueById('junk')", undefined);
26 43
27 consoleWrite("<br>*** Create a new cue, check values"); 44 // create a new cue and add it to a track created with
28 run("textCue = new VTTCue(33, 3.4, 'Sausage?')"); 45 // video.addTextTrack, make sure it is inserted correctly.
29 testExpected("textCue.track", null); 46 var newTrack = video.addTextTrack("subtitles", "French subtitles", "fr") ;
30 testExpected("textCue.id", ''); 47 newTrack.mode = "showing";
31 testExpected("textCue.startTime", 33); 48 var newCue = new VTTCue(0, 1, "Test!");
32 testExpected("textCue.endTime", 3.4); 49 newTrack.addCue(newCue);
33 testExpected("textCue.pauseOnExit", false); 50 assert_equals(newCue, newTrack.cues[0])
34 testExpected("textCue.vertical", ""); 51 assert_equals(newCue.track, newTrack);
35 testExpected("textCue.snapToLines", true); 52 assert_equals(newCue.id, "");
36 testExpected("textCue.line", "auto"); 53 assert_equals(newCue.startTime, 0);
37 testExpected("textCue.position", "auto"); 54 assert_equals(newCue.endTime, 1);
38 testExpected("textCue.size", 100); 55 assert_equals(newCue.pauseOnExit, false);
39 testExpected("textCue.align", "middle"); 56 assert_equals(newCue.vertical, "");
57 assert_equals(newCue.snapToLines, true);
58 assert_equals(newCue.line, "auto");
59 assert_equals(newCue.position, "auto");
60 assert_equals(newCue.size, 100);
61 assert_equals(newCue.align, "middle");
40 62
41 consoleWrite("<br>*** Remove the unadded track, make sure it thr ows correctly."); 63 trackElement.track.removeCue(textCue);
42 testException("testTrack.track.removeCue(textCue)", '"NotFoundEr ror: Failed to execute \'removeCue\' on \'TextTrack\': The specified cue is not listed in the TextTrack\'s list of cues."'); 64 assert_equals(textCue.track, null);
65 assert_equals(cues[1].startTime, 31);
66 assert_equals(cues[2].startTime, 61);
43 67
44 consoleWrite("<br>*** Add the new cue to a track, make sure it i s inserted correctly."); 68 // Remove a cue added from the WebVTT file.
45 run("testTrack.track.addCue(textCue)"); 69 textCue = cues[2];
46 testExpected("textCue.track", testTrack.track); 70 trackElement.track.removeCue(textCue);
47 testExpected("cues[1].startTime", 31); 71 assert_equals(textCue.track, null);
48 testExpected("cues[2].startTime", 33); 72 assert_equals(cues[1].startTime, 31);
49 testExpected("cues[3].startTime", 61); 73 assert_equals(cues[2].startTime, 121);
50 74
51 consoleWrite("<br>*** create a new cue and add it to a track cre ated with video.addTextTrack, make sure it is inserted correctly."); 75 // Try to remove the cue again.
52 findMediaElement(); 76 assert_throws("NotFoundError", function() { trackElement.track.removeCue (textCue); });
53 run('newTrack = video.addTextTrack("subtitles", "French subtitle s", "fr")');
54 run('newTrack.mode = "showing"');
55 run('newTrack.addCue(new VTTCue(0.0, 1.0, "Test!"))');
56 run('newCue = newTrack.cues[0]');
57 testExpected("newCue.track", newTrack);
58 testExpected("newCue.id", "");
59 testExpected("newCue.startTime", 0.0);
60 testExpected("newCue.endTime", 1.0);
61 testExpected("newCue.pauseOnExit", false);
62 testExpected("newCue.vertical", "");
63 testExpected("newCue.snapToLines", true);
64 testExpected("newCue.line", "auto");
65 testExpected("newCue.position", "auto");
66 testExpected("newCue.size", 100);
67 testExpected("newCue.align", "middle");
68 77
69 consoleWrite("<br>*** Remove a cue created with addCue()."); 78 // Add a cue before all the existing cues.
70 run("testTrack.track.removeCue(textCue)"); 79 trackElement.track.addCue(new VTTCue(0, 31, "I am first"));
71 testExpected("textCue.track", null); 80 assert_equals(cues[0].startTime, 0);
72 testExpected("cues[1].startTime", 31); 81 assert_equals(cues[0].endTime, 31);
73 testExpected("cues[2].startTime", 61); 82 assert_equals(cues[1].startTime, 0);
83 assert_equals(cues[1].endTime, 30.5);
84 assert_equals(cues[2].startTime, 31);
85 });
74 86
75 consoleWrite("<br>*** Remove a cue added from the WebVTT file.") ; 87 trackElement.src = "captions-webvtt/tc013-settings.vtt";
76 run("textCue = cues[2]"); 88 trackElement.kind = "captions";
77 run("testTrack.track.removeCue(textCue)"); 89 trackElement.default = true;
78 testExpected("textCue.track", null); 90 video.appendChild(trackElement);
79 testExpected("cues[1].startTime", 31); 91 });
80 testExpected("cues[2].startTime", 121); 92 </script>
81
82 consoleWrite("<br>*** Try to remove the cue again.");
83 testDOMException("testTrack.track.removeCue(textCue)", "DOMExcep tion.NOT_FOUND_ERR");
84
85 consoleWrite("<br>*** Add a cue before all the existing cues.");
86 run("testTrack.track.addCue(new VTTCue(0, 31, 'I am first'))");
87 testExpected("cues[0].startTime", 0);
88 testExpected("cues[0].endTime", 31);
89 testExpected("cues[1].startTime", 0);
90 testExpected("cues[1].endTime", 30.5);
91 testExpected("cues[2].startTime", 31);
92 endTest();
93 }
94
95 </script>
96 </head>
97 <body>
98 <p>Tests TextTrack's addCue and removeCue</p>
99 <video>
100 <track id="testTrack" src="captions-webvtt/tc013-settings.vtt" kind= "captions" onload="trackLoaded()" default>
101 </video>
102 </body>
103 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-add-remove-cue-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698