Commit 593e5206 authored by rtoy's avatar rtoy Committed by Commit bot

Convert audiobuffersource-grain test to testharness

Manually convert test to use testharness

BUG=676394
TEST=audiobuffersource-grain.html

Review-Url: https://codereview.chromium.org/2595153002
Cr-Commit-Position: refs/heads/master@{#441475}
parent 8e37fbee
Test setting the source buffer after starting the grain
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Buffer was played.
PASS successfullyParsed is true
TEST COMPLETE
...@@ -2,31 +2,30 @@ ...@@ -2,31 +2,30 @@
<html> <html>
<head> <head>
<title>Test Start Grain with Delayed Buffer Setting </title> <title>Test Start Grain with Delayed Buffer Setting </title>
<script src="../../resources/js-test.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/audit-util.js"></script> <script src="../resources/audit-util.js"></script>
<script src="../resources/audio-testing.js"></script> <script src="../resources/audit.js"></script>
</head> </head>
<body> <body>
<script> <script>
description("Test setting the source buffer after starting the grain"); let audit = Audit.createTaskRunner();
let context;
let source;
let buffer;
let renderedData;
var context; let sampleRate = 44100;
var source;
var buffer;
var renderedData;
var sampleRate = 44100; let testDurationSec = 1;
let testDurationSamples = testDurationSec * sampleRate;
let startTime = 0.9 * testDurationSec;
var testDurationSec = 1; audit.define("Test setting the source buffer after starting the grain",
var testDurationSamples = testDurationSec * sampleRate; function (task, should) {
var startTime = 0.9 * testDurationSec; context = new OfflineAudioContext(1, testDurationSamples,
sampleRate);
function runTest() {
window.jsTestIsAsync = true;
context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
context.oncomplete = checkResult;
buffer = createConstantBuffer(context, testDurationSamples, 1); buffer = createConstantBuffer(context, testDurationSamples, 1);
source = context.createBufferSource(); source = context.createBufferSource();
...@@ -38,34 +37,32 @@ ...@@ -38,34 +37,32 @@
source.buffer = buffer; source.buffer = buffer;
// Render it! // Render it!
context.startRendering(); context.startRendering()
} .then(function (buffer) {
checkResult(buffer, should);
})
.then(task.done.bind(task));;
});
function checkResult(event) { function checkResult(buffer, should) {
var success = false; let success = false;
renderedData = event.renderedBuffer.getChannelData(0); renderedData = buffer.getChannelData(0);
// Check that the rendered data is not all zeroes. Any non-zero data means the test // Check that the rendered data is not all zeroes. Any non-zero data means the test
// passed. // passed.
var startFrame = Math.round(startTime * sampleRate); let startFrame = Math.round(startTime * sampleRate);
for (k = 0; k < renderedData.length; ++k) { for (k = 0; k < renderedData.length; ++k) {
if (renderedData[k]) { if (renderedData[k]) {
success = true; success = true;
break; break;
}
} }
}
if (success) should(success, "Buffer was played").beTrue();
testPassed("Buffer was played.");
else
testFailed("Buffer was not played.");
finishJSTest();
} }
runTest(); audit.run();
successfullyParsed = true;
</script> </script>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment