mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 836599 - Part 13: Add a unit test for OfflineAudioContext; r=roc
This commit is contained in:
parent
d2c63bc836
commit
30c4151889
@ -58,6 +58,7 @@ MOCHITEST_FILES := \
|
|||||||
test_mediaDecoding.html \
|
test_mediaDecoding.html \
|
||||||
test_mixingRules.html \
|
test_mixingRules.html \
|
||||||
test_nodeToParamConnection.html \
|
test_nodeToParamConnection.html \
|
||||||
|
test_OfflineAudioContext.html \
|
||||||
test_pannerNode.html \
|
test_pannerNode.html \
|
||||||
test_scriptProcessorNode.html \
|
test_scriptProcessorNode.html \
|
||||||
test_scriptProcessorNodeChannelCount.html \
|
test_scriptProcessorNodeChannelCount.html \
|
||||||
|
45
content/media/webaudio/test/test_OfflineAudioContext.html
Normal file
45
content/media/webaudio/test/test_OfflineAudioContext.html
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Test OfflineAudioContext</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">
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
addLoadEvent(function() {
|
||||||
|
SpecialPowers.setBoolPref("media.webaudio.enabled", true);
|
||||||
|
var ctx = new OfflineAudioContext(2, 100, (new AudioContext()).sampleRate);
|
||||||
|
ok(ctx instanceof EventTarget, "OfflineAudioContexts must be EventTargets");
|
||||||
|
|
||||||
|
var buf = ctx.createBuffer(2, 100, ctx.sampleRate);
|
||||||
|
for (var i = 0; i < 2; ++i) {
|
||||||
|
for (var j = 0; j < 100; ++j) {
|
||||||
|
buf.getChannelData(i)[j] = Math.sin(2 * Math.PI * 200 * j / ctx.sampleRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var src = ctx.createBufferSource();
|
||||||
|
src.buffer = buf;
|
||||||
|
src.start(0);
|
||||||
|
src.connect(ctx.destination);
|
||||||
|
ctx.startRendering();
|
||||||
|
ctx.addEventListener("complete", function(e) {
|
||||||
|
ok(e instanceof OfflineAudioCompletionEvent, "Correct event received");
|
||||||
|
is(e.renderedBuffer.numberOfChannels, 2, "Correct expected number of buffers");
|
||||||
|
compareBuffers(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
|
||||||
|
compareBuffers(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
|
||||||
|
|
||||||
|
SpecialPowers.clearUserPref("media.webaudio.enabled");
|
||||||
|
SimpleTest.finish();
|
||||||
|
}, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user