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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/resources/biquad-testing.js

Issue 2667153002: Convert BiquadFilter response tests to testharness (Closed)
Patch Set: Revert indentation. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/BiquadFilter/biquad-peaking-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/resources/biquad-testing.js
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/biquad-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/biquad-testing.js
index dea7b1cbb5a1487a81135494df171883eeab1182..9327d295ee1d304e9dcff982c5ac5d4980a5b2ba 100644
--- a/third_party/WebKit/LayoutTests/webaudio/resources/biquad-testing.js
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/biquad-testing.js
@@ -76,8 +76,10 @@ function createTestAndRun(context, filterType, testParameters) {
signal[k].start(timeStep * k);
}
- context.oncomplete = checkFilterResponse(filterType, testParameters);
- context.startRendering();
+ return context.startRendering()
+ .then(buffer => {
+ checkFilterResponse(filterType, testParameters)(buffer);
hongchan 2017/02/01 18:18:47 This looks a bit off. I know it's a valid expressi
Raymond Toy 2017/02/01 19:08:53 Yeah, this can be fixed. I was going for minimal c
+ });
}
function addSignal(dest, src, destOffset) {
@@ -117,10 +119,11 @@ function generateReference(filterType, filterParameters) {
}
function checkFilterResponse(filterType, testParameters) {
- return function(event) {
+ return function(renderedBuffer) {
var filterParameters = testParameters.filterParameters;
var maxAllowedError = testParameters.threshold;
- renderedBuffer = event.renderedBuffer;
+ let should = testParameters.should;
+
renderedData = renderedBuffer.getChannelData(0);
reference = generateReference(filterType, filterParameters);
@@ -138,10 +141,8 @@ function checkFilterResponse(filterType, testParameters) {
// Number of infinities or NaNs that occurred in the rendered data.
var invalidNumberCount = 0;
- if (nFilters != filterParameters.length) {
- testFailed("Test wanted " + filterParameters.length + " filters but only " + maxFilters + " allowed.");
- success = false;
- }
+ should(nFilters, "Number of filters tested")
+ .beEqualTo(filterParameters.length);
// Compare the rendered signal with our reference, keeping
// track of the maximum difference (and the offset of the max
@@ -158,25 +159,12 @@ function checkFilterResponse(filterType, testParameters) {
}
}
- if (invalidNumberCount > 0) {
- testFailed("Rendered output has " + invalidNumberCount + " infinities or NaNs.");
- success = false;
- } else {
- testPassed("Rendered output did not have infinities or NaNs.");
- }
-
- if (maxError <= maxAllowedError) {
- testPassed(filterTypeName[filterType] + " response is correct.");
- } else {
- testFailed(filterTypeName[filterType] + " response is incorrect. Max err = " + maxError + " at " + maxPosition + ". Threshold = " + maxAllowedError);
- success = false;
- }
-
- if (success) {
- testPassed("Test signal was correctly filtered.");
- } else {
- testFailed("Test signal was not correctly filtered.");
- }
- finishJSTest();
+ should(invalidNumberCount,
+ "Number of non-finite values in the rendered output")
+ .beEqualTo(0);
+
+ should(maxError,
+ "Max error in " + filterTypeName[filterType] + " response")
+ .beLessThanOrEqualTo(maxAllowedError);
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/BiquadFilter/biquad-peaking-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698