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

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

Issue 2658703002: Convert AudioParam Audit tests to testharness (Closed)
Patch Set: Rebase test Created 3 years, 10 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 Exceptions from setValueCurveAtTime</title> 4 <title>Test Exceptions from setValueCurveAtTime</title>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audio-testing.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
11 <script> 12 <script>
12 description("Test Exceptions from setValueCurveAtTime");
13 window.jsTestIsAsync = true;
14 13
15 var sampleRate = 48000; 14 var sampleRate = 48000;
16 // Some short duration because we don't need to run the test for very long . 15 // Some short duration because we don't need to run the test for very long .
17 var testDurationSec = 0.125; 16 var testDurationSec = 0.125;
18 var testDurationFrames = testDurationSec * sampleRate; 17 var testDurationFrames = testDurationSec * sampleRate;
19 18
20 var audit = Audit.createTaskRunner(); 19 var audit = Audit.createTaskRunner();
21 20
22 audit.defineTask("setValueCurve", function(done) { 21 audit.defineTask("setValueCurve", function(done) {
23 var success = true; 22 var success = true;
(...skipping 26 matching lines...) Expand all
50 49
51 success = Should("setTargetAtTime(1, " + automationTime + ", 1)", functi on() { 50 success = Should("setTargetAtTime(1, " + automationTime + ", 1)", functi on() {
52 g.gain.setTargetAtTime(1, automationTime, 1); 51 g.gain.setTargetAtTime(1, automationTime, 1);
53 }).throw("NotSupportedError") && success; 52 }).throw("NotSupportedError") && success;
54 53
55 success = Should("setValueAtTime(1, " + (curveStartTime + 1.1 * duration ) + ")", function() { 54 success = Should("setValueAtTime(1, " + (curveStartTime + 1.1 * duration ) + ")", function() {
56 g.gain.setValueAtTime(1, curveStartTime + 1.1 * duration); 55 g.gain.setValueAtTime(1, curveStartTime + 1.1 * duration);
57 }).notThrow() && success; 56 }).notThrow() && success;
58 57
59 var prefix = "Automation functions overlapping an existing setValueCurve AtTime"; 58 var prefix = "Automation functions overlapping an existing setValueCurve AtTime";
60 if (success) 59 Should(prefix, success)
61 testPassed(prefix + " correctly signaled errors.\n"); 60 .summarize(" correctly signaled errors",
62 else 61 " failed to signal errors");
63 testFailed(prefix + " failed to signal errors.\n");
64 62
65 done(); 63 done();
66 }); 64 });
67 65
68 audit.defineTask("automations", function (done) { 66 audit.defineTask("automations", function (done) {
69 var success = true; 67 var success = true;
70 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; 68 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
71 var g = context.createGain(); 69 var g = context.createGain();
72 70
73 var curve = new Float32Array(2); 71 var curve = new Float32Array(2);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 d.delayTime.setValueCurveAtTime(Float32Array.from([1, 5, Infinity]), time, 0.01); 124 d.delayTime.setValueCurveAtTime(Float32Array.from([1, 5, Infinity]), time, 0.01);
127 }).throw("TypeError") && success; 125 }).throw("TypeError") && success;
128 126
129 // One last test that prints out lots of digits for the time. 127 // One last test that prints out lots of digits for the time.
130 var time = Math.PI / 100; 128 var time = Math.PI / 100;
131 success = Should("setValueCurveAtTime(curve, " + time + ", 0.01)", funct ion () { 129 success = Should("setValueCurveAtTime(curve, " + time + ", 0.01)", funct ion () {
132 g.gain.setValueCurveAtTime(curve, time, 0.01); 130 g.gain.setValueCurveAtTime(curve, time, 0.01);
133 }).throw("NotSupportedError") && success; 131 }).throw("NotSupportedError") && success;
134 132
135 var prefix = "setValueCurve overlapping existing automation functions"; 133 var prefix = "setValueCurve overlapping existing automation functions";
136 if (success) 134 Should(prefix, success)
137 testPassed(prefix + " correctly signaled errors.\n"); 135 .summarize(" correctly signaled errors",
138 else 136 " failed to signal errors");
139 testFailed(prefix + " failed to signal errors.\n");
140 137
141 done(); 138 done();
142 }); 139 });
143 140
144 audit.defineTask("catch-exception", function (done) { 141 audit.defineTask("catch-exception", function (done) {
145 // Verify that the curve isn't inserted into the time line even if we ca tch the exception. 142 // Verify that the curve isn't inserted into the time line even if we ca tch the exception.
146 var success = true; 143 var success = true;
147 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; 144 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
148 var gain = context.createGain(); 145 var gain = context.createGain();
149 var source = context.createBufferSource(); 146 var source = context.createBufferSource();
(...skipping 13 matching lines...) Expand all
163 } catch (e) { 160 } catch (e) {
164 }; 161 };
165 source.start(); 162 source.start();
166 163
167 context.startRendering().then(function (resultBuffer) { 164 context.startRendering().then(function (resultBuffer) {
168 // Since the setValueCurve wasn't inserted, the output should be exact ly 1 for the entire 165 // Since the setValueCurve wasn't inserted, the output should be exact ly 1 for the entire
169 // duration. 166 // duration.
170 var success = Should("Handled setValueCurve exception so output", resu ltBuffer.getChannelData(0)) 167 var success = Should("Handled setValueCurve exception so output", resu ltBuffer.getChannelData(0))
171 .beConstantValueOf(1); 168 .beConstantValueOf(1);
172 169
173 if (success) 170 Should("setValueCurveAtTime", success)
174 testPassed("setValueCurveAtTime correctly not inserted into timeline .\n"); 171 .summarize("correctly not inserted into timeline",
175 else 172 "incorrectly still inserted into timeline");
176 testFailed("setValueCurveAtTime incorrectly still inserted into time line.\n");
177 }).then(done); 173 }).then(done);
178 }); 174 });
179 175
180 audit.defineTask("start-end", function (done) { 176 audit.defineTask("start-end", function (done) {
181 var success = true; 177 var success = true;
182 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; 178 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
183 var g = context.createGain(); 179 var g = context.createGain();
184 var curve = new Float32Array(2); 180 var curve = new Float32Array(2);
185 181
186 // Verify that a setValueCurve can start at the end of an automation. 182 // Verify that a setValueCurve can start at the end of an automation.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 g.gain.setValueCurveAtTime(curve, time, timeInterval); 224 g.gain.setValueCurveAtTime(curve, time, timeInterval);
229 }).notThrow() && success; 225 }).notThrow() && success;
230 226
231 // setTarget starting at the end of setValueCurve should be fine. 227 // setTarget starting at the end of setValueCurve should be fine.
232 time += timeInterval; 228 time += timeInterval;
233 success = Should("setTargetAtTime(1, " + time + ", 1)", function () { 229 success = Should("setTargetAtTime(1, " + time + ", 1)", function () {
234 g.gain.setTargetAtTime(1, time, 1); 230 g.gain.setTargetAtTime(1, time, 1);
235 }).notThrow() && success; 231 }).notThrow() && success;
236 232
237 var prefix = "setValueCurve with adjoining automation functions"; 233 var prefix = "setValueCurve with adjoining automation functions";
238 if (success) 234 Should(prefix, success)
239 testPassed(prefix + " allowed as expected.\n"); 235 .summarize("allowed as expected",
240 else 236 "unexpectedly signaled errors");
241 testFailed(prefix + " unexpectedly signaled errors.\n");
242 237
243 done(); 238 done();
244 }); 239 });
245 240
246 audit.defineTask("curve lengths", function (done) { 241 audit.defineTask("curve lengths", function (done) {
247 var success = true; 242 var success = true;
248 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ; 243 var context = new OfflineAudioContext(1, testDurationFrames, sampleRate) ;
249 var g = context.createGain(); 244 var g = context.createGain();
250 var time = 0; 245 var time = 0;
251 246
252 // Check for invalid curve lengths 247 // Check for invalid curve lengths
253 success = Should("setValueCurveAtTime([], " + time + ", 0.01)", function () { 248 success = Should("setValueCurveAtTime([], " + time + ", 0.01)", function () {
254 g.gain.setValueCurveAtTime(Float32Array.from([]), time, 0.01); 249 g.gain.setValueCurveAtTime(Float32Array.from([]), time, 0.01);
255 }).throw("InvalidStateError") && success; 250 }).throw("InvalidStateError") && success;
256 251
257 success = Should("setValueCurveAtTime([1], " + time + ", 0.01)", functio n () { 252 success = Should("setValueCurveAtTime([1], " + time + ", 0.01)", functio n () {
258 g.gain.setValueCurveAtTime(Float32Array.from([1]), time, 0.01); 253 g.gain.setValueCurveAtTime(Float32Array.from([1]), time, 0.01);
259 }).throw("InvalidStateError") && success; 254 }).throw("InvalidStateError") && success;
260 255
261 success = Should("setValueCurveAtTime([1,2], " + time + ", 0.01)", funct ion () { 256 success = Should("setValueCurveAtTime([1,2], " + time + ", 0.01)", funct ion () {
262 g.gain.setValueCurveAtTime(Float32Array.from([1,2]), time, 0.01); 257 g.gain.setValueCurveAtTime(Float32Array.from([1,2]), time, 0.01);
263 }).notThrow() && success; 258 }).notThrow() && success;
264 259
265 if (success) 260 Should("Exceptions for curve length", success)
266 testPassed("Exceptions for curve length correctly handled.\n"); 261 .summarize("correctly handled",
267 else 262 "not correctly handled");
268 testFailed("Exceptions for curve length not correctly handled.\n");
269 263
270 done(); 264 done();
271 }); 265 });
272 266
273 audit.defineTask("finish", function (done) { 267 audit.defineTask("finish", function (done) {
274 finishJSTest();
275 done(); 268 done();
276 }); 269 });
277 270
278 audit.runTasks(); 271 audit.runTasks();
279 successfullyParsed = true; 272 successfullyParsed = true;
280 </script> 273 </script>
281 </body> 274 </body>
282 </html> 275 </html>
283 276
284 277
285 278
286 279
287 280
288 281
289 282
290 283
291 284
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698