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

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: Re comments. 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
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_key in CachedState) {
37 seekRecords[cache_key] = [];
38 for (seek_key in SeekTestCase) {
39 seekRecords[cache_key][seek_key] = [];
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 originalSrc = src;
55 video.addEventListener("playing", playing);
56 video.addEventListener("seeked", seeked);
57 video.addEventListener("error",
58 function() { end("Error loading media"); });
59 log("Starting seek tests without browser caching:");
60 cacheState = CachedState.UNCACHED;
61 iteration = 0;
62 IterationTest();
63 }
64
65 function IterationTest() {
66 if (iteration < ITERATIONS) {
67 iteration++;
68 log("Test iteration " + iteration);
69 seekState = SeekTestCase.SHORT_SEEK;
70 video.src = getVideoSrc();
71 video.play();
72 } else if (cacheState == CachedState.UNCACHED) {
73 log("Starting seek tests with browser caching:");
74 cacheState = CachedState.CACHED;
75 iteration = 0;
76 IterationTest();
77 } else {
78 endTest = true;
79 }
80 }
81
82 function getVideoSrc() {
83 if (cacheState == CachedState.UNCACHED) {
84 return GenerateUniqueURL(originalSrc);
85 } else {
86 return video.src;
87 }
88 }
89
90 function playing() {
91 if (seekState == SeekTestCase.SHORT_SEEK) {
92 timer.start();
93 video.currentTime = 1;
94 }
95 }
96
97 function seeked() {
98 delta = timer.stop();
99 switch (seekState) {
100 case SeekTestCase.SHORT_SEEK:
101 seekRecords[cacheState][SeekTestCase.SHORT_SEEK].push(delta);
102 log ("short seek in " + delta + "ms.")
103 seekState = SeekTestCase.LONG_SEEK;
104 timer.start();
105 video.currentTime = video.duration - 1;
106 break;
107 // Seek to almost end of file (unbuffered area).
108 case SeekTestCase.LONG_SEEK:
109 seekRecords[cacheState][SeekTestCase.LONG_SEEK].push(delta);
110 log("long seek in " + delta + "ms.")
111 seekState = SeekTestCase.BUFFERED_SEEK;
112 timer.start();
113 video.currentTime = 1;
114 break;
115 case SeekTestCase.BUFFERED_SEEK:
116 seekRecords[cacheState][SeekTestCase.BUFFERED_SEEK].push(delta);
117 log("buffered seek in " + delta + "ms.")
118 IterationTest();
119 break;
120 default:
121 end("An un-expected seek occured.");
122 }
123 }
124
125 function end(msg) {
126 errorMsg = msg;
127 endTest = true;
128 log(msg);
129 }
130 </script>
131 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/media/html/utils.js » ('j') | chrome/test/functional/media/media_seek_perf.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698