Chromium Code Reviews| Index: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-sequence.html | 
| diff --git a/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-sequence.html b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-sequence.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..8f2254c9e003f01f2fe04d545ae5abf766b4e614 | 
| --- /dev/null | 
| +++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-sequence.html | 
| @@ -0,0 +1,61 @@ | 
| +<!doctype html> | 
| +<html> | 
| + <head> | 
| + <script src="../resources/js-test.js"></script> | 
| + <script src="resources/compatibility.js"></script> | 
| + <script src="resources/audio-testing.js"></script> | 
| + </head> | 
| + | 
| + <body> | 
| + <script> | 
| + description('Test OfflineAudioContext.resume() and OfflineAudioContext.suspend() with the timed sequence.'); | 
| + window.jsTestIsAsync = true; | 
| + | 
| + var context; | 
| + | 
| + // The sample rate is multiple of the rendering quantum, so suspension | 
| + // times fall in to the render quantum boundary. | 
| + var renderQuantum = 128; | 
| + | 
| + var sampleRate = renderQuantum * 100; | 
| + var renderDuration = 2; | 
| + | 
| + // These numbers are in an arbitrary order, but not randomly generated in | 
| + // runtime to avoid moving pieces. However, it is safe to arrange them | 
| + // in a random order in runtime. | 
| + // | 
| + // Also these numbers are multiple of 0.25, so they are supposed to fall | 
| + // in the render quantum boundary for easier and more intuitive | 
| + // verification. | 
| + var suspendTimes = [0.25, 0.75, 1.0, 0.5, 1.25, 0.0, 1.75]; | 
| + | 
| + // Get sorted suspend time sequence. | 
| + var sortedSuspendTime = suspendTimes.sort(function ascendingOrder(a, b) { | 
| + return a - b; | 
| + }); | 
| + | 
| + var currentSuspendIndex = 0; | 
| + | 
| + context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); | 
| + | 
| + for (var i = 0; i < suspendTimes.length; i++) { | 
| + | 
| + // Schedule suspends in a random order, but the actual suspend time | 
| + // must happen in ascending order. | 
| + context.suspend(suspendTimes[i]).then(function () { | 
| + Should('The suspend time (' + currentSuspendIndex + ')', context.currentTime) | 
| 
 
Raymond Toy
2015/06/16 17:57:09
I don't think printing currentSuspendIndex is usef
 
hongchan
2015/06/16 21:31:20
Acknowledged.
 
 | 
| + .beEqualTo(sortedSuspendTime[currentSuspendIndex++]); | 
| + context.resume(); | 
| + }); | 
| + | 
| + } | 
| + | 
| + context.startRendering().then(function () { | 
| + finishJSTest(); | 
| + }); | 
| + | 
| + successfullyParsed = true; | 
| + </script> | 
| + | 
| + </body> | 
| +</html> |