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

Unified Diff: chrome/test/data/media/html/media_seek.html

Issue 9960063: CNS seek tests for <video>. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: New tests with cached videos. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/media/html/utils.js » ('j') | chrome/test/data/media/html/utils.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d3655cd955e0fd48885931af8059135f91007738
--- /dev/null
+++ b/chrome/test/data/media/html/media_seek.html
@@ -0,0 +1,133 @@
+<!-- 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>
+ <div></div>
DaleCurtis 2012/04/19 19:42:10 Will having the div above the video cause it to mo
shadi 2012/04/20 00:17:47 Done.
+ <video controls></video>
+ </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 = {
+ UN_CACHED: 0,
DaleCurtis 2012/04/19 19:42:10 s/_//
shadi 2012/04/20 00:17:47 Done.
+ CACHED: 1
+ }
+
+ function log(text) {
+ logDiv.innerText += text + "\n";
+ }
+
+ function resetSeekRecords() {
+ seekRecords = [2];
DaleCurtis 2012/04/19 19:42:10 Why [2]? Wouldn't the whole function be simpler/mo
shadi 2012/04/20 00:17:47 Done.
+ seekRecords[CachedState.UN_CACHED] = [];
+ seekRecords[CachedState.CACHED] = [];
+ for (key in SeekTestCase) {
+ seekRecords[CachedState.UN_CACHED].push([]);
+ seekRecords[CachedState.CACHED].push([]);
+ }
+ }
+
+ // 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();
+ cacheState = CachedState.UN_CACHED;
DaleCurtis 2012/04/19 19:42:10 Should bundle this with the log message below so i
shadi 2012/04/20 00:17:47 Done.
+
+ iteration = 0;
+ 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:");
+ IterationTest();
+ }
+
+ function IterationTest() {
+ if (iteration < ITERATIONS) {
+ iteration++;
+ log('Test iteration ' + iteration);
DaleCurtis 2012/04/19 19:42:10 s/'/"/g
shadi 2012/04/20 00:17:47 Done.
+ seekState = SeekTestCase.SHORT_SEEK;
+ video.src = getVideoSrc();
+ video.play();
+ } else if (cacheState == CachedState.UN_CACHED) {
+ log("Starting seek tests with browser caching:");
DaleCurtis 2012/04/19 19:42:10 Indent?
shadi 2012/04/20 00:17:47 Done.
+ cacheState = CachedState.CACHED;
+ iteration = 0;
+ IterationTest();
+ } else {
+ endTest = true;
+ }
+ }
+
+ function getVideoSrc() {
+ if (cacheState == CachedState.UN_CACHED) {
+ return GenerateUniqueURL(originalSrc);
DaleCurtis 2012/04/19 19:42:10 Indent.
shadi 2012/04/20 00:17:47 Done.
+ } else {
+ return video.src;
+ }
+ }
+
+ function playing() {
+ if (seekState == SeekTestCase.SHORT_SEEK) {
+ timer.start();
+ video.currentTime = 1;
+ }
+ }
+
+ function seeked() {
+ delta = timer.stop();
+ switch (seekState) {
+ // first short seek
DaleCurtis 2012/04/19 19:42:10 Remove comment or elaborate, SeekTestCase.SHORT_SE
shadi 2012/04/20 00:17:47 Done.
+ 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 (uncached)
DaleCurtis 2012/04/19 19:42:10 s/(uncached)/./
shadi 2012/04/20 00:17:47 Done.
+ 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;
+ // Second seek to a buffered aread.
DaleCurtis 2012/04/19 19:42:10 Remove or elaborate.
shadi 2012/04/20 00:17:47 Done.
+ case SeekTestCase.BUFFERED_SEEK:
+ seekRecords[cacheState][SeekTestCase.BUFFERED_SEEK].push(delta);
+ log("cached seek seek in " + delta + "ms.")
DaleCurtis 2012/04/19 19:42:10 s/cached/buffered/ ?
shadi 2012/04/20 00:17:47 Done.
+ IterationTest();
+ break;
+ default:
+ end("An un-expected seek occured.");
+ }
+ }
+
+ function end(msg) {
+ errorMsg = msg;
+ endTest = true;
+ log(msg);
+ }
+ </script>
+</html>
« no previous file with comments | « no previous file | chrome/test/data/media/html/utils.js » ('j') | chrome/test/data/media/html/utils.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698