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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-middle.html

Issue 2177793003: Convert video-seek* and video-served* http tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/http/tests/media/video-seek-to-middle.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-middle.html b/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-middle.html
index 26caf8b81c0c7b29c98cf993efce7409f1758b4f..e37af9b66a962ee069aaf03f6e87c82e955726d4 100644
--- a/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-middle.html
+++ b/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-middle.html
@@ -1,63 +1,46 @@
-<html>
- <head>
- <script src=../../media-resources/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=../../media-resources/video-test.js></script>
- <script>
- function testCommonAttributes(seekingExpected)
- {
- testExpected('video.seeking', seekingExpected, '==');
- testExpected('video.ended', false, '==');
- testExpected('video.currentTime == (video.duration / 2)', true, '==');
- testExpected('video.paused', false, '==');
- }
+<!DOCTYPE html>
+<title>Test event dispatches and attribute changes for seek to middle.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../../media-resources/media-file.js"></script>
+<video></video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
- function start()
- {
- findMediaElement();
+ video.onended = t.unreached_func();
- waitForEventAndFail('ended');
+ var watcher = new EventWatcher(t, video, ["durationchange", "loadedmetadata", "loadeddata", "seeking", "timeupdate", "seeked"]);
- waitForEvent('durationchange');
- waitForEvent('loadedmetadata');
- waitForEventOnce('loadeddata', function ()
- {
- waitForEvent('seeking', function ()
- {
- testCommonAttributes(true);
- waitForEventOnce('timeupdate', function()
- {
- testCommonAttributes(false);
- });
- });
+ watcher.wait_for(["durationchange", "loadedmetadata", "loadeddata"]).then(t.step_func(function() {
+ assert_less_than(video.currentTime, video.duration);
+ assert_false(video.ended);
+ assert_false(video.seeking);
+ assert_false(video.paused);
+ // Starting seek to middle by setting video.currentTime to half the duration.
+ video.currentTime = video.duration / 2;
+ testCommonAttributes(true);
+ assert_less_than(video.currentTime, video.duration);
+ assert_greater_than(video.currentTime, 0);
+ return watcher.wait_for("seeking");
+ })).then(t.step_func(function() {
+ testCommonAttributes(true);
+ return watcher.wait_for("timeupdate");
+ })).then(t.step_func(function() {
+ testCommonAttributes(false);
+ return watcher.wait_for("seeked");
+ })).then(t.step_func_done(function() {
+ testCommonAttributes(false);
+ }));
- waitForEvent('seeked', function ()
- {
- testCommonAttributes(false);
- endTest();
- });
+ function testCommonAttributes(seekingExpected) {
+ assert_equals(video.seeking, seekingExpected);
+ assert_false(video.ended);
+ assert_equals(video.currentTime, video.duration / 2);
+ assert_false(video.paused);
+ }
- // Seek to half the duration of the media
- testExpected('video.currentTime < video.duration', true, '==');
- testExpected('video.ended', false, '==');
- testExpected('video.seeking', false, '==');
- testExpected('video.paused', false, '==');
- consoleWrite('Starting seek to middle by setting video.currentTime to video.duration / 2');
- video.currentTime = video.duration / 2;
- testCommonAttributes(true);
- testExpected('video.currentTime < video.duration', true, '==');
- testExpected('video.currentTime > 0', true, '==');
- });
-
- var mediaFile = findMediaFile('video', 'resources/test');
- video.src = '/' + mediaFile;
- run('video.play()');
- }
- </script>
- </head>
- <body onload="start()">
- <video></video>
- <p>Test event dispatches and attribute changes for seek to middle</p>
- </body>
-</html>
+ video.src = findMediaFile("video", "resources/test");
+ video.play();
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698