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 event handler callback from OfflineAudioContext resume/s uspend.'); | |
12 window.jsTestIsAsync = true; | |
13 | |
14 var context; | |
15 var sampleRate = 44100; | |
16 var renderDuration = 2; | |
17 var renderQuantum = 128; | |
18 var scheduledSuspendTime = 0.1; | |
Raymond Toy
2015/05/28 16:37:34
I think you should compute scheduledSuspendTime fr
hongchan
2015/06/09 20:49:58
It should not matter, I believe. It should do what
| |
19 | |
20 // Get the time quantized by render quantum size. | |
21 function quantizeByRenderQuantum(time) { | |
22 var samples = time * sampleRate; | |
23 return (samples - (samples % renderQuantum)) / sampleRate; | |
24 } | |
25 | |
26 function runTest() { | |
27 context = new OfflineAudioContext(1, sampleRate * renderDuration, sample Rate); | |
28 | |
29 context.onstatechange = function () { | |
30 if (context.state === 'suspended') { | |
31 Should('context.currentTime', context.currentTime) | |
32 .beEqualTo(quantizeByRenderQuantum(scheduledSuspendTime)); | |
33 | |
34 // When context.currentTime 0.1 > renderDuration, the promise should | |
Raymond Toy
2015/05/28 16:37:34
"currentTime 0.1"?
hongchan
2015/06/09 20:49:58
Oops. This should read |context.currentTime + 0.1
| |
35 // be rejected and throw an exception. | |
36 scheduledSuspendTime = context.currentTime + 0.1; | |
Raymond Toy
2015/05/28 16:37:34
This delta of 0.1 should also be computed so that
hongchan
2015/06/09 20:49:58
I don't think it matters as the comment above.
| |
37 context.suspend(scheduledSuspendTime); | |
38 context.resume(); | |
39 } | |
40 }; | |
41 | |
42 context.oncomplete = function () { | |
43 Should('context.state', context.state).beEqualTo('closed'); | |
44 finishJSTest(); | |
45 }; | |
46 | |
47 context.suspend(scheduledSuspendTime); | |
48 context.startRendering(); | |
Raymond Toy
2015/05/28 16:37:34
If you really want to use oncomplete instead of a
hongchan
2015/06/09 20:49:58
This test is about testing all event handlers are
| |
49 } | |
50 | |
51 runTest(); | |
52 successfullyParsed = true; | |
53 </script> | |
54 | |
55 </body> | |
56 </html> | |
OLD | NEW |