OLD | NEW |
---|---|
(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. | |
26 // | |
27 // Also these numbers are multiple of 0.25, so they are supposed to fall | |
28 // in the render quantum boundary for easier and more intuitive | |
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 // must happen in ascending order. | |
45 context.suspend(suspendTimes[i]).then(function () { | |
46 Should('The suspend time (' + currentSuspendIndex + ')', context.curre ntTime) | |
Raymond Toy
2015/06/16 17:57:09
I don't think printing currentSuspendIndex is usef
hongchan
2015/06/16 21:31:20
Acknowledged.
| |
47 .beEqualTo(sortedSuspendTime[currentSuspendIndex++]); | |
48 context.resume(); | |
49 }); | |
50 | |
51 } | |
52 | |
53 context.startRendering().then(function () { | |
54 finishJSTest(); | |
55 }); | |
56 | |
57 successfullyParsed = true; | |
58 </script> | |
59 | |
60 </body> | |
61 </html> | |
OLD | NEW |