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

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: Value vs index 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') | no next file with comments »
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..03e72123289795dac90417980760b4548c40ebef
--- /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_index in Object.keys(CachedState)) {
+ seekRecords[cache_index] = [];
+ for (seek_index in Object.keys(SeekTestCase)) {
+ seekRecords[cache_index][seek_index] = [];
+ }
+ }
+ }
+
+ // 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>
« no previous file with comments | « no previous file | chrome/test/data/media/html/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698