Chromium Code Reviews| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 }); | 169 }); |
| 170 } | 170 } |
| 171 | 171 |
| 172 this.impulseIndex++; | 172 this.impulseIndex++; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 | 177 |
| 178 Test.prototype.showResult = function () { | 178 Test.prototype.showResult = function () { |
| 179 /* | |
|
hongchan
2017/02/17 18:36:19
Please remove commented out sections.
Raymond Toy
2017/02/17 19:18:41
Done.
| |
| 179 if (this.impulseIndex === gNodesToCreate) { | 180 if (this.impulseIndex === gNodesToCreate) { |
| 180 testPassed('Number of impulses matches the number of panner nodes.'); | 181 testPassed('Number of impulses matches the number of panner nodes.'); |
| 181 } else { | 182 } else { |
| 182 testFailed('Number of impulses is incorrect. (Found ' | 183 testFailed('Number of impulses is incorrect. (Found ' |
| 183 + this.impulseIndex | 184 + this.impulseIndex |
| 184 + ' but expected ' | 185 + ' but expected ' |
| 185 + gNodesToCreate | 186 + gNodesToCreate |
| 186 + ')' | 187 + ')' |
| 187 ); | 188 ); |
| 188 this.success = false; | 189 this.success = false; |
| 189 } | 190 } |
| 191 */ | |
| 192 Should("Number of impulses found", this.impulseIndex) | |
| 193 .beEqualTo(gNodesToCreate); | |
| 190 | 194 |
| 195 /* | |
| 191 if (this.errors.length === 0) { | 196 if (this.errors.length === 0) { |
| 192 testPassed('All impulses at expected offsets.'); | 197 testPassed('All impulses at expected offsets.'); |
| 193 } else { | 198 } else { |
| 194 testFailed(this.errors.length + ' timing errors found in ' | 199 testFailed(this.errors.length + ' timing errors found in ' |
| 195 + this.nodesToCreate + ' panner nodes.' | 200 + this.nodesToCreate + ' panner nodes.' |
| 196 ); | 201 ); |
| 197 for (var i = 0; i < this.errors.length; i++) { | 202 for (var i = 0; i < this.errors.length; i++) { |
| 198 testFailed('Impulse at sample ' + this.errors[i].actual | 203 testFailed('Impulse at sample ' + this.errors[i].actual |
| 199 + ' but expected ' + this.errors[i].expected | 204 + ' but expected ' + this.errors[i].expected |
| 200 ); | 205 ); |
| 201 } | 206 } |
| 202 this.success = false; | 207 this.success = false; |
| 203 } | 208 } |
| 209 */ | |
| 210 Should("Number of impulse at the wrong offset", this.errors.length) | |
| 211 .beEqualTo(0); | |
| 204 | 212 |
| 213 /* | |
| 205 if (this.maxErrorL <= this.maxAllowedError) { | 214 if (this.maxErrorL <= this.maxAllowedError) { |
| 206 testPassed('Left channel gain values are correct.'); | 215 testPassed('Left channel gain values are correct.'); |
| 207 } else { | 216 } else { |
| 208 testFailed('Left channel gain values are incorrect. Max error = ' | 217 testFailed('Left channel gain values are incorrect. Max error = ' |
| 209 + this.maxErrorL + ' at time ' + this.onsets[this.maxErrorIndexL] | 218 + this.maxErrorL + ' at time ' + this.onsets[this.maxErrorIndexL] |
| 210 + ' (threshold = ' + this.maxAllowedError + ')' | 219 + ' (threshold = ' + this.maxAllowedError + ')' |
| 211 ); | 220 ); |
| 212 this.success = false; | 221 this.success = false; |
| 213 } | 222 } |
| 223 */ | |
| 214 | 224 |
| 225 Should("Left channel error magnitude", this.maxErrorL) | |
| 226 .beLessThanOrEqualTo(this.maxAllowedError); | |
| 227 | |
| 228 /* | |
| 215 if (this.maxErrorR <= this.maxAllowedError) { | 229 if (this.maxErrorR <= this.maxAllowedError) { |
| 216 testPassed('Right channel gain values are correct.'); | 230 testPassed('Right channel gain values are correct.'); |
| 217 } else { | 231 } else { |
| 218 testFailed('Right channel gain values are incorrect. Max error = ' | 232 testFailed('Right channel gain values are incorrect. Max error = ' |
| 219 + this.maxErrorR + ' at time ' + this.onsets[this.maxErrorIndexR] | 233 + this.maxErrorR + ' at time ' + this.onsets[this.maxErrorIndexR] |
| 220 + ' (threshold = ' + this.maxAllowedError + ')' | 234 + ' (threshold = ' + this.maxAllowedError + ')' |
| 221 ); | 235 ); |
| 222 this.success = false; | 236 this.success = false; |
| 223 } | 237 } |
| 238 */ | |
| 239 | |
| 240 Should("Right channel error magnitude", this.maxErrorR) | |
| 241 .beLessThanOrEqualTo(this.maxAllowedError); | |
| 224 }; | 242 }; |
| 225 | 243 |
| 226 | 244 |
| 227 Test.prototype.finish = function () { | 245 Test.prototype.finish = function () { |
| 246 /* | |
| 228 if (this.success) | 247 if (this.success) |
| 229 testPassed(this.description + ': passed.'); | 248 testPassed(this.description + ': passed.'); |
| 230 else | 249 else |
| 231 testFailed(this.description + ': failed.'); | 250 testFailed(this.description + ': failed.'); |
| 251 */ | |
| 252 Should(this.description, this.success) | |
| 253 .summarize('passed', 'failed'); | |
| 232 }; | 254 }; |
| 233 | 255 |
| 234 | 256 |
| 235 Test.prototype.run = function (done) { | 257 Test.prototype.run = function (done) { |
| 236 | 258 |
| 237 this.init(); | 259 this.init(); |
| 238 this.prepare(); | 260 this.prepare(); |
| 239 this.context.oncomplete = function (event) { | 261 this.context.oncomplete = function (event) { |
| 240 this.renderedBufferL = event.renderedBuffer.getChannelData(0); | 262 this.renderedBufferL = event.renderedBuffer.getChannelData(0); |
| 241 this.renderedBufferR = event.renderedBuffer.getChannelData(1); | 263 this.renderedBufferR = event.renderedBuffer.getChannelData(1); |
| 242 this.verify(); | 264 this.verify(); |
| 243 this.showResult(); | 265 this.showResult(); |
| 244 this.finish(); | 266 this.finish(); |
| 245 done(); | 267 done(); |
| 246 }.bind(this); | 268 }.bind(this); |
| 247 this.context.startRendering(); | 269 this.context.startRendering(); |
| 248 | 270 |
| 249 }; | 271 }; |
| 250 | 272 |
| 251 | 273 |
| 252 return { | 274 return { |
| 253 create: function (options) { | 275 create: function (options) { |
| 254 return new Test(options); | 276 return new Test(options); |
| 255 } | 277 } |
| 256 }; | 278 }; |
| 257 | 279 |
| 258 })(); | 280 })(); |
| 259 | 281 |
| OLD | NEW |