Commit e1456e34 authored by rtoy's avatar rtoy Committed by Commit bot

Convert constructor/stereopanner.html to use new Audit

Manually converted to use new Audit.

BUG=704967
TEST=constructor/stereopanner.html

Review-Url: https://codereview.chromium.org/2832493005
Cr-Commit-Position: refs/heads/master@{#469011}
parent 1fcc6d6a
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<script src="../../resources/testharness.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script> <script src="../resources/audit-util.js"></script>
<script src="../resources/audio-testing.js"></script> <script src="../resources/audit.js"></script>
<script src="audionodeoptions.js"></script> <script src="new-audionodeoptions.js"></script>
</head> </head>
<body> <body>
...@@ -15,210 +15,174 @@ ...@@ -15,210 +15,174 @@
var audit = Audit.createTaskRunner(); var audit = Audit.createTaskRunner();
audit.defineTask("initialize", function (taskDone) { audit.define('initialize', (task, should) => {
Should("context = new OfflineAudioContext(...)", function () { context = initializeContext(should);
context = new OfflineAudioContext(1, 1, 48000); task.done();
}).notThrow();
taskDone();
}); });
audit.defineTask("invalid constructor", function (taskDone) { audit.define('invalid constructor', (task, should) => {
var node; testInvalidConstructor(should, 'StereoPannerNode', context);
var success = true; task.done();
success = Should("new StereoPannerNode()", function () {
node = new StereoPannerNode();
}).throw("TypeError");
success = Should("new StereoPannerNode(1)", function () {
node = new StereoPannerNode(1) && success;
}).throw("TypeError");
success = Should("new StereoPannerNode(context, 42)", function () {
node = new StereoPannerNode(context, 42) && success;
}).throw("TypeError");
Should("Invalid constructors", success)
.summarize(
"correctly threw errors",
"did not throw errors in all cases");
taskDone();
}); });
audit.defineTask("default constructor", function (taskDone) { audit.define('default constructor', (task, should) => {
var node; let prefix = 'node0';
var success = true; let node = testDefaultConstructor(should, 'StereoPannerNode', context, {
prefix: prefix,
success = Should("node0 = new StereoPannerNode(context)", function () { numberOfInputs: 1,
node = new StereoPannerNode(context); numberOfOutputs: 1,
}).notThrow(); channelCount: 2,
success = Should("node0 instanceof StereoPannerNode", node instanceof StereoPannerNode) channelCountMode: 'clamped-max',
.beEqualTo(true) && success; channelInterpretation: 'speakers'
});
success = Should("node0.pan.value", node.pan.value)
.beEqualTo(0) && success;
Should("new StereoPannerNode(context)", success) testDefaultAttributes(should, node, prefix, [{name: 'pan', value: 0}]);
.summarize(
"constructed node with correct attributes",
"did not construct correct node correctly")
taskDone(); task.done();
}); });
audit.defineTask("test AudioNodeOptions", function (taskDone) { audit.define('test AudioNodeOptions', (task, should) => {
// Can't use testAudioNodeOptions because the constraints for this node // Can't use testAudioNodeOptions because the constraints for this node
// are not supported there. // are not supported there.
var node; var node;
var success = true;
// Test that we can set the channel count to 1 or 2. // Test that we can set the channel count to 1 or 2.
var options = { var options = {channelCount: 1};
channelCount: 1 should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).notThrow() && success; .notThrow();
success = Should("node.channelCount", node.channelCount) should(node.channelCount, 'node.channelCount').beEqualTo(1);
.beEqualTo(1) && success;
options = {channelCount: 2};
options = { should(
channelCount: 2 () => {
}; node = new StereoPannerNode(context, options);
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", },
function () { 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
node = new StereoPannerNode(context, options); .notThrow();
}).notThrow() && success; should(node.channelCount, 'node.channelCount').beEqualTo(2);
success = Should("node.channelCount", node.channelCount)
.beEqualTo(2) && success;
// Test that other channel counts throw an error // Test that other channel counts throw an error
options = { options = {channelCount: 0};
channelCount: 0 should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).throw("NotSupportedError") && success; .throw('NotSupportedError');
options = { options = {channelCount: 3};
channelCount: 3 should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).throw("NotSupportedError") && success; .throw('NotSupportedError');
options = { options = {channelCount: 99};
channelCount: 99 should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).throw("NotSupportedError") && success; .throw('NotSupportedError');
// Test channelCountMode. A mode of "max" is illegal, but others are // Test channelCountMode. A mode of "max" is illegal, but others are
// ok. // ok.
options = { options = {channelCountMode: 'clamped-max'};
channelCountMode: "clamped-max" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).notThrow() && success; .notThrow();
success = Should("node.channelCountMode", node.channelCountMode) should(node.channelCountMode, 'node.channelCountMode')
.beEqualTo(options.channelCountMode) && success; .beEqualTo(options.channelCountMode);
options = { options = {channelCountMode: 'explicit'};
channelCountMode: "explicit" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).notThrow() && success; .notThrow();
success = Should("node.channelCountMode", node.channelCountMode) should(node.channelCountMode, 'node.channelCountMode')
.beEqualTo(options.channelCountMode) && success; .beEqualTo(options.channelCountMode);
options = { options = {channelCountMode: 'max'};
channelCountMode: "max" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).throw("NotSupportedError") && success; .throw('NotSupportedError');
options = { options = {channelCountMode: 'foobar'};
channelCountMode: "foobar" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).throw("TypeError") && success; .throw('TypeError');
// Test channelInterpretation. // Test channelInterpretation.
options = { options = {channelInterpretation: 'speakers'};
channelInterpretation: "speakers" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).notThrow() && success; .notThrow();
success = Should("node.channelInterpretation", node.channelInterpretation) should(node.channelInterpretation, 'node.channelInterpretation')
.beEqualTo(options.channelInterpretation) && success; .beEqualTo(options.channelInterpretation);
options = { options = {channelInterpretation: 'discrete'};
channelInterpretation: "discrete" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).notThrow() && success; .notThrow();
success = Should("node.channelInterpretation", node.channelInterpretation) should(node.channelInterpretation, 'node.channelInterpretation')
.beEqualTo(options.channelInterpretation) && success; .beEqualTo(options.channelInterpretation);
options = { options = {channelInterpretation: 'foobar'};
channelInterpretation: "foobar" should(
}; () => {
success = Should("new StereoPannerNode(c, " + JSON.stringify(options) + ")", node = new StereoPannerNode(context, options);
function () { },
node = new StereoPannerNode(context, options); 'new StereoPannerNode(c, ' + JSON.stringify(options) + ')')
}).throw("TypeError") && success; .throw('TypeError');
Should("AudioNodeOptions for StereoPannerNode", success) task.done();
.summarize(
"were correctly handled",
"were not correctly handled");
taskDone();
}); });
audit.defineTask("constructor with options", function (taskDone) { audit.define('constructor with options', (task, should) => {
var node; var node;
var success = true;
var options = { var options = {
pan: 0.75, pan: 0.75,
}; };
success = Should("node1 = new StereoPannerNode(, " + JSON.stringify(options) + ")", should(
function () { () => {
node = new StereoPannerNode(context, options); node = new StereoPannerNode(context, options);
}).notThrow(); },
success = Should("node1 instanceof StereoPannerNode", node instanceof StereoPannerNode) 'node1 = new StereoPannerNode(, ' + JSON.stringify(options) + ')')
.beEqualTo(true) && success; .notThrow();
should(
success = Should("node1.pan.value", node.pan.value) node instanceof StereoPannerNode,
.beEqualTo(options.pan) && success; 'node1 instanceof StereoPannerNode')
.beEqualTo(true);
Should("new StereoPannerNode() with options", success) should(node.pan.value, 'node1.pan.value').beEqualTo(options.pan);
.summarize(
"constructed with correct attributes",
"was not constructed correctly");
taskDone(); task.done();
}); });
audit.runTasks(); audit.run();
</script> </script>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment