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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/audioparam-linearRamp-value-attribute.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 <title>Test linearRampToValue Updates the Param Value</title>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audit-util.js"></script>
8 <script src="resources/audio-testing.js"></script>
9 </head>
10
11 <body>
12 <script>
13 description("Test linearRampToValue Updates the Param Value");
14 window.jsTestIsAsync = true;
15
16 var renderQuantumSize = 128;
17 // Should be a power of two to get rid of rounding errors when converting between time and
18 // frame.
19 var sampleRate = 4096;
20 var renderDuration = 1;
21 // End time of the linear ramp automation
22 var rampEndTime = renderDuration / 2;
23
24 var audit = Audit.createTaskRunner();
25
26 // Test that linearRampToValue properly sets the AudioParam .value attribu te when the
27 // linearRamp automation is running.
28 audit.defineTask("propagate", function (done) {
29 var context = new OfflineAudioContext(1, renderDuration * sampleRate, sa mpleRate);
30
31 // Create a constant source.
32 var source = context.createBufferSource();
33 source.buffer = createConstantBuffer(context, 1, 1);
34 source.loop = true;
35
36 // The gain node to be automated for testing.
37 var gain = context.createGain();
38
39 gain.gain.setValueAtTime(0, 0);
40 gain.gain.linearRampToValueAtTime(1, rampEndTime);
41
42 // Connect up the graph
43 source.connect(gain);
44 gain.connect(context.destination);
45
46 var success = true;
47
48 // The number of rendering quanta that will be processed in the context. At the beginning
49 // of each rendering quantum (except the first), we will check that gain .gain.value has the
50 // expected value.
51 var renderLoops = Math.floor(renderDuration * sampleRate / renderQuantum Size);
52
53 for (var k = 1; k < renderLoops; ++k) {
54 var time = k * renderQuantumSize / sampleRate;
55 context.suspend(time).then(function () {
56 var expected = 1;
57
58 if (context.currentTime <= rampEndTime) {
59 // The expected value of the gain is the last computed value from the previous
60 // rendering quantum because suspend() stops at the beginning of a rendering quantum,
61 // so we haven't computed the new value yet.
62 expected = (context.currentTime - 1 / sampleRate) / rampEndTime;
63 }
64
65 var frame = context.currentTime * sampleRate - 1;
66 success = Should("gain.gain.value at frame " + frame, gain.gain.valu e)
67 .beEqualTo(expected) && success;
68 }).then(context.resume.bind(context));
69 }
70
71 // Rock and roll!
72 source.start();
73 context.startRendering().then(function (result) {
74 if (success)
75 testPassed("linearRampToValue properly set the AudioParam value.");
76 else
77 testFailed("linearRampToValue did not properly set the AudioParam va lue.");
78 }).then(done);
79 });
80
81 audit.defineTask("finish", function (done) {
82 finishJSTest();
83 done();
84 });
85
86 audit.runTasks();
87 </script>
88 </body>
89 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698