Index: chrome/test/data/media/html/media_seek.html |
diff --git a/chrome/test/data/media/html/media_seek.html b/chrome/test/data/media/html/media_seek.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1982aeb9712871567d4b357675f6aa416030f6f8 |
--- /dev/null |
+++ b/chrome/test/data/media/html/media_seek.html |
@@ -0,0 +1,132 @@ |
+<!-- Used by media_seek_perf to record seek perf metrics. --> |
+<!DOCTYPE html> |
+<html lang="en-US"> |
+ <head> |
+ <title>CNS Seek Tests</title> |
+ <script src="utils.js" type="text/javascript"></script> |
+ </head> |
+ |
+ <body> |
+ <video controls></video> |
+ <div></div> |
+ </body> |
+ |
+ <script type="text/javascript"> |
+ var video = document.querySelector("video"); |
+ var logDiv = document.querySelector("div"); |
+ var ITERATIONS = 3; |
+ |
+ var SeekTestCase = { |
+ SHORT_SEEK: 0, |
+ LONG_SEEK: 1, |
+ BUFFERED_SEEK: 2 |
+ } |
+ |
+ var CachedState = { |
+ UNCACHED: 0, |
+ CACHED: 1 |
+ } |
+ |
+ function log(text) { |
+ logDiv.innerText += text + "\n"; |
+ } |
+ |
+ function resetSeekRecords() { |
+ seekRecords = []; |
+ for (cache_value in Object.keys(CachedState)) { |
DaleCurtis
2012/04/23 22:56:20
Why the change to cache_value? Aren't we reading t
shadi
2012/04/23 23:24:28
Well, Object.keys(CachedState) is ["UNCACHED", "CA
|
+ seekRecords[cache_value] = []; |
+ for (seek_value in Object.keys(SeekTestCase)) { |
DaleCurtis
2012/04/23 22:56:20
Ditto.
shadi
2012/04/23 23:24:28
Done.
|
+ seekRecords[cache_value][seek_value] = []; |
+ } |
+ } |
+ } |
+ |
+ // Called by the PyAuto controller to initiate testing. |
+ function startTest(src) { |
+ if (window.domAutomationController) |
+ window.domAutomationController.send(true); |
+ |
+ resetSeekRecords(); |
+ endTest = false; |
+ errorMsg = ""; |
+ timer = new Timer(); |
+ |
+ video.addEventListener("playing", playing); |
+ video.addEventListener("seeked", seeked); |
+ video.addEventListener("error", |
+ function() { end("Error loading media"); }); |
+ originalSrc = src; |
+ log("Running tests on " + originalSrc); |
+ log("Starting seek tests without browser caching:"); |
+ cacheState = CachedState.UNCACHED; |
+ iteration = 0; |
+ IterationTest(); |
+ } |
+ |
+ function IterationTest() { |
+ if (iteration < ITERATIONS) { |
+ iteration++; |
+ log("Test iteration " + iteration); |
+ seekState = SeekTestCase.SHORT_SEEK; |
+ video.src = getVideoSrc(); |
+ video.play(); |
+ } else if (cacheState == CachedState.UNCACHED) { |
+ log("Starting seek tests with browser caching:"); |
+ cacheState = CachedState.CACHED; |
+ iteration = 0; |
+ IterationTest(); |
+ } else { |
+ endTest = true; |
+ } |
+ } |
+ |
+ function getVideoSrc() { |
+ if (cacheState == CachedState.UNCACHED) { |
+ return GenerateUniqueURL(originalSrc); |
+ } else { |
+ return video.src; |
+ } |
+ } |
+ |
+ function playing() { |
+ if (seekState == SeekTestCase.SHORT_SEEK) { |
+ timer.start(); |
+ video.currentTime = 1; |
+ } |
+ } |
+ |
+ function seeked() { |
+ delta = timer.stop(); |
+ switch (seekState) { |
+ case SeekTestCase.SHORT_SEEK: |
+ seekRecords[cacheState][SeekTestCase.SHORT_SEEK].push(delta); |
+ log ("short seek in " + delta + "ms.") |
+ seekState = SeekTestCase.LONG_SEEK; |
+ timer.start(); |
+ video.currentTime = video.duration - 1; |
+ break; |
+ // Seek to almost end of file (unbuffered area). |
+ case SeekTestCase.LONG_SEEK: |
+ seekRecords[cacheState][SeekTestCase.LONG_SEEK].push(delta); |
+ log("long seek in " + delta + "ms.") |
+ seekState = SeekTestCase.BUFFERED_SEEK; |
+ timer.start(); |
+ video.currentTime = 1; |
+ break; |
+ case SeekTestCase.BUFFERED_SEEK: |
+ seekRecords[cacheState][SeekTestCase.BUFFERED_SEEK].push(delta); |
+ log("buffered seek in " + delta + "ms.") |
+ IterationTest(); |
+ break; |
+ default: |
+ end("An un-expected seek occured."); |
+ } |
+ } |
+ |
+ function end(msg) { |
+ errorMsg = msg; |
+ endTest = true; |
+ log(msg); |
+ } |
+ </script> |
+</html> |