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

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: 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 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 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 CreateANewRange, 18 // Test playing when there are no ranges.
15 JumpAndCollapseTwoRanges, 19 timeRangeCount = currentTimeRange = 0;
16 TestLoopingAndPassToTheEnd 20 video.currentTime = 0.5;
17 ]; 21 currentTimeRange++;
22 startPlayingInNewRange(t, expectedStartTimes);
23 });
24 waitForPauseAndContinue(t, createANewRange, false, expectedStartTimes, expec tedEndTimes);
18 25
19 // NOTE: Result details are not printed for this test because time v alues are different from machine 26 function createANewRange() {
20 // to machine and run to run. Commenting out the following line turn s on detailed logging back on, which 27 // Create a new range.
21 // can be useful for debugging test failure. 28 var newTime = (video.played.end(0) + 0.05).toFixed(2);
22 disableFullTestDetailsPrinting(); 29 video.currentTime = newTime;
30 startPlayingInNewRange(t, expectedStartTimes);
31 waitForPauseAndContinue(t, jumpAndCollapseTwoRanges, false, expectedStar tTimes, expectedEndTimes);
32 }
23 33
24 function PlayWithNoRanges() 34 function jumpAndCollapseTwoRanges() {
25 { 35 // 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>"); 36 timeRangeCount--;
37 currentTimeRange = timeRangeCount - 1;
38 expectedStartTimes[0] = (expectedStartTimes[0] - 0.1).toFixed(2);
39 expectedEndTimes[0] = expectedEndTimes[1];
40 video.currentTime = expectedStartTimes[0];
41 playForDuration(expectedEndTimes[1] - expectedStartTimes[0], t);
42 waitForPauseAndContinue(t, testLoopingAndPassToTheEnd, false, expectedSt artTimes, expectedEndTimes);
43 }
27 44
28 willPauseInExistingRange = false; 45 function testLoopingAndPassToTheEnd() {
29 willExtendAnExistingRange = false; 46 // Start playing near the end of the movie so it will loop quickly.
30 timeRangeCount = currentTimeRange = 0; 47 video.loop = true;
48 var startTime = (video.duration - 0.05).toFixed(2);
49 video.currentTime = startTime;
31 50
32 runSilently("video.currentTime = 0.5"); 51 // We will end in the very first time range
52 currentTimeRange = 0;
33 53
34 currentTimeRange++; 54 // Playing from near the end so we will create a new time range from sta rtTime, duration.
35 startPlayingInNewRange(); 55 timeRangeCount++;
36 } 56 expectedStartTimes[timeRangeCount - 1] = startTime;
57 expectedEndTimes[timeRangeCount - 1] = video.duration.toFixed(2);
37 58
59 // Playback restarts from beginning, so expect the beginning of first ti me range to be 0.
60 expectedStartTimes[0] = "0.00";
61 // Have to play for long enough to loop and play into the existing range .
62 playForDuration(1.25, t);
63 waitForPauseAndContinue(t, null, true, expectedStartTimes, expectedEndTi mes);
64 }
38 65
39 function CreateANewRange() 66 video.src = findMediaFile("video", "content/test");
40 { 67 });
41 consoleWrite("<br><b><em>Create a new range</em></b>"); 68 </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