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

Side by Side 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: 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 and range collapse.</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 video = document.querySelector("video");
10 12
11 var testFunctions = 13 video.onerror = t.step_func(function() {});
12 [ 14 video.onloadstart = t.step_func(function() {});
13 PlayWithNoRanges, 15 video.onratechange = t.step_func(function() {});
14 CreateANewRange, 16 video.onloadedmetadata = t.step_func(function() {});
15 JumpAndCollapseTwoRanges, 17 video.oncanplay = t.step_func(function() {
16 TestLoopingAndPassToTheEnd 18 video.oncanplay = null;
17 ]; 19 testRanges();
20 // Test playing when there are no ranges.
21 timeRangeCount = currentTimeRange = 0;
22 video.currentTime = 0.5;
23 currentTimeRange++;
24 startPlayingInNewRange(t);
25 });
26 waitForPauseAndContinue(t, createANewRange, false);
18 27
19 // NOTE: Result details are not printed for this test because time v alues are different from machine 28 function createANewRange() {
20 // to machine and run to run. Commenting out the following line turn s on detailed logging back on, which 29 // Create a new range.
21 // can be useful for debugging test failure. 30 var newTime = (video.played.end(0) + 0.05).toFixed(2);
22 disableFullTestDetailsPrinting(); 31 video.currentTime = newTime;
32 startPlayingInNewRange(t);
33 waitForPauseAndContinue(t, jumpAndCollapseTwoRanges, false);
34 }
23 35
24 function PlayWithNoRanges() 36 function jumpAndCollapseTwoRanges() {
25 { 37 // Test playing from one range into another, should collapse the two ran ges.
26 consoleWrite("<br><b><em>Test playing when there are no ranges</ em></b>"); 38 timeRangeCount--;
39 currentTimeRange = timeRangeCount - 1;
40 var startTime = expectedStartTimes[0] - 0.1;
41 expectedStartTimes[0] = startTime.toFixed(2);
42 expectedEndTimes[0] = expectedEndTimes[1];
43 video.currentTime = startTime;
44 playForDuration(expectedEndTimes[1] - startTime + 0.1, t);
45 waitForPauseAndContinue(t, testLoopingAndPassToTheEnd, false);
46 }
27 47
28 willPauseInExistingRange = false; 48 function testLoopingAndPassToTheEnd() {
29 willExtendAnExistingRange = false; 49 // Start playing near the end of the movie so it will loop quickly.
30 timeRangeCount = currentTimeRange = 0; 50 video.loop = true;
51 var startTime = (video.duration - 0.05).toFixed(2);
52 video.currentTime = startTime;
31 53
32 runSilently("video.currentTime = 0.5"); 54 // We will end in the very first time range
55 currentTimeRange = 0;
33 56
34 currentTimeRange++; 57 // Playing from near the end so we will create a new time range from sta rtTime, duration.
35 startPlayingInNewRange(); 58 timeRangeCount++;
36 } 59 expectedStartTimes[timeRangeCount-1] = startTime;
60 expectedEndTimes[timeRangeCount-1] = video.duration.toFixed(2);
37 61
62 // Playback restarts from beginning, so expect the beginning of first ti me range to be 0.
63 expectedStartTimes[0] = "0.00";
64 // Have to play for long enough to loop and play into the existing range .
65 playForDuration(1.25, t);
66 waitForPauseAndContinue(t, null, true);
67 }
38 68
39 function CreateANewRange() 69 video.src = findMediaFile("video", "content/test");
40 { 70 });
41 consoleWrite("<br><b><em>Create a new range</em></b>"); 71 </script>
42
43 var newTime = (video.played.end(0) + 0.05).toFixed(2);
44 runSilently("video.currentTime = " + newTime);
45
46 willPauseInExistingRange = false;
47 willExtendAnExistingRange = false;
48
49 startPlayingInNewRange();
50 }
51
52 function JumpAndCollapseTwoRanges()
53 {
54 consoleWrite("<br><b><em>Test playing from one range into anothe r, should collapse the two ranges</em></b>");
55
56 timeRangeCount--;
57 currentTimeRange = timeRangeCount - 1;
58 var startTime = expectedStartTimes[0] - 0.1;
59 expectedStartTimes[0] = startTime;
60 expectedEndTimes[0] = expectedEndTimes[1];
61
62 willPauseInExistingRange = false;
63 willExtendAnExistingRange = false;
64 runSilently("video.currentTime = " + startTime);
65
66 playForMillisecs(secToMilli(expectedEndTimes[1] - startTime + 0. 1)); // Triggers pause()
67 }
68
69 function TestLoopingAndPassToTheEnd()
70 {
71 consoleWrite("<br><b><em>Test looping</em></b>");
72
73 // Start playing near the end of the movie so it will loop quick ly.
74 run("video.loop = true");
75 var startTime = (video.duration - 0.05).toFixed(2);
76 runSilently("video.currentTime = " + startTime);
77
78 // We will end in the very first time range
79 currentTimeRange = 0;
80
81 willPauseInExistingRange = true;
82 willExtendAnExistingRange = true;
83
84 // Playing from near the end so we will create a new time range from startTime .. duration
85 timeRangeCount++;
86 expectedStartTimes[timeRangeCount-1] = startTime;
87 expectedEndTimes[timeRangeCount-1] = video.duration.toFixed(2);
88
89 // Have to play for long enough to loop and play into the existi ng range.
90 var playDuration = 1.25;
91
92 // Playback restarts from beginning, so expect the beginning of first time range to be 0.
93 expectedStartTimes[0] = 0;
94 playForMillisecs(secToMilli(playDuration)); // Triggers pause()
95 }
96
97 </script>
98 </head>
99
100 <body onload="videoPlayedMain()">
101
102 <video controls></video>
103 <p>Test of the media element 'played' attribute</p>
104
105 </body>
106 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698