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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/audit-util.js

Issue 2593043003: Convert AudioBufferSource tests using Audit to testharness (Closed)
Patch Set: Missed a couple testFailed calls. Created 3 years, 11 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 | « third_party/WebKit/LayoutTests/webaudio/resources/audiobuffersource-testing.js ('k') | 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileOverview This file includes legacy utility functions for the layout 7 * @fileOverview This file includes legacy utility functions for the layout
8 * test. 8 * test.
9 */ 9 */
10 10
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 // The reference file is a 16-bit WAV file, so we will almost never get 153 // The reference file is a 16-bit WAV file, so we will almost never get
154 // an exact match between it and the actual floating-point result. 154 // an exact match between it and the actual floating-point result.
155 if (Math.abs(diff) > scaleFactor) 155 if (Math.abs(diff) > scaleFactor)
156 diffCount++; 156 diffCount++;
157 } 157 }
158 158
159 var snr = 10 * Math.log10(signalPower / noisePower); 159 var snr = 10 * Math.log10(signalPower / noisePower);
160 var maxErrorULP = maxError * scaleFactor; 160 var maxErrorULP = maxError * scaleFactor;
161 161
162 if (snr >= thresholdSNR) { 162 Should("SNR", snr).beGreaterThanOrEqualTo(thresholdSNR);
163 testPassed('Exceeded SNR threshold of ' + thresholdSNR + ' dB.');
164 } else {
165 testFailed('Expected SNR of ' + thresholdSNR + ' dB, but actual SNR is ' +
166 snr + ' dB.');
167 }
168 163
169 if (maxErrorULP <= thresholdDiffULP) { 164 Should('Maximum difference (in ulp units (' + bitDepth + '-bits))',
170 testPassed('Maximum difference below threshold of ' + 165 maxErrorULP).beLessThanOrEqualTo(thresholdDiffULP);
171 thresholdDiffULP + ' ulp (' + bitDepth + '-bits).');
172 } else {
173 testFailed('Maximum difference of ' + maxErrorULP +
174 ' at the index ' + errorPosition + ' exceeded threshold of ' +
175 thresholdDiffULP + ' ulp (' + bitDepth + '-bits).');
176 }
177 166
178 if (diffCount <= thresholdDiffCount) { 167 Should('Number of differences between results', diffCount)
179 testPassed('Number of differences between results is ' + 168 .beLessThanOrEqualTo(thresholdDiffCount);
180 diffCount + ' out of ' + actual.length + '.');
181 } else {
182 testFailed(diffCount + ' differences found but expected no more than ' +
183 diffCount + ' out of ' + actual.length + '.');
184 }
185 } 169 }
186 170
187 // Create an impulse in a buffer of length sampleFrameLength 171 // Create an impulse in a buffer of length sampleFrameLength
188 function createImpulseBuffer(context, sampleFrameLength) { 172 function createImpulseBuffer(context, sampleFrameLength) {
189 var audioBuffer = context.createBuffer(1, sampleFrameLength, context.sampleR ate); 173 var audioBuffer = context.createBuffer(1, sampleFrameLength, context.sampleR ate);
190 var n = audioBuffer.length; 174 var n = audioBuffer.length;
191 var dataL = audioBuffer.getChannelData(0); 175 var dataL = audioBuffer.getChannelData(0);
192 176
193 for (var k = 0; k < n; ++k) { 177 for (var k = 0; k < n; ++k) {
194 dataL[k] = 0; 178 dataL[k] = 0;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 var startFrame = timeToSampleFrame(grainOffset, sampleRate); 250 var startFrame = timeToSampleFrame(grainOffset, sampleRate);
267 var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate); 251 var endFrame = timeToSampleFrame(grainOffset + duration, sampleRate);
268 252
269 return endFrame - startFrame; 253 return endFrame - startFrame;
270 } 254 }
271 255
272 // True if the number is not an infinity or NaN 256 // True if the number is not an infinity or NaN
273 function isValidNumber(x) { 257 function isValidNumber(x) {
274 return !isNaN(x) && (x != Infinity) && (x != -Infinity); 258 return !isNaN(x) && (x != Infinity) && (x != -Infinity);
275 } 259 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/resources/audiobuffersource-testing.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698