Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../resources/js-test.js"></script> | |
| 5 <script src="resources/compatibility.js"></script> | |
| 6 <script src="resources/audio-testing.js"></script> | |
| 7 </head> | |
| 8 | |
| 9 <body> | |
| 10 <script> | |
| 11 description('Test OfflineAudioContext.resume() and OfflineAudioContext.sus pend() with the timed sequence.'); | |
| 12 window.jsTestIsAsync = true; | |
| 13 | |
| 14 var context; | |
| 15 var renderQuantum = 128; | |
| 16 var sampleRate = renderQuantum * 100; | |
| 17 var renderDuration = 2; | |
| 18 | |
| 19 // Hard-coded arbitrary suspend times. | |
|
Raymond Toy
2015/06/12 21:11:36
Add more comment. Presumably, they should be in a
hongchan
2015/06/15 18:40:46
I am a bit confused. Isn't this what we agreed on?
| |
| 20 var suspendTimes = [0.25, 0.75, 1.0, 0.5, 1.25, 0.0, 1.75]; | |
| 21 var actualSuspendTimes = []; | |
| 22 | |
| 23 // Sort utility. | |
| 24 function ascendingOrder(a, b) { | |
| 25 return a - b; | |
| 26 } | |
| 27 | |
| 28 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa te); | |
| 29 | |
| 30 for (var i = 0; i < suspendTimes.length; i++) { | |
| 31 | |
| 32 // Schedule suspends in a random order, but the actual suspend time | |
| 33 // which is pushed into |actualSuspendTimes| should be in the ascending | |
| 34 // order. | |
| 35 context.suspend(suspendTimes[i]).then(function () { | |
| 36 actualSuspendTimes.push(context.currentTime); | |
| 37 context.resume(); | |
| 38 }); | |
| 39 | |
| 40 } | |
| 41 | |
| 42 context.startRendering().then(function () { | |
| 43 | |
| 44 // Get sorted suspend time sequence. | |
| 45 var sortedSuspendTime = suspendTimes.sort(ascendingOrder); | |
| 46 | |
| 47 // The actual suspend time and the sorted one should match. | |
| 48 Should('Sorted suspend times array', sortedSuspendTime) | |
| 49 .beEqualToArray(actualSuspendTimes); | |
| 50 | |
| 51 finishJSTest(); | |
| 52 }); | |
| 53 | |
| 54 successfullyParsed = true; | |
| 55 </script> | |
| 56 | |
| 57 </body> | |
| 58 </html> | |
| OLD | NEW |