Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Bring ToT Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html
diff --git a/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html
new file mode 100644
index 0000000000000000000000000000000000000000..af19f41f47fafcd0d8152391ab85726f7c528473
--- /dev/null
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html
@@ -0,0 +1,58 @@
+<!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 promise resolution of OfflineAudioContext.resume() and OfflineAudioContext.suspend().');
+ 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;
+ var scheduledSuspendTime = 0;
+
+ // With the sample rate setting above, this ensures suspension time fall
+ // in to the render quantum boundary.
+ var suspendInterval = 0.25;
+
+ context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
+
+ function onSuspended() {
+ Should('context.currentTime', context.currentTime)
+ .beEqualTo(scheduledSuspendTime);
+
+ scheduledSuspendTime = context.currentTime + suspendInterval;
+
+ // When |scheduledSuspendTime >= renderDuration|, suspending the context
+ // will reject the promise.
+ if (scheduledSuspendTime < renderDuration) {
+ context.suspend(scheduledSuspendTime).then(onSuspended);
+ } else {
+ Should('context.suspend(scheduledSuspendTime)',
+ context.suspend(scheduledSuspendTime)).beRejected();
+ }
+
+ context.resume();
+ }
+
+ // Initiate the suspension loop.
+ context.suspend(scheduledSuspendTime).then(onSuspended);
+ context.startRendering().then(function () {
+ Should('context.state', context.state).beEqualTo('closed');
+ }).then(finishJSTest);
+
+ successfullyParsed = true;
+ </script>
+
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698