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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setValueCurve-duration.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 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../resources/audit-util.js"></script> 6 <script src="../resources/audit-util.js"></script>
6 <script src="../resources/audio-testing.js"></script> 7 <script src="../resources/audio-testing.js"></script>
7 <script src="../resources/audioparam-testing.js"></script> 8 <script src="../resources/audioparam-testing.js"></script>
8 <title>Test setValueCurveAtTime with Huge Duration</title> 9 <title>Test setValueCurveAtTime with Huge Duration</title>
9 </head> 10 </head>
10 11
11 <body> 12 <body>
12 <script> 13 <script>
13 description("Test AudioParam setValueCurveAtTime() with Huge Duration.");
14 window.jsTestIsAsync = true;
15 14
16 var sampleRate = 48000; 15 var sampleRate = 48000;
17 var renderFrames = 1000; 16 var renderFrames = 1000;
18 17
19 var audit = Audit.createTaskRunner(); 18 var audit = Audit.createTaskRunner();
20 19
21 audit.defineTask("long duration", function (done) { 20 audit.defineTask("long duration", function (done) {
22 // We only need to generate a small number of frames for this test. 21 // We only need to generate a small number of frames for this test.
23 var context = new OfflineAudioContext(1, renderFrames, sampleRate); 22 var context = new OfflineAudioContext(1, renderFrames, sampleRate);
24 var src = context.createBufferSource(); 23 var src = context.createBufferSource();
25 24
26 // Constant source of amplitude 1, looping. 25 // Constant source of amplitude 1, looping.
27 src.buffer = createConstantBuffer(context, 1, 1); 26 src.buffer = createConstantBuffer(context, 1, 1);
28 src.loop = true; 27 src.loop = true;
29 28
30 // Automate the gain with a setValueCurve with a very long duration. Th e duration should 29 // Automate the gain with a setValueCurve with a very long duration. Th e duration should
31 // produce a frame number greater than 2^64 (larger than the largest siz e_t value). 30 // produce a frame number greater than 2^64 (larger than the largest siz e_t value).
32 var gain = context.createGain(); 31 var gain = context.createGain();
33 var duration = Math.pow(2, 64); 32 var duration = Math.pow(2, 64);
34 var curve = Float32Array.from([0, 1]); 33 var curve = Float32Array.from([0, 1]);
35 gain.gain.setValueCurveAtTime(curve, 0, duration); 34 gain.gain.setValueCurveAtTime(curve, 0, duration);
36 35
37 // Create the graph and go! 36 // Create the graph and go!
38 src.connect(gain); 37 src.connect(gain);
39 gain.connect(context.destination); 38 gain.connect(context.destination);
40 src.start(); 39 src.start();
41 40
42 context.startRendering().then(function (result) { 41 context.startRendering().then(function (result) {
43 // Find the maximum value of the buffer. 42 // Find the maximum value of the buffer.
44 console.log(result);
45 var max = Math.max.apply(null, result.getChannelData(0)); 43 var max = Math.max.apply(null, result.getChannelData(0));
46 44
47 // The automation does linear interpolation between 0 and 1 from time 0 to duration. 45 // The automation does linear interpolation between 0 and 1 from time 0 to duration.
48 // Hence the max value of the interpolation occurs at the end of the rendering. Compute 46 // Hence the max value of the interpolation occurs at the end of the rendering. Compute
49 // this value. 47 // this value.
50 48
51 var expectedMax = (renderFrames / sampleRate) * (1 / duration); 49 var expectedMax = (renderFrames / sampleRate) * (1 / duration);
52 50
53 var message = "setValueCurve([" + curve + "], 0, " + duration + ")"; 51 var message = "setValueCurve([" + curve + "], 0, " + duration + ")";
54 52
55 success = Should("Max amplitude of " + message, max, { 53 success = Should("Max amplitude of " + message, max, {
56 brief: true 54 brief: true
57 }).beLessThanOrEqualTo(expectedMax); 55 }).beLessThanOrEqualTo(expectedMax);
58 56
59 if (success) 57 Should(message, success)
60 testPassed(message + " correctly rendered.") 58 .summarize("correctly rounded",
61 else 59 "incorrectly rendered with a peak value of " + max);
62 testFailed(message + " incorrectly rendered with a peak value of " + max);
63 }).then(done); 60 }).then(done);
64 }); 61 });
65 62
66 audit.defineTask("finish", function (done) { 63 audit.defineTask("finish", function (done) {
67 finishJSTest();
68 done(); 64 done();
69 }); 65 });
70 66
71 audit.runTasks(); 67 audit.runTasks();
72 </script> 68 </script>
73 </body> 69 </body>
74 </html> 70 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698