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

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

Issue 2713943002: Convert more PannerNode tests to testharness (Closed)
Patch Set: 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
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..194cfe7d3987c6a2b540acea7d352737c59c2fc5 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,13 @@ function createGraph(context, nodeCount, positionSetter) {
}
}
-function createTestAndRun(context, nodeCount, numberOfSourceChannels, positionSetter) {
+function createTestAndRun(context, should, nodeCount, numberOfSourceChannels, positionSetter) {
hongchan 2017/02/24 22:07:24 Let's wrap this line.
Raymond Toy 2017/02/24 22:19:24 Done.
numberOfChannels = numberOfSourceChannels;
createGraph(context, nodeCount, positionSetter);
- context.oncomplete = checkResult;
- context.startRendering();
+ return context.startRendering()
+ .then(buffer => checkResult(buffer, should));;
hongchan 2017/02/24 22:07:24 Two semicolons.
Raymond Toy 2017/02/24 22:19:24 Done.
}
// Map our position angle to the azimuth angle (in degrees).
@@ -108,8 +108,7 @@ function equalPowerGain(angle) {
}
}
-function checkResult(event) {
- renderedBuffer = event.renderedBuffer;
+function checkResult(renderedBuffer, should) {
renderedLeft = renderedBuffer.getChannelData(0);
renderedRight = renderedBuffer.getChannelData(1);
@@ -168,42 +167,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);
}

Powered by Google App Engine
This is Rietveld 408576698