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 event handler callback from OfflineAudioContext.resume() and OfflineAudioContext.suspend().'); | |
| 12 window.jsTestIsAsync = true; | |
| 13 | |
| 14 var context; | |
| 15 var renderQuantum = 128; | |
| 16 var sampleRate = renderQuantum * 100; | |
|
Raymond Toy
2015/06/12 21:11:36
Explain why the sampleRate is 12800 Hz.
| |
| 17 var renderDuration = 2; | |
| 18 var scheduledSuspendTime = 0; | |
| 19 var suspendInterval = 0.25; | |
|
Raymond Toy
2015/06/12 21:11:36
Why 0.25?
| |
| 20 | |
| 21 function runTest() { | |
| 22 context = new OfflineAudioContext(1, sampleRate * renderDuration, sample Rate); | |
| 23 | |
| 24 context.onstatechange = function () { | |
| 25 if (context.state === 'suspended') { | |
| 26 Should('context.currentTime', context.currentTime) | |
| 27 .beEqualTo(scheduledSuspendTime); | |
| 28 | |
| 29 // When |scheduledSuspendTime > renderDuration|, the promise | |
| 30 // should be rejected and throw an exception. | |
|
Raymond Toy
2015/06/12 21:11:36
And throw exception? I think the comment is wrong.
hongchan
2015/06/15 18:40:45
Done.
| |
| 31 scheduledSuspendTime = context.currentTime + suspendInterval; | |
| 32 if (scheduledSuspendTime >= renderDuration) { | |
| 33 Should('context.suspend(scheduledSuspendTime)', | |
| 34 context.suspend(scheduledSuspendTime)).beRejected(); | |
| 35 } else { | |
| 36 context.suspend(scheduledSuspendTime); | |
|
Raymond Toy
2015/06/12 21:11:36
Should this handle the promise in case it was reje
hongchan
2015/06/15 18:40:45
This test should be about the event handler. I thi
| |
| 37 } | |
| 38 context.resume(); | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 // This test is for verifying all the event handlers on OAC and that is | |
| 43 // why 'oncomplete' is used here. | |
| 44 context.oncomplete = function () { | |
| 45 Should('context.state', context.state).beEqualTo('closed'); | |
| 46 finishJSTest(); | |
| 47 }; | |
| 48 | |
| 49 // Initiate the suspension loop. | |
| 50 context.suspend(scheduledSuspendTime); | |
| 51 context.startRendering(); | |
| 52 } | |
| 53 | |
| 54 runTest(); | |
| 55 successfullyParsed = true; | |
| 56 </script> | |
| 57 | |
| 58 </body> | |
| 59 </html> | |
| OLD | NEW |