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

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

Issue 2672093002: Convert PeriodicWave Audit tests to testharness (Closed)
Patch Set: Clean up. Created 3 years, 10 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 | « no previous file | third_party/WebKit/LayoutTests/webaudio/PeriodicWave/periodicwave-lengths-expected.txt » ('j') | 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 Different PeriodicWave Lengths at Different Sample Rates</title> 4 <title>Test Different PeriodicWave Lengths at Different Sample Rates</title>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audio-testing.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
11 <script> 12 <script>
12 description("Test Different PeriodicWave Lengths at Different Sample Rates ");
13 window.jsTestIsAsync = true;
14
15 // Test PeriodicWave objects with varying number of coefficients at differ ent sample rates. 13 // Test PeriodicWave objects with varying number of coefficients at differ ent sample rates.
16 // Basically, verify that the coefficients are used at the appropriate sam ple rates. This is 14 // Basically, verify that the coefficients are used at the appropriate sam ple rates. This is
17 // done by comparing the outputs of two periodic waves used in oscillators . The output should 15 // done by comparing the outputs of two periodic waves used in oscillators . The output should
18 // either be exactly zero or not depending on whether the coefficients wer e used. 16 // either be exactly zero or not depending on whether the coefficients wer e used.
19 17
20 var renderLength = 1; 18 var renderLength = 1;
21 var context; 19 var context;
22 20
23 var audit = Audit.createTaskRunner(); 21 var audit = Audit.createTaskRunner();
24 22
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return "At " + (sampleRate / 1000) + " kHz, PeriodicWave with " 138 return "At " + (sampleRate / 1000) + " kHz, PeriodicWave with "
141 + bigLength + " coefficients vs " 139 + bigLength + " coefficients vs "
142 + smallLength + ": "; 140 + smallLength + ": ";
143 } 141 }
144 142
145 // Returns a function the verifies that the result is zero. The parameter s control what is 143 // Returns a function the verifies that the result is zero. The parameter s control what is
146 // printed in the messages. 144 // printed in the messages.
147 function resultShouldBeZero(sampleRate, bigLength, smallLength) { 145 function resultShouldBeZero(sampleRate, bigLength, smallLength) {
148 return function (buffer) { 146 return function (buffer) {
149 var prefix = generatePrefix(sampleRate, bigLength, smallLength); 147 var prefix = generatePrefix(sampleRate, bigLength, smallLength);
150 if (isBufferZero(buffer)) 148 Should(prefix + "are identical", isBufferZero(buffer))
151 testPassed(prefix + "identical as expected."); 149 .beEqualTo(true);
152 else
153 testFailed(prefix + "unexpectedly differ.");
154 } 150 }
155 } 151 }
156 152
157 // Returns a function the verifies that the result is non-zero. The param eters control what is 153 // Returns a function the verifies that the result is non-zero. The param eters control what is
158 // printed in the messages. 154 // printed in the messages.
159 function resultShouldBeNonZero(sampleRate, bigLength, smallLength) { 155 function resultShouldBeNonZero(sampleRate, bigLength, smallLength) {
160 return function (buffer) { 156 return function (buffer) {
161 var prefix = generatePrefix(sampleRate, bigLength, smallLength); 157 var prefix = generatePrefix(sampleRate, bigLength, smallLength);
162 if (!isBufferZero(buffer)) 158 Should(prefix + "are different", !isBufferZero(buffer))
163 testPassed(prefix + "differ as expected."); 159 .beEqualTo(true);
164 else
165 testFailed(prefix + "unexpectedly are identical.");
166 } 160 }
167 } 161 }
168 162
169 // Creates a function that is used to run an Audit test for a given sample rate, periodic wave 163 // Creates a function that is used to run an Audit test for a given sample rate, periodic wave
170 // sizes, and verifier. 164 // sizes, and verifier.
171 function createAuditTestFunction(sampleRate, bigLength, smallLength, verif ier) { 165 function createAuditTestFunction(sampleRate, bigLength, smallLength, verif ier) {
172 return function (done) { 166 return function (done) {
173 // Create the audio graph, render it, and then verify that the output is the expected 167 // Create the audio graph, render it, and then verify that the output is the expected
174 // result. 168 // result.
175 createAudioGraph(sampleRate, bigLength, smallLength); 169 createAudioGraph(sampleRate, bigLength, smallLength);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 234 }
241 235
242 // Define the tasks based on the entries in testSet. 236 // Define the tasks based on the entries in testSet.
243 function defineAuditTests () { 237 function defineAuditTests () {
244 for (var k = 0; k < testSet.length; ++k) { 238 for (var k = 0; k < testSet.length; ++k) {
245 var test = testSet[k]; 239 var test = testSet[k];
246 var actualName = actualTestName(test.name, k); 240 var actualName = actualTestName(test.name, k);
247 audit.defineTask(actualName, 241 audit.defineTask(actualName,
248 createAuditTestFunction(test.sampleRate, test.bigWave, test.smallWav e, test.verifier)); 242 createAuditTestFunction(test.sampleRate, test.bigWave, test.smallWav e, test.verifier));
249 } 243 }
250 // Define the finish test last.
251 audit.defineTask(actualTestName("finish-tests", testSet.length), functio n (done) {
252 finishJSTest();
253 done();
254 });
255 } 244 }
256 245
257 defineAuditTests(); 246 defineAuditTests();
258 audit.runTasks(); 247 audit.runTasks();
259 248
260 successfullyParsed = true; 249 successfullyParsed = true;
261 </script> 250 </script>
262 </body> 251 </body>
263 </html> 252 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/PeriodicWave/periodicwave-lengths-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698