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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-end.html

Issue 2780433005: Convert AudioParam tests to new Audit (Closed)
Patch Set: Address review comments Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Automation Following setValueCurveAtTime Automations</title> 4 <title>Test Automation Following setValueCurveAtTime Automations</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
9 <script src="../resources/audio-param.js"></script> 9 <script src="../resources/audio-param.js"></script>
10 </head> 10 </head>
11 11
12 <body> 12 <body>
13 <script> 13 <script>
14 14
15 var sampleRate = 12800; 15 var sampleRate = 12800;
16 // Some short duration because we don't need to run the test for very long . 16 // Some short duration because we don't need to run the test for very long .
17 var testDurationFrames = 256; 17 var testDurationFrames = 256;
18 var testDurationSec = testDurationFrames / sampleRate; 18 var testDurationSec = testDurationFrames / sampleRate;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 threshold: 1.5895e-7 56 threshold: 1.5895e-7
57 }, { 57 }, {
58 automation: "setTargetAtTime", 58 automation: "setTargetAtTime",
59 time: curveDuration + 0.5 / sampleRate, 59 time: curveDuration + 0.5 / sampleRate,
60 extraDuration: 0.5 / sampleRate, 60 extraDuration: 0.5 / sampleRate,
61 threshold: 1.3278e-7 61 threshold: 1.3278e-7
62 }]; 62 }];
63 63
64 // Define tests from the configs 64 // Define tests from the configs
65 for (k in testConfigs) { 65 for (k in testConfigs) {
66 audit.defineTask(k + ": " + testConfigs[k].automation, (function (config ) { 66 audit.define(k + ": " + testConfigs[k].automation, (function (config) {
67 return function (done) { 67 return (task, should) => {
68 runTest(config).then(done); 68 runTest(should, config).then(() => task.done());
69 }; 69 };
70 })(testConfigs[k])); 70 })(testConfigs[k]));
71 } 71 }
72 72
73 audit.defineTask("finish", function (done) { 73 audit.run();
74 done();
75 });
76 74
77 audit.runTasks(); 75 function runTest(should, options) {
78
79 function runTest(options) {
80 // For the test, use a gain node with a constant input to test the 76 // For the test, use a gain node with a constant input to test the
81 // automations. 77 // automations.
82 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; 78 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
83 var source = context.createBufferSource(); 79 var source = context.createBufferSource();
84 source.buffer = createConstantBuffer(context, 1, 1); 80 source.buffer = createConstantBuffer(context, 1, 1);
85 source.loop = true; 81 source.loop = true;
86 82
87 var gain = context.createGain(); 83 var gain = context.createGain();
88 84
89 // Any valid curve is ok. We only use the last value for testing. 85 // Any valid curve is ok. We only use the last value for testing.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 125 }
130 126
131 var message = "setValueCurve(..., " + 0 + ", " + actualDuration + 127 var message = "setValueCurve(..., " + 0 + ", " + actualDuration +
132 ")." + options.automation + 128 ")." + options.automation +
133 "(2, " + testDurationSec; 129 "(2, " + testDurationSec;
134 130
135 if (options.automation == "setTargetAtTime") 131 if (options.automation == "setTargetAtTime")
136 message += ", 0.01"; 132 message += ", 0.01";
137 message += ")"; 133 message += ")";
138 134
139 Should(message + ": value at time " + curveEndFrame / sampleRate, resu lt[curveEndFrame]) 135 should(result[curveEndFrame],
140 .beCloseTo(expectedResult, options.threshold || 0); 136 message + ": value at time " + curveEndFrame / sampleRate)
137 .beCloseTo(expectedResult, {
138 threshold: options.threshold || 0
139 });
141 }); 140 });
142 } 141 }
143 142
144 function linearRampValue(t, t0, v0, t1, v1) { 143 function linearRampValue(t, t0, v0, t1, v1) {
145 return v0 + (v1 - v0) * (t - t0) / (t1 - t0); 144 return v0 + (v1 - v0) * (t - t0) / (t1 - t0);
146 } 145 }
147 146
148 function exponentialRampValue(t, t0, v0, t1, v1) { 147 function exponentialRampValue(t, t0, v0, t1, v1) {
149 return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0)); 148 return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0));
150 } 149 }
151 150
152 function setTargetValue(t, t0, v0, v1, timeConstant) { 151 function setTargetValue(t, t0, v0, v1, timeConstant) {
153 return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant) 152 return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant)
154 } 153 }
155 </script> 154 </script>
156 </body> 155 </body>
157 </html> 156 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698