OLD | NEW |
1 var StereoPannerTest = (function () { | 1 var StereoPannerTest = (function () { |
2 | 2 |
3 // Constants | 3 // Constants |
4 var PI_OVER_TWO = Math.PI * 0.5; | 4 var PI_OVER_TWO = Math.PI * 0.5; |
5 | 5 |
6 var gSampleRate = 44100; | 6 var gSampleRate = 44100; |
7 | 7 |
8 // Time step when each panner node starts. | 8 // Time step when each panner node starts. |
9 var gTimeStep = 0.001; | 9 var gTimeStep = 0.001; |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 }; | 41 }; |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 /** | 45 /** |
46 * Test implementation class. | 46 * Test implementation class. |
47 * @param {Object} options Test options | 47 * @param {Object} options Test options |
48 * @param {Object} options.description Test description | 48 * @param {Object} options.description Test description |
49 * @param {Object} options.numberOfInputChannels Number of input channels | 49 * @param {Object} options.numberOfInputChannels Number of input channels |
50 */ | 50 */ |
51 function Test(options) { | 51 function Test(should, options) { |
52 | 52 |
53 // Primary test flag. | 53 // Primary test flag. |
54 this.success = true; | 54 this.success = true; |
55 | 55 |
| 56 this.should = should; |
56 this.context = null; | 57 this.context = null; |
57 this.prefix = options.prefix; | 58 this.prefix = options.prefix; |
58 this.numberOfInputChannels = (options.numberOfInputChannels || 1); | 59 this.numberOfInputChannels = (options.numberOfInputChannels || 1); |
59 switch (this.numberOfInputChannels) { | 60 switch (this.numberOfInputChannels) { |
60 case 1: | 61 case 1: |
61 this.description = 'Test for mono input'; | 62 this.description = 'Test for mono input'; |
62 break; | 63 break; |
63 case 2: | 64 case 2: |
64 this.description = 'Test for stereo input'; | 65 this.description = 'Test for stereo input'; |
65 break; | 66 break; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 }); | 171 }); |
171 } | 172 } |
172 | 173 |
173 this.impulseIndex++; | 174 this.impulseIndex++; |
174 } | 175 } |
175 } | 176 } |
176 }; | 177 }; |
177 | 178 |
178 | 179 |
179 Test.prototype.showResult = function () { | 180 Test.prototype.showResult = function () { |
180 Should(this.prefix + "Number of impulses found", this.impulseIndex) | 181 this.should(this.impulseIndex, this.prefix + "Number of impulses found") |
181 .beEqualTo(gNodesToCreate); | 182 .beEqualTo(gNodesToCreate); |
182 | 183 |
183 Should(this.prefix + "Number of impulse at the wrong offset", this.errors.le
ngth) | 184 this.should(this.errors.length, this.prefix + "Number of impulse at the wron
g offset") |
184 .beEqualTo(0); | 185 .beEqualTo(0); |
185 | 186 |
186 Should(this.prefix + "Left channel error magnitude", this.maxErrorL) | 187 this.should(this.maxErrorL, this.prefix + "Left channel error magnitude") |
187 .beLessThanOrEqualTo(this.maxAllowedError); | 188 .beLessThanOrEqualTo(this.maxAllowedError); |
188 | 189 |
189 Should(this.prefix + "Right channel error magnitude", this.maxErrorR) | 190 this.should(this.maxErrorR, this.prefix + "Right channel error magnitude") |
190 .beLessThanOrEqualTo(this.maxAllowedError); | 191 .beLessThanOrEqualTo(this.maxAllowedError); |
191 }; | 192 }; |
192 | 193 |
193 | 194 Test.prototype.run = function () { |
194 Test.prototype.finish = function () { | |
195 Should(this.description, this.success) | |
196 .summarize('passed', 'failed'); | |
197 }; | |
198 | |
199 | |
200 Test.prototype.run = function (done) { | |
201 | 195 |
202 this.init(); | 196 this.init(); |
203 this.prepare(); | 197 this.prepare(); |
204 this.context.oncomplete = function (event) { | |
205 this.renderedBufferL = event.renderedBuffer.getChannelData(0); | |
206 this.renderedBufferR = event.renderedBuffer.getChannelData(1); | |
207 this.verify(); | |
208 this.showResult(); | |
209 this.finish(); | |
210 done(); | |
211 }.bind(this); | |
212 this.context.startRendering(); | |
213 | 198 |
| 199 return this.context.startRendering() |
| 200 .then(renderedBuffer => { |
| 201 this.renderedBufferL = renderedBuffer.getChannelData(0); |
| 202 this.renderedBufferR = renderedBuffer.getChannelData(1); |
| 203 this.verify(); |
| 204 this.showResult(); |
| 205 }); |
214 }; | 206 }; |
215 | 207 |
216 | |
217 return { | 208 return { |
218 create: function (options) { | 209 create: function (should, options) { |
219 return new Test(options); | 210 return new Test(should, options); |
220 } | 211 } |
221 }; | 212 }; |
222 | 213 |
223 })(); | 214 })(); |
224 | 215 |
OLD | NEW |