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

Unified 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: address philip's comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html
diff --git a/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html b/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html
index 062f74d564fe9590acb2e3c2bfc528f7371202bd..5f3b9c610819beda5bfd0e50b9a162b815058863 100644
--- a/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html
+++ b/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html
@@ -1,87 +1,52 @@
<!DOCTYPE html>
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Test closed caption track selection on and off.</title>
- <script src=media-file.js></script>
- <script src=media-controls.js></script>
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
- <script src=video-test.js></script>
- <script>
- var text = ["First", "Second", "Third"];
- var displayElement;
-
- function addTextTrack()
- {
- var track = video.addTextTrack('captions');
-
- for (var i = 0; i < 3; i++) {
- var cue = new VTTCue(0, 120, text[i]);
- track.addCue(cue);
- }
- }
-
- function checkCaptionsDisplay()
- {
- for (var i = 0; i < 3; i++) {
- try {
- displayElement = textTrackDisplayElement(video, "display", i);
- testExpected("displayElement.innerText", text[i]);
- } catch (e) {
- consoleWrite(e);
- }
- }
- }
-
- function startTest()
- {
- if (!window.eventSender) {
- consoleWrite("No eventSender found.");
- failTest();
- }
-
- addTextTrack();
-
- findMediaElement();
- testClosedCaptionsButtonVisibility(true);
-
- consoleWrite("");
- consoleWrite("** The captions track should be listed in textTracks, but not yet loaded. **");
- testExpected("video.textTracks.length", 1);
- testExpected("video.textTracks[0].mode", "hidden");
- checkCaptionsDisplay();
-
- consoleWrite("");
- consoleWrite("** Captions track should become visible after the track is selected **");
- selectTextTrack(video, 0);
- checkCaptionsDisplay();
-
- consoleWrite("");
- consoleWrite("** Captions should not be visible after they're turned off through the menu **");
- turnClosedCaptionsOff(video);
- checkCaptionsDisplay();
-
- consoleWrite("");
- consoleWrite("** Captions track should become visible after the track is selected again **");
- selectTextTrack(video, 0);
- checkCaptionsDisplay();
-
- consoleWrite("");
- endTest();
- }
-
- function loaded()
- {
- findMediaElement();
- waitForEvent('canplaythrough', startTest);
-
- video.src = findMediaFile('video', 'content/counting');
+<title>Tests that tracks can be turned on and off through the track selection menu.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<script src="media-controls.js"></script>
+<video controls></video>
+<script>
+async_test(function(t) {
+ var text = ["First", "Second", "Third"];
+ var video = document.querySelector("video");
+
+ video.oncanplaythrough = t.step_func_done(function() {
+ var track = video.addTextTrack("captions");
+
+ for (var i = 0; i < 3; i++) {
foolip 2016/07/06 10:00:47 The hard-coded 3 is a bit unsightly, but oh well.
Srirama 2016/07/06 11:35:49 Replaced with text.length.
+ var cue = new VTTCue(0, 120, text[i]);
+ track.addCue(cue);
}
- </script>
-</head>
-<body onload="loaded()">
- <p>Tests that tracks can be turned on and off through the track selection menu</p>
- <video controls></video>
-</body>
-</html>
+ assert_true(isClosedCaptionsButtonVisible(video));
+
+ // The captions track should be listed in textTracks, but not yet loaded.
+ assert_equals(video.textTracks.length, 1);
+ assert_equals(video.textTracks[0].mode, "hidden");
+ checkCaptionsHidden();
+
+ // Captions track should become visible after the track is selected.
+ clickTextTrackAtIndex(video, 0);
+ checkCaptionsVisible();
+
+ // Captions should not be visible after they're turned off through the menu.
+ turnClosedCaptionsOff(video);
+ checkCaptionsHidden();
+
+ // Captions track should become visible after the track is selected again.
+ clickTextTrackAtIndex(video, 0);
+ checkCaptionsVisible();
+ });
+
+ function checkCaptionsVisible() {
+ for (var i = 0; i < 3; i++)
+ assert_equals(textTrackCueElementByIndex(video, i).innerText, text[i]);
+ }
+
+ function checkCaptionsHidden() {
+ for (var i = 0; i < 3; i++)
+ assert_equals(textTrackCueElementByIndex(video, i), null);
foolip 2016/07/06 10:00:47 Simplify this to just assert_equals(textTrackCueEl
Srirama 2016/07/06 11:35:49 Done.
+ }
+
+ video.src = findMediaFile("video", "content/counting");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698