| 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..36e206048d548702ec9f1ff3d4368d16e63a2ac1
|
| --- /dev/null
|
| +++ b/chrome/test/data/media/html/media_seek.html
|
| @@ -0,0 +1,131 @@
|
| +<!-- 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_key in CachedState) {
|
| + seekRecords[cache_key] = [];
|
| + for (seek_key in SeekTestCase) {
|
| + seekRecords[cache_key][seek_key] = [];
|
| + }
|
| + }
|
| + }
|
| +
|
| + // 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();
|
| +
|
| + originalSrc = src;
|
| + video.addEventListener("playing", playing);
|
| + video.addEventListener("seeked", seeked);
|
| + video.addEventListener("error",
|
| + function() { end("Error loading media"); });
|
| + 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>
|
|
|