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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/PeriodicWave/periodicwave-normalization.html

Issue 2789093004: Convert PeriodicWave tests to use new Audit (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/PeriodicWave/periodicwave-lengths.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test PeriodicWave Normalization</title> 4 <title>Test PeriodicWave Normalization</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 var sampleRate = 48000; 13 var sampleRate = 48000;
14 var renderFrames = 6000; 14 var renderFrames = 6000;
15 var context; 15 var context;
16 var audit = Audit.createTaskRunner(); 16 var audit = Audit.createTaskRunner();
17 17
18 var testSet = [ 18 var testSet = [
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 osc.setPeriodicWave(wave); 170 osc.setPeriodicWave(wave);
171 osc.connect(context.destination); 171 osc.connect(context.destination);
172 osc.start(); 172 osc.start();
173 173
174 return context.startRendering().then(verify); 174 return context.startRendering().then(verify);
175 } 175 }
176 176
177 // Define a test function from the given test parameter. This is used as the Audit.defineTask 177 // Define a test function from the given test parameter. This is used as the Audit.defineTask
178 // task function. 178 // task function.
179 function defineTest(test) { 179 function defineTest(testInfo) {
180 return function (done) { 180 return (task, should) => {
181 var imagCoef = new Float32Array(test.realCoef.length); 181 var imagCoef = new Float32Array(testInfo.realCoef.length);
182 createAndRunAudioGraph(test.option, test.realCoef, imagCoef, function (result) { 182 createAndRunAudioGraph(testInfo.option, testInfo.realCoef, imagCoef, f unction (result) {
183 var prefix; 183 var prefix;
184 184
185 // Try to print out the test.option in a reasonably nice but explici t way. 185 // Try to print out the test.option in a reasonably nice but explici t way.
186 if (test.option === "NONE") { 186 if (testInfo.option === "NONE") {
187 prefix = ""; 187 prefix = "";
188 } else if (Array.isArray(test.option)) { 188 } else if (Array.isArray(testInfo.option)) {
189 prefix = "[" + test.option + "]: "; 189 prefix = "[" + testInfo.option + "]: ";
190 } else { 190 } else {
191 prefix = JSON.stringify(test.option) + ": "; 191 prefix = JSON.stringify(testInfo.option) + ": ";
192 } 192 }
193 193
194 Should(prefix + "amplitude", arrayMax(result.getChannelData(0))) 194 should(arrayMax(result.getChannelData(0)), prefix + "amplitude")
195 .beCloseTo(test.expectedMax, test.threshold); 195 .beCloseTo(testInfo.expectedMax, {threshold: testInfo.threshold});
196 }).then(done); 196 }).then(() => task.done());
197 }; 197 };
198 } 198 }
199 199
200 // Ensure the actual Audit test name is unique by prepending an index to t he provided test 200 // Ensure the actual Audit test name is unique by prepending an index to t he provided test
201 // name. 201 // name.
202 function actualTestName(name, index) { 202 function actualTestName(name, index) {
203 return index + ":" + name; 203 return index + ":" + name;
204 } 204 }
205 205
206 function defineTasks() { 206 function defineTasks() {
207 for (var k = 0; k < testSet.length; ++k) { 207 for (var k = 0; k < testSet.length; ++k) {
208 var test = testSet[k]; 208 var testInfo = testSet[k];
209 audit.defineTask(actualTestName(test.name, k), defineTest(test)); 209 audit.define(actualTestName(test.name, k), defineTest(testInfo));
210 } 210 }
211 } 211 }
212 212
213 defineTasks(); 213 defineTasks();
214 audit.runTasks(); 214 audit.run();
215 215
216 successfullyParsed = true; 216 successfullyParsed = true;
217 </script> 217 </script>
218 </body> 218 </body>
219 </html> 219 </html>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/PeriodicWave/periodicwave-lengths.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698