OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test Constructor: Convolver</title> | 4 <title>Test Constructor: Convolver</title> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
7 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
8 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
9 <script src="audionodeoptions.js"></script> | 9 <script src="new-audionodeoptions.js"></script> |
10 </head> | 10 </head> |
11 | 11 |
12 <body> | 12 <body> |
13 <script> | 13 <script> |
14 var context; | 14 var context; |
15 | 15 |
16 var audit = Audit.createTaskRunner(); | 16 var audit = Audit.createTaskRunner(); |
17 | 17 |
18 audit.defineTask("initialize", function (taskDone) { | 18 audit.define('initialize', (task, should) => { |
19 Should("context = new OfflineAudioContext(...)", function () { | 19 context = initializeContext(should); |
20 context = new OfflineAudioContext(1, 1, 48000); | 20 task.done(); |
21 }).notThrow(); | |
22 taskDone(); | |
23 }); | 21 }); |
24 | 22 |
25 audit.defineTask("invalid constructor", function (taskDone) { | 23 audit.define('invalid constructor', (task, should) => { |
26 var node; | 24 testInvalidConstructor(should, 'ConvolverNode', context); |
27 var success = true; | 25 task.done(); |
28 | |
29 succes = Should("new ConvolverNode()", function () { | |
30 node = new ConvolverNode(); | |
31 }).throw("TypeError"); | |
32 success = Should("new ConvolverNode(1)", function () { | |
33 node = new ConvolverNode(1); | |
34 }).throw("TypeError") && success; | |
35 success = Should("new ConvolverNode(context, 42)", function () { | |
36 node = new ConvolverNode(context, 42); | |
37 }).throw("TypeError") && success; | |
38 | |
39 Should("Invalid constructors", success) | |
40 .summarize( | |
41 "correctly threw errors", | |
42 "did not throw errors in all cases"); | |
43 taskDone(); | |
44 }); | 26 }); |
45 | 27 |
46 audit.defineTask("default constructor", function (taskDone) { | 28 audit.define('default constructor', (task, should) => { |
47 var node; | 29 let prefix = 'node0'; |
48 var success = true; | 30 let node = testDefaultConstructor(should, 'ConvolverNode', context, { |
| 31 prefix: prefix, |
| 32 numberOfInputs: 1, |
| 33 numberOfOutputs: 1, |
| 34 channelCount: 2, |
| 35 channelCountMode: 'clamped-max', |
| 36 channelInterpretation: 'speakers' |
| 37 }); |
49 | 38 |
50 success = Should("node0 = new ConvolverNode(context)", function () { | 39 testDefaultAttributes( |
51 node = new ConvolverNode(context); | 40 should, node, prefix, |
52 }).notThrow(); | 41 [{name: 'normalize', value: true}, {name: 'buffer', value: null}]); |
53 success = Should("node0 instanceOf ConvolverNode", node instanceof Convo
lverNode) | |
54 .beEqualTo(true) && success; | |
55 success = Should("node0.normalize", node.normalize) | |
56 .beEqualTo(true) && success; | |
57 | 42 |
58 success = Should("node0.channelCount", node.channelCount) | 43 task.done(); |
59 .beEqualTo(2) && success; | |
60 success = Should("node0.channelCountMode", node.channelCountMode) | |
61 .beEqualTo("clamped-max") && success; | |
62 success = Should("node0.channelInterpretation", node.channelInterpretati
on) | |
63 .beEqualTo("speakers") && success; | |
64 | |
65 success = Should("new ConvolverNode(context)", success) | |
66 .summarize( | |
67 "constructed node with correct attributes", | |
68 "did not construct correct node correctly") | |
69 | |
70 taskDone(); | |
71 }); | 44 }); |
72 | 45 |
73 audit.defineTask("test AudioNodeOptions", function (taskDone) { | 46 audit.define('test AudioNodeOptions', (task, should) => { |
74 testAudioNodeOptions(context, "ConvolverNode", { | 47 testAudioNodeOptions(should, context, 'ConvolverNode', { |
75 expectedChannelCount: { | 48 channelCount: |
76 value: 2, | 49 {value: 2, isFixed: true, errorType: 'NotSupportedError'}, |
| 50 channelCountMode: { |
| 51 value: 'clamped-max', |
77 isFixed: true, | 52 isFixed: true, |
78 errorType: "NotSupportedError" | 53 errorType: 'NotSupportedError' |
79 }, | |
80 expectedChannelCountMode: { | |
81 value: "clamped-max", | |
82 isFixed: true, | |
83 errorType: "NotSupportedError" | |
84 }, | 54 }, |
85 }); | 55 }); |
86 taskDone(); | 56 task.done(); |
87 }); | 57 }); |
88 | 58 |
89 audit.defineTask("nullable buffer", function (taskDone) { | 59 audit.define('nullable buffer', (task, should) => { |
90 var node; | 60 var node; |
91 var success = true; | 61 var options = {buffer: null}; |
92 | 62 |
93 var options = { buffer: null }; | 63 should( |
94 | 64 () => { |
95 success = Should("node1 = new ConvolverNode(c, " + JSON.stringify(option
s), function () { | 65 node = new ConvolverNode(context, options); |
96 node = new ConvolverNode(context, options); | 66 }, |
97 }).notThrow(); | 67 'node1 = new ConvolverNode(c, ' + JSON.stringify(options)) |
| 68 .notThrow(); |
98 | 69 |
99 success = Should("node1.buffer", node.buffer) | 70 should(node.buffer, 'node1.buffer').beEqualTo(null); |
100 .beEqualTo(null); | |
101 | 71 |
102 Should("Null buffer in constructor handled", success) | 72 task.done(); |
103 .summarize( | |
104 "correctly", | |
105 "incorrectly"); | |
106 | |
107 taskDone(); | |
108 }); | 73 }); |
109 | 74 |
110 audit.defineTask("construct with options", function (taskDone) { | 75 audit.define('construct with options', (task, should) => { |
111 var buf = context.createBuffer(1, 1, context.sampleRate); | 76 var buf = context.createBuffer(1, 1, context.sampleRate); |
112 var options = { | 77 var options = {buffer: buf, disableNormalization: false}; |
113 buffer: buf, | |
114 disableNormalization: false | |
115 }; | |
116 | 78 |
117 var message = "node = new ConvolverNode(c, " + JSON.stringify(options) +
")"; | 79 var message = |
| 80 'node = new ConvolverNode(c, ' + JSON.stringify(options) + ')'; |
118 | 81 |
119 var node; | 82 var node; |
120 success = Should(message, function () { | 83 should(() => { |
121 node = new ConvolverNode(context, options); | 84 node = new ConvolverNode(context, options); |
122 }).notThrow(); | 85 }, message).notThrow(); |
123 | 86 |
124 success = Should("node1 instanceOf ConvolverNode", node instanceof Convo
lverNode) | 87 should(node instanceof ConvolverNode, 'node1 instanceOf ConvolverNode') |
125 .beEqualTo(true) && success; | 88 .beEqualTo(true); |
126 success = Should("node1.buffer === <buf>", node.buffer === | 89 should(node.buffer === options.buffer, 'node1.buffer === <buf>') |
127 options.buffer) | 90 .beEqualTo(true); |
128 .beEqualTo(true) && success; | 91 should(node.normalize, 'node1.normalize') |
129 success = Should("node1.normalize", node.normalize) | 92 .beEqualTo(!options.disableNormalization); |
130 .beEqualTo(!options.disableNormalization) && success; | |
131 | 93 |
132 options.buffer = null; | 94 options.buffer = null; |
133 options.disableNormalization = true; | 95 options.disableNormalization = true; |
134 | 96 |
135 message = "node2 = new ConvolverNode(, " + JSON.stringify(options) + ")"
; | 97 message = |
| 98 'node2 = new ConvolverNode(, ' + JSON.stringify(options) + ')'; |
136 | 99 |
137 success = Should(message, function () { | 100 should(() => { |
138 node = new ConvolverNode(context, options); | 101 node = new ConvolverNode(context, options); |
139 }).notThrow() && success; | 102 }, message).notThrow(); |
140 success = Should("node2.buffer", node.buffer).beEqualTo(null) && success
; | 103 should(node.buffer, 'node2.buffer').beEqualTo(null); |
141 success = Should("node2.normalize", node.normalize) | 104 should(node.normalize, 'node2.normalize') |
142 .beEqualTo(!options.disableNormalization) && success; | 105 .beEqualTo(!options.disableNormalization); |
143 | 106 |
144 options.disableNormalization = false; | 107 options.disableNormalization = false; |
145 message = "node3 = new ConvolverNode(context, " + JSON.stringify(options
) + ")"; | 108 message = 'node3 = new ConvolverNode(context, ' + |
| 109 JSON.stringify(options) + ')'; |
146 | 110 |
147 success = Should(message, function () { | 111 should(() => { |
148 node = new ConvolverNode(context, options); | 112 node = new ConvolverNode(context, options); |
149 }).notThrow() && success; | 113 }, message).notThrow(); |
150 success = Should("node3.buffer", node.buffer).beEqualTo(null) && success
; | 114 should(node.buffer, 'node3.buffer').beEqualTo(null); |
151 success = Should("node3.normalize", node.normalize) | 115 should(node.normalize, 'node3.normalize') |
152 .beEqualTo(!options.disableNormalization) && success; | 116 .beEqualTo(!options.disableNormalization); |
153 | 117 |
154 Should("new ConvolverNode() with options", success) | 118 task.done(); |
155 .summarize( | |
156 "constructed with correct attributes", | |
157 "was not constructed correctly"); | |
158 | |
159 taskDone(); | |
160 }); | 119 }); |
161 | 120 |
162 audit.runTasks(); | 121 audit.run(); |
163 </script> | 122 </script> |
164 </body> | 123 </body> |
165 </html> | 124 </html> |
OLD | NEW |