2009-08-14 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Aug 2009 17:58:15 +0000 (17:58 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Aug 2009 17:58:15 +0000 (17:58 +0000)
        Reviewed by Simon Fraser.

        media/video-played.html always times out on Windows
        https://bugs.webkit.org/show_bug.cgi?id=28275

        * media/video-played-collapse.html:
            Make sub-test assumptions obvious for someone reading this later.

        * media/video-played.html: Removed.
        * media/video-played-expected.txt: Removed.
        * media/video-played-ranges-1-expected.txt: Copied from LayoutTests/media/video-played-expected.txt.
        * media/video-played-ranges-1.html: Copied from LayoutTests/media/video-played.html.
            Split video-played.html into video-played-ranges-1.html and video-played-ranges-2.html.

        * media/video-played-reset.html:
            Make sub-test assumptions obvious for someone reading this later.

        * media/video-played.js:
        (logRanges):
            New but not currently called. Allows all ranges to be logged for debugging.
        (testRanges):
            Log ranges and the amount of time each test takes when logTestTiming != 0.
        (nextTest):
            Record test start time when logTestTiming is true;
        (startPlaying):
            Run each sub-test for 100ms instead of 250ms to decrease overall test time.
        (playForMillisecs.callPauseIfTimeIsReached):
        (playForMillisecs):
            Make error conditions trigger immediate failure instead of just logging.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@47287 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/video-played-collapse.html
LayoutTests/media/video-played-ranges-1-expected.txt [moved from LayoutTests/media/video-played-expected.txt with 63% similarity]
LayoutTests/media/video-played-ranges-1.html [moved from LayoutTests/media/video-played.html with 61% similarity]
LayoutTests/media/video-played-reset.html
LayoutTests/media/video-played.js

index d6f552f..ef8b704 100644 (file)
@@ -1,3 +1,35 @@
+2009-08-14  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        media/video-played.html always times out on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=28275
+
+        * media/video-played-collapse.html:
+            Make sub-test assumptions obvious for someone reading this later.
+
+        * media/video-played.html: Removed.
+        * media/video-played-expected.txt: Removed.
+        * media/video-played-ranges-1-expected.txt: Copied from LayoutTests/media/video-played-expected.txt.
+        * media/video-played-ranges-1.html: Copied from LayoutTests/media/video-played.html.
+            Split video-played.html into video-played-ranges-1.html and video-played-ranges-2.html.
+
+        * media/video-played-reset.html:
+            Make sub-test assumptions obvious for someone reading this later.
+
+        * media/video-played.js:
+        (logRanges):
+            New but not currently called. Allows all ranges to be logged for debugging.
+        (testRanges):
+            Log ranges and the amount of time each test takes when logTestTiming != 0.
+        (nextTest):
+            Record test start time when logTestTiming is true;
+        (startPlaying):
+            Run each sub-test for 100ms instead of 250ms to decrease overall test time.
+        (playForMillisecs.callPauseIfTimeIsReached):
+        (playForMillisecs):
+            Make error conditions trigger immediate failure instead of just logging.
+
 2009-08-14  Ariya Hidayat  <ariya.hidayat@nokia.com>
 
         Rubber-stamped by Tor Arne Vestbø.
index dd8e674..0cca40d 100644 (file)
             {
                 consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
 
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
                 timeRangeCount = currentTimeRange = 0;
+
                 runSilently("video.currentTime = 0.5");
 
                 currentTimeRange++;
@@ -37,6 +40,9 @@
                 var newTime = (video.played.end(0) + 0.05).toFixed(2);
                 runSilently("video.currentTime = " + newTime);
 
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
+
                 startPlayingInNewRange();
             }
 
@@ -51,6 +57,7 @@
                 expectedEndTimes[0] = expectedEndTimes[1];
 
                 willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
                 runSilently("video.currentTime = " + startTime);
 
                 playForMillisecs(secToMilli(expectedEndTimes[1] - startTime + 0.1)); // Triggers pause()
@@ -1,4 +1,4 @@
-Test of the media element 'played' attribute
+Test of the media element 'played' attribute, ranges part 1.
 
 EVENT(loadstart)
 EVENT(loadedmetadata)
@@ -58,35 +58,5 @@ Test 27 OK
 Test 28 OK
 Test 29 OK
 Test 30 OK
-
-Test jumping forward without playing, should not create new range
-Test 31 OK
-Test 32 OK
-Test 33 OK
-Test 34 OK
-Test 35 OK
-Test 36 OK
-Test 37 OK
-
-Test jumping back without playing, should not create new range
-Test 38 OK
-Test 39 OK
-Test 40 OK
-Test 41 OK
-Test 42 OK
-Test 43 OK
-Test 44 OK
-
-Test jumping before an existing range and play beyond its end, should extend start and end
-RUN(video.play())
-RUN(video.pause())
-EVENT(pause)
-Test 45 OK
-Test 46 OK
-Test 47 OK
-Test 48 OK
-Test 49 OK
-Test 50 OK
-Test 51 OK
 END OF TEST
 
similarity index 61%
rename from LayoutTests/media/video-played.html
rename to LayoutTests/media/video-played-ranges-1.html
index a1cd114..955ce6f 100644 (file)
                 JumpBackAndPlayToNewRange,
                 JumpAndExtendRangeStart,
                 JumpAndExtendRangeEnd,
-                JumpFwdWithoutPlaying, 
-                JumpBackWithoutPlaying,
-                JumpAndExtendRangeStartAndEnd
             ];
     
-            // NOTE: Result details are not printed for this test because time values are different from machine
+            // NOTE: Detailed results are not printed for this test because time values are different from machine
             // to machine and run to run. Commenting out the following line turns on detailed logging back on, which
             // can be useful for debugging test failure.
             disableFullTestDetailsPrinting(); 
@@ -27,6 +24,9 @@
                 consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
 
                 timeRangeCount = currentTimeRange = 0;
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
+
                 startPlayingInNewRange();
             }
     
             {
                 consoleWrite("<br><b><em>Test jumping forward into a new range and play</em></b>");
 
-                var newTime = video.duration - 0.5;
+                var newTime = video.duration - 1.0;
                 runSilently("video.currentTime = " + (newTime.toFixed(2)));
+
                 currentTimeRange = 1;
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
+
                 startPlayingInNewRange();
             }
     
@@ -48,6 +52,9 @@
                 runSilently("video.currentTime = " + newTime);
     
                 currentTimeRange = 1;
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
+
                 startPlayingInNewRange();
             }
                         
                 playForMillisecs(30);
             }
 
-            function JumpFwdWithoutPlaying()
-            {
-                consoleWrite("<br><b><em>Test jumping forward without playing, should not create new range</em></b>");
-    
-                var newTime = (video.played.end(1) + 0.5).toFixed(2);
-                runSilently("video.currentTime = " + newTime);
-    
-                setTimeout(function () { testRanges(); nextTest() }, 10);
-            }
-    
-            function JumpBackWithoutPlaying()
-            {
-                consoleWrite("<br><b><em>Test jumping back without playing, should not create new range</em></b>");
-    
-                var newTime = (video.played.start(1) - 0.5).toFixed(2);
-                runSilently("video.currentTime = " + newTime);
-
-                setTimeout(function () { testRanges(); nextTest() }, 10);
-            }
-
-            function JumpAndExtendRangeStartAndEnd()
-            {
-                consoleWrite("<br><b><em>Test jumping before an existing range and play beyond its end, should extend start and end</em></b>");
-    
-                currentTimeRange = 1;
-    
-                var newTime = (video.played.start(currentTimeRange) - 0.05).toFixed(2);
-                runSilently("video.currentTime = " + newTime);
-                expectedStartTimes[currentTimeRange] = newTime;
-
-                willPauseInExistingRange = false;
-                willExtendAnExistingRange = true;
-                playForMillisecs(secToMilli(video.played.end(currentTimeRange) - video.played.start(currentTimeRange) + 0.1));
-            }
-
         </script>
      </head>
 
 <body onload="videoPlayedMain()">
 
     <video controls></video>
-    <p>Test of the media element 'played' attribute</p>
+    <p>Test of the media element 'played' attribute, ranges part 1.</p>
 
 </body>
 </html>
index 3343a7d..dcca1d6 100644 (file)
@@ -23,6 +23,9 @@
                 consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
 
                 timeRangeCount = currentTimeRange = 0;
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
+
                 startPlayingInNewRange();
             }
         
@@ -33,6 +36,7 @@
                 timeRangeCount = currentTimeRange = 0;
                 expectedStartTimes = new Array();
                 expectedEndTimes = new Array();
+
                 willPauseInExistingRange = false;
                 willExtendAnExistingRange = false;
 
 
                 var newTime = video.duration - 0.5;
                 runSilently("video.currentTime = " + (newTime.toFixed(2)));
+
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
                 currentTimeRange = 1;
+
                 startPlayingInNewRange();
             }
 
             {
                 consoleWrite("<br><b><em>Test to reset to an empty video source</em></b>");
     
+                willPauseInExistingRange = false;
+                willExtendAnExistingRange = false;
                 timeRangeCount = currentTimeRange = 0;
+
                 expectedStartTimes = new Array();
                 expectedEndTimes = new Array();
 
index 076d4fc..b6d6516 100644 (file)
@@ -1,3 +1,4 @@
+
 var expectedStartTimes = new Array();
 var expectedEndTimes = new Array();
 var timeRangeCount = 0;
@@ -6,8 +7,29 @@ var currentTest = 0;
 var willPauseInExistingRange = false;
 var willExtendAnExistingRange = false;
 
+var testStartTime = 0;
+var logTestTiming = false;
+
+//@@@@@ Uncomment the following line to log the time each "video-played" sub-test takes in test output
+//@@@@@ logTestTiming = true;
+
+function logRanges()
+{
+    consoleWrite("");
+    for (i = 0; i < timeRangeCount; i++) {
+        consoleWrite("****  range " + i + " ( " + video.played.start(i).toFixed(2) + ".." + video.played.end(i).toFixed(2) + ")");
+    }
+}
+
 function testRanges()
 {
+    if (testStartTime) {
+        logRanges();
+
+        var duration = (new Date().getTime() - testStartTime) / 1000;
+        consoleWrite("**** Test " + currentTest + " took " + duration.toFixed(2) + " seconds");
+    }
+
     testExpected("video.played.length", timeRangeCount);
     
     for (i = 0; i < timeRangeCount; i++) {
@@ -18,6 +40,9 @@ function testRanges()
 
 function nextTest()
 {
+    if (logTestTiming)
+        testStartTime = new Date().getTime();
+
     if (currentTest >= testFunctions.length)
         endTest();
     else
@@ -58,7 +83,7 @@ function startPlayingInNewRange()
 
 function startPlaying()
 {
-    playForMillisecs(250); // Triggers pause()
+    playForMillisecs(100); // Triggers pause()
 }
 
 function secToMilli(seconds)
@@ -74,12 +99,15 @@ function milliToSecs(milliseconds)
 function playForMillisecs(milliseconds)
 {
     if (milliToSecs(milliseconds) > video.duration) {
-        consoleWrite("WARNING: playForMillisecs() does not support range ("+milliToSecs(milliseconds)+") bigger than video duration ("+video.duration+") (yet)");
+        failTest("WARNING: playForMillisecs() does not support range ("+milliToSecs(milliseconds)+") bigger than video duration ("+video.duration+") (yet)");
         return;
     }
-    var playedFromTime = video.currentTime;
+
     run("video.play()");
+
+    var playedFromTime = video.currentTime;
     var callCount = 0;
+    var playDuration = milliToSecs(milliseconds);
     var callPauseIfTimeIsReached = function ()
     {
         var playedTime = video.currentTime - playedFromTime;
@@ -92,18 +120,22 @@ function playForMillisecs(milliseconds)
         
         if (callCount++ > 10) {
             // Just in case something goes wrong.
-            consoleWrite("WARNING: Call count exceeded");
+            var elapsed = milliToSecs(callCount * milliseconds);
+            failTest("ERROR: test stalled, waited " + milliToSecs(elapsed) + "seconds for movie to play " + playedTime + " seconds");
             return;
         }
         
-        if (playedTime >= milliToSecs(milliseconds) || video.currentTime == video.duration) {
+        if (playedTime >= playDuration || video.currentTime == video.duration)
             run("video.pause()");
-        else {
-            var waitingTime = milliseconds - playedTime  * 1000;
-            setTimeout(callPauseIfTimeIsReached, waitingTime);
+        else {
+            var delta = milliseconds - playedTime  * 1000;
+            setTimeout(callPauseIfTimeIsReached, delta);
         }
     }
-    setTimeout(callPauseIfTimeIsReached, milliseconds);
+
+    // Add a small amount to the timer because it will take a non-zero amount of time for the 
+    // video to start playing.
+    setTimeout(callPauseIfTimeIsReached, milliseconds + 100);
 }
 
 function videoPlayedMain()