tests for convolver and panner channelCount b=906966
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 05 Sep 2013 07:44:04 +1200
changeset 145492 2ee662f747a2194cf28a7678aa3b1f8555f26e6b
parent 145491 c2bfb5b08f75e6bbe246271170f200b2ece5158a
child 145493 4d5107aea7080cbc0e7e4ac11e37da2f81caeffe
push id33296
push userktomlinson@mozilla.com
push dateWed, 04 Sep 2013 20:32:35 +0000
treeherdermozilla-inbound@15a71c6cb0d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs906966
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
tests for convolver and panner channelCount b=906966
content/media/webaudio/test/Makefile.in
content/media/webaudio/test/test_convolverNodeChannelCount.html
content/media/webaudio/test/test_pannerNodeChannelCount.html
--- a/content/media/webaudio/test/Makefile.in
+++ b/content/media/webaudio/test/Makefile.in
@@ -110,13 +110,20 @@ MOCHITEST_FILES := \
   audio-expected.wav \
   audio-mono-expected.wav \
   audio-mono-expected-2.wav \
   audio-quad.wav \
   $(NULL)
 
 ifneq ($(MOZ_DEBUG)+$(MOZ_WIDGET_TOOLKIT),+gtk2) # bug 911777
 MOCHITEST_FILES += \
+  test_convolverNodeChannelCount.html \
   test_delayNodeAtMax.html \
   $(NULL)
+endif # bug 911777
+
+ifneq ($(OS_TARGET),Android) # bug 912474
+MOCHITEST_FILES += \
+  test_pannerNodeChannelCount.html \
+  $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/content/media/webaudio/test/test_convolverNodeChannelCount.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test PannerNode directly above</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+const signalLength = 2048;
+const responseLength = 1000;
+const outputLength = 4096; // > signalLength + responseLength to work around bug 910171
+
+var gTest = {
+  length: outputLength,
+  numberOfChannels: 2,
+  createGraph: function(context) {
+    var buffer = context.createBuffer(2, signalLength, context.sampleRate);
+    for (var i = 0; i < signalLength; ++i) {
+      var sample = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
+      // When mixed into a single channel, this produces silence
+      buffer.getChannelData(0)[i] = sample;
+      buffer.getChannelData(1)[i] = -sample;
+    }
+
+    var response = context.createBuffer(2, responseLength, context.sampleRate);
+    for (var i = 0; i < responseLength; ++i) {
+      response.getChannelData(0)[i] = i / responseLength;
+      response.getChannelData(1)[i] = 1 - (i / responseLength);
+    }
+
+    var convolver = context.createConvolver();
+    convolver.buffer = response;
+    convolver.channelCount = 1;
+
+    expectException(function() { convolver.channelCount = 3; },
+                    DOMException.NOT_SUPPORTED_ERR);
+    convolver.channelCountMode = "explicit";
+    expectException(function() { convolver.channelCountMode = "max"; },
+                    DOMException.NOT_SUPPORTED_ERR);
+    convolver.channelInterpretation = "discrete";
+    convolver.channelInterpretation = "speakers";
+
+    var source = context.createBufferSource();
+    source.buffer = buffer;
+    source.connect(convolver);
+    source.start(0);
+
+    return convolver;
+  },
+};
+
+runTest();
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/media/webaudio/test/test_pannerNodeChannelCount.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test PannerNode directly above</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<pre id="test">
+<script src="webaudio.js" type="text/javascript"></script>
+<script class="testbody" type="text/javascript">
+
+var gTest = {
+  length: 2048,
+  numberOfChannels: 2,
+  createGraph: function(context) {
+    var buffer = context.createBuffer(2, 2048, context.sampleRate);
+    for (var i = 0; i < 2048; ++i) {
+      var sample = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
+      // When mixed into a single channel, this produces silence
+      buffer.getChannelData(0)[i] = sample;
+      buffer.getChannelData(1)[i] = -sample;
+    }
+
+    var panner = context.createPanner();
+    panner.setPosition(1, 2, 3);
+    panner.channelCount = 1;
+    expectException(function() { panner.channelCount = 3; },
+                    DOMException.NOT_SUPPORTED_ERR);
+    panner.channelCountMode = "explicit";
+    expectException(function() { panner.channelCountMode = "max"; },
+                    DOMException.NOT_SUPPORTED_ERR);
+    panner.channelInterpretation = "discrete";
+    panner.channelInterpretation = "speakers";
+
+    var source = context.createBufferSource();
+    source.buffer = buffer;
+    source.connect(panner);
+    source.start(0);
+
+    return panner;
+  },
+};
+
+runTest();
+
+</script>
+</pre>
+</body>
+</html>