зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1130010 - Add tests for the new {AudioParam,AudioNode}.disconnect() methods. r=dminor
Initial patch by Thomas Escalon <tesc.bugzilla@gmail.com>. MozReview-Commit-ID: 2cptcTYuzDQ
This commit is contained in:
Родитель
4616d008f9
Коммит
d408de78ad
|
@ -121,6 +121,14 @@ skip-if = toolkit == 'android' # bug 1056706
|
|||
[test_delayNodeTailWithGain.html]
|
||||
[test_delayNodeTailWithReconnect.html]
|
||||
[test_delayNodeWithGain.html]
|
||||
[test_disconnectAll.html]
|
||||
[test_disconnectAudioParam.html]
|
||||
[test_disconnectAudioParamFromOutput.html]
|
||||
[test_disconnectExceptions.html]
|
||||
[test_disconnectFromAudioNode.html]
|
||||
[test_disconnectFromAudioNodeAndOutput.html]
|
||||
[test_disconnectFromAudioNodeAndOutputAndInput.html]
|
||||
[test_disconnectFromOutput.html]
|
||||
[test_dynamicsCompressorNode.html]
|
||||
[test_dynamicsCompressorNodePassThrough.html]
|
||||
[test_dynamicsCompressorNodeWithGain.html]
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
var data = sourceBuffer.getChannelData(0);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var gain3 = context.createGain();
|
||||
var merger = context.createChannelMerger(3);
|
||||
|
||||
source.connect(gain1);
|
||||
source.connect(gain2);
|
||||
source.connect(gain3);
|
||||
gain1.connect(merger);
|
||||
gain2.connect(merger);
|
||||
gain3.connect(merger);
|
||||
source.start();
|
||||
|
||||
source.disconnect();
|
||||
|
||||
return merger;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioParam</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
var data = sourceBuffer.getChannelData(0);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var half = context.createGain();
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
|
||||
half.gain.value = 0.5;
|
||||
|
||||
source.connect(gain1);
|
||||
gain1.connect(gain2);
|
||||
source.connect(half);
|
||||
|
||||
half.connect(gain1.gain);
|
||||
half.connect(gain2.gain);
|
||||
|
||||
half.disconnect(gain2.gain);
|
||||
|
||||
source.start();
|
||||
|
||||
return gain2;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 1.5;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioParam</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 2,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var half = context.createGain();
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var splitter = context.createChannelSplitter(2);
|
||||
|
||||
half.gain.value = 0.5;
|
||||
|
||||
source.connect(gain1);
|
||||
gain1.connect(gain2);
|
||||
source.connect(half);
|
||||
half.connect(splitter);
|
||||
splitter.connect(gain1.gain, 0);
|
||||
splitter.connect(gain2.gain, 1);
|
||||
|
||||
splitter.disconnect(gain2.gain, 1);
|
||||
|
||||
source.start();
|
||||
|
||||
return gain2;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
var expectedBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = expectedBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = (i == 1) ? 1.5 : 3.0;
|
||||
}
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,75 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var ctx = new AudioContext();
|
||||
var sourceBuffer = ctx.createBuffer(2, 256, ctx.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = ctx.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain1 = ctx.createGain();
|
||||
var splitter = ctx.createChannelSplitter(2);
|
||||
var merger = ctx.createChannelMerger(2);
|
||||
var gain2 = ctx.createGain();
|
||||
var gain3 = ctx.createGain();
|
||||
|
||||
gain1.connect(splitter);
|
||||
splitter.connect(gain2, 0);
|
||||
splitter.connect(gain3, 1);
|
||||
splitter.connect(merger, 0, 0);
|
||||
splitter.connect(merger, 1, 1);
|
||||
gain2.connect(gain3);
|
||||
gain3.connect(ctx.destination);
|
||||
merger.connect(ctx.destination);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(2);
|
||||
}, DOMException.INDEX_SIZE_ERR);
|
||||
|
||||
expectNoException(function() {
|
||||
splitter.disconnect(1);
|
||||
splitter.disconnect(1);
|
||||
});
|
||||
|
||||
expectException(function() {
|
||||
gain1.disconnect(gain2);
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
gain1.disconnect(gain3);
|
||||
ok(false, 'Should get InvalidAccessError exception');
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(gain2, 2);
|
||||
}, DOMException.INDEX_SIZE_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(gain1, 0);
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(gain3, 0, 0);
|
||||
}, DOMException.INVALID_ACCESS_ERR);
|
||||
|
||||
expectException(function() {
|
||||
splitter.disconnect(merger, 3, 0);
|
||||
}, DOMException.INDEX_SIZE_ERR);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,55 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
var data = sourceBuffer.getChannelData(0);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = 1;
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var gain3 = context.createGain();
|
||||
|
||||
source.connect(gain1);
|
||||
source.connect(gain2);
|
||||
|
||||
gain1.connect(gain3);
|
||||
gain2.connect(gain3);
|
||||
|
||||
source.start();
|
||||
|
||||
source.disconnect(gain2);
|
||||
|
||||
return gain3;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 1.0;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 2,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 2; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var splitter = context.createChannelSplitter(2);
|
||||
var gain1 = context.createGain();
|
||||
var gain2 = context.createGain();
|
||||
var merger = context.createChannelMerger(2);
|
||||
|
||||
source.connect(splitter);
|
||||
splitter.connect(gain1, 0);
|
||||
splitter.connect(gain2, 0);
|
||||
splitter.connect(gain2, 1);
|
||||
gain1.connect(merger, 0, 1);
|
||||
gain2.connect(merger, 0, 1);
|
||||
source.start();
|
||||
|
||||
splitter.disconnect(gain2, 0);
|
||||
|
||||
return merger;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(2, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 0;
|
||||
expectedBuffer.getChannelData(1)[i] = 3;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 3,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(3, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var splitter = context.createChannelSplitter(3);
|
||||
var merger = context.createChannelMerger(3);
|
||||
|
||||
source.connect(splitter);
|
||||
splitter.connect(merger, 0, 0);
|
||||
splitter.connect(merger, 1, 1);
|
||||
splitter.connect(merger, 2, 2);
|
||||
source.start();
|
||||
|
||||
splitter.disconnect(merger, 2, 2);
|
||||
|
||||
return merger;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
var expectedBuffer = context.createBuffer(3, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
var data = expectedBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = (i == 3) ? 0 : i;
|
||||
}
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test whether we can disconnect an AudioNode</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="webaudio.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var gTest = {
|
||||
length: 256,
|
||||
numberOfChannels: 1,
|
||||
createGraph: function(context) {
|
||||
var sourceBuffer = context.createBuffer(3, 256, context.sampleRate);
|
||||
for (var i = 1; i <= 3; i++) {
|
||||
var data = sourceBuffer.getChannelData(i-1);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
data[j] = i;
|
||||
}
|
||||
}
|
||||
|
||||
var source = context.createBufferSource();
|
||||
source.buffer = sourceBuffer;
|
||||
|
||||
var splitter = context.createChannelSplitter(3);
|
||||
var sum = context.createGain();
|
||||
|
||||
source.connect(splitter);
|
||||
splitter.connect(sum, 0);
|
||||
splitter.connect(sum, 1);
|
||||
splitter.connect(sum, 2);
|
||||
source.start();
|
||||
|
||||
splitter.disconnect(1);
|
||||
|
||||
return sum;
|
||||
},
|
||||
createExpectedBuffers: function(context) {
|
||||
expectedBuffer = context.createBuffer(1, 256, context.sampleRate);
|
||||
for (var i = 0; i < 256; ++i) {
|
||||
expectedBuffer.getChannelData(0)[i] = 4;
|
||||
}
|
||||
|
||||
return expectedBuffer;
|
||||
},
|
||||
};
|
||||
|
||||
runTest();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче