|
6 | 6 | </title>
|
7 | 7 | <script src="/resources/testharness.js"></script>
|
8 | 8 | <script src="/resources/testharnessreport.js"></script>
|
9 |
| - <script src="/webaudio/resources/audit-util.js"></script> |
10 |
| - <script src="/webaudio/resources/audit.js"></script> |
11 | 9 | </head>
|
12 | 10 | <body>
|
13 |
| - <script id="layout-test-code"> |
14 |
| - let sampleRate = 48000; |
15 |
| - let testFrames = 100; |
| 11 | + <script> |
| 12 | + const sampleRate = 48000; |
| 13 | + const testFrames = 100; |
16 | 14 |
|
17 |
| - // Global context that can be used by the individual tasks. It must be |
18 |
| - // defined by the initialize task. |
19 |
| - let context; |
| 15 | + // Global context that can be used by the individual tests. |
| 16 | + const context = new OfflineAudioContext(1, testFrames, sampleRate); |
20 | 17 |
|
21 |
| - let audit = Audit.createTaskRunner(); |
| 18 | + test(t => { |
| 19 | + // If construction threw, the test would fail automatically. |
| 20 | + assert_true(context instanceof OfflineAudioContext, |
| 21 | + 'context should be an OfflineAudioContext'); |
| 22 | + }, 'initialize'); |
22 | 23 |
|
23 |
| - audit.define('initialize', (task, should) => { |
24 |
| - should(() => { |
25 |
| - context = new OfflineAudioContext(1, testFrames, sampleRate); |
26 |
| - }, 'Initialize context for testing').notThrow(); |
27 |
| - task.done(); |
28 |
| - }); |
| 24 | + test(t => { |
| 25 | + assert_true('createBiquadFilter' in context, |
| 26 | + 'context.createBiquadFilter should exist'); |
| 27 | + }, 'existence'); |
29 | 28 |
|
30 |
| - audit.define('existence', (task, should) => { |
31 |
| - should(context.createBiquadFilter, 'context.createBiquadFilter') |
32 |
| - .exist(); |
33 |
| - task.done(); |
34 |
| - }); |
35 |
| - |
36 |
| - audit.define('parameters', (task, should) => { |
| 29 | + test(t => { |
37 | 30 | // Create a really simple IIR filter. Doesn't much matter what.
|
38 |
| - let coef = Float32Array.from([1]); |
39 |
| - |
40 |
| - let f = context.createBiquadFilter(coef, coef); |
41 |
| - |
42 |
| - should(f.numberOfInputs, 'numberOfInputs').beEqualTo(1); |
43 |
| - should(f.numberOfOutputs, 'numberOfOutputs').beEqualTo(1); |
44 |
| - should(f.channelCountMode, 'channelCountMode').beEqualTo('max'); |
45 |
| - should(f.channelInterpretation, 'channelInterpretation') |
46 |
| - .beEqualTo('speakers'); |
| 31 | + const coef = Float32Array.from([1]); |
47 | 32 |
|
48 |
| - task.done(); |
49 |
| - }); |
| 33 | + const f = context.createBiquadFilter(coef, coef); |
50 | 34 |
|
51 |
| - audit.define('exceptions-createBiquadFilter', (task, should) => { |
52 |
| - should(function() { |
53 |
| - // Two args are required. |
54 |
| - context.createBiquadFilter(); |
55 |
| - }, 'createBiquadFilter()').notThrow(); |
| 35 | + assert_equals(f.numberOfInputs, 1, 'numberOfInputs'); |
| 36 | + assert_equals(f.numberOfOutputs, 1, 'numberOfOutputs'); |
| 37 | + assert_equals(f.channelCountMode, 'max', 'channelCountMode'); |
| 38 | + assert_equals(f.channelInterpretation, 'speakers', |
| 39 | + 'channelInterpretation'); |
| 40 | + }, 'parameters'); |
56 | 41 |
|
57 |
| - task.done(); |
58 |
| - }); |
| 42 | + test(t => { |
| 43 | + // Two args are required. Should _not_ throw. |
| 44 | + context.createBiquadFilter(); |
| 45 | + }, 'exceptions-createBiquadFilter'); |
59 | 46 |
|
60 |
| - audit.define('exceptions-getFrequencyData', (task, should) => { |
| 47 | + test(t => { |
61 | 48 | // Create a really simple IIR filter. Doesn't much matter what.
|
62 |
| - let coef = Float32Array.from([1]); |
63 |
| - |
64 |
| - let f = context.createBiquadFilter(coef, coef); |
65 |
| - |
66 |
| - should( |
67 |
| - function() { |
68 |
| - // frequencyHz can't be null. |
69 |
| - f.getFrequencyResponse( |
70 |
| - null, new Float32Array(1), new Float32Array(1)); |
71 |
| - }, |
72 |
| - 'getFrequencyResponse(' + |
73 |
| - 'null, ' + |
74 |
| - 'new Float32Array(1), ' + |
75 |
| - 'new Float32Array(1))') |
76 |
| - .throw(TypeError); |
77 |
| - |
78 |
| - should( |
79 |
| - function() { |
80 |
| - // magResponse can't be null. |
81 |
| - f.getFrequencyResponse( |
82 |
| - new Float32Array(1), null, new Float32Array(1)); |
83 |
| - }, |
84 |
| - 'getFrequencyResponse(' + |
85 |
| - 'new Float32Array(1), ' + |
86 |
| - 'null, ' + |
87 |
| - 'new Float32Array(1))') |
88 |
| - .throw(TypeError); |
89 |
| - |
90 |
| - should( |
91 |
| - function() { |
92 |
| - // phaseResponse can't be null. |
93 |
| - f.getFrequencyResponse( |
94 |
| - new Float32Array(1), new Float32Array(1), null); |
95 |
| - }, |
96 |
| - 'getFrequencyResponse(' + |
97 |
| - 'new Float32Array(1), ' + |
98 |
| - 'new Float32Array(1), ' + |
99 |
| - 'null)') |
100 |
| - .throw(TypeError); |
101 |
| - |
102 |
| - should( |
103 |
| - function() { |
104 |
| - // magResponse array must the same length as frequencyHz |
105 |
| - f.getFrequencyResponse( |
106 |
| - new Float32Array(10), new Float32Array(1), |
107 |
| - new Float32Array(20)); |
108 |
| - }, |
109 |
| - 'getFrequencyResponse(' + |
110 |
| - 'new Float32Array(10), ' + |
111 |
| - 'new Float32Array(1), ' + |
112 |
| - 'new Float32Array(20))') |
113 |
| - .throw(DOMException, 'InvalidAccessError'); |
114 |
| - |
115 |
| - should( |
116 |
| - function() { |
117 |
| - // phaseResponse array must be the same length as frequencyHz |
118 |
| - f.getFrequencyResponse( |
119 |
| - new Float32Array(10), new Float32Array(20), |
120 |
| - new Float32Array(1)); |
121 |
| - }, |
122 |
| - 'getFrequencyResponse(' + |
123 |
| - 'new Float32Array(10), ' + |
124 |
| - 'new Float32Array(20), ' + |
125 |
| - 'new Float32Array(1))') |
126 |
| - .throw(DOMException, 'InvalidAccessError'); |
127 |
| - |
128 |
| - task.done(); |
129 |
| - }); |
130 |
| - |
131 |
| - audit.run(); |
| 49 | + const coef = Float32Array.from([1]); |
| 50 | + const f = context.createBiquadFilter(coef, coef); |
| 51 | + |
| 52 | + // frequencyHz can't be null. |
| 53 | + assert_throws_js(TypeError, () => { |
| 54 | + f.getFrequencyResponse( |
| 55 | + null, new Float32Array(1), new Float32Array(1)); |
| 56 | + }, 'frequencyHz is null'); |
| 57 | + |
| 58 | + // magResponse can't be null. |
| 59 | + assert_throws_js(TypeError, () => { |
| 60 | + f.getFrequencyResponse( |
| 61 | + new Float32Array(1), null, new Float32Array(1)); |
| 62 | + }, 'magResponse is null'); |
| 63 | + |
| 64 | + // phaseResponse can't be null. |
| 65 | + assert_throws_js(TypeError, () => { |
| 66 | + f.getFrequencyResponse( |
| 67 | + new Float32Array(1), new Float32Array(1), null); |
| 68 | + }, 'phaseResponse is null'); |
| 69 | + |
| 70 | + // magResponse array must be the same length as frequencyHz |
| 71 | + assert_throws_dom('InvalidAccessError', () => { |
| 72 | + f.getFrequencyResponse( |
| 73 | + new Float32Array(10), new Float32Array(1), |
| 74 | + new Float32Array(20)); |
| 75 | + }, 'magResponse length mismatch'); |
| 76 | + |
| 77 | + // phaseResponse array must be the same length as frequencyHz |
| 78 | + assert_throws_dom('InvalidAccessError', () => { |
| 79 | + f.getFrequencyResponse( |
| 80 | + new Float32Array(10), new Float32Array(20), |
| 81 | + new Float32Array(1)); |
| 82 | + }, 'phaseResponse length mismatch'); |
| 83 | + }, 'exceptions-getFrequencyData'); |
132 | 84 | </script>
|
133 | 85 | </body>
|
134 | 86 | </html>
|
0 commit comments