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 @@
<html>
<head>
<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/audio-testing.js"></script>
<script src="../resources/audit.js"></script>
</head>
<body>
<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;
var source;
var buffer;
var renderedData;
let sampleRate = 44100;
var sampleRate = 44100;
let testDurationSec = 1;
let testDurationSamples = testDurationSec * sampleRate;
let startTime = 0.9 * testDurationSec;
var testDurationSec = 1;
var testDurationSamples = testDurationSec * sampleRate;
var startTime = 0.9 * testDurationSec;
function runTest() {
window.jsTestIsAsync = true;
context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
context.oncomplete = checkResult;
audit.define("Test setting the source buffer after starting the grain",
function (task, should) {
context = new OfflineAudioContext(1, testDurationSamples,
sampleRate);
buffer = createConstantBuffer(context, testDurationSamples, 1);
source = context.createBufferSource();
......@@ -38,34 +37,32 @@
source.buffer = buffer;
// Render it!
context.startRendering();
}
context.startRendering()
.then(function (buffer) {
checkResult(buffer, should);
})
.then(task.done.bind(task));;
});
function checkResult(event) {
var success = false;
function checkResult(buffer, should) {
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
// passed.
var startFrame = Math.round(startTime * sampleRate);
for (k = 0; k < renderedData.length; ++k) {
if (renderedData[k]) {
success = true;
break;
}
// Check that the rendered data is not all zeroes. Any non-zero data means the test
// passed.
let startFrame = Math.round(startTime * sampleRate);
for (k = 0; k < renderedData.length; ++k) {
if (renderedData[k]) {
success = true;
break;
}
}
if (success)
testPassed("Buffer was played.");
else
testFailed("Buffer was not played.");
finishJSTest();
should(success, "Buffer was played").beTrue();
}
runTest();
successfullyParsed = true;
audit.run();
</script>
</body>
</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