Index: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html |
diff --git a/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86dfeda64c2b110249ae1babb3e048774a7b2232 |
--- /dev/null |
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-basic.html |
@@ -0,0 +1,95 @@ |
+<!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('Basic test for OfflineAudioContext.suspend() and OfflineAudioContext.resume().'); |
+ window.jsTestIsAsync = true; |
+ |
+ var sampleRate = 44100; |
+ var renderDuration = 1; |
+ var renderQuantum = 128; |
+ |
+ var audit = Audit.createTaskRunner(); |
+ |
+ // Task: Calling suspend with no argument or the negative time should |
Raymond Toy
2015/06/15 20:42:13
"or the negative" -> "or negative"
hongchan
2015/06/15 21:44:20
Done.
|
+ // reject the promise. |
+ audit.defineTask('suspend-no-argument', function (done) { |
Raymond Toy
2015/06/15 20:42:13
Task name doesn't match the code anymore.
hongchan
2015/06/15 21:44:20
Done.
|
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ Should('context.suspend()', context.suspend()).beRejected(); |
+ Should('context.suspend(-1.0)', context.suspend(-1.0)).beRejected().then(done); |
+ }); |
+ |
+ // Task: Scheduling a suspend in the past should be rejected. |
+ audit.defineTask('suspend-invalid-argument', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ context.suspend(0.5).then(function () { |
+ Should('Scheduling a suspend in the past', |
+ context.suspend(context.currentTime - 0.1)).beRejected(); |
Raymond Toy
2015/06/15 20:42:13
Did you forget to update the expected results? I c
hongchan
2015/06/15 21:44:20
Hmm. It is in there:
PASS context.suspend(-1.0) r
Raymond Toy
2015/06/15 22:03:17
Isn't that from line 26? I was expecting some outp
hongchan
2015/06/15 22:15:42
It was a stupid mistake of mine. I forgot to add t
|
+ context.resume(); |
+ }); |
+ |
+ context.startRendering().then(done); |
+ }); |
+ |
+ // Task: Calling multiple suspends at the same rendering quantum should |
+ // reject the promise. |
+ audit.defineTask('identical-suspend-time', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ // |suspendTime1| and |suspendTime2| are identical when quantized to |
+ // the render quantum size. |
+ var suspendTime1 = renderQuantum / sampleRate; |
+ var suspendTime2 = (renderQuantum + renderQuantum * 0.5) / sampleRate; |
+ |
+ context.suspend(suspendTime1); |
+ |
+ Should('Calling multiple suspends at the same rendering quantum', |
+ context.suspend(suspendTime2)).beRejected().then(done); |
+ }); |
+ |
+ // Task: Resuming the context before the actual suspension happens. |
+ audit.defineTask('resume-before-suspend', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ // A suspend is scheduled at the half. |
+ context.suspend(renderDuration * 0.5); |
+ |
+ // However, the next resume will be executed before the actual |
+ // suspension happens. |
+ Should('Resuming before suspend', context.resume()).beRejected().then(done); |
+ }); |
+ |
+ // Task: Calling resume on non-suspended context should reject the promise. |
+ audit.defineTask('resume-without-suspend', function (done) { |
+ var context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate); |
+ |
+ Should('Calling resume on non-suspended context', context.resume()) |
+ .beRejected().then(done); |
+ }); |
+ |
+ audit.defineTask('finish', function (done) { |
+ finishJSTest(); |
+ done(); |
+ }); |
+ |
+ audit.runTasks( |
+ 'suspend-no-argument', |
+ 'identical-suspend-time', |
+ 'resume-before-suspend', |
+ 'resume-without-suspend', |
+ 'finish' |
+ ); |
+ |
+ successfullyParsed = true; |
+ </script> |
+ |
+ </body> |
+</html> |