Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play.html

Issue 2594183003: Convert note-grain-on tests to testharness (Closed)
Patch Set: Address review comments and git cl format Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play.html
index fe0ca7008956e9b7659374bdada6c233eaa88fb0..b5d0b7838c77d0c1bacafc4a2b79af95b7f73e6d 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play.html
@@ -1,9 +1,10 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!doctype>
<html>
<head>
- <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>
<script src="../resources/note-grain-on-testing.js"></script>
</head>
@@ -12,7 +13,7 @@
<div id="console"></div>
<script>
- description("Test noteGrainOn offset rendering.");
+ let audit = Audit.createTaskRunner();
// To test noteGrainOn, a single ramp signal is created.
// Various sections of the ramp are rendered by noteGrainOn() at
@@ -20,25 +21,27 @@
// consists of the correct section of the ramp at the correct
// time.
- var linearRampBuffer;
+ let linearRampBuffer;
// Array of the grain offset used for each ramp played.
- var grainOffsetTime = [];
+ let grainOffsetTime = [];
// Verify the received signal is a ramp from the correct section
// of our ramp signal.
function verifyGrain(renderedData, startFrame, endFrame, grainIndex) {
- var grainOffsetFrame = timeToSampleFrame(grainOffsetTime[grainIndex], sampleRate);
- var grainFrameLength = endFrame - startFrame;
- var ramp = linearRampBuffer.getChannelData(0);
- var isCorrect = true;
-
- var expected;
- var actual;
- var frame;
-
- for (var k = 0; k < grainFrameLength; ++k) {
- if (renderedData[startFrame + k] != ramp[grainOffsetFrame + k]) {
+ let grainOffsetFrame = timeToSampleFrame(grainOffsetTime[
+ grainIndex], sampleRate);
+ let grainFrameLength = endFrame - startFrame;
+ let ramp = linearRampBuffer.getChannelData(0);
+ let isCorrect = true;
+
+ let expected;
+ let actual;
+ let frame;
+
+ for (let k = 0; k < grainFrameLength; ++k) {
+ if (renderedData[startFrame + k] != ramp[grainOffsetFrame +
+ k]) {
expected = ramp[grainOffsetFrame + k];
actual = renderedData[startFrame + k];
frame = startFrame + k;
@@ -46,90 +49,71 @@
break;
}
}
- return { verified: isCorrect,
- expected : expected ,
- actual : actual,
- frame : frame };
+ return {
+ verified: isCorrect,
+ expected: expected,
+ actual: actual,
+ frame: frame
+ };
}
-
- function checkResult(event) {
- var buffer = event.renderedBuffer;
- renderedData = buffer.getChannelData(0);
- var nSamples = renderedData.length;
- var success = true;
+ function checkResult(buffer, should) {
+ renderedData = buffer.getChannelData(0);
+ let nSamples = renderedData.length;
// Number of grains that we found that have incorrect data.
- var invalidGrainDataCount = 0;
-
- var startEndFrames = findStartAndEndSamples(renderedData);
+ let invalidGrainDataCount = 0;
+
+ let startEndFrames = findStartAndEndSamples(renderedData);
// Verify the start and stop times. Not strictly needed for
// this test, but it's useful to know that if the ramp data
// appears to be incorrect.
- success = success && verifyStartAndEndFrames(startEndFrames);
+ verifyStartAndEndFrames(startEndFrames, should);
// Loop through each of the rendered grains and check that
// each grain contains our expected ramp.
- for (var k = 0; k < startEndFrames.start.length; ++k) {
- // Verify that the rendered data matches the expected
- // section of our ramp signal.
- var result = verifyGrain(renderedData, startEndFrames.start[k], startEndFrames.end[k], k);
-
- if (!result.verified) {
- testFailed("Grain " + k + " incorrect. Expected " + result.expected + " but received " + result.actual + " at sample frame " + result.frame);
- ++invalidGrainDataCount;
- success = false;
- }
+ for (let k = 0; k < startEndFrames.start.length; ++k) {
+ // Verify that the rendered data matches the expected
+ // section of our ramp signal.
+ let result = verifyGrain(renderedData, startEndFrames.start[
+ k], startEndFrames.end[k], k);
+ should(result.verified, "Pulse " + k +
+ " contained the expected data")
+ .beTrue();
}
-
- if (!invalidGrainDataCount) {
- testPassed("All " + numberOfTests + " grains contained the correct data.");
- } else {
- testFailed(invalidGrainDataCount + " grains out of " + numberOfTests + " did not contain the expected data.");
- success = false;
- }
-
- if (success) {
- testPassed("noteGrainOn offset rendering tests passed.");
- } else {
- testFailed("noteGrainOn offset rendering tests failed.");
- }
-
- finishJSTest();
+ should(invalidGrainDataCount,
+ "Number of grains that did not contain the expected data")
+ .beEqualTo(0);
}
- function runTest() {
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
-
- window.jsTestIsAsync = true;
-
+ audit.define("note-grain-on-play", function(task, should) {
+ task.describe("Test noteGrainOn offset rendering");
// Create offline audio context.
- context = new OfflineAudioContext(2, sampleRate * renderTime, sampleRate);
+ context = new OfflineAudioContext(2, sampleRate *
+ renderTime, sampleRate);
// Create a linear ramp for testing noteGrainOn.
linearRampBuffer = createSignalBuffer(context,
- function(k) {
- // Want the ramp to start
- // with 1, not 0.
- return k + 1;
- });
+ function(k) {
+ // Want the ramp to start
+ // with 1, not 0.
+ return k + 1;
+ });
- var grainInfo = playAllGrains(context, linearRampBuffer, numberOfTests);
+ let grainInfo = playAllGrains(context, linearRampBuffer,
+ numberOfTests);
grainOffsetTime = grainInfo.grainOffsetTimes;
- context.oncomplete = checkResult;
- context.startRendering();
- }
+ context.startRendering()
+ .then(function(audioBuffer) {
+ checkResult(audioBuffer, should);
+ task.done();
+ });
+ });
- runTest();
- successfullyParsed = true;
-
+ audit.run();
</script>
-
</body>
</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/note-grain-on-play-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698