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

Unified Diff: LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.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-eventhandler.html
diff --git a/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html
new file mode 100644
index 0000000000000000000000000000000000000000..cd375f88f24d8a6dee531d76ddde5d495ab45c5e
--- /dev/null
+++ b/LayoutTests/webaudio/offlineaudiocontext-suspend-resume-eventhandler.html
@@ -0,0 +1,59 @@
+<!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 event handler callback from 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 Explain why the sampleRate is 12800 Hz.
+ var renderDuration = 2;
+ var scheduledSuspendTime = 0;
+ var suspendInterval = 0.25;
Raymond Toy 2015/06/12 21:11:36 Why 0.25?
+
+ function runTest() {
+ context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRate);
+
+ context.onstatechange = function () {
+ if (context.state === 'suspended') {
+ Should('context.currentTime', context.currentTime)
+ .beEqualTo(scheduledSuspendTime);
+
+ // When |scheduledSuspendTime > renderDuration|, the promise
+ // should be rejected and throw an exception.
Raymond Toy 2015/06/12 21:11:36 And throw exception? I think the comment is wrong.
hongchan 2015/06/15 18:40:45 Done.
+ scheduledSuspendTime = context.currentTime + suspendInterval;
+ if (scheduledSuspendTime >= renderDuration) {
+ Should('context.suspend(scheduledSuspendTime)',
+ context.suspend(scheduledSuspendTime)).beRejected();
+ } else {
+ context.suspend(scheduledSuspendTime);
Raymond Toy 2015/06/12 21:11:36 Should this handle the promise in case it was reje
hongchan 2015/06/15 18:40:45 This test should be about the event handler. I thi
+ }
+ context.resume();
+ }
+ };
+
+ // This test is for verifying all the event handlers on OAC and that is
+ // why 'oncomplete' is used here.
+ context.oncomplete = function () {
+ Should('context.state', context.state).beEqualTo('closed');
+ finishJSTest();
+ };
+
+ // Initiate the suspension loop.
+ context.suspend(scheduledSuspendTime);
+ context.startRendering();
+ }
+
+ runTest();
+ successfullyParsed = true;
+ </script>
+
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698