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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-freq-data.html

Issue 2595633002: Convert Analyser tests to use testharness (Closed)
Patch Set: Remove jsTestIsAsync Created 4 years 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 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../resources/compatibility.js"></script> 6 <script src="../resources/compatibility.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 <script src="../resources/realtimeanalyser-testing.js"></script> 9 <script src="../resources/realtimeanalyser-testing.js"></script>
9 <script src="../resources/fft.js"></script> 10 <script src="../resources/fft.js"></script>
10 <title>Test Analyser getFloatFrequencyData and getByteFrequencyData, No Smoo thing</title> 11 <title>Test Analyser getFloatFrequencyData and getByteFrequencyData, No Smoo thing</title>
11 </head> 12 </head>
12 13
13 <body> 14 <body>
14 <script> 15 <script>
15 description("Test AnalyserNode getFloatFrequencyData and getByteFrequencyD ata, no Smoothing");
16 window.jsTestIsAsync = true;
17 16
18 // Use a power of two to eliminate any round-off in the computation of the times for 17 // Use a power of two to eliminate any round-off in the computation of the times for
19 // context.suspend(). 18 // context.suspend().
20 var sampleRate = 32768; 19 var sampleRate = 32768;
21 20
22 // The largest FFT size for the analyser node is 32768. We want to render longer than this so 21 // The largest FFT size for the analyser node is 32768. We want to render longer than this so
23 // that we have at least one complete buffer of data of 32768 samples. 22 // that we have at least one complete buffer of data of 32768 samples.
24 var renderFrames = 2 * 32768; 23 var renderFrames = 2 * 32768;
25 var renderDuration = renderFrames / sampleRate; 24 var renderDuration = renderFrames / sampleRate;
26 25
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 var name = testConfig[k].order + "-order FFT"; 74 var name = testConfig[k].order + "-order FFT";
76 (function (config) { 75 (function (config) {
77 audit.defineTask(name, function (done) { 76 audit.defineTask(name, function (done) {
78 basicFFTTest(config).then(done); 77 basicFFTTest(config).then(done);
79 }); 78 });
80 })(testConfig[k]); 79 })(testConfig[k]);
81 } 80 }
82 81
83 // Just print a summary of the result of the above tests. 82 // Just print a summary of the result of the above tests.
84 audit.defineTask("summarize basic tests", function (done) { 83 audit.defineTask("summarize basic tests", function (done) {
85 if (basicTestsPassed) 84 Should("Basic frequency data computed", basicTestsPassed)
86 testPassed("Basic frequency data computed correctly.\n"); 85 .summarize("correctly", "incorrectly");
87 else
88 testFailed("Basic frequency data computed incorrectly.\n");
89 done(); 86 done();
90 }); 87 });
91 88
92 // Test that smoothing isn't done and we have the expected data, calling g etFloatFrequencyData 89 // Test that smoothing isn't done and we have the expected data, calling g etFloatFrequencyData
93 // twice at different times. 90 // twice at different times.
94 audit.defineTask("no smoothing", function (done) { 91 audit.defineTask("no smoothing", function (done) {
95 // Use 128-point FFT for the test. The actual order doesn't matter (but the error threshold 92 // Use 128-point FFT for the test. The actual order doesn't matter (but the error threshold
96 // depends on the order). 93 // depends on the order).
97 var options = { 94 var options = {
98 order: 7, 95 order: 7,
(...skipping 26 matching lines...) Expand all
125 122
126 // Grab the time domain and frequency domain data 123 // Grab the time domain and frequency domain data
127 analyser.getFloatTimeDomainData(timeData); 124 analyser.getFloatTimeDomainData(timeData);
128 analyser.getFloatFrequencyData(freqData); 125 analyser.getFloatFrequencyData(freqData);
129 126
130 var expected = computeFFTMagnitude(timeData, options.order).map(linear ToDb); 127 var expected = computeFFTMagnitude(timeData, options.order).map(linear ToDb);
131 var comparison = compareFloatFreq(Math.pow(2, options.order) + "-point float FFT", 128 var comparison = compareFloatFreq(Math.pow(2, options.order) + "-point float FFT",
132 freqData, expected, options); 129 freqData, expected, options);
133 basicTestsPassed = basicTestsPassed && comparison.success; 130 basicTestsPassed = basicTestsPassed && comparison.success;
134 131
135 if (comparison.success) 132 Should("Smoothing constant of 0", comparison.success)
136 testPassed("Smoothing constant of 0 correctly handled.\n"); 133 .summarize("correctly handled", "incorrectly handled");
137 else
138 testFailed("Smoothing constant of 0 incorrectly handled.\n");
139 }).then(context.resume.bind(context)); 134 }).then(context.resume.bind(context));
140 135
141 context.startRendering().then(done); 136 context.startRendering().then(done);
142 }); 137 });
143 138
144 audit.defineTask("finish", function (done) { 139 audit.defineTask("finish", function (done) {
145 finishJSTest();
146 done(); 140 done();
147 }); 141 });
148 142
149 audit.runTasks(); 143 audit.runTasks();
150 144
151 // Run a simple test of the AnalyserNode's frequency domain data. Both th e float and byte 145 // Run a simple test of the AnalyserNode's frequency domain data. Both th e float and byte
152 // frequency data are tested. The byte tests depend on the float tests be ing correct. 146 // frequency data are tested. The byte tests depend on the float tests be ing correct.
153 // 147 //
154 // The parameters of the test are given by |options| which is a property b ag consisting of the 148 // The parameters of the test are given by |options| which is a property b ag consisting of the
155 // following: 149 // following:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 basicTestsPassed = Should(analyser.fftSize + "-point byte FFT", byteFr eqData) 200 basicTestsPassed = Should(analyser.fftSize + "-point byte FFT", byteFr eqData)
207 .beCloseToArray(expectedByteData, 0) && basicTestsPassed; 201 .beCloseToArray(expectedByteData, 0) && basicTestsPassed;
208 202
209 }).then(context.resume.bind(context)); 203 }).then(context.resume.bind(context));
210 204
211 return context.startRendering(); 205 return context.startRendering();
212 } 206 }
213 </script> 207 </script>
214 </body> 208 </body>
215 </html> 209 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698