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/Panner/panner-distance-clamping.html

Issue 2799793003: Convert Panner tests to new Audit (Closed)
Patch Set: Rebase Created 3 years, 8 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/Panner/panner-distance-clamping.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html b/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html
index 585f8aff10d3ebc9748afb6c8ce364901524f011..0207cbec9f4a7a863547df74549c57d7b7a0642d 100644
--- a/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html
+++ b/third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html
@@ -5,7 +5,7 @@
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script>
- <script src="../resources/audio-testing.js"></script>
+ <script src="../resources/audit.js"></script>
</head>
<body>
@@ -16,157 +16,142 @@
var audit = Audit.createTaskRunner();
- audit.defineTask("ref-distance-error", function (taskDone) {
- testDistanceLimits({name: "refDistance", isZeroAllowed: true});
- taskDone();
+ audit.define("ref-distance-error", (task, should) => {
+ testDistanceLimits(should, {name: "refDistance"});
+ task.done();
});
- audit.defineTask("max-distance-error", function (taskDone) {
- testDistanceLimits({name: "maxDistance", isZeroAllowed: false});
- taskDone();
+ audit.define("max-distance-error", (task, should) => {
+ testDistanceLimits(should, {name: "maxDistance"});
+ task.done();
});
- function testDistanceLimits(options) {
+ function testDistanceLimits(should, options) {
// Verify that exceptions are thrown for invalid values of refDistance.
var context = new OfflineAudioContext(1, renderFrames, sampleRate);
var attrName = options.name;
var prefix = "new PannerNode(c, {" + attrName + ": ";
- success = Should(prefix + "-1})", function () {
+ should(function () {
var nodeOptions = {};
nodeOptions[attrName] = -1;
new PannerNode(context, nodeOptions);
- }).throw("RangeError");
-
- if (options.isZeroAllowed) {
- success = Should(prefix + "0})", function () {
- var nodeOptions = {};
- nodeOptions[attrName] = 0;
- new PannerNode(context, nodeOptions);
- }).notThrow() && success;
- } else {
- success = Should(prefix + "0})", function () {
- var nodeOptions = {};
- nodeOptions[attrName] = 0;
- new PannerNode(context, nodeOptions);
- }).throw("RangeError") && success;
- }
+ }, prefix + "-1})").throw("RangeError");
+
+ should(function () {
+ var nodeOptions = {};
+ nodeOptions[attrName] = 0;
+ new PannerNode(context, nodeOptions);
+ }, prefix + "0})").throw("RangeError");
// The smallest representable positive single float.
var leastPositiveDoubleFloat = 4.9406564584124654e-324;
- success = Should(prefix + leastPositiveDoubleFloat + "})",
- function () {
- var nodeOptions = {};
- nodeOptions[attrName] = leastPositiveDoubleFloat;
- new PannerNode(context, nodeOptions);
- }).notThrow() && success;
+ should(
+ function () {
+ var nodeOptions = {};
+ nodeOptions[attrName] = leastPositiveDoubleFloat;
+ new PannerNode(context, nodeOptions);
+ }, prefix + leastPositiveDoubleFloat + "})")
+ .notThrow();
prefix = "panner." + attrName + " = ";
panner = new PannerNode(context);
- success = Should(prefix + "-1", function () {
+ should(function () {
panner[attrName] = -1;
- }).throw("RangeError") && success;
-
- if (options.isZeroAllowed) {
- success = Should(prefix + "0", function () {
- panner[attrName] = 0;
- }).notThrow() && success;
- } else {
- success = Should(prefix + "0", function () {
- panner[attrName] = 0;
- }).throw("RangeError") && success;
- }
-
- success = Should(prefix + leastPositiveDoubleFloat, function () {
- panner[attrName] = leastPositiveDoubleFloat;
- }).notThrow() && success;
+ }, prefix + "-1").throw("RangeError");
- Should("Invalid " + attrName + " values handled", success)
- .summarize("correctly", "incorrectly");
+ should(function () {
+ panner[attrName] = 0;
+ }, prefix + "0").throw("RangeError");
+ should(function () {
+ panner[attrName] = leastPositiveDoubleFloat;
+ }, prefix + leastPositiveDoubleFloat).notThrow();
}
- audit.defineTask("min-distance", function (taskDone) {
+ audit.define("min-distance", (task, should) => {
// Test clamping of panner distance to refDistance for all of the
// distance models. The actual distance is arbitrary as long as it's
// less than refDistance. We test default and non-default values for
// the panner's refDistance and maxDistance.
// correctly.
Promise.all([
- runTest({
+ runTest(should, {
distance: 0.01,
distanceModel: "linear",
}),
- runTest({
+ runTest(should, {
distance: 0.01,
distanceModel: "exponential",
}),
- runTest({
+ runTest(should, {
distance: 0.01,
distanceModel: "inverse",
}),
- runTest({
+ runTest(should, {
distance: 2,
distanceModel: "linear",
maxDistance: 1000,
refDistance: 10,
}),
- runTest({
+ runTest(should, {
distance: 2,
distanceModel: "exponential",
maxDistance: 1000,
refDistance: 10,
}),
- runTest({
+ runTest(should, {
distance: 2,
distanceModel: "inverse",
maxDistance: 1000,
refDistance: 10,
}),
- ]).then(taskDone);
+ ])
+ .then(() => task.done());
});
- audit.defineTask("max-distance", function (taskDone) {
+ audit.define("max-distance", (task, should) => {
// Like the "min-distance" task, but for clamping to the max
// distance. The actual distance is again arbitrary as long as it is
// greater than maxDistance.
Promise.all([
- runTest({
+ runTest(should, {
distance: 20000,
distanceModel: "linear",
}),
- runTest({
+ runTest(should, {
distance: 21000,
distanceModel: "exponential",
}),
- runTest({
+ runTest(should, {
distance: 23000,
distanceModel: "inverse",
}),
- runTest({
+ runTest(should, {
distance: 5000,
distanceModel: "linear",
maxDistance: 1000,
refDistance: 10,
}),
- runTest({
+ runTest(should, {
distance: 5000,
distanceModel: "exponential",
maxDistance: 1000,
refDistance: 10,
}),
- runTest({
+ runTest(should, {
distance: 5000,
distanceModel: "inverse",
maxDistance: 1000,
refDistance: 10,
}),
- ]).then(taskDone);
+ ])
+ .then(() => task.done());
});
- function runTest(options) {
+ function runTest(should, options) {
var context = new OfflineAudioContext(2, renderFrames, sampleRate);
var src = new OscillatorNode(context, {
type: "sawtooth",
@@ -212,16 +197,17 @@
var actual = resultBuffer.getChannelData(0);
var expected = resultBuffer.getChannelData(1);
- Should("Model: " + options.distanceModel + ": Distance (" + xTest + ") is outside the range [" +
- pannerRef.refDistance + ", " + pannerRef.maxDistance + "]",
- xTest < pannerRef.refDistance || xTest > pannerRef.maxDistance)
+ should(xTest < pannerRef.refDistance || xTest > pannerRef.maxDistance,
+ "Model: " + options.distanceModel + ": Distance (" + xTest +
+ ") is outside the range [" + pannerRef.refDistance + ", " +
+ pannerRef.maxDistance + "]")
.beEqualTo(true);
- Should("Test panner output " + JSON.stringify(options), actual)
+ should(actual, "Test panner output " + JSON.stringify(options))
.beEqualToArray(expected);
});
}
- audit.runTasks();
+ audit.run();
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698