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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html

Issue 2121613002: Convert video-controls-[captions, overlay, track]* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 5 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests that tracks can be turned on and off through the track selection me nu.</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 <title>Test closed caption track selection on and off.</title> 5 <script src="media-file.js"></script>
6 <script src=media-file.js></script> 6 <script src="media-controls.js"></script>
7 <script src=media-controls.js></script> 7 <video controls></video>
8 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 8 <script>
9 (Please avoid writing new tests using video-test.js) --> 9 async_test(function(t) {
10 <script src=video-test.js></script> 10 var text = ["First", "Second", "Third"];
11 <script> 11 var video = document.querySelector("video");
12 var text = ["First", "Second", "Third"];
13 var displayElement;
14 12
15 function addTextTrack() 13 video.oncanplaythrough = t.step_func_done(function() {
16 { 14 var track = video.addTextTrack("captions");
17 var track = video.addTextTrack('captions');
18 15
19 for (var i = 0; i < 3; i++) { 16 for (var i = 0; i < 3; i++) {
20 var cue = new VTTCue(0, 120, text[i]); 17 var cue = new VTTCue(0, 120, text[i]);
21 track.addCue(cue); 18 track.addCue(cue);
19 }
20 assert_true(isClosedCaptionsButtonVisible(video));
21
22 // The captions track should be listed in textTracks, but not yet loaded .
23 assert_equals(video.textTracks.length, 1);
24 assert_equals(video.textTracks[0].mode, "hidden");
25 checkCaptionsDisplay(false);
26
27 // Captions track should become visible after the track is selected.
28 selectTextTrackAtIndex(video, 0);
29 checkCaptionsDisplay(true);
30
31 // Captions should not be visible after they're turned off through the m enu.
32 turnClosedCaptionsOff(video);
33 checkCaptionsDisplay(false);
34
35 // Captions track should become visible after the track is selected agai n.
36 selectTextTrackAtIndex(video, 0);
37 checkCaptionsDisplay(true);
38 });
39
40 function checkCaptionsDisplay(captionsVisible) {
fs 2016/07/04 08:46:55 Could probably also be split into two functions, e
Srirama 2016/07/04 13:00:23 Done.
41 for (var i = 0; i < 3; i++) {
42 if (captionsVisible) {
43 var cue = textTrackDisplayElement(video, "display", i);
44 assert_equals(cue.innerText, text[i]);
45 } else {
46 assert_throws(null, function() { textTrackDisplayElement(video, "display", i); });
22 } 47 }
23 } 48 }
49 }
24 50
25 function checkCaptionsDisplay() 51 video.src = findMediaFile("video", "content/counting");
26 { 52 });
27 for (var i = 0; i < 3; i++) { 53 </script>
28 try {
29 displayElement = textTrackDisplayElement(video, "display", i );
30 testExpected("displayElement.innerText", text[i]);
31 } catch (e) {
32 consoleWrite(e);
33 }
34 }
35 }
36
37 function startTest()
38 {
39 if (!window.eventSender) {
40 consoleWrite("No eventSender found.");
41 failTest();
42 }
43
44 addTextTrack();
45
46 findMediaElement();
47 testClosedCaptionsButtonVisibility(true);
48
49 consoleWrite("");
50 consoleWrite("** The captions track should be listed in textTracks, but not yet loaded. **");
51 testExpected("video.textTracks.length", 1);
52 testExpected("video.textTracks[0].mode", "hidden");
53 checkCaptionsDisplay();
54
55 consoleWrite("");
56 consoleWrite("** Captions track should become visible after the trac k is selected **");
57 selectTextTrack(video, 0);
58 checkCaptionsDisplay();
59
60 consoleWrite("");
61 consoleWrite("** Captions should not be visible after they're turned off through the menu **");
62 turnClosedCaptionsOff(video);
63 checkCaptionsDisplay();
64
65 consoleWrite("");
66 consoleWrite("** Captions track should become visible after the trac k is selected again **");
67 selectTextTrack(video, 0);
68 checkCaptionsDisplay();
69
70 consoleWrite("");
71 endTest();
72 }
73
74 function loaded()
75 {
76 findMediaElement();
77 waitForEvent('canplaythrough', startTest);
78
79 video.src = findMediaFile('video', 'content/counting');
80 }
81 </script>
82 </head>
83 <body onload="loaded()">
84 <p>Tests that tracks can be turned on and off through the track selection me nu</p>
85 <video controls></video>
86 </body>
87 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698