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

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: 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-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..256a8ad6228d8d21159a2d8980e1ae82f98d2ce5
--- /dev/null
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-sequence.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 OfflineAudioContext.resume() and OfflineAudioContext.suspend() with the timed sequence.');
+ window.jsTestIsAsync = true;
+
+ var context;
+ var renderQuantum = 128;
+ var sampleRate = renderQuantum * 100;
+ var renderDuration = 2;
+
+ // Hard-coded arbitrary suspend times.
Raymond Toy 2015/06/12 21:11:36 Add more comment. Presumably, they should be in a
hongchan 2015/06/15 18:40:46 I am a bit confused. Isn't this what we agreed on?
+ var suspendTimes = [0.25, 0.75, 1.0, 0.5, 1.25, 0.0, 1.75];
+ var actualSuspendTimes = [];
+
+ // Sort utility.
+ function ascendingOrder(a, b) {
+ return a - b;
+ }
+
+ 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
+ // order.
+ context.suspend(suspendTimes[i]).then(function () {
+ actualSuspendTimes.push(context.currentTime);
+ context.resume();
+ });
+
+ }
+
+ context.startRendering().then(function () {
+
+ // Get sorted suspend time sequence.
+ var sortedSuspendTime = suspendTimes.sort(ascendingOrder);
+
+ // The actual suspend time and the sorted one should match.
+ Should('Sorted suspend times array', sortedSuspendTime)
+ .beEqualToArray(actualSuspendTimes);
+
+ finishJSTest();
+ });
+
+ successfullyParsed = true;
+ </script>
+
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698