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

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

Issue 2581463002: Refactor WebAudio test directory (Closed)
Patch Set: Use correct path for wav result files Created 3 years, 12 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
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/compatibility.js"></script>
6 <script src="resources/audit-util.js"></script>
7 <script src="resources/audio-testing.js"></script>
8 <script src="resources/panner-formulas.js"></script>
9 <title>Test setValueCurveAtTime Copies the Curve Data</title>
10 </head>
11
12 <body>
13 <script>
14 description("Test setValueCurveAtTime Copies the Curve Data");
15 window.jsTestIsAsync = true;
16
17 var sampleRate = 48000;
18 var renderFrames = 1024;
19 var renderDuration = renderFrames / sampleRate;
20
21 var audit = Audit.createTaskRunner();
22
23 // Test that changing the curve array to setValueCurveAtTime doesn't
24 // change the automation output.
25 audit.defineTask("test-copy", function (done) {
26 // Two-channel context; channel 0 is the test result, and channel 1 is
27 // the expected result.
28 var context = new OfflineAudioContext(2, renderFrames, sampleRate);
29
30 var source = context.createBufferSource();
31 source.buffer = createConstantBuffer(context, 1, 1);
32 source.loop = true;
33
34 // Create two gain nodes. gainRef is the reference with the expected
35 // automation results. gainTest is the test which will have the curve
36 // modified.
37 var gainTest = context.createGain();
38 var gainRef = context.createGain();
39
40 var merger = context.createChannelMerger(2);
41
42 // The actual curve data can be anything, but we use this for
43 // simplicity.
44 var curveData = [1, 0];
45 var curveRef = Float32Array.from(curveData);
46 var curveTest = Float32Array.from(curveData);
47
48 // Create the graph.
49 source.connect(gainTest);
50 source.connect(gainRef);
51 gainTest.connect(merger, 0, 0);
52 gainRef.connect(merger, 0, 1);
53 merger.connect(context.destination);
54
55 // Initialize the gains.
56 gainTest.gain.setValueAtTime(0, 0);
57 gainRef.gain.setValueAtTime(0, 0);
58
59 // Set up the value curve. At this point curveTest and curveRef are the
60 // same.
61 gainTest.gain.setValueCurveAtTime(curveTest, 0, renderDuration);
62 gainRef.gain.setValueCurveAtTime(curveRef, 0, renderDuration);
63
64 // After rendering has started, modify curveTest.
65 context.suspend(128 / sampleRate).then(function () {
66 // Change the values of curve now. Any transformation is ok as long
67 // as curveTest changes. We do this to make it really obvious.
68 for (var k = 0; k < curveTest.length; ++k)
69 curveTest[k] = 100 * curveTest[k] + 1;
70 }).then(context.resume.bind(context));
71
72 // Start the test!
73 source.start();
74
75 context.startRendering().then(function (resultBuffer) {
76 var testData = resultBuffer.getChannelData(0);
77 var refData = resultBuffer.getChannelData(1);
78
79 // The test result and the reference should be identical since
80 // changing the curve data should not affect the automation.
81 var success = Should("setValueCurve output", testData).beEqualToArray( refData);
82
83 if (success)
84 testPassed("Changing the curve data did not change the result.");
85 else
86 testFailed("Changing the curve data unexpectedly changed the result. ");
87 }).then(done);
88 });
89
90 audit.defineTask("finish", function (done) {
91 finishJSTest();
92 done();
93 });
94
95 audit.runTasks();
96 </script>
97 </body>
98 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698