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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/compatibility.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 </head>
8
9 <body>
10 <script>
11 description('Test OfflineAudioContext.resume() and OfflineAudioContext.sus pend() with the timed sequence.');
12 window.jsTestIsAsync = true;
13
14 var context;
15
16 // The sample rate is multiple of the rendering quantum, so suspension
17 // times fall in to the render quantum boundary.
18 var renderQuantum = 128;
19
20 var sampleRate = renderQuantum * 100;
21 var renderDuration = 2;
22
23 // These numbers are in an arbitrary order, but not randomly generated in
24 // runtime to avoid moving pieces. However, it is safe to arrange them
25 // 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
26 //
27 // Also these numbers are multiple of 0.25, so they are supposed to fall
28 // 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.
29 // verification.
30 var suspendTimes = [0.25, 0.75, 1.0, 0.5, 1.25, 0.0, 1.75];
31
32 // Get sorted suspend time sequence.
33 var sortedSuspendTime = suspendTimes.sort(function ascendingOrder(a, b) {
34 return a - b;
35 });
36
37 var currentSuspendIndex = 0;
38
39 context = new OfflineAudioContext(1, sampleRate * renderDuration, sampleRa te);
40
41 for (var i = 0; i < suspendTimes.length; i++) {
42
43 // Schedule suspends in a random order, but the actual suspend time
44 // 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.
45 // order.
46 context.suspend(suspendTimes[i]).then(function () {
47 Should('The suspend time (' + currentSuspendIndex + ')', context.curre ntTime)
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.
48 .beEqualTo(sortedSuspendTime[currentSuspendIndex++]);
49 context.resume();
50 });
51
52 }
53
54 context.startRendering().then(function () {
55 finishJSTest();
56 });
57
58 successfullyParsed = true;
59 </script>
60
61 </body>
62 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698