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

Side by Side 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, 4 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 <html> 1 <!DOCTYPE html>
2 <head> 2 <title>Test event dispatches and attribute changes for seek to middle.</title>
3 <script src=../../media-resources/media-file.js></script> 3 <script src="../resources/testharness.js"></script>
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 4 <script src="../resources/testharnessreport.js"></script>
5 (Please avoid writing new tests using video-test.js) --> 5 <script src="../../media-resources/media-file.js"></script>
6 <script src=../../media-resources/video-test.js></script> 6 <video></video>
7 <script> 7 <script>
8 function testCommonAttributes(seekingExpected) 8 async_test(function(t) {
9 { 9 var video = document.querySelector("video");
10 testExpected('video.seeking', seekingExpected, '==');
11 testExpected('video.ended', false, '==');
12 testExpected('video.currentTime == (video.duration / 2)', true, '==');
13 testExpected('video.paused', false, '==');
14 }
15 10
16 function start() 11 video.onended = t.unreached_func();
17 {
18 findMediaElement();
19 12
20 waitForEventAndFail('ended'); 13 var watcher = new EventWatcher(t, video, ["durationchange", "loadedmetadata" , "loadeddata", "seeking", "timeupdate", "seeked"]);
21 14
22 waitForEvent('durationchange'); 15 watcher.wait_for(["durationchange", "loadedmetadata", "loadeddata"]).then(t. step_func(function() {
23 waitForEvent('loadedmetadata'); 16 assert_less_than(video.currentTime, video.duration);
24 waitForEventOnce('loadeddata', function () 17 assert_false(video.ended);
25 { 18 assert_false(video.seeking);
26 waitForEvent('seeking', function () 19 assert_false(video.paused);
27 { 20 // Starting seek to middle by setting video.currentTime to half the dura tion.
28 testCommonAttributes(true); 21 video.currentTime = video.duration / 2;
29 waitForEventOnce('timeupdate', function() 22 testCommonAttributes(true);
30 { 23 assert_less_than(video.currentTime, video.duration);
31 testCommonAttributes(false); 24 assert_greater_than(video.currentTime, 0);
32 }); 25 return watcher.wait_for("seeking");
33 }); 26 })).then(t.step_func(function() {
27 testCommonAttributes(true);
28 return watcher.wait_for("timeupdate");
29 })).then(t.step_func(function() {
30 testCommonAttributes(false);
31 return watcher.wait_for("seeked");
32 })).then(t.step_func_done(function() {
33 testCommonAttributes(false);
34 }));
34 35
35 waitForEvent('seeked', function () 36 function testCommonAttributes(seekingExpected) {
36 { 37 assert_equals(video.seeking, seekingExpected);
37 testCommonAttributes(false); 38 assert_false(video.ended);
38 endTest(); 39 assert_equals(video.currentTime, video.duration / 2);
39 }); 40 assert_false(video.paused);
41 }
40 42
41 // Seek to half the duration of the media 43 video.src = findMediaFile("video", "resources/test");
42 testExpected('video.currentTime < video.duration', true, '== '); 44 video.play();
43 testExpected('video.ended', false, '=='); 45 });
44 testExpected('video.seeking', false, '=='); 46 </script>
45 testExpected('video.paused', false, '==');
46 consoleWrite('Starting seek to middle by setting video.curre ntTime to video.duration / 2');
47 video.currentTime = video.duration / 2;
48 testCommonAttributes(true);
49 testExpected('video.currentTime < video.duration', true, '== ');
50 testExpected('video.currentTime > 0', true, '==');
51 });
52
53 var mediaFile = findMediaFile('video', 'resources/test');
54 video.src = '/' + mediaFile;
55 run('video.play()');
56 }
57 </script>
58 </head>
59 <body onload="start()">
60 <video></video>
61 <p>Test event dispatches and attribute changes for seek to middle</p>
62 </body>
63 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698