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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-setTarget-timeConstant-0.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 setTargetAtTime with timeConstant=0</title> 4 <title>
5 Test setTargetAtTime with timeConstant=0
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.js"></script> 9 <script src="../resources/audit.js"></script>
8 </head> 10 </head>
9
10 <body> 11 <body>
11 <script> 12 <script id="layout-test-code">
12 // Fairly arbitrary sample rate and number of frames, so choose a low 13 // Fairly arbitrary sample rate and number of frames, so choose a low
13 // sample rate, and short rendering length. 14 // sample rate, and short rendering length.
14 var sampleRate = 8000; 15 let sampleRate = 8000;
15 var renderFrames = 128; 16 let renderFrames = 128;
16 17
17 // Array specifying parameters for setTargetAtTime. |frame| is the frame 18 // Array specifying parameters for setTargetAtTime. |frame| is the frame
18 // (not necessarily an integer) at which setTargetAtTime starts, and 19 // (not necessarily an integer) at which setTargetAtTime starts, and
19 // |value| is the target value. Non-integral values for |frame| tests 20 // |value| is the target value. Non-integral values for |frame| tests
20 // that we started the setTargetAtTime at the right time. 21 // that we started the setTargetAtTime at the right time.
21 var targetValueInfo = [{ 22 let targetValueInfo = [
22 frame: 10.1, 23 {frame: 10.1, value: 0}, {frame: 20.3, value: 0.5},
23 value: 0 24 {frame: 100.5, value: 1}
24 }, { 25 ];
25 frame: 20.3,
26 value: 0.5
27 }, {
28 frame: 100.5,
29 value: 1
30 }];
31 26
32 var audit = Audit.createTaskRunner(); 27 let audit = Audit.createTaskRunner();
33 28
34 audit.define("timeconstant-0", (task, should) => { 29 audit.define('timeconstant-0', (task, should) => {
35 var context = new OfflineAudioContext(1, renderFrames, sampleRate); 30 let context = new OfflineAudioContext(1, renderFrames, sampleRate);
36 31
37 // Simple constant source for testing. 32 // Simple constant source for testing.
38 33
39 var src = new ConstantSourceNode(context); 34 let src = new ConstantSourceNode(context);
40 35
41 // We're going to automate the gain node to test setTargetAtTime. 36 // We're going to automate the gain node to test setTargetAtTime.
42 var gain = new GainNode(context, { 37 let gain = new GainNode(context, {gain: 1});
43 gain: 1
44 });
45 38
46 src.connect(gain).connect(context.destination); 39 src.connect(gain).connect(context.destination);
47 40
48 for (var k = 0; k < targetValueInfo.length; ++k) { 41 for (let k = 0; k < targetValueInfo.length; ++k) {
49 gain.gain.setTargetAtTime( 42 gain.gain.setTargetAtTime(
50 targetValueInfo[k].value, 43 targetValueInfo[k].value,
51 targetValueInfo[k].frame / context.sampleRate, 44 targetValueInfo[k].frame / context.sampleRate, 0);
52 0);
53 } 45 }
54 46
55 src.start(); 47 src.start();
56 48
57 context.startRendering().then(function (resultBuffer) { 49 context.startRendering()
58 var result = resultBuffer.getChannelData(0); 50 .then(function(resultBuffer) {
59 var success = true; 51 let result = resultBuffer.getChannelData(0);
52 let success = true;
60 53
61 // Because the time constant is 0, the automation should instantly 54 // Because the time constant is 0, the automation should instantly
62 // jump to the target value at the start time. Verify that the output 55 // jump to the target value at the start time. Verify that the
63 // has the expected value. 56 // output has the expected value.
64 for (var k = 0; k < targetValueInfo.length; ++k) { 57 for (let k = 0; k < targetValueInfo.length; ++k) {
65 var startFrame = Math.ceil(targetValueInfo[k].frame); 58 let startFrame = Math.ceil(targetValueInfo[k].frame);
66 var endFrame = k < targetValueInfo.length - 1 ? 59 let endFrame = k < targetValueInfo.length - 1 ?
67 Math.ceil(targetValueInfo[k + 1].frame) : renderFrames; 60 Math.ceil(targetValueInfo[k + 1].frame) :
68 var value = targetValueInfo[k].value; 61 renderFrames;
62 let value = targetValueInfo[k].value;
69 63
70 should(result.slice(startFrame, endFrame), 64 should(
71 "Output for frame [" + startFrame + ", " + endFrame + 65 result.slice(startFrame, endFrame),
72 ")") 66 'Output for frame [' + startFrame + ', ' + endFrame + ')')
73 .beConstantValueOf(value); 67 .beConstantValueOf(value);
74 } 68 }
75 69
76 }).then(() => task.done()); 70 })
71 .then(() => task.done());
77 }); 72 });
78 73
79 audit.run(); 74 audit.run();
80 </script> 75 </script>
81 </body> 76 </body>
82 </html> 77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698