Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/constructor/panner.html

Issue 2829143002: Convert constructor/panner.html to use new Audit (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Constructor: Panner</title> 4 <title>Test Constructor: Panner</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="new-audionodeoptions.js"></script>
9 </head> 10 </head>
10 11
11 <body> 12 <body>
12 <script> 13 <script>
13 var context; 14 var context;
14 15
15 var audit = Audit.createTaskRunner(); 16 var audit = Audit.createTaskRunner();
16 17
17 audit.defineTask("initialize", function (taskDone) { 18 audit.define('initialize', (task, should) => {
18 Should("context = new OfflineAudioContext(...)", function () { 19 context = initializeContext(should);
19 context = new OfflineAudioContext(1, 1, 48000); 20 task.done();
20 }).notThrow();
21
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, 'PannerNode', context);
27 var success = true; 25 task.done();
28
29 success = Should("new PannerNode()", function () {
30 node = new PannerNode();
31 }).throw("TypeError");
32 success = Should("new PannerNode(1)", function () {
33 node = new PannerNode(1) && success;
34 }).throw("TypeError");
35 success = Should("new PannerNode(context, 42)", function () {
36 node = new PannerNode(context, 42) && success;
37 }).throw("TypeError");
38
39 Should("Invalid constructors", success)
40 .summarize(
41 "correctly threw errors",
42 "did not throw errors in all cases");
43
44 taskDone();
45 }); 26 });
46 27
47 audit.defineTask("default constructor", function (taskDone) { 28 audit.define('default constructor', (task, should) => {
48 var node; 29 let prefix = 'node0';
49 var success = true; 30 let node = testDefaultConstructor(should, 'PannerNode', context, {
31 prefix: prefix,
32 numberOfInputs: 1,
33 numberOfOutputs: 1,
34 channelCount: 2,
35 channelCountMode: 'clamped-max',
36 channelInterpretation: 'speakers'
37 });
50 38
51 success = Should("node0 = new PannerNode(context)", function () { 39 testDefaultAttributes(should, node, prefix, [
52 node = new PannerNode(context); 40 {name: 'panningModel', value: 'equalpower'},
53 }).notThrow(); 41 {name: 'positionX', value: 0}, {name: 'positionY', value: 0},
54 success = Should("node0 instanceof PannerNode", node instanceof PannerNo de) 42 {name: 'positionZ', value: 0}, {name: 'orientationX', value: 1},
55 .beEqualTo(true) && success; 43 {name: 'orientationY', value: 0}, {name: 'orientationZ', value: 0},
56 44 {name: 'distanceModel', value: 'inverse'},
57 success = Should("node0.panningModel", node.panningModel) 45 {name: 'refDistance', value: 1}, {name: 'maxDistance', value: 10000},
58 .beEqualTo("equalpower") && success; 46 {name: 'rolloffFactor', value: 1},
59 success = Should("node0.positionX.value", node.positionX.value) 47 {name: 'coneInnerAngle', value: 360},
60 .beEqualTo(0) && success; 48 {name: 'coneOuterAngle', value: 360},
61 success = Should("node0.positionY.value", node.positionY.value) 49 {name: 'coneOuterGain', value: 0}
62 .beEqualTo(0) && success; 50 ]);
63 success = Should("node0.positionZ.value", node.positionZ.value)
64 .beEqualTo(0) && success;
65 success = Should("node0.orientationX.value", node.orientationX.value)
66 .beEqualTo(1) && success;
67 success = Should("node0.orientationY.value", node.orientationY.value)
68 .beEqualTo(0) && success;
69 success = Should("node0.orientationZ.value", node.orientationZ.value)
70 .beEqualTo(0) && success;
71 success = Should("node0.distanceModel", node.distanceModel)
72 .beEqualTo("inverse") && success;
73 success = Should("node0.refDistance", node.refDistance)
74 .beEqualTo(1) && success;
75 success = Should("node0.maxDistance", node.maxDistance)
76 .beEqualTo(10000) && success;
77 success = Should("node0.rolloffFactor", node.rolloffFactor)
78 .beEqualTo(1) && success;
79 success = Should("node0.coneInnerAngle", node.coneInnerAngle)
80 .beEqualTo(360) && success;
81 success = Should("node0.coneOuterAngle", node.coneOuterAngle)
82 .beEqualTo(360) && success;
83 success = Should("node0.coneOuterGain", node.coneOuterGain)
84 .beEqualTo(0) && success;
85 51
86 // Test the listener too, while we're at it. 52 // Test the listener too, while we're at it.
87 success = Should("context.listener.positionX.value", context.listener.po sitionX.value) 53 let listenerAttributes = [
88 .beEqualTo(0) && success; 54 {name: 'positionX', value: 0},
89 success = Should("context.listener.positionY.value", context.listener.po sitionY.value) 55 {name: 'positionY', value: 0},
90 .beEqualTo(0) && success; 56 {name: 'positionZ', value: 0},
91 success = Should("context.listener.positionZ.value", context.listener.po sitionZ.value) 57 {name: 'forwardX', value: 0},
92 .beEqualTo(0) && success; 58 {name: 'forwardY', value: 0},
93 success = Should("context.listener.forwardX.value", context.listener.for wardX.value) 59 {name: 'forwardZ', value: -1},
94 .beEqualTo(0) && success; 60 {name: 'upX', value: 0},
95 success = Should("context.listener.forwardY.value", context.listener.for wardY.value) 61 {name: 'upY', value: 1},
96 .beEqualTo(0) && success; 62 {name: 'upZ', value: 0},
97 success = Should("context.listener.forwardZ.value", context.listener.for wardZ.value) 63 ];
98 .beEqualTo(-1) && success;
99 success = Should("context.listener.upX.value", context.listener.upX.valu e)
100 .beEqualTo(0) && success;
101 success = Should("context.listener.upY.value", context.listener.upY.valu e)
102 .beEqualTo(1) && success;
103 success = Should("context.listener.upZ.value", context.listener.upZ.valu e)
104 .beEqualTo(0) && success;
105 64
106 success = Should("node0.channelCount", node.channelCount) 65 listenerAttributes.forEach((item) => {
107 .beEqualTo(2) && success; 66 should(
108 success = Should("node0.channelCountMode", node.channelCountMode) 67 context.listener[item.name].value,
109 .beEqualTo("clamped-max") && success; 68 'context.listener.' + item.name + '.value')
110 success = Should("node0.channelInterpretation", node.channelInterpretati on) 69 .beEqualTo(item.value);
111 .beEqualTo("speakers") && success; 70 });
112 71
113 Should("new PannerNode(context)", success) 72 task.done();
114 .summarize(
115 "constructed node with correct attributes",
116 "did not construct correct node correctly")
117
118 taskDone();
119 }); 73 });
120 74
121 audit.defineTask("test AudioNodeOptions", function (taskDone) { 75 audit.define('test AudioNodeOptions', (task, should) => {
122 // Can't use testAudioNodeOptions because the constraints for this node 76 // Can't use testAudioNodeOptions because the constraints for this node
123 // are not supported there. 77 // are not supported there.
124 var node; 78 var node;
125 var success = true; 79 var success = true;
126 80
127 // Test that we can set the channel count to 1 or 2. 81 // Test that we can set the channel count to 1 or 2.
128 var options = { 82 var options = {channelCount: 1};
129 channelCount: 1 83 should(
130 }; 84 () => {
131 success = Should("node1 = new PannerNode(c, " + JSON.stringify(options) + ")", 85 node = new PannerNode(context, options);
132 function () { 86 },
133 node = new PannerNode(context, options); 87 'node1 = new PannerNode(c, ' + JSON.stringify(options) + ')')
134 }).notThrow() && success; 88 .notThrow();
135 success = Should("node1.channelCount", node.channelCount) 89 should(node.channelCount, 'node1.channelCount')
136 .beEqualTo(options.channelCount) && success; 90 .beEqualTo(options.channelCount);
137 91
138 options = { 92 options = {channelCount: 2};
139 channelCount: 2 93 should(
140 }; 94 () => {
141 success = Should("node2 = new PannerNode(c, " + JSON.stringify(options) + ")", 95 node = new PannerNode(context, options);
142 function () { 96 },
143 node = new PannerNode(context, options); 97 'node2 = new PannerNode(c, ' + JSON.stringify(options) + ')')
144 }).notThrow() && success; 98 .notThrow();
145 success = Should("node2.channelCount", node.channelCount) 99 should(node.channelCount, 'node2.channelCount')
146 .beEqualTo(options.channelCount) && success; 100 .beEqualTo(options.channelCount);
147 101
148 // Test that other channel counts throw an error 102 // Test that other channel counts throw an error
149 options = { 103 options = {channelCount: 0};
150 channelCount: 0 104 should(
151 }; 105 () => {
152 success = Should("new PannerNode(c, " + JSON.stringify(options) + ")", 106 node = new PannerNode(context, options);
153 function () { 107 },
154 node = new PannerNode(context, options); 108 'new PannerNode(c, ' + JSON.stringify(options) + ')')
155 }).throw("NotSupportedError") && success; 109 .throw('NotSupportedError');
156 110
157 options = { 111 options = {channelCount: 3};
158 channelCount: 3 112 should(
159 }; 113 () => {
160 success = Should("new PannerNode(c, " + JSON.stringify(options) + ")", 114 node = new PannerNode(context, options);
161 function () { 115 },
162 node = new PannerNode(context, options); 116 'new PannerNode(c, ' + JSON.stringify(options) + ')')
163 }).throw("NotSupportedError") && success; 117 .throw('NotSupportedError');
164 118
165 options = { 119 options = {channelCount: 99};
166 channelCount: 99 120 should(
167 }; 121 () => {
168 success = Should("new PannerNode(c, " + JSON.stringify(options) + ")", 122 node = new PannerNode(context, options);
169 function () { 123 },
170 node = new PannerNode(context, options); 124 'new PannerNode(c, ' + JSON.stringify(options) + ')')
171 }).throw("NotSupportedError") && success; 125 .throw('NotSupportedError');
172 126
173 // Test channelCountMode. A mode of "max" is illegal, but others are 127 // Test channelCountMode. A mode of "max" is illegal, but others are
174 // ok. 128 // ok.
175 options = { 129 options = {channelCountMode: 'clamped-max'};
176 channelCountMode: "clamped-max" 130 should(
177 }; 131 () => {
178 success = Should("node3 = new PannerNode(c, " + JSON.stringify(options) + ")", 132 node = new PannerNode(context, options);
179 function () { 133 },
180 node = new PannerNode(context, options); 134 'node3 = new PannerNode(c, ' + JSON.stringify(options) + ')')
181 }).notThrow() && success; 135 .notThrow();
182 success = Should("node3.channelCountMode", node.channelCountMode) 136 should(node.channelCountMode, 'node3.channelCountMode')
183 .beEqualTo(options.channelCountMode) && success; 137 .beEqualTo(options.channelCountMode);
184 138
185 options = { 139 options = {channelCountMode: 'explicit'};
186 channelCountMode: "explicit" 140 should(
187 }; 141 () => {
188 success = Should("node4 = new PannerNode(c, " + JSON.stringify(options) + ")", 142 node = new PannerNode(context, options);
189 function () { 143 },
190 node = new PannerNode(context, options); 144 'node4 = new PannerNode(c, ' + JSON.stringify(options) + ')')
191 }).notThrow() && success; 145 .notThrow();
192 success = Should("node4.channelCountMode", node.channelCountMode) 146 should(node.channelCountMode, 'node4.channelCountMode')
193 .beEqualTo(options.channelCountMode); 147 .beEqualTo(options.channelCountMode);
194 148
195 options = { 149 options = {channelCountMode: 'max'};
196 channelCountMode: "max" 150 should(
197 }; 151 () => {
198 success = Should("new PannerNode(c, " + JSON.stringify(options) + ")", 152 node = new PannerNode(context, options);
199 function () { 153 },
200 node = new PannerNode(context, options); 154 'new PannerNode(c, ' + JSON.stringify(options) + ')')
201 }).throw("NotSupportedError") && success; 155 .throw('NotSupportedError');
202 156
203 options = { 157 options = {channelCountMode: 'foobar'};
204 channelCountMode: "foobar" 158 should(
205 }; 159 () => {
206 success = Should('new PannerNode(c, " + JSON.stringify(options) + ")', 160 node = new PannerNode(context, options);
207 function () { 161 },
208 node = new PannerNode(context, options); 162 'new PannerNode(c, " + JSON.stringify(options) + ")')
209 }).throw("TypeError") && success; 163 .throw('TypeError');
210 164
211 // Test channelInterpretation. 165 // Test channelInterpretation.
212 options = { 166 options = {channelInterpretation: 'speakers'};
213 channelInterpretation: "speakers" 167 should(
214 }; 168 () => {
215 success = Should("node5 = new PannerNode(c, " + JSON.stringify(options) + ")", 169 node = new PannerNode(context, options);
216 function () { 170 },
217 node = new PannerNode(context, options); 171 'node5 = new PannerNode(c, ' + JSON.stringify(options) + ')')
218 }).notThrow() && success; 172 .notThrow();
219 success = Should("node5.channelInterpretation", node.channelInterpretati on) 173 should(node.channelInterpretation, 'node5.channelInterpretation')
220 .beEqualTo(options.channelInterpretation) && success; 174 .beEqualTo(options.channelInterpretation);
221 175
222 options = { 176 options = {channelInterpretation: 'discrete'};
223 channelInterpretation: "discrete" 177 should(
224 }; 178 () => {
225 success = Should("node6 = new PannerNode(c, " + JSON.stringify(options) + ")", 179 node = new PannerNode(context, options);
226 function () { 180 },
227 node = new PannerNode(context, options); 181 'node6 = new PannerNode(c, ' + JSON.stringify(options) + ')')
228 }).notThrow() && success; 182 .notThrow();
229 success = Should("node6.channelInterpretation", node.channelInterpretati on) 183 should(node.channelInterpretation, 'node6.channelInterpretation')
230 .beEqualTo(options.channelInterpretation) && success; 184 .beEqualTo(options.channelInterpretation);
231 185
232 options = { 186 options = {channelInterpretation: 'foobar'};
233 channelInterpretation: "foobar" 187 should(
234 }; 188 () => {
235 success = Should("new PannerNode(c, " + JSON.stringify(options) + ")", 189 node = new PannerNode(context, options);
236 function () { 190 },
237 node = new PannerNode(context, options); 191 'new PannerNode(c, ' + JSON.stringify(options) + ')')
238 }).throw("TypeError") && success; 192 .throw('TypeError');
239 193
240 Should("AudioNodeOptions for PannerNode", success) 194 task.done();
241 .summarize(
242 "were correctly handled",
243 "were not correctly handled");
244
245 taskDone();
246 }); 195 });
247 196
248 audit.defineTask("constructor with options", function (taskDone) { 197 audit.define('constructor with options', (task, should) => {
249 var node; 198 var node;
250 var success = true; 199 var success = true;
251 var options = { 200 var options = {
252 panningModel: "HRTF", 201 panningModel: 'HRTF',
253 // We use full double float values here to verify also that the actual 202 // We use full double float values here to verify also that the actual
254 // AudioParam value is properly rounded to a float. The actual value 203 // AudioParam value is properly rounded to a float. The actual value
255 // is immaterial as long as x != Math.fround(x). 204 // is immaterial as long as x != Math.fround(x).
256 positionX: Math.SQRT2, 205 positionX: Math.SQRT2,
257 positionY: 2 * Math.SQRT2, 206 positionY: 2 * Math.SQRT2,
258 positionZ: 3 * Math.SQRT2, 207 positionZ: 3 * Math.SQRT2,
259 orientationX: -Math.SQRT2, 208 orientationX: -Math.SQRT2,
260 orientationY: -2 * Math.SQRT2, 209 orientationY: -2 * Math.SQRT2,
261 orientationZ: -3 * Math.SQRT2, 210 orientationZ: -3 * Math.SQRT2,
262 distanceModel: "linear", 211 distanceModel: 'linear',
263 // We use full double float values here to verify also that the actual 212 // We use full double float values here to verify also that the actual
264 // attribute is a double float. The actual value is immaterial as 213 // attribute is a double float. The actual value is immaterial as
265 // long as x != Math.fround(x). 214 // long as x != Math.fround(x).
266 refDistance: Math.PI, 215 refDistance: Math.PI,
267 maxDistance: 2 * Math.PI, 216 maxDistance: 2 * Math.PI,
268 rolloffFactor: 3 * Math.PI, 217 rolloffFactor: 3 * Math.PI,
269 coneInnerAngle: 4 * Math.PI, 218 coneInnerAngle: 4 * Math.PI,
270 coneOuterAngle: 5 * Math.PI, 219 coneOuterAngle: 5 * Math.PI,
271 coneOuterGain: 6 * Math.PI 220 coneOuterGain: 6 * Math.PI
272 }; 221 };
273 222
274 success = Should("node = new PannerNode(c, " + JSON.stringify(options) + ")", function () { 223 should(
275 node = new PannerNode(context, options); 224 () => {
276 }).notThrow(); 225 node = new PannerNode(context, options);
277 success = Should("node instanceof PannerNode", node instanceof PannerNod e) 226 },
278 .beEqualTo(true) && success; 227 'node = new PannerNode(c, ' + JSON.stringify(options) + ')')
228 .notThrow();
229 should(node instanceof PannerNode, 'node instanceof PannerNode')
230 .beEqualTo(true);
279 231
280 success = Should("node.panningModel", node.panningModel) 232 should(node.panningModel, 'node.panningModel')
281 .beEqualTo(options.panningModel) && success; 233 .beEqualTo(options.panningModel);
282 success = Should("node.positionX.value", node.positionX.value) 234 should(node.positionX.value, 'node.positionX.value')
283 .beEqualTo(Math.fround(options.positionX)) && success; 235 .beEqualTo(Math.fround(options.positionX));
284 success = Should("node.positionY.value", node.positionY.value) 236 should(node.positionY.value, 'node.positionY.value')
285 .beEqualTo(Math.fround(options.positionY)) && success; 237 .beEqualTo(Math.fround(options.positionY));
286 success = Should("node.positionZ.value", node.positionZ.value) 238 should(node.positionZ.value, 'node.positionZ.value')
287 .beEqualTo(Math.fround(options.positionZ)) && success; 239 .beEqualTo(Math.fround(options.positionZ));
288 success = Should("node.orientationX.value", node.orientationX.value) 240 should(node.orientationX.value, 'node.orientationX.value')
289 .beEqualTo(Math.fround(options.orientationX)) && success; 241 .beEqualTo(Math.fround(options.orientationX));
290 success = Should("node.orientationY.value", node.orientationY.value) 242 should(node.orientationY.value, 'node.orientationY.value')
291 .beEqualTo(Math.fround(options.orientationY)) && success; 243 .beEqualTo(Math.fround(options.orientationY));
292 success = Should("node.orientationZ.value", node.orientationZ.value) 244 should(node.orientationZ.value, 'node.orientationZ.value')
293 .beEqualTo(Math.fround(options.orientationZ)) && success; 245 .beEqualTo(Math.fround(options.orientationZ));
294 success = Should("node.distanceModel", node.distanceModel) 246 should(node.distanceModel, 'node.distanceModel')
295 .beEqualTo(options.distanceModel) && success; 247 .beEqualTo(options.distanceModel);
296 success = Should("node.refDistance", node.refDistance) 248 should(node.refDistance, 'node.refDistance')
297 .beEqualTo(options.refDistance) && success; 249 .beEqualTo(options.refDistance);
298 success = Should("node.maxDistance", node.maxDistance) 250 should(node.maxDistance, 'node.maxDistance')
299 .beEqualTo(options.maxDistance) && success; 251 .beEqualTo(options.maxDistance);
300 success = Should("node.rolloffFactor", node.rolloffFactor) 252 should(node.rolloffFactor, 'node.rolloffFactor')
301 .beEqualTo(options.rolloffFactor) && success; 253 .beEqualTo(options.rolloffFactor);
302 success = Should("node.coneInnerAngle", node.coneInnerAngle) 254 should(node.coneInnerAngle, 'node.coneInnerAngle')
303 .beEqualTo(options.coneInnerAngle) && success; 255 .beEqualTo(options.coneInnerAngle);
304 success = Should("node.coneOuterAngle", node.coneOuterAngle) 256 should(node.coneOuterAngle, 'node.coneOuterAngle')
305 .beEqualTo(options.coneOuterAngle) && success; 257 .beEqualTo(options.coneOuterAngle);
306 success = Should("node.coneOuterGain", node.coneOuterGain) 258 should(node.coneOuterGain, 'node.coneOuterGain')
307 .beEqualTo(options.coneOuterGain) && success; 259 .beEqualTo(options.coneOuterGain);
308 260
309 success = Should("node.channelCount", node.channelCount) 261 should(node.channelCount, 'node.channelCount').beEqualTo(2);
310 .beEqualTo(2) && success; 262 should(node.channelCountMode, 'node.channelCountMode')
311 success = Should("node.channelCountMode", node.channelCountMode) 263 .beEqualTo('clamped-max');
312 .beEqualTo("clamped-max") && success; 264 should(node.channelInterpretation, 'node.channelInterpretation')
313 success = Should("node.channelInterpretation", node.channelInterpretatio n) 265 .beEqualTo('speakers');
314 .beEqualTo("speakers") && success;
315 266
316 Should("new PannerNode() with options", success) 267 task.done();
317 .summarize(
318 "constructed with correct attributes",
319 "was not constructed correctly");
320
321 taskDone();
322 }); 268 });
323 269
324 audit.runTasks(); 270 audit.run();
325 </script> 271 </script>
326 </body> 272 </body>
327 </html> 273 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698