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('Basic test for OfflineAudioContext.suspend() and OfflineAudio Context.resume().'); | |
12 window.jsTestIsAsync = true; | |
13 | |
14 var sampleRate = 44100; | |
15 var renderDuration = 1; | |
16 var renderQuantum = 128; | |
17 | |
18 var audit = Audit.createTaskRunner(); | |
19 | |
20 // Task: Calling suspend with no argument or the negative time should | |
Raymond Toy
2015/06/15 20:42:13
"or the negative" -> "or negative"
hongchan
2015/06/15 21:44:20
Done.
| |
21 // reject the promise. | |
22 audit.defineTask('suspend-no-argument', function (done) { | |
Raymond Toy
2015/06/15 20:42:13
Task name doesn't match the code anymore.
hongchan
2015/06/15 21:44:20
Done.
| |
23 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); | |
24 | |
25 Should('context.suspend()', context.suspend()).beRejected(); | |
26 Should('context.suspend(-1.0)', context.suspend(-1.0)).beRejected().then (done); | |
27 }); | |
28 | |
29 // Task: Scheduling a suspend in the past should be rejected. | |
30 audit.defineTask('suspend-invalid-argument', function (done) { | |
31 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); | |
32 | |
33 context.suspend(0.5).then(function () { | |
34 Should('Scheduling a suspend in the past', | |
35 context.suspend(context.currentTime - 0.1)).beRejected(); | |
Raymond Toy
2015/06/15 20:42:13
Did you forget to update the expected results? I c
hongchan
2015/06/15 21:44:20
Hmm. It is in there:
PASS context.suspend(-1.0) r
Raymond Toy
2015/06/15 22:03:17
Isn't that from line 26? I was expecting some outp
hongchan
2015/06/15 22:15:42
It was a stupid mistake of mine. I forgot to add t
| |
36 context.resume(); | |
37 }); | |
38 | |
39 context.startRendering().then(done); | |
40 }); | |
41 | |
42 // Task: Calling multiple suspends at the same rendering quantum should | |
43 // reject the promise. | |
44 audit.defineTask('identical-suspend-time', function (done) { | |
45 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); | |
46 | |
47 // |suspendTime1| and |suspendTime2| are identical when quantized to | |
48 // the render quantum size. | |
49 var suspendTime1 = renderQuantum / sampleRate; | |
50 var suspendTime2 = (renderQuantum + renderQuantum * 0.5) / sampleRate; | |
51 | |
52 context.suspend(suspendTime1); | |
53 | |
54 Should('Calling multiple suspends at the same rendering quantum', | |
55 context.suspend(suspendTime2)).beRejected().then(done); | |
56 }); | |
57 | |
58 // Task: Resuming the context before the actual suspension happens. | |
59 audit.defineTask('resume-before-suspend', function (done) { | |
60 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); | |
61 | |
62 // A suspend is scheduled at the half. | |
63 context.suspend(renderDuration * 0.5); | |
64 | |
65 // However, the next resume will be executed before the actual | |
66 // suspension happens. | |
67 Should('Resuming before suspend', context.resume()).beRejected().then(do ne); | |
68 }); | |
69 | |
70 // Task: Calling resume on non-suspended context should reject the promise . | |
71 audit.defineTask('resume-without-suspend', function (done) { | |
72 var context = new OfflineAudioContext(1, sampleRate * renderDuration, sa mpleRate); | |
73 | |
74 Should('Calling resume on non-suspended context', context.resume()) | |
75 .beRejected().then(done); | |
76 }); | |
77 | |
78 audit.defineTask('finish', function (done) { | |
79 finishJSTest(); | |
80 done(); | |
81 }); | |
82 | |
83 audit.runTasks( | |
84 'suspend-no-argument', | |
85 'identical-suspend-time', | |
86 'resume-before-suspend', | |
87 'resume-without-suspend', | |
88 'finish' | |
89 ); | |
90 | |
91 successfullyParsed = true; | |
92 </script> | |
93 | |
94 </body> | |
95 </html> | |
OLD | NEW |