Add tests for options bounds in PannerNode's constructor

This commit is contained in:
Manish Goregaokar 2018-08-31 02:40:59 -07:00
parent 303b62ae8d
commit e1131b474c
2 changed files with 63 additions and 2 deletions

View file

@ -647778,7 +647778,7 @@
"support" "support"
], ],
"webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html": [ "webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html": [
"5475a6210b724ab2d6a0cefedee9c5432953c61f", "95e914a75f6784a76af79fcfce2e372ddb865814",
"testharness" "testharness"
], ],
"webaudio/the-audio-api/the-pannernode-interface/distance-exponential.html": [ "webaudio/the-audio-api/the-pannernode-interface/distance-exponential.html": [

View file

@ -192,6 +192,67 @@
'new PannerNode(c, ' + JSON.stringify(options) + ')') 'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw(TypeError); .throw(TypeError);
// Test maxDistance
options = {maxDistance: -1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw(RangeError);
options = {maxDistance: 100};
should(
() => {
node = new PannerNode(context, options);
},
'node7 = new PannerNode(c, ' + JSON.stringify(options) + ')')
.notThrow();
should(node.maxDistance, 'node7.maxDistance')
.beEqualTo(options.maxDistance);
// Test rolloffFactor
options = {rolloffFactor: -1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw(RangeError);
options = {rolloffFactor: 0.5};
should(
() => {
node = new PannerNode(context, options);
},
'node8 = new PannerNode(c, ' + JSON.stringify(options) + ')')
.notThrow();
should(node.rolloffFactor, 'node8.rolloffFactor')
.beEqualTo(options.rolloffFactor);
// Test coneOuterGain
options = {coneOuterGain: -1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw('InvalidStateError');
options = {coneOuterGain: 1.1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw('InvalidStateError');
options = {coneOuterGain: 0.5};
should(
() => {
node = new PannerNode(context, options);
},
'node9 = new PannerNode(c, ' + JSON.stringify(options) + ')')
.notThrow();
should(node.coneOuterGain, 'node9.coneOuterGain')
.beEqualTo(options.coneOuterGain);
task.done(); task.done();
}); });
@ -218,7 +279,7 @@
rolloffFactor: 3 * Math.PI, rolloffFactor: 3 * Math.PI,
coneInnerAngle: 4 * Math.PI, coneInnerAngle: 4 * Math.PI,
coneOuterAngle: 5 * Math.PI, coneOuterAngle: 5 * Math.PI,
coneOuterGain: 6 * Math.PI coneOuterGain: 0.1 * Math.PI
}; };
should( should(