Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 <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.
| |
| 11 <video controls></video> | |
| 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 UN_CACHED: 0, | |
|
DaleCurtis
2012/04/19 19:42:10
s/_//
shadi
2012/04/20 00:17:47
Done.
| |
| 27 CACHED: 1 | |
| 28 } | |
| 29 | |
| 30 function log(text) { | |
| 31 logDiv.innerText += text + "\n"; | |
| 32 } | |
| 33 | |
| 34 function resetSeekRecords() { | |
| 35 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.
| |
| 36 seekRecords[CachedState.UN_CACHED] = []; | |
| 37 seekRecords[CachedState.CACHED] = []; | |
| 38 for (key in SeekTestCase) { | |
| 39 seekRecords[CachedState.UN_CACHED].push([]); | |
| 40 seekRecords[CachedState.CACHED].push([]); | |
| 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 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.
| |
| 54 | |
| 55 iteration = 0; | |
| 56 originalSrc = src; | |
| 57 video.addEventListener("playing", playing); | |
| 58 video.addEventListener("seeked", seeked); | |
| 59 video.addEventListener("error", | |
| 60 function() { end("Error loading media"); }); | |
| 61 log("Starting seek tests without browser caching:"); | |
| 62 IterationTest(); | |
| 63 } | |
| 64 | |
| 65 function IterationTest() { | |
| 66 if (iteration < ITERATIONS) { | |
| 67 iteration++; | |
| 68 log('Test iteration ' + iteration); | |
|
DaleCurtis
2012/04/19 19:42:10
s/'/"/g
shadi
2012/04/20 00:17:47
Done.
| |
| 69 seekState = SeekTestCase.SHORT_SEEK; | |
| 70 video.src = getVideoSrc(); | |
| 71 video.play(); | |
| 72 } else if (cacheState == CachedState.UN_CACHED) { | |
| 73 log("Starting seek tests with browser caching:"); | |
|
DaleCurtis
2012/04/19 19:42:10
Indent?
shadi
2012/04/20 00:17:47
Done.
| |
| 74 cacheState = CachedState.CACHED; | |
| 75 iteration = 0; | |
| 76 IterationTest(); | |
| 77 } else { | |
| 78 endTest = true; | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 function getVideoSrc() { | |
| 83 if (cacheState == CachedState.UN_CACHED) { | |
| 84 return GenerateUniqueURL(originalSrc); | |
|
DaleCurtis
2012/04/19 19:42:10
Indent.
shadi
2012/04/20 00:17:47
Done.
| |
| 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 // 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.
| |
| 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 (uncached) | |
|
DaleCurtis
2012/04/19 19:42:10
s/(uncached)/./
shadi
2012/04/20 00:17:47
Done.
| |
| 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 // Second seek to a buffered aread. | |
|
DaleCurtis
2012/04/19 19:42:10
Remove or elaborate.
shadi
2012/04/20 00:17:47
Done.
| |
| 117 case SeekTestCase.BUFFERED_SEEK: | |
| 118 seekRecords[cacheState][SeekTestCase.BUFFERED_SEEK].push(delta); | |
| 119 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.
| |
| 120 IterationTest(); | |
| 121 break; | |
| 122 default: | |
| 123 end("An un-expected seek occured."); | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 function end(msg) { | |
| 128 errorMsg = msg; | |
| 129 endTest = true; | |
| 130 log(msg); | |
| 131 } | |
| 132 </script> | |
| 133 </html> | |
| OLD | NEW |