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

Unified Diff: third_party/WebKit/LayoutTests/media/video-played-collapse.html

Issue 2133223004: Convert video-played* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit, add TODO 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-played-collapse.html
diff --git a/third_party/WebKit/LayoutTests/media/video-played-collapse.html b/third_party/WebKit/LayoutTests/media/video-played-collapse.html
index 3a8419381affc591b645a776a0934bf70cf27ccc..426fcb75f4318bf6ace836ebfd0b310e1a3d5d02 100644
--- a/third_party/WebKit/LayoutTests/media/video-played-collapse.html
+++ b/third_party/WebKit/LayoutTests/media/video-played-collapse.html
@@ -1,106 +1,68 @@
-<html>
- <head>
- <title>Test of 'played' attribute</title>
- <script src=media-file.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 src=video-played.js></script>
- <script>
-
- var testFunctions =
- [
- PlayWithNoRanges,
- CreateANewRange,
- JumpAndCollapseTwoRanges,
- TestLoopingAndPassToTheEnd
- ];
-
- // NOTE: Result details are not printed for this test because time values are different from machine
- // to machine and run to run. Commenting out the following line turns on detailed logging back on, which
- // can be useful for debugging test failure.
- disableFullTestDetailsPrinting();
-
- function PlayWithNoRanges()
- {
- consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
-
- willPauseInExistingRange = false;
- willExtendAnExistingRange = false;
- timeRangeCount = currentTimeRange = 0;
-
- runSilently("video.currentTime = 0.5");
-
- currentTimeRange++;
- startPlayingInNewRange();
- }
-
-
- function CreateANewRange()
- {
- consoleWrite("<br><b><em>Create a new range</em></b>");
-
- var newTime = (video.played.end(0) + 0.05).toFixed(2);
- runSilently("video.currentTime = " + newTime);
-
- willPauseInExistingRange = false;
- willExtendAnExistingRange = false;
-
- startPlayingInNewRange();
- }
-
- function JumpAndCollapseTwoRanges()
- {
- consoleWrite("<br><b><em>Test playing from one range into another, should collapse the two ranges</em></b>");
-
- timeRangeCount--;
- currentTimeRange = timeRangeCount - 1;
- var startTime = expectedStartTimes[0] - 0.1;
- expectedStartTimes[0] = startTime;
- expectedEndTimes[0] = expectedEndTimes[1];
-
- willPauseInExistingRange = false;
- willExtendAnExistingRange = false;
- runSilently("video.currentTime = " + startTime);
-
- playForMillisecs(secToMilli(expectedEndTimes[1] - startTime + 0.1)); // Triggers pause()
- }
-
- function TestLoopingAndPassToTheEnd()
- {
- consoleWrite("<br><b><em>Test looping</em></b>");
-
- // Start playing near the end of the movie so it will loop quickly.
- run("video.loop = true");
- var startTime = (video.duration - 0.05).toFixed(2);
- runSilently("video.currentTime = " + startTime);
-
- // We will end in the very first time range
- currentTimeRange = 0;
-
- willPauseInExistingRange = true;
- willExtendAnExistingRange = true;
-
- // Playing from near the end so we will create a new time range from startTime .. duration
- timeRangeCount++;
- expectedStartTimes[timeRangeCount-1] = startTime;
- expectedEndTimes[timeRangeCount-1] = video.duration.toFixed(2);
-
- // Have to play for long enough to loop and play into the existing range.
- var playDuration = 1.25;
-
- // Playback restarts from beginning, so expect the beginning of first time range to be 0.
- expectedStartTimes[0] = 0;
- playForMillisecs(secToMilli(playDuration)); // Triggers pause()
- }
-
- </script>
- </head>
-
-<body onload="videoPlayedMain()">
-
- <video controls></video>
- <p>Test of the media element 'played' attribute</p>
-
-</body>
-</html>
+<!DOCTYPE html>
+<title>Test media element's "played" attribute and range collapse.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<script src="video-played.js"></script>
+<video></video>
+<script>
+var video;
+async_test(function(t) {
+ var expectedStartTimes = [];
+ var expectedEndTimes = [];
+ video = document.querySelector("video");
+
+ video.oncanplay = t.step_func(function() {
+ video.oncanplay = null;
+ testRanges(expectedStartTimes, expectedEndTimes);
+ // Test playing when there are no ranges.
+ timeRangeCount = currentTimeRange = 0;
+ video.currentTime = 0.5;
+ currentTimeRange++;
+ startPlayingInNewRange(t, expectedStartTimes);
+ });
+ waitForPauseAndContinue(t, createANewRange, false, expectedStartTimes, expectedEndTimes);
+
+ function createANewRange() {
+ // Create a new range.
+ var newTime = (video.played.end(0) + 0.05).toFixed(2);
+ video.currentTime = newTime;
+ startPlayingInNewRange(t, expectedStartTimes);
+ waitForPauseAndContinue(t, jumpAndCollapseTwoRanges, false, expectedStartTimes, expectedEndTimes);
+ }
+
+ function jumpAndCollapseTwoRanges() {
+ // Test playing from one range into another, should collapse the two ranges.
+ timeRangeCount--;
+ currentTimeRange = timeRangeCount - 1;
+ expectedStartTimes[0] = (expectedStartTimes[0] - 0.1).toFixed(2);
+ expectedEndTimes[0] = expectedEndTimes[1];
+ video.currentTime = expectedStartTimes[0];
+ playForDuration(expectedEndTimes[1] - expectedStartTimes[0], t);
+ waitForPauseAndContinue(t, testLoopingAndPassToTheEnd, false, expectedStartTimes, expectedEndTimes);
+ }
+
+ function testLoopingAndPassToTheEnd() {
+ // Start playing near the end of the movie so it will loop quickly.
+ video.loop = true;
+ var startTime = (video.duration - 0.05).toFixed(2);
+ video.currentTime = startTime;
+
+ // We will end in the very first time range
+ currentTimeRange = 0;
+
+ // Playing from near the end so we will create a new time range from startTime, duration.
+ timeRangeCount++;
+ expectedStartTimes[timeRangeCount - 1] = startTime;
+ expectedEndTimes[timeRangeCount - 1] = video.duration.toFixed(2);
+
+ // Playback restarts from beginning, so expect the beginning of first time range to be 0.
+ expectedStartTimes[0] = "0.00";
+ // Have to play for long enough to loop and play into the existing range.
+ playForDuration(1.25, t);
+ waitForPauseAndContinue(t, null, true, expectedStartTimes, expectedEndTimes);
+ }
+
+ video.src = findMediaFile("video", "content/test");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698