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

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: Ready for Review Created 5 years, 6 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..05e3e29822e59e468b4b15014a8528282792b627
--- /dev/null
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-promise.html
@@ -0,0 +1,49 @@
+<!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;
+ var renderQuantum = 128;
+ var sampleRate = renderQuantum * 100;
Raymond Toy 2015/06/12 21:11:36 Pretty much the same comments for this file as for
hongchan 2015/06/15 18:40:46 Done.
+ var renderDuration = 2;
+ var scheduledSuspendTime = 0;
+ var suspendInterval = 0.25;
+
+ context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
+
+ function onSuspended() {
+ Should('context.currentTime', context.currentTime)
+ .beEqualTo(scheduledSuspendTime);
+
+ // When |scheduledSuspendTime > renderDuration|, the promise should be
+ // rejected and throw an exception.
+ scheduledSuspendTime = context.currentTime + suspendInterval;
+ if (scheduledSuspendTime >= renderDuration) {
+ Should('context.suspend(scheduledSuspendTime)',
+ context.suspend(scheduledSuspendTime)).beRejected();
+ } else {
+ context.suspend(scheduledSuspendTime).then(onSuspended);
+ }
+ context.resume();
+ }
+
+ context.suspend(scheduledSuspendTime).then(onSuspended);
+ context.startRendering().then(function () {
+ Should('context.state', context.state).beEqualTo('closed');
+ finishJSTest();
+ });
+
+ successfullyParsed = true;
+ </script>
+
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698