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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-end.html

Issue 2581463002: Refactor WebAudio test directory (Closed)
Patch Set: Use correct path for wav result files Created 4 years 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
Index: third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-end.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-end.html b/third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-end.html
deleted file mode 100644
index 38c0dac34f5461c1ee1a9e20bf5332e94436a9bb..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/webaudio/audioparam-setValueCurve-end.html
+++ /dev/null
@@ -1,160 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <title>Test Automation Following setValueCurveAtTime Automations</title>
- <script src="../resources/js-test.js"></script>
- <script src="resources/compatibility.js"></script>
- <script src="resources/audit-util.js"></script>
- <script src="resources/audio-testing.js"></script>
- <script src="resources/audio-param.js"></script>
- </head>
-
- <body>
- <script>
- description("Test Automation Following setValueCurveAtTime Automations");
- window.jsTestIsAsync = true;
-
- var sampleRate = 12800;
- // Some short duration because we don't need to run the test for very long.
- var testDurationFrames = 256;
- var testDurationSec = testDurationFrames / sampleRate;
- var curveDuration = testDurationSec / 2;
-
- var audit = Audit.createTaskRunner();
-
- // Configuration for each test.
- //
- // Required options:
- // automation - Name of automation method to test
- // time - Time for the automation method.
- // Optional options:
- // extraDuration - extra time for the duration of the setValueCurve
- // duration. Default is 0. This should not be on a
- // sample frame boundary. This is for testing that
- // curves that don't end on a frame boundary are handled
- // correctly.
- // threshold - Error threshold for the test; default is 0.
- var testConfigs = [{
- automation: "linearRampToValueAtTime",
- time: testDurationSec,
- threshold: 3.9737e-8
- }, {
- automation: "linearRampToValueAtTime",
- time: testDurationSec,
- extraDuration: 0.5 / sampleRate,
- threshold: 1.8141e-8
- }, {
- automation: "exponentialRampToValueAtTime",
- time: testDurationSec,
- threshold: 3.9737e-8
- }, {
- automation: "exponentialRampToValueAtTime",
- time: testDurationSec,
- extraDuration: 0.5 / sampleRate,
- threshold: 2.0312e-8
- }, {
- automation: "setTargetAtTime",
- time: curveDuration,
- threshold: 1.5895e-7
- }, {
- automation: "setTargetAtTime",
- time: curveDuration + 0.5 / sampleRate,
- extraDuration: 0.5 / sampleRate,
- threshold: 1.3278e-7
- }];
-
- // Define tests from the configs
- for (k in testConfigs) {
- audit.defineTask(k + ": " + testConfigs[k].automation, (function (config) {
- return function (done) {
- runTest(config).then(done);
- };
- })(testConfigs[k]));
- }
-
- audit.defineTask("finish", function (done) {
- finishJSTest();
- done();
- });
-
- audit.runTasks();
-
- function runTest(options) {
- // For the test, use a gain node with a constant input to test the
- // automations.
- var context = new OfflineAudioContext(1, testDurationFrames, sampleRate);
- var source = context.createBufferSource();
- source.buffer = createConstantBuffer(context, 1, 1);
- source.loop = true;
-
- var gain = context.createGain();
-
- // Any valid curve is ok. We only use the last value for testing.
- var curve = [0, 2, 0.3];
- var actualDuration = curveDuration + (options.extraDuration || 0);
- gain.gain.setValueCurveAtTime(Float32Array.from(curve), 0, actualDuration);
-
- // Run the desired test automation. The extra parameter (0.01) is only
- // used for setTargetAtTime tests; it's ignored for other tests.
- var automationValue = 2;
- gain.gain[options.automation](automationValue, options.time, 0.01);
-
- source.connect(gain);
- gain.connect(context.destination);
-
- source.start();
-
- return context.startRendering().then(function (resultBuffer) {
- var result = resultBuffer.getChannelData(0);
-
- // Only need to verify that the ramp started at the right
- // value. Figure the nearest sample frame to the end curve.
- var curveEndFrame = Math.ceil(actualDuration * sampleRate);
-
- var expectedResult = curve[curve.length - 1];
-
- // Determine the expected value after the end of the setValueCurve event.
- if (options.automation == "linearRampToValueAtTime") {
- expectedResult = audioParamLinearRamp(
- curveEndFrame / sampleRate,
- curve[curve.length - 1], actualDuration,
- automationValue, testDurationSec);
- } else if (options.automation == "exponentialRampToValueAtTime") {
- expectedResult = audioParamExponentialRamp(
- curveEndFrame / sampleRate,
- curve[curve.length - 1], actualDuration,
- automationValue, testDurationSec);
- } else if (options.automation == "setTargetAtTime") {
- expectedResult = audioParamSetTarget(
- curveEndFrame / sampleRate,
- curve[curve.length - 1], actualDuration,
- automationValue, 0.01);
- }
-
- var message = "setValueCurve(..., " + 0 + ", " + actualDuration +
- ")." + options.automation +
- "(2, " + testDurationSec;
-
- if (options.automation == "setTargetAtTime")
- message += ", 0.01";
- message += ")";
-
- Should(message + ": value at time " + curveEndFrame / sampleRate, result[curveEndFrame])
- .beCloseTo(expectedResult, options.threshold || 0);
- });
- }
-
- function linearRampValue(t, t0, v0, t1, v1) {
- return v0 + (v1 - v0) * (t - t0) / (t1 - t0);
- }
-
- function exponentialRampValue(t, t0, v0, t1, v1) {
- return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));
- }
-
- function setTargetValue(t, t0, v0, v1, timeConstant) {
- return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant)
- }
- </script>
- </body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698