|
|
Chromium Code Reviews|
Created:
4 years ago by Raymond Toy Modified:
3 years, 11 months ago Reviewers:
hongchan CC:
chromium-reviews, blink-reviews Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionConvert realtimeanalyser-fft-scaling to testharness
Test converted to use testharness and new Audit. By doing this, we
also remove the flakiness caused by oncomplete handler finishing at
different times.
The expected result file is also removed.
BUG=675987, 676708
TEST=realtimeanalyser-fft-scaling.html
Committed: https://crrev.com/faa3e9c3de15cf738fac0bc21406f2af3cc424c7
Cr-Commit-Position: refs/heads/master@{#441209}
Patch Set 1 #Patch Set 2 : Clean up implementation #Patch Set 3 : Slightly simplify creation of tests #Patch Set 4 : Rebase #
Messages
Total messages: 15 (8 generated)
rtoy@chromium.org changed reviewers: + hongchan@chromium.org
PTAL. The actual output: This is a testharness.js-based test. PASS # AUDIT TASK RUNNER STARTED. PASS > [FFT scaling tests] Test Scaling of FFT in AnalyserNode PASS 32-point FFT peak position is equal to 1. PASS 32-point FFT peak value in dBFS is greater than or equal to -14.43. PASS 64-point FFT peak position is equal to 2. PASS 64-point FFT peak value in dBFS is greater than or equal to -13.56. PASS 128-point FFT peak position is equal to 4. PASS 128-point FFT peak value in dBFS is greater than or equal to -13.56. PASS 256-point FFT peak position is equal to 8. PASS 256-point FFT peak value in dBFS is greater than or equal to -13.56. PASS 512-point FFT peak position is equal to 16. PASS 512-point FFT peak value in dBFS is greater than or equal to -13.56. PASS 1024-point FFT peak position is equal to 32. PASS 1024-point FFT peak value in dBFS is greater than or equal to -13.56. PASS 2048-point FFT peak position is equal to 64. PASS 2048-point FFT peak value in dBFS is greater than or equal to -13.56. PASS < [FFT scaling tests] All assertions passed. (total 14 assertions) PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. Harness: the test ran to completion.
lgtm
The CQ bit was checked by rtoy@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for
third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html:
While running git apply --index -p1;
error: patch failed:
third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html:1
error:
third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html:
patch does not apply
Patch:
third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html
Index:
third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html
diff --git
a/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html
b/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html
index
25b6c88835d82e5c1f5392edfce1ae41f36cb9f4..2f102a284851ac94ec0648a7cba207053c17417f
100644
---
a/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html
+++
b/third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-fft-scaling.html
@@ -1,10 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
- <script src="../../resources/js-test.js"></script>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
<script src="../resources/compatibility.js"></script>
<script src="../resources/audit-util.js"></script>
- <script src="../resources/audio-testing.js"></script>
+ <script src="../resources/audit.js"></script>
</head>
<body>
@@ -12,21 +13,21 @@
<div id="console"></div>
<script>
- description("Test scaling of FFT data for AnalyserNode");
+ let audit = Audit.createTaskRunner();
// The number of analysers. We have analysers from size for each of the
possible sizes of 32,
// 64, 128, 256, 512, 1024 and 2048 for a total of 7.
- var numberOfAnalysers = 7;
- var sampleRate = 44100;
- var nyquistFrequency = sampleRate / 2;
+ let numberOfAnalysers = 7;
+ let sampleRate = 44100;
+ let nyquistFrequency = sampleRate / 2;
// Frequency of the sine wave test signal. Should be high enough so that
we get at least one
// full cycle for the 32-point FFT. This should also be such that the
frequency should be
// exactly in one of the FFT bins for each of the possible FFT sizes.
- var oscFrequency = nyquistFrequency/16;
+ let oscFrequency = nyquistFrequency/16;
// The actual peak values from each analyser. Useful for examining the
results in Chrome.
- var peakValue = new Array(numberOfAnalysers);
+ let peakValue = new Array(numberOfAnalysers);
// For a 0dBFS sine wave, we would expect the FFT magnitude to be 0dB as
well, but the
// analyzer node applies a Blackman window (to smooth the estimate).
This reduces the energy
@@ -34,22 +35,20 @@
// determined experimentally.
//
// See https://code.google.com/p/chromium/issues/detail?id=341596.
- var peakThreshold = [-14.43, -13.56, -13.56, -13.56, -13.56, -13.56,
-13.56];
+ let peakThreshold = [-14.43, -13.56, -13.56, -13.56, -13.56, -13.56,
-13.56];
- var allTestsPassed = true;
-
- function checkResult(order, analyser) {
+ function checkResult(order, analyser, should) {
return function () {
- var index = order - 5;
- var fftSize = 1 << order;
- var fftData = new Float32Array(fftSize);
+ let index = order - 5;
+ let fftSize = 1 << order;
+ let fftData = new Float32Array(fftSize);
analyser.getFloatFrequencyData(fftData);
// Compute the frequency bin that should contain the peak.
- var expectedBin = analyser.frequencyBinCount * (oscFrequency /
nyquistFrequency);
+ let expectedBin = analyser.frequencyBinCount * (oscFrequency /
nyquistFrequency);
// Find the actual bin by finding the bin containing the peak.
- var actualBin = 0;
+ let actualBin = 0;
peakValue[index] = -1000;
for (k = 0; k < analyser.frequencyBinCount; ++k) {
if (fftData[k] > peakValue[index]) {
@@ -58,77 +57,48 @@
}
}
- var success = true;
-
- if (actualBin == expectedBin) {
- testPassed("Actual FFT peak in the expected position (" +
expectedBin + ").");
- } else {
- success = false;
- testFailed("Actual FFT peak (" + actualBin + ") differs from
expected (" + expectedBin + ").");
- }
-
- if (peakValue[index] >= peakThreshold[index]) {
- testPassed("Peak value is near " + peakThreshold[index] + "
dBFS as expected.");
- } else {
- success = false;
- testFailed("Peak value of " + peakValue[index]
- + " is incorrect. (Expected approximately "
- + peakThreshold[index] + ").");
- }
-
- if (success) {
- testPassed("Analyser correctly scaled FFT data of size " +
fftSize);
- } else {
- testFailed("Analyser incorrectly scaled FFT data of size " +
fftSize);
- }
- allTestsPassed = allTestsPassed && success;
+ should(actualBin, (1 << order) + "-point FFT peak position")
+ .beEqualTo(expectedBin);
- if (fftSize == 2048) {
- if (allTestsPassed) {
- testPassed("All Analyser tests passed.");
- } else {
- testFailed("At least one Analyser test failed.");
- }
-
- finishJSTest();
- }
+ should(peakValue[index], (1 << order) +
+ "-point FFT peak value in dBFS")
+ .beGreaterThanOrEqualTo(peakThreshold[index]);
}
}
- function runTests() {
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
-
- window.jsTestIsAsync = true;
-
- // Test each analyser size from order 5 (size 32) to 11 (size 2048).
- for (order = 5; order < 12; ++order) {
- // Create a new offline context for each analyser test with the
number of samples
- // exactly equal to the fft size. This ensures that the analyser
node gets the
- // expected data from the oscillator.
- var context = new OfflineAudioContext(1, 1 << order, sampleRate);
- // Use a sine wave oscillator as the reference source signal.
- var osc = context.createOscillator();
- osc.type = "sine";
- osc.frequency.value = oscFrequency;
- osc.connect(context.destination);
-
- var analyser = context.createAnalyser();
- // No smoothing to simplify the analysis of the result.
- analyser.smoothingTimeConstant = 0;
- analyser.fftSize = 1 << order;
- osc.connect(analyser);
-
- osc.start();
- context.oncomplete = checkResult(order, analyser);
- context.startRendering();
- }
+ audit.define("FFT scaling tests", function (task, should) {
+ task.describe("Test Scaling of FFT in AnalyserNode");
+ let tests = [];
+ for (let k = 5; k < 12; ++k)
+ tests.push(runTest(k, should));
+
+ Promise.all(tests)
+ .then(task.done.bind(task));
+ });
+
+ function runTest(order, should) {
+ let context = new OfflineAudioContext(1, 1 << order, sampleRate);
+ // Use a sine wave oscillator as the reference source signal.
+ let osc = context.createOscillator();
+ osc.type = "sine";
+ osc.frequency.value = oscFrequency;
+ osc.connect(context.destination);
+
+ let analyser = context.createAnalyser();
+ // No smoothing to simplify the analysis of the result.
+ analyser.smoothingTimeConstant = 0;
+ analyser.fftSize = 1 << order;
+ osc.connect(analyser);
+
+ osc.start();
+ context.oncomplete = checkResult(order, analyser, should);
+ return context.startRendering()
+ .then(function (audioBuffer) {
+ checkResult(audioBuffer, order, analyser);
+ });
}
- runTests();
- successfullyParsed = true;
+ audit.run();
</script>
</body>
</html>
The CQ bit was checked by rtoy@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from hongchan@chromium.org Link to the patchset: https://codereview.chromium.org/2596983004/#ps60001 (title: "Rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 60001, "attempt_start_ts": 1483473912652580,
"parent_rev": "695615d5dcfbe28051f1bcf8252559071a0c5d15", "commit_rev":
"fbe56769f8b05a7772990a3f8dab28d35242a93e"}
Message was sent while issue was closed.
Description was changed from ========== Convert realtimeanalyser-fft-scaling to testharness Test converted to use testharness and new Audit. By doing this, we also remove the flakiness caused by oncomplete handler finishing at different times. The expected result file is also removed. BUG=675987, 676708 TEST=realtimeanalyser-fft-scaling.html ========== to ========== Convert realtimeanalyser-fft-scaling to testharness Test converted to use testharness and new Audit. By doing this, we also remove the flakiness caused by oncomplete handler finishing at different times. The expected result file is also removed. BUG=675987, 676708 TEST=realtimeanalyser-fft-scaling.html Review-Url: https://codereview.chromium.org/2596983004 ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001)
Message was sent while issue was closed.
Description was changed from ========== Convert realtimeanalyser-fft-scaling to testharness Test converted to use testharness and new Audit. By doing this, we also remove the flakiness caused by oncomplete handler finishing at different times. The expected result file is also removed. BUG=675987, 676708 TEST=realtimeanalyser-fft-scaling.html Review-Url: https://codereview.chromium.org/2596983004 ========== to ========== Convert realtimeanalyser-fft-scaling to testharness Test converted to use testharness and new Audit. By doing this, we also remove the flakiness caused by oncomplete handler finishing at different times. The expected result file is also removed. BUG=675987, 676708 TEST=realtimeanalyser-fft-scaling.html Committed: https://crrev.com/faa3e9c3de15cf738fac0bc21406f2af3cc424c7 Cr-Commit-Position: refs/heads/master@{#441209} ==========
Message was sent while issue was closed.
Patchset 4 (id:??) landed as https://crrev.com/faa3e9c3de15cf738fac0bc21406f2af3cc424c7 Cr-Commit-Position: refs/heads/master@{#441209} |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
