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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-comprehensive.html

Issue 2599573003: Convert AudioBufferSource start and loop-comprehensive 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/audiobuffersource-loop-comprehensive-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/audiobuffersource-loop-comprehensive.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-comprehensive.html b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-comprehensive.html
index 72590c109cc52e99a30c04598f627498edbcc5f2..8bd161a5942012f087d44950aa400332bff67147 100644
--- a/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-comprehensive.html
+++ b/third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-comprehensive.html
@@ -2,21 +2,22 @@
<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/audiobuffersource-testing.js"></script>
</head>
<body>
<script>
-description("Tests AudioBufferSourceNode looping with a variety of loop points.");
+let audit = Audit.createTaskRunner();
// The following test cases assume an AudioBuffer of length 8 whose PCM data is a linear ramp, 0, 1, 2, 3,...
// |description| is optional and will be computed from the other parameters. |offsetFrame| is
// optional and defaults to 0.
-var tests = [
+let tests = [
{ description: "loop whole buffer by default with loopStart == loopEnd == 0",
loopStartFrame: 0,
@@ -166,15 +167,15 @@ var tests = [
];
-var sampleRate = 44100;
-var buffer;
-var bufferFrameLength = 8;
-var testSpacingFrames = 32;
-var testSpacingSeconds = testSpacingFrames / sampleRate;
-var totalRenderLengthFrames = tests.length * testSpacingFrames;
+let sampleRate = 44100;
+let buffer;
+let bufferFrameLength = 8;
+let testSpacingFrames = 32;
+let testSpacingSeconds = testSpacingFrames / sampleRate;
+let totalRenderLengthFrames = tests.length * testSpacingFrames;
-function runLoopTest(context, testNumber, test) {
- var source = context.createBufferSource();
+function runLoopTest(context, testNumber, test, should) {
+ let source = context.createBufferSource();
source.buffer = buffer;
source.playbackRate.value = test.playbackRate;
@@ -182,56 +183,57 @@ function runLoopTest(context, testNumber, test) {
source.loopStart = test.loopStartFrame / context.sampleRate;
source.loopEnd = test.loopEndFrame / context.sampleRate;
- var offset = test.offsetFrame ? test.offsetFrame / context.sampleRate : 0;
+ let offset = test.offsetFrame ? test.offsetFrame / context.sampleRate : 0;
source.connect(context.destination);
// Render each test one after the other, spaced apart by testSpacingSeconds.
- var startTime = testNumber * testSpacingSeconds;
+ let startTime = testNumber * testSpacingSeconds;
// If durationFrames is given, run the test for the specified duration.
if (test.durationFrames) {
if (!test.renderFrames) {
- testFailed("renderFrames is required for test " + testNumber + ": " + test.description);
+ throw("renderFrames is required for test " + testNumber + ": " + test.description);
} else {
if (test.durationFrames > testSpacingFrames || test.durationFrames < 0) {
- testFailed("Test " + testNumber
+ throw("Test " + testNumber
+ ": durationFrames (" + test.durationFrames + ") outside the range [0, "
+ testSpacingFrames + "]");
}
source.start(startTime, offset, test.durationFrames / context.sampleRate);
}
} else if (test.renderFrames) {
- var duration = test.renderFrames / context.sampleRate;
+ let duration = test.renderFrames / context.sampleRate;
if (test.renderFrames > testSpacingFrames || test.renderFrames < 0) {
- testFailed("Test " + testNumber
+ throw("Test " + testNumber
+ ": renderFrames (" + test.renderFrames + ") outside the range [0, "
+ testSpacingFrames + "]");
}
source.start(startTime, offset);
source.stop(startTime + duration);
} else {
- testFailed("Test " + testNumber + " must specify renderFrames and possibly durationFrames");
+ throw("Test " + testNumber + " must specify renderFrames and possibly durationFrames");
}
}
-function runTest() {
- window.jsTestIsAsync = true;
-
+audit.define("AudioBufferSource looping test", function (task, should) {
// Create offline audio context.
- var context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate);
+ let context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate);
buffer = createTestBuffer(context, bufferFrameLength);
- for (var i = 0; i < tests.length; ++i)
- runLoopTest(context, i, tests[i]);
-
- context.oncomplete = checkAllTests;
- context.startRendering();
-}
+ should(function () {
+ for (let i = 0; i < tests.length; ++i)
+ runLoopTest(context, i, tests[i], should);
+ }, "Generate " + tests.length + " test cases").notThrow();
-runTest();
-successfullyParsed = true;
+ context.startRendering()
+ .then(function (audioBuffer) {
+ checkAllTests(audioBuffer, should);
+ task.done();
+ });
+});
+audit.run();
</script>
</body>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-loop-comprehensive-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698