Bug 1408456 - convert mochitest test_audioBufferSourceNodeLoopStartEnd.html to a web-platform-test r?padenot draft
authorp1509425
Fri, 05 Jan 2018 11:56:12 +0100
changeset 716247 345347719c463cc8a71364bc943a21095d488279
parent 716246 215308aecad4ea9efd8113e48458ccc542f140e7
child 716248 f61ad5beed6629306b5179ed4523c6a9d518216d
push id94373
push userbmo:alan.guyoch@gmail.com
push dateFri, 05 Jan 2018 10:57:04 +0000
reviewerspadenot
bugs1408456
milestone59.0a1
Bug 1408456 - convert mochitest test_audioBufferSourceNodeLoopStartEnd.html to a web-platform-test r?padenot MozReview-Commit-ID: ApBRoGmR2k1
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -348558,16 +348558,22 @@
     ]
    ],
    "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoop.html": [
     [
      "/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoop.html",
      {}
     ]
    ],
+   "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html": [
+    [
+     "/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html",
+     {}
+    ]
+   ],
    "webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html": [
     [
      "/webaudio/the-audio-api/the-audiodestinationnode-interface/idl-test.html",
      {}
     ]
    ],
    "webaudio/the-audio-api/the-audionode-interface/audionode-connect-return-value.html": [
     [
@@ -576463,16 +576469,20 @@
   "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLazyLoopParam.html": [
    "5ac3d042f02eea9ccd49c4985162b8f147f161e3",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoop.html": [
    "a6047ca7c70167e32eac544dd1e5d31708db2c29",
    "testharness"
   ],
+  "webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html": [
+   "88d9b5d9930a0a59b3a509cc724d0f539a10cd89",
+   "testharness"
+  ],
   "webaudio/the-audio-api/the-audiocontext-interface/.gitkeep": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
   "webaudio/the-audio-api/the-audiodestinationnode-interface/.gitkeep": [
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/test_audioBufferSourceNodeLoopStartEnd.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
+  <script src="/webaudio/js/helpers.js"></script>
+  <script>
+var gTest = {
+  length: 2048 * 4,
+  numberOfChannels: 1,
+  createGraph: function(context) {
+    var buffer = context.createBuffer(1, 2048, context.sampleRate);
+    for (var i = 0; i < 2048; ++i) {
+      buffer.getChannelData(0)[i] = Math.sin(
+        440 * 2 * Math.PI * i / context.sampleRate
+      );
+    }
+
+    var source = new AudioBufferSourceNode(context, {
+      buffer: buffer,
+      loop: true,
+      loopStart: buffer.duration * 0.25,
+      loopEnd: buffer.duration * 0.75
+    });
+    source.start(0);
+    return source;
+  },
+  createExpectedBuffers: function(context) {
+    var expectedBuffer = context.createBuffer(1, 2048 * 4, context.sampleRate);
+    for (var i = 0; i < 1536; ++i) {
+      expectedBuffer.getChannelData(0)[i] = Math.sin(
+        440 * 2 * Math.PI * i / context.sampleRate
+      );
+    }
+    for (var i = 0; i < 6; ++i) {
+      for (var j = 512; j < 1536; ++j) {
+        expectedBuffer.getChannelData(0)[1536 + i * 1024 + j - 512] = Math.sin(
+          440 * 2 * Math.PI * j / context.sampleRate
+        );
+      }
+    }
+    for (var j = 7680; j < 2048 * 4; ++j) {
+      expectedBuffer.getChannelData(0)[j] = Math.sin(
+        440 * 2 * Math.PI * (j - 7168) / context.sampleRate
+      );
+    }
+    return expectedBuffer;
+  }
+};
+
+runTest();
+  </script>
+</head>
+</body>
+</html>