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

Unified Diff: third_party/WebKit/LayoutTests/media/track/track-cue-rendering-mode-changed.html

Issue 1887943002: 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 nits 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/track/track-cue-rendering-mode-changed.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-mode-changed.html b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-mode-changed.html
index 1b2e2b5a2742f2e2ac595a0938dce981f5ce77e6..dec19058ed2fa39b0dba365b72e3860792aab794 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-mode-changed.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-mode-changed.html
@@ -1,92 +1,64 @@
<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
- <script src=../media-file.js></script>
- <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
- <script src=../video-test.js></script>
- <script src=../media-controls.js></script>
-
- <script>
-
- var testTrackArabic;
- var testTrackEnglish;
- var testCueDisplayBox;
-
- function addTracks()
- {
- consoleWrite("");
-
- consoleWrite("Add 'Arabic' text track with one cue");
- testTrackArabic = video.addTextTrack('captions', 'Arabic', 'ar');
- testTrackArabic.addCue(new VTTCue(0.0, 10.0, 'Arabic'));
-
- consoleWrite("Add 'English' text track with one cue");
- testTrackEnglish = video.addTextTrack('captions', 'English', 'en');
- testTrackEnglish.addCue(new VTTCue(0.0, 10.0, 'English'));
-
- consoleWrite("");
- consoleWrite("Set the mode of the 'Arabic' track to showing");
- testTrackArabic.mode = "showing";
-
- consoleWrite("Set the mode of the 'English' track to hidden");
- testTrackEnglish.mode = "hidden";
- }
-
- function testCueActiveState()
- {
- consoleWrite("");
- consoleWrite("** Both cues should be active **");
- testExpected("testTrackEnglish.activeCues.length", 1);
- testExpected("testTrackEnglish.activeCues[0].text", "English");
-
- testExpected("testTrackArabic.activeCues.length", 1);
- testExpected("testTrackArabic.activeCues[0].text", "Arabic");
- }
-
- function testCueVisibility()
- {
- consoleWrite("");
- consoleWrite("** Only one cue should be visible **");
- testCueDisplayBox = textTrackDisplayElement(video, 'display', 0);
- testExpected("testCueDisplayBox.innerText", "Arabic");
- testExpected("testCueDisplayBox.nextSibling", null);
-
- consoleWrite("");
- consoleWrite("Set the mode of the 'English' track to showing");
- testTrackEnglish.mode = "showing";
-
- consoleWrite("");
- consoleWrite("** Both cues shold be visible. **");
- testCueDisplayBox = textTrackDisplayElement(video, 'display', 0);
- testExpected("testCueDisplayBox.innerText", "Arabic");
-
- testCueDisplayBox = textTrackDisplayElement(video, 'display', 1);
- testExpected("testCueDisplayBox.innerText", "English");
- }
-
- function runTests() {
- addTracks();
- testCueActiveState();
- testCueVisibility();
- endTest();
- }
-
- function loaded()
- {
- consoleWrite("Test that cues are rendered when only the track mode is changed");
-
- findMediaElement();
- video.src = findMediaFile('video', '../content/test');
-
- waitForEvent('canplaythrough', runTests);
- }
-
- </script>
- </head>
- <body onload="loaded()">
- <video controls ></video>
- </body>
-</html>
+<title>Test that cues are rendered when only the track mode is changed.</title>
+<script src="../media-file.js"></script>
+<script src="../media-controls.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+async_test(function(t) {
+ var video = document.createElement('video');
+ video.src = findMediaFile('video', '../content/test');
+
+ video.oncanplaythrough = t.step_func_done(function() {
+ addTracks();
+ testCueActiveState();
+ testCueVisibility();
+ });
+
+ var testTrackArabic;
+ var testTrackEnglish;
+ var testCueDisplayBox;
+
+ function addTracks() {
+ // Add 'Arabic' text track with one cue.
+ testTrackArabic = video.addTextTrack('captions', 'Arabic', 'ar');
+ testTrackArabic.addCue(new VTTCue(0, 10, 'Arabic'));
+
+ // Add 'English' text track with one cue.
+ testTrackEnglish = video.addTextTrack('captions', 'English', 'en');
+ testTrackEnglish.addCue(new VTTCue(0, 10, 'English'));
+
+ // Set the mode of the 'Arabic' track to showing.
+ testTrackArabic.mode = 'showing';
+
+ // Set the mode of the 'English' track to hidden.
+ testTrackEnglish.mode = 'hidden';
+ }
+
+ function testCueActiveState() {
+ // Both cues should be active.
+ assert_equals(testTrackEnglish.activeCues.length, 1);
+ assert_equals(testTrackEnglish.activeCues[0].text, 'English');
+
+ assert_equals(testTrackArabic.activeCues.length, 1);
+ assert_equals(testTrackArabic.activeCues[0].text, 'Arabic');
+ }
+
+ function testCueVisibility() {
+ // Only one cue should be visible.
+ testCueDisplayBox = textTrackDisplayElement(video, 'display', 0);
+ assert_equals(testCueDisplayBox.innerText, 'Arabic');
+ assert_equals(testCueDisplayBox.nextSibling, null);
+
+ // Set the mode of the 'English' track to showing.
+ testTrackEnglish.mode = 'showing';
+
+ // Both cues shold be visible.
+ testCueDisplayBox = textTrackDisplayElement(video, 'display', 0);
+ assert_equals(testCueDisplayBox.innerText, 'Arabic');
+
+ testCueDisplayBox = textTrackDisplayElement(video, 'display', 1);
+ assert_equals(testCueDisplayBox.innerText, 'English');
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698