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

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

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added UseCounter 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-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..9b998131de9e4157e1ae6fbb951f5ba8559bcd47
--- /dev/null
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-sequence.html
@@ -0,0 +1,62 @@
+<!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.
Raymond Toy 2015/06/15 20:42:13 I wonder if it might be useful to have some random
+ //
+ // Also these numbers are multiple of 0.25, so they are supposed to fall
+ // in the render quantum boundary for the easier and intuitive
Raymond Toy 2015/06/15 20:42:13 "for the easier" -> "for easier" "intuitive" -> "m
hongchan 2015/06/15 21:44:20 Oops.
+ // 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
+ // which is pushed into |actualSuspendTimes| should be in the ascending
Raymond Toy 2015/06/15 20:42:13 There's no |actualSuspendTimes| variable here. I'd
hongchan 2015/06/15 21:44:20 Oops again.
+ // order.
+ context.suspend(suspendTimes[i]).then(function () {
+ Should('The suspend time (' + currentSuspendIndex + ')', context.currentTime)
Raymond Toy 2015/06/15 20:42:13 Is printing currentSuspendIndex useful? I was actu
hongchan 2015/06/15 21:44:20 I will think about this a bit more.
+ .beEqualTo(sortedSuspendTime[currentSuspendIndex++]);
+ context.resume();
+ });
+
+ }
+
+ context.startRendering().then(function () {
+ finishJSTest();
+ });
+
+ successfullyParsed = true;
+ </script>
+
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698