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

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

Issue 2713943002: Convert more PannerNode tests to testharness (Closed)
Patch Set: Address review comments Created 3 years, 10 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/Panner/panner-loop-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/panner-model-testing.js
diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/panner-model-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/panner-model-testing.js
index 16ef23ea9851254692281bee2ce15656de829f31..cf9c8287edfc934a7fe58308a6b71be847657b69 100644
--- a/third_party/WebKit/LayoutTests/webaudio/resources/panner-model-testing.js
+++ b/third_party/WebKit/LayoutTests/webaudio/resources/panner-model-testing.js
@@ -62,13 +62,14 @@ function createGraph(context, nodeCount, positionSetter) {
}
}
-function createTestAndRun(context, nodeCount, numberOfSourceChannels, positionSetter) {
+function createTestAndRun(context, should, nodeCount, numberOfSourceChannels,
+ positionSetter) {
numberOfChannels = numberOfSourceChannels;
createGraph(context, nodeCount, positionSetter);
- context.oncomplete = checkResult;
- context.startRendering();
+ return context.startRendering()
+ .then(buffer => checkResult(buffer, should));
}
// Map our position angle to the azimuth angle (in degrees).
@@ -108,8 +109,7 @@ function equalPowerGain(angle) {
}
}
-function checkResult(event) {
- renderedBuffer = event.renderedBuffer;
+function checkResult(renderedBuffer, should) {
renderedLeft = renderedBuffer.getChannelData(0);
renderedRight = renderedBuffer.getChannelData(1);
@@ -168,42 +168,15 @@ function checkResult(event) {
}
}
- if (impulseCount == nodesToCreate) {
- testPassed("Number of impulses matches the number of panner nodes.");
- } else {
- testFailed("Number of impulses is incorrect. (Found " + impulseCount + " but expected " + nodesToCreate + ")");
- success = false;
- }
+ should(impulseCount, "Number of impulses found")
+ .beEqualTo(nodesToCreate);
- if (timeErrors.length > 0) {
- success = false;
- testFailed(timeErrors.length + " timing errors found in " + nodesToCreate + " panner nodes.");
- for (var k = 0; k < timeErrors.length; ++k) {
- testFailed("Impulse at sample " + timeErrors[k].actual + " but expected " + timeErrors[k].expected);
- }
- } else {
- testPassed("All impulses at expected offsets.");
- }
+ should(timeErrors.map(x => x.actual), "Offsets of impulses at the wrong position")
+ .beEqualToArray(timeErrors.map(x => x.expected));
- if (maxErrorL <= maxAllowedError) {
- testPassed("Left channel gain values are correct.");
- } else {
- testFailed("Left channel gain values are incorrect. Max error = " + maxErrorL + " at time " + time[maxErrorIndexL] + " (threshold = " + maxAllowedError + ")");
- success = false;
- }
-
- if (maxErrorR <= maxAllowedError) {
- testPassed("Right channel gain values are correct.");
- } else {
- testFailed("Right channel gain values are incorrect. Max error = " + maxErrorR + " at time " + time[maxErrorIndexR] + " (threshold = " + maxAllowedError + ")");
- success = false;
- }
-
- if (success) {
- testPassed("EqualPower panner test passed");
- } else {
- testFailed("EqualPower panner test failed");
- }
+ should(maxErrorL, "Error in left channel gain values")
+ .beLessThanOrEqualTo(maxAllowedError);
- finishJSTest();
+ should(maxErrorR, "Error in right channel gain values")
+ .beLessThanOrEqualTo(maxAllowedError);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/Panner/panner-loop-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698