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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/media/html/utils.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!-- Used by media_seek_perf to record seek perf metrics. -->
2 <!DOCTYPE html>
3 <html lang="en-US">
4 <head>
5 <title>CNS Seek Tests</title>
6 <script src="utils.js" type="text/javascript"></script>
7 </head>
8
9 <body>
10 <video controls></video>
11 <div></div>
12 </body>
13
14 <script type="text/javascript">
15 var video = document.querySelector("video");
16 var logDiv = document.querySelector("div");
17 var ITERATIONS = 3;
18
19 var SeekTestCase = {
20 SHORT_SEEK: 0,
21 LONG_SEEK: 1,
22 BUFFERED_SEEK: 2
23 }
24
25 var CachedState = {
26 UNCACHED: 0,
27 CACHED: 1
28 }
29
30 function log(text) {
31 logDiv.innerText += text + "\n";
32 }
33
34 function resetSeekRecords() {
35 seekRecords = [];
36 for (cache_index in Object.keys(CachedState)) {
37 seekRecords[cache_index] = [];
38 for (seek_index in Object.keys(SeekTestCase)) {
39 seekRecords[cache_index][seek_index] = [];
40 }
41 }
42 }
43
44 // Called by the PyAuto controller to initiate testing.
45 function startTest(src) {
46 if (window.domAutomationController)
47 window.domAutomationController.send(true);
48
49 resetSeekRecords();
50 endTest = false;
51 errorMsg = "";
52 timer = new Timer();
53
54 video.addEventListener("playing", playing);
55 video.addEventListener("seeked", seeked);
56 video.addEventListener("error",
57 function() { end("Error loading media"); });
58 originalSrc = src;
59 log("Running tests on " + originalSrc);
60 log("Starting seek tests without browser caching:");
61 cacheState = CachedState.UNCACHED;
62 iteration = 0;
63 IterationTest();
64 }
65
66 function IterationTest() {
67 if (iteration < ITERATIONS) {
68 iteration++;
69 log("Test iteration " + iteration);
70 seekState = SeekTestCase.SHORT_SEEK;
71 video.src = getVideoSrc();
72 video.play();
73 } else if (cacheState == CachedState.UNCACHED) {
74 log("Starting seek tests with browser caching:");
75 cacheState = CachedState.CACHED;
76 iteration = 0;
77 IterationTest();
78 } else {
79 endTest = true;
80 }
81 }
82
83 function getVideoSrc() {
84 if (cacheState == CachedState.UNCACHED) {
85 return GenerateUniqueURL(originalSrc);
86 } else {
87 return video.src;
88 }
89 }
90
91 function playing() {
92 if (seekState == SeekTestCase.SHORT_SEEK) {
93 timer.start();
94 video.currentTime = 1;
95 }
96 }
97
98 function seeked() {
99 delta = timer.stop();
100 switch (seekState) {
101 case SeekTestCase.SHORT_SEEK:
102 seekRecords[cacheState][SeekTestCase.SHORT_SEEK].push(delta);
103 log ("short seek in " + delta + "ms.")
104 seekState = SeekTestCase.LONG_SEEK;
105 timer.start();
106 video.currentTime = video.duration - 1;
107 break;
108 // Seek to almost end of file (unbuffered area).
109 case SeekTestCase.LONG_SEEK:
110 seekRecords[cacheState][SeekTestCase.LONG_SEEK].push(delta);
111 log("long seek in " + delta + "ms.")
112 seekState = SeekTestCase.BUFFERED_SEEK;
113 timer.start();
114 video.currentTime = 1;
115 break;
116 case SeekTestCase.BUFFERED_SEEK:
117 seekRecords[cacheState][SeekTestCase.BUFFERED_SEEK].push(delta);
118 log("buffered seek in " + delta + "ms.")
119 IterationTest();
120 break;
121 default:
122 end("An un-expected seek occured.");
123 }
124 }
125
126 function end(msg) {
127 errorMsg = msg;
128 endTest = true;
129 log(msg);
130 }
131 </script>
132 </html>
OLDNEW
« 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