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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-played-reset.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 unified diff | Download patch
OLDNEW
1 <html> 1 <!DOCTYPE html>
2 <head> 2 <title>Test media element's "played" attribute.</title>
3 <title>Test of 'played' attribute</title> 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 <script src="video-played.js"></script>
7 <script src=video-test.js></script> 7 <video></video>
8 <script src=video-played.js></script> 8 <script>
9 <script> 9 var video;
10 async_test(function(t) {
11 var expectedStartTimes = [];
12 var expectedEndTimes = [];
13 video = document.querySelector("video");
10 14
11 var testFunctions = 15 video.oncanplay = t.step_func(function() {
12 [ 16 video.oncanplay = null;
13 PlayWithNoRanges, 17 testRanges(expectedStartTimes, expectedEndTimes);
14 ResetToAVideoSource, 18 // Test playing when there are no ranges.
15 JumpAndPlayFwd, 19 timeRangeCount = currentTimeRange = 0;
16 ResetToAnEmptyVideoSource 20 startPlayingInNewRange(t, expectedStartTimes);
17 ]; 21 });
22 waitForPauseAndContinue(t, resetToAVideoSource, false, expectedStartTimes, e xpectedEndTimes);
18 23
19 // NOTE: Result details are not printed for this test because time v alues are different from machine 24 function resetToAVideoSource() {
20 // to machine and run to run. Commenting out the following line turn s on detailed logging back on, which 25 // Test to reset to non empty video source.
21 // can be useful for debugging test failure. 26 timeRangeCount = currentTimeRange = 0;
22 disableFullTestDetailsPrinting(); 27 expectedStartTimes = [];
28 expectedEndTimes = [];
29 video.src = findMediaFile("video", "content/test");
30 video.oncanplay = t.step_func(jumpAndPlayFwd);
31 }
23 32
24 function PlayWithNoRanges() 33 function jumpAndPlayFwd() {
25 { 34 video.oncanplay = null;
26 consoleWrite("<br><b><em>Test playing when there are no ranges</ em></b>"); 35 testRanges(expectedStartTimes, expectedEndTimes);
36 // Test jumping forward into a new range and play.
37 video.currentTime = (video.duration - 0.5).toFixed(2);
38 currentTimeRange = 1;
39 startPlayingInNewRange(t, expectedStartTimes);
40 waitForPauseAndContinue(t, resetToAnEmptyVideoSource, false, expectedSta rtTimes, expectedEndTimes);
41 }
27 42
28 timeRangeCount = currentTimeRange = 0; 43 function resetToAnEmptyVideoSource() {
29 willPauseInExistingRange = false; 44 // Test to reset to an empty video source.
30 willExtendAnExistingRange = false; 45 timeRangeCount = currentTimeRange = 0;
46 expectedStartTimes = [];
47 expectedEndTimes = [];
48 video.src = "";
49 video.onloadstart = t.step_func_done(testRanges(expectedStartTimes, expe ctedEndTimes));
50 }
31 51
32 startPlayingInNewRange(); 52 video.src = findMediaFile("video", "content/test");
33 } 53 });
34 54 </script>
35 function ResetToAVideoSource()
36 {
37 consoleWrite("<br><b><em>Test to reset to non empty video source </em></b>");
38
39 timeRangeCount = currentTimeRange = 0;
40 expectedStartTimes = new Array();
41 expectedEndTimes = new Array();
42
43 willPauseInExistingRange = false;
44 willExtendAnExistingRange = false;
45
46 var mediaFile = findMediaFile("video", "content/test");
47 runSilently("video.src = \"" + mediaFile + "\"");
48
49 waitForEventOnce("canplay", canplay);
50 run("video.load()"); // Triggers canplay()
51 }
52
53 function JumpAndPlayFwd()
54 {
55 consoleWrite("<br><b><em>Test jumping forward into a new range a nd play</em></b>");
56
57 var newTime = video.duration - 0.5;
58 runSilently("video.currentTime = " + (newTime.toFixed(2)));
59
60 willPauseInExistingRange = false;
61 willExtendAnExistingRange = false;
62 currentTimeRange = 1;
63
64 startPlayingInNewRange();
65 }
66
67 function ResetToAnEmptyVideoSource()
68 {
69 consoleWrite("<br><b><em>Test to reset to an empty video source< /em></b>");
70
71 willPauseInExistingRange = false;
72 willExtendAnExistingRange = false;
73 timeRangeCount = currentTimeRange = 0;
74
75 expectedStartTimes = new Array();
76 expectedEndTimes = new Array();
77
78 run("video.src = \"\"");
79 waitForEvent("loadstart", function () { testRanges(); nextTest() ; });
80 run("video.load()"); // Triggers loadstart()
81 }
82 </script>
83 </head>
84
85 <body onload="videoPlayedMain()">
86
87 <video controls></video>
88 <p>Test of the media element 'played' attribute</p>
89
90 </body>
91 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698