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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioParam/audioparam-clamp-time-to-current-time.html

Issue 2780433005: Convert AudioParam tests to new Audit (Closed)
Patch Set: Address review comments Created 3 years, 8 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 Clamping of AudioParam Time</title> 4 <title>Test Clamping of AudioParam Time</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 <script> 12 <script>
13 // Fairly arbitrary sample rate and render frames. 13 // Fairly arbitrary sample rate and render frames.
14 var sampleRate = 24000; 14 var sampleRate = 24000;
15 var renderFrames = 1024; 15 var renderFrames = 1024;
16 16
17 var audit = Audit.createTaskRunner(); 17 var audit = Audit.createTaskRunner();
18 18
19 audit.defineTask("setValue", function (taskDone) { 19 audit.define("setValue", (task, should) => {
20 var suspendFrame = 128; 20 var suspendFrame = 128;
21 createGraph({ 21 createGraph({
22 suspendFrame: suspendFrame, 22 suspendFrame: suspendFrame,
23 method: "setValueAtTime", 23 method: "setValueAtTime",
24 initialGain: 0, 24 initialGain: 0,
25 arg0: 1, 25 arg0: 1,
26 }) 26 })
27 .then(function (resultBuffer) { 27 .then(function (resultBuffer) {
28 // Just verify that the cosine wave actually started at 28 // Just verify that the cosine wave actually started at
29 // suspendFrame. 29 // suspendFrame.
30 var result = resultBuffer.getChannelData(0); 30 var result = resultBuffer.getChannelData(0);
31 var success = true;
32 31
33 success = Should("setValue: Output[0-" + (suspendFrame - 1) + "]", 32 should(result.slice(0, suspendFrame),
34 result.slice(0, suspendFrame)) 33 "setValue: Output[0-" + (suspendFrame - 1) + "]")
35 .beConstantValueOf(0) && success; 34 .beConstantValueOf(0);
36 success = Should("setValue: Output[" + suspendFrame + "-" + ( 35 should(result.slice(suspendFrame),
37 renderFrames - 1) + "]", 36 "setValue: Output[" + suspendFrame + "-" + (renderFrames - 1) +
38 result.slice(suspendFrame)) 37 "]")
39 .beConstantValueOf(1) && success; 38 .beConstantValueOf(1);
40
41 Should("*** setValueAtTime in the past", success)
42 .summarize(
43 "correctly clamped to current time",
44 "was not correctly clamped to current time");
45 }) 39 })
46 .then(taskDone); 40 .then(() => task.done());
47 }); 41 });
48 42
49 audit.defineTask("linear", function (taskDone) { 43 audit.define("linear", (task, should) => {
50 var suspendFrame = 128; 44 var suspendFrame = 128;
51 createGraph({ 45 createGraph({
52 suspendFrame: suspendFrame, 46 suspendFrame: suspendFrame,
53 method: "linearRampToValueAtTime", 47 method: "linearRampToValueAtTime",
54 initialGain: 1, 48 initialGain: 1,
55 arg0: 0.5 49 arg0: 0.5
56 }) 50 })
57 .then(function (resultBuffer) { 51 .then(function (resultBuffer) {
58 // Just verify that the cosine wave actually started at 52 // Just verify that the cosine wave actually started at
59 // suspendFrame. 53 // suspendFrame.
60 var result = resultBuffer.getChannelData(0); 54 var result = resultBuffer.getChannelData(0);
61 var success = true;
62 55
63 success = Should("linear: Output[0-" + (suspendFrame - 1) + "]", 56 should(result.slice(0, suspendFrame),
64 result.slice(0, suspendFrame)) 57 "linear: Output[0-" + (suspendFrame - 1) + "]")
65 .beConstantValueOf(1) && success; 58 .beConstantValueOf(1);
66 success = Should("linear: Output[" + suspendFrame + "-" + ( 59 should(result.slice(suspendFrame),
67 renderFrames - 1) + "]", 60 "linear: Output[" + suspendFrame + "-" + (renderFrames - 1) + "]" )
68 result.slice(suspendFrame)) 61 .beConstantValueOf(0.5);
69 .beConstantValueOf(0.5) && success;
70 62
71 Should("*** linearRampToValueAtTime in the past", success)
72 .summarize(
73 "correctly clamped to current time",
74 "was not correctly clamped to current time");
75 }) 63 })
76 .then(taskDone); 64 .then(() => task.done());
77 }); 65 });
78 66
79 audit.defineTask("exponential", function (taskDone) { 67 audit.define("exponential", (task, should) => {
80 var suspendFrame = 128; 68 var suspendFrame = 128;
81 createGraph({ 69 createGraph({
82 suspendFrame: suspendFrame, 70 suspendFrame: suspendFrame,
83 method: "exponentialRampToValueAtTime", 71 method: "exponentialRampToValueAtTime",
84 initialGain: 1, 72 initialGain: 1,
85 arg0: 0.5 73 arg0: 0.5
86 }) 74 })
87 .then(function (resultBuffer) { 75 .then(function (resultBuffer) {
88 // Just verify that the cosine wave actually started at 76 // Just verify that the cosine wave actually started at
89 // suspendFrame. 77 // suspendFrame.
90 var result = resultBuffer.getChannelData(0); 78 var result = resultBuffer.getChannelData(0);
91 var success = true;
92 79
93 success = Should("exponential: Output[0-" + (suspendFrame - 1) + "]" , 80 should(result.slice(0, suspendFrame),
94 result.slice(0, suspendFrame)) 81 "exponential: Output[0-" + (suspendFrame - 1) + "]")
95 .beConstantValueOf(1) && success; 82 .beConstantValueOf(1);
96 success = Should("exponential: Output[" + suspendFrame + "-" + ( 83 should(result.slice(suspendFrame),
97 renderFrames - 1) + "]", 84 "exponential: Output[" + suspendFrame + "-" + (renderFrames - 1) +
98 result.slice(suspendFrame)) 85 "]")
99 .beConstantValueOf(0.5) && success; 86 .beConstantValueOf(0.5);
100
101 Should("*** exponentialRampToValueAtTime in the past",
102 success)
103 .summarize(
104 "correctly clamped to current time",
105 "was not correctly clamped to current time");
106 }) 87 })
107 .then(taskDone); 88 .then(() => task.done());
108 }); 89 });
109 90
110 audit.defineTask("setTarget", function (taskDone) { 91 audit.define("setTarget", (task, should) => {
111 var suspendFrame = 128; 92 var suspendFrame = 128;
112 createGraph({ 93 createGraph({
113 suspendFrame: suspendFrame, 94 suspendFrame: suspendFrame,
114 method: "setTargetAtTime", 95 method: "setTargetAtTime",
115 initialGain: 1, 96 initialGain: 1,
116 arg0: 0.5, 97 arg0: 0.5,
117 moreArgs: 0.1 98 moreArgs: 0.1
118 }) 99 })
119 .then(function (resultBuffer) { 100 .then(function (resultBuffer) {
120 // Just verify that the cosine wave actually started at 101 // Just verify that the cosine wave actually started at
121 // suspendFrame. 102 // suspendFrame.
122 var result = resultBuffer.getChannelData(0); 103 var result = resultBuffer.getChannelData(0);
123 var success = true;
124 104
125 success = Should("setTarget: Output[0-" + (suspendFrame - 1) + "]", 105 should(result.slice(0, suspendFrame),
126 result.slice(0, suspendFrame)) 106 "setTarget: Output[0-" + (suspendFrame - 1) + "]")
127 .beConstantValueOf(1) && success; 107 .beConstantValueOf(1);
128 // For the samples past the suspend time, we only care that first 108 // For the samples past the suspend time, we only care that first
129 // value is 1 and that the rest are not zero. 109 // value is 1 and that the rest are not zero.
130 success = Should("setTarget: Output[" + suspendFrame + "]", 110 should(result[suspendFrame],
131 result[suspendFrame]).beEqualTo(1) && success; 111 "setTarget: Output[" + suspendFrame + "]")
112 .beEqualTo(1);
132 113
133 var positive = result.slice(suspendFrame + 1).every(x => x > 114 var positive = result.slice(suspendFrame + 1).every(x => x >
134 0); 115 0);
135 success = Should("Output[" + (suspendFrame + 1) + "-" + 116 should(positive, "Output[" + (suspendFrame + 1) + "-" +
136 (renderFrames - 1) + "] contains only positive values", 117 (renderFrames - 1) + "] contains only positive values")
137 positive) 118 .beEqualTo(true);
138 .beEqualTo(true) && success;
139
140 Should("*** setTargetAtTime in the past", success)
141 .summarize(
142 "correctly clamped to current time",
143 "was not correctly clamped to current time");
144 }) 119 })
145 .then(taskDone); 120 .then(() => task.done());
146 }); 121 });
147 122
148 audit.defineTask("setValueCurve", function (taskDone) { 123 audit.define("setValueCurve", (task, should) => {
149 var suspendFrame = 128; 124 var suspendFrame = 128;
150 createGraph({ 125 createGraph({
151 suspendFrame: suspendFrame, 126 suspendFrame: suspendFrame,
152 method: "setValueCurveAtTime", 127 method: "setValueCurveAtTime",
153 initialGain: 1, 128 initialGain: 1,
154 arg0: Float32Array.from([2, 3]), 129 arg0: Float32Array.from([2, 3]),
155 moreArgs: 0.1 130 moreArgs: 0.1
156 }) 131 })
157 .then(function (resultBuffer) { 132 .then(function (resultBuffer) {
158 // Just verify that the cosine wave actually started at 133 // Just verify that the cosine wave actually started at
159 // suspendFrame. 134 // suspendFrame.
160 var result = resultBuffer.getChannelData(0); 135 var result = resultBuffer.getChannelData(0);
161 var success = true;
162 136
163 success = Should("setValueCurve: Output[0-" + (suspendFrame - 1) + " ]", 137 should(result.slice(0, suspendFrame),
164 result.slice(0, suspendFrame)) 138 "setValueCurve: Output[0-" + (suspendFrame - 1) + "]")
165 .beConstantValueOf(1) && success; 139 .beConstantValueOf(1);
166 140
167 // The selected curve contains values greater than or equal to 2. 141 // The selected curve contains values greater than or equal to 2.
168 // Just verify that all values are greater than or equal to 2. 142 // Just verify that all values are greater than or equal to 2.
169 var biggerThan2 = result.slice(suspendFrame).every(x => x >= 143 var biggerThan2 = result.slice(suspendFrame).every(x => x >=
170 2); 144 2);
171 success = Should("setValueCurve: Output[" + suspendFrame + "-" + ( 145 should(biggerThan2,
172 renderFrames - 1) + "]", 146 "setValueCurve: Output[" + suspendFrame + "-" +
173 biggerThan2) 147 (renderFrames - 1) + "]")
174 .beEqualTo(true) && success; 148 .beEqualTo(true);
175
176 Should("*** setValueCurveAtTime in the past", success)
177 .summarize(
178 "correctly clamped to current time",
179 "was not correctly clamped to current time");
180 }) 149 })
181 .then(taskDone); 150 .then(() => task.done());
182 }); 151 });
183 152
184 153
185 // Create the test graph consisting of a constant source followed by a 154 // Create the test graph consisting of a constant source followed by a
186 // gain node. The gain node automations will be tested. |options| 155 // gain node. The gain node automations will be tested. |options|
187 // specifies the parameters for the test including 156 // specifies the parameters for the test including
188 // 157 //
189 // suspendFrame: time at which we schedule the automation call 158 // suspendFrame: time at which we schedule the automation call
190 // method: the name of automation method to be tested 159 // method: the name of automation method to be tested
191 // initialGain: the initial gain at time 0 for the gain node 160 // initialGain: the initial gain at time 0 for the gain node
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 }) 194 })
226 .then(context.resume.bind(context)); 195 .then(context.resume.bind(context));
227 196
228 // Start the source and begin rendering, returning the promise from 197 // Start the source and begin rendering, returning the promise from
229 // rendering. 198 // rendering.
230 src.start(); 199 src.start();
231 200
232 return context.startRendering(); 201 return context.startRendering();
233 } 202 }
234 203
235 audit.runTasks(); 204 audit.run();
236 </script> 205 </script>
237 </body> 206 </body>
238 </html> 207 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698