Chromium Code Reviews| Index: LayoutTests/webaudio/audiobuffersource-loop-457099.html |
| diff --git a/LayoutTests/webaudio/audiobuffersource-loop-457099.html b/LayoutTests/webaudio/audiobuffersource-loop-457099.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e36eb3d398b91b1e5701850beedb523d58717bcd |
| --- /dev/null |
| +++ b/LayoutTests/webaudio/audiobuffersource-loop-457099.html |
| @@ -0,0 +1,71 @@ |
| +<!doctype html> |
| +<html> |
| + <head> |
| + <title>Test AudioBufferSourceNode looping without explicit duration</title> |
| + <script src="resources/compatibility.js"></script> |
| + <script src="resources/audio-testing.js"></script> |
| + <script src="../resources/js-test.js"></script> |
| + </head> |
| + |
| + <body> |
| + <script> |
|
hongchan
2015/02/12 18:36:58
I think it's better to include the URL to the crbu
Raymond Toy
2015/02/12 21:36:42
Because I ran out of ideas for a good descriptive
Raymond Toy
2015/02/13 20:07:06
Renamed file.
|
| + description("Test AudioBufferSourceNode looping without explicit duration"); |
| + |
| + var context; |
| + var buffer; |
| + var output; |
| + var expected; |
| + var sourceFrames = 8; |
| + var loopCount = 4; |
| + var renderFrames = sourceFrames * loopCount; |
| + var sampleRate = 44100; |
| + |
| + |
| + function checkResult(renderedBuffer) { |
| + var badIndex = -1; |
| + var success = true; |
| + |
| + expected = buffer.getChannelData(0); |
| + output = renderedBuffer.getChannelData(0); |
| + |
| + // Verify the output has the expected data. |
| + for (var k = 0; k < loopCount; ++k) { |
| + for (var n = 0; n < sourceFrames; ++n) { |
| + if (expected[n] != output[n + k * sourceFrames]) { |
| + if (success) |
| + badIndex = n + k * sourceFrames; |
| + success = false; |
| + } |
| + } |
| + } |
| + |
| + if (success) { |
| + testPassed("Source looped correctly"); |
| + } else { |
| + testFailed("First incorrect sample at index " + badIndex); |
| + } |
| + } |
| + |
| + function runTest() { |
| + window.jsTestIsAsync = true; |
| + |
| + context = new OfflineAudioContext(1, renderFrames, sampleRate); |
| + buffer = createLinearRampBuffer(context, sourceFrames); |
| + var source = context.createBufferSource(); |
| + source.buffer = buffer; |
| + source.connect(context.destination); |
| + |
| + // Loop the source, and start the source with an offset, but without a duration. In this |
| + // case, the source should loop "forever". The case where the duration is given is covered |
| + // in other tests. |
| + source.loop = true; |
| + source.start(0, 0); |
| + context.startRendering() |
| + .then(checkResult) |
| + .then(function () { finishJSTest(); }); |
| + } |
| + |
| + runTest(); |
|
hongchan
2015/02/12 18:36:58
I see this runTest() pattern a lot in our layout t
Raymond Toy
2015/02/12 21:36:42
I was mostly following Chris's existing pattern.
|
| + </script> |
| + </body> |
| +</html> |