| Index: third_party/WebKit/LayoutTests/webaudio/Analyser/automatic-pull-node.html
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/Analyser/automatic-pull-node.html b/third_party/WebKit/LayoutTests/webaudio/Analyser/automatic-pull-node.html
|
| index a46a49c3f69e6618d18bdee76324e8884b6c7685..840bad87a246b589c2894d51f803587ea8fe99e6 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/Analyser/automatic-pull-node.html
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/Analyser/automatic-pull-node.html
|
| @@ -2,23 +2,24 @@
|
|
|
| <html>
|
| <head>
|
| -<script src="../../resources/js-test.js"></script>
|
| -<script src="../resources/compatibility.js"></script>
|
| +<script src="../../resources/testharness.js"></script>
|
| +<script src="../../resources/testharnessreport.js"></script>
|
| <script src="../resources/audit-util.js"></script>
|
| -<script src="../resources/audio-testing.js"></script>
|
| +<script src="../resources/audit.js"></script>
|
| </head>
|
|
|
| <body>
|
|
|
| -<div id="description"></div>
|
| -<div id="console"></div>
|
| -
|
| <script>
|
| -description("This test verifies that the AudioBasicInspectorNode based nodes work correctly.");
|
| +// This test verifies that the AudioBasicInspectorNode based nodes work correctly
|
| +
|
| +var audit = Audit.createTaskRunner();
|
|
|
| var sampleRate = 44100.0;
|
| -// We carefully arrange the renderLengthInFrames to be a multiple of the AudioNode rendering quantum (AudioNode::ProcessingSizeInFrames)
|
| -// so that AudioSourceNode will not feed tailing zeroes into the context and fail this test.
|
| +// We carefully arrange the renderLengthInFrames to be a multiple of the
|
| +// AudioNode rendering quantum (AudioNode::ProcessingSizeInFrames) so that
|
| +// AudioSourceNode will not feed tailing zeroes into the context and fail this
|
| +// test.
|
| var renderLengthInFrames = 256;
|
| var fftSize = 64;
|
|
|
| @@ -31,106 +32,92 @@ var bufferSource;
|
| var analyser;
|
|
|
| function constructCommonGraph() {
|
| - // Create offline audio context.
|
| - context = new OfflineAudioContext(1, renderLengthInFrames, sampleRate);
|
| - constantBuffer = createConstantBuffer(context, renderLengthInFrames, 1);
|
| + // Create offline audio context.
|
| + context = new OfflineAudioContext(1, renderLengthInFrames, sampleRate);
|
| + constantBuffer = createConstantBuffer(context, renderLengthInFrames, 1);
|
|
|
| - bufferSource = context.createBufferSource();
|
| - bufferSource.buffer = constantBuffer;
|
| + bufferSource = context.createBufferSource();
|
| + bufferSource.buffer = constantBuffer;
|
|
|
| - analyser = context.createAnalyser();
|
| - analyser.fftSize = fftSize;
|
| + analyser = context.createAnalyser();
|
| + analyser.fftSize = fftSize;
|
|
|
| - bufferSource.connect(analyser);
|
| + bufferSource.connect(analyser);
|
| }
|
|
|
| -function test1Finished() {
|
| - var timeDomainData = new Uint8Array(fftSize);
|
| - analyser.getByteTimeDomainData(timeDomainData);
|
| -
|
| - if (timeDomainData[0] >= audioDataOne)
|
| - testPassed("RealtimeAnalyserNode got pulled when connected from upstream node but not to downstream node.");
|
| - else
|
| - testFailed("RealtimeAnalyserNode failed to get pulled when connected from upstream node but not to downstream node.");
|
| +function test1Finished(should) {
|
| + var timeDomainData = new Uint8Array(fftSize);
|
| + analyser.getByteTimeDomainData(timeDomainData);
|
|
|
| - test2();
|
| + should(timeDomainData[0] >= audioDataOne,
|
| + "RealtimeAnalyserNode got pulled when connected from upstream node but not to downstream node"
|
| + )
|
| + .beTrue();
|
| }
|
|
|
| -// To verify the realtimeAnalyser can pull data when there is an upstream node connected to it
|
| -// but it's not connected to a downstream node.
|
| -function test1() {
|
| - constructCommonGraph();
|
| +// To verify the realtimeAnalyser can pull data when there is an upstream node
|
| +// connected to it but it's not connected to a downstream node.
|
| +audit.define("test1", function (task, should) {
|
| + constructCommonGraph();
|
|
|
| - bufferSource.start(0);
|
| + bufferSource.start(0);
|
|
|
| - context.oncomplete = test1Finished;
|
| - context.startRendering();
|
| -}
|
| -
|
| -function test2Finished() {
|
| - var timeDomainData = new Uint8Array(fftSize);
|
| - analyser.getByteTimeDomainData(timeDomainData);
|
| + context.startRendering()
|
| + .then(test1Finished(should))
|
| + .then(task.done.bind(task));
|
| +});
|
|
|
| - if (timeDomainData[0] >= audioDataOne)
|
| - testPassed("RealtimeAnalyserNode got pulled when connected from upstream node and to destination node.");
|
| - else
|
| - testFailed("RealtimeAnalyserNode failed to be pulled when connected by upstream node and to destination node.");
|
| +function test2Finished(should) {
|
| + var timeDomainData = new Uint8Array(fftSize);
|
| + analyser.getByteTimeDomainData(timeDomainData);
|
|
|
| - test3();
|
| + should(timeDomainData[0] >= audioDataOne,
|
| + "RealtimeAnalyserNode got pulled when connected from upstream node and to destination node"
|
| + )
|
| + .beTrue();
|
| }
|
|
|
| -// To verify the realtimeAnalyser can process normally when there is an upstream node connected to it
|
| -// and it's also connected to a downstream node which ultimately connect to audio destination.
|
| -function test2() {
|
| - constructCommonGraph();
|
| -
|
| - analyser.connect(context.destination);
|
| +// To verify the realtimeAnalyser can process normally when there is an upstream
|
| +// node connected to it and it's also connected to a downstream node which
|
| +// ultimately connect to audio destination.
|
| +audit.define("test2", function (task, should) {
|
| + constructCommonGraph();
|
|
|
| - bufferSource.start(0);
|
| + analyser.connect(context.destination);
|
|
|
| - context.oncomplete = test2Finished;
|
| - context.startRendering();
|
| -}
|
| + bufferSource.start(0);
|
|
|
| -function test3Finished() {
|
| - var timeDomainData = new Uint8Array(fftSize);
|
| - analyser.getByteTimeDomainData(timeDomainData);
|
| + context.startRendering()
|
| + .then(test2Finished(should))
|
| + .then(task.done.bind(task));
|
| +});
|
|
|
| - // If realtimeAnalyser hasn't pulled any data, the data in buffer will be 0.
|
| - if (timeDomainData[0] == audioDataZero)
|
| - testPassed("RealtimeAnalyserNode didn't get pulled when it should not.");
|
| - else
|
| - testFailed("RealtimeAnalyserNode been pulled when it should not.");
|
| +function test3Finished(should) {
|
| + var timeDomainData = new Uint8Array(fftSize);
|
| + analyser.getByteTimeDomainData(timeDomainData);
|
|
|
| - finishJSTest();
|
| + // If realtimeAnalyser hasn't pulled any data, the data in buffer will be 0.
|
| + should(timeDomainData[0] == audioDataZero,
|
| + "RealtimeAnalyserNode didn't get pulled when it should not")
|
| + .beTrue();;
|
| }
|
|
|
| -// To verify the realtimeAnalyser will stop pulling if it is connected to a downstream node
|
| -// which is not ultimatly connected to any audio destination.
|
| -function test3() {
|
| - constructCommonGraph();
|
| -
|
| - var gain = context.createGain();
|
| - analyser.connect(gain);
|
| -
|
| - bufferSource.start(0);
|
| +// To verify the realtimeAnalyser will stop pulling if it is connected to a
|
| +// downstream node which is not ultimatly connected to any audio destination.
|
| +audit.define("test3", function (task, should) {
|
| + constructCommonGraph();
|
|
|
| - context.oncomplete = test3Finished;
|
| - context.startRendering();
|
| -}
|
| -
|
| -function runTest() {
|
| - if (window.testRunner) {
|
| - testRunner.dumpAsText();
|
| - testRunner.waitUntilDone();
|
| - }
|
| + var gain = context.createGain();
|
| + analyser.connect(gain);
|
|
|
| - window.jsTestIsAsync = true;
|
| + bufferSource.start(0);
|
|
|
| - test1();
|
| -}
|
| + context.startRendering()
|
| + .then(test3Finished(should))
|
| + .then(task.done.bind(task));
|
| +});
|
|
|
| -runTest();
|
| +audit.run();
|
|
|
| </script>
|
|
|
|
|