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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-loop-from-ended.html

Issue 2124223002: Convert video-[loop, double]* 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test looping edge case to verify http://crbug.com/364442.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <script src=media-file.js></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 5 <script src="media-file.js"></script>
6 (Please avoid writing new tests using video-test.js) --> 6 <video></video>
7 <script src=video-test.js></script> 7 <script>
8 // Seek towards end of video (for faster testing).
9 // Play video to end with "loop" set to false.
10 // Once ended, set "loop" to true. Call play.
11 // Verify that "seeked" event fires, seeking back to the beginning.
12 // Pause video and end test.
13 async_test(function(t) {
14 var video = document.querySelector("video");
8 15
9 <script> 16 video.onloadedmetadata = t.step_func(function() {
10 function start() 17 // Video is initially paused and "loop" unset.
11 { 18 assert_true(video.paused);
12 findMediaElement(); 19 assert_false(video.loop);
13 var mediaFile = findMediaFile("video", "content/test"); 20 // Seek to just before the end of the video and play.
14 video.src = mediaFile; 21 video.currentTime = video.duration - 0.5;
22 video.onended = t.step_func(function() {
23 // Verify played to end and stopped.
24 assert_true(video.ended);
25 assert_true(video.paused);
26 assert_equals(video.currentTime, video.duration);
15 27
16 consoleWrite("<br><em>++ Video is initially paused and 'loop' un set.</em>"); 28 // With playback ended, set "loop" attribute. This will cause ended == false.
17 testExpected("video.paused", true) 29 // looping video cannot be "ended", only paused.
18 testExpected("video.loop", false); 30 assert_false(video.loop);
31 video.loop = true;
32 assert_true(video.loop);
33 assert_false(video.ended);
34 assert_true(video.paused);
19 35
20 seekThenPlayWhenReady(); 36 video.onseeked = t.step_func_done(function() {
21 } 37 // Observed seek. Verify current time decreased and still playin g.
38 assert_true(video.loop)
39 assert_false(video.paused);
40 assert_false(video.ended);
41 assert_less_than(video.currentTime, video.duration);
42 // Pausing now that test is over to prevent additional unwanted looping.
43 video.pause();
44 });
22 45
23 function seekThenPlayWhenReady() { 46 // Play video with "loop" set. Expect seek back to start.
24 if (video.readyState < HTMLMediaElement.HAVE_METADATA) { 47 video.play();
25 setTimeout(seekThenPlayWhenReady, 100); 48 });
26 return;
27 }
28 49
29 consoleWrite("<br><em>++ Seek to just before the end of the vide o and play.</em>"); 50 video.play();
30 run("video.currentTime = video.duration - .5"); 51 });
31 waitForEvent("play");
32 waitForEvent("ended", ended);
33 run("video.play()");
34 consoleWrite("");
35 }
36 52
37 function ended() 53 video.src = findMediaFile("video", "content/test");
38 { 54 });
39 consoleWrite("<br><em>++ Verify played to end and stopped.</em>" ); 55 </script>
40 testExpected("video.ended", true);
41 testExpected("video.paused", true);
42 // Using reportExpected to avoid logging floating point value wh ich may differ across engines.
43 reportExpected(video.currentTime == video.duration, "video.curre ntTime", "==", "video.duration", video.currentTime);
44
45 consoleWrite("<br><em>++ With playback ended, set 'loop' attribu te. This will cause ended == false; looping video cannot be 'ended', only paused .</em>");
46 testExpected("video.loop", false);
47 run("video.loop = true");
48 testExpected("video.loop", true);
49 testExpected("video.ended", false);
50 testExpected("video.paused", true);
51
52 consoleWrite("<br><em>++ Play video with 'loop' set. Expect seek back to start.<em>");
53 waitForEvent("seeked", seeked);
54 run("video.play()");
55 consoleWrite("");
56 }
57
58 function seeked()
59 {
60 consoleWrite("<br><em>++ Observed seek. Verify current time decr eased and still playing.</em>");
61 testExpected("video.loop", true);
62 testExpected("video.paused", false);
63 testExpected("video.ended", false);
64 // Using reportExpected to avoid logging floating point value wh ich may differ across engines.
65 reportExpected(video.currentTime < video.duration, "video.curren tTime", "<", "video.duration", video.currentTime);
66
67 consoleWrite("<br><em>++ Pausing now that test is over to preven t additional unwanted looping.</em>");
68 run("video.pause()");
69 consoleWrite("");
70 endTest();
71 }
72 </script>
73
74 </head>
75 <body>
76 <video controls></video>
77 <p><b>Test looping edge case to verify http://crbug.com/364442. Steps:</ b>
78 <ol>
79 <li>Seek toward end of video (for faster testing).</li>
80 <li>Play video to end with 'loop' set to false.</li>
81 <li>Once ended, set 'loop' to true.</li>
82 <li>Call play.</li>
83 <li>Verify that 'seeked' event fires, seeking back to the beginning. </li>
84 <li>Pause video and end test.</li>
85 </ol>
86 </p>
87 <script>start()</script>
88 </body>
89 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698