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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-linearRamp-value-attribute.html

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

Powered by Google App Engine
This is Rietveld 408576698