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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/audionode-disconnect-audioparam.html

Issue 1488693006: Fix flaky WebAudio layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webaudio/audionode-disconnect-audioparam.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/audionode-disconnect-audioparam.html b/third_party/WebKit/LayoutTests/webaudio/audionode-disconnect-audioparam.html
index 3c9f1fb4d523d31e29f039d0a096a90fa9c2ffb7..84d1565f37ac1cf689ea4666bb1084f754ab1138 100644
--- a/third_party/WebKit/LayoutTests/webaudio/audionode-disconnect-audioparam.html
+++ b/third_party/WebKit/LayoutTests/webaudio/audionode-disconnect-audioparam.html
@@ -12,12 +12,10 @@
description('Test disconnect() method on AudioParam destination.');
window.jsTestIsAsync = true;
- var audit = Audit.createTaskRunner();
+ var sampleRate = 44100;
+ var renderLength = 2 * sampleRate;
- // The long render length (20 seconds) test 1 and 2 is to make sure the
- // |onstatechange| event gets fired to start the source, which can take
- // quite a bit of time.
- var testDuration = 20;
+ var audit = Audit.createTaskRunner();
// Task 1: test disconnect(AudioParam) method.
audit.defineTask('disconnect(AudioParam)', function (done) {
@@ -25,14 +23,16 @@
// Creates a buffer source with value [1] and then connect it to two gain
// nodes in series. The output of the buffer source is lowered by half
// (* 0.5) and then connected to two |.gain| AudioParams in each gain node.
+ //
// (1) bufferSource => gain1 => gain2
// (2) bufferSource => half => gain1.gain
// (3) half => gain2.gain
+ //
// This graph should produce the output of 2.25 (= 1 * 1.5 * 1.5). After
// disconnecting (3), it should produce 1.5.
- var context = new OfflineAudioContext(1, 44100 * testDuration, 44100);
+ var context = new OfflineAudioContext(1, renderLength, sampleRate);
var source = context.createBufferSource();
- var buffer1ch = createTestingAudioBuffer(context, 1, 128);
+ var buffer1ch = createTestingAudioBuffer(context, 1, 1);
var half = context.createGain();
var gain1 = context.createGain();
var gain2 = context.createGain();
@@ -54,26 +54,14 @@
source.start();
- // Disconnects after the rendering starts.
- //
- // FIXME: Although this guarantees that the disconnection happens after
- // the rendering starts, still the actual disconnection might happen after
- // oncomplete event fired.
- //
- // The 10ms delay is 1/1000 of the total render length (10,000ms). Because
- // OfflineAudioContext runs faster than real time, the disconnection might
- // happen after the rendering finishes. Then lower the delay and increase
- // the render length to avoid the test failure.
- context.onstatechange = function () {
- if (context.state === 'running')
- half.disconnect(gain2.gain);
- };
+ // Schedule the disconnection at 1.0 second.
Raymond Toy 2015/12/01 22:14:37 Can we run the test for a much shorter duration?
hongchan 2015/12/02 18:58:31 Done.
+ context.suspend(1.0).then(function () {
+ half.disconnect(gain2.gain);
+ context.resume();
+ });
context.startRendering().then(function (buffer) {
-
- // Note that this test depends on the disconnection below to happen
- // sometime during rendering.
-
+
// Expected values are: 1 * 1.5 * 1.5 -> 1 * 1.5 = [2.25, 1.5]
Raymond Toy 2015/12/01 22:14:37 We should probably check the values change at exac
hongchan 2015/12/02 18:58:32 Done.
Should('Channel #0', buffer.getChannelData(0)).containValues([2.25, 1.5]);
@@ -87,13 +75,15 @@
// make a serial connection through gain1 and gain 2. The make the buffer
// source half with a gain node and connect it to a 2-output splitter.
// Connect each output to 2 gain AudioParams respectively.
+ //
// (1) bufferSource => gain1 => gain2
// (2) bufferSource => half => splitter(2)
// (3) splitter#0 => gain1.gain
// (4) splitter#1 => gain2.gain
+ //
// This graph should produce 3 (= 1 * 1.5 * 2) and 6 (= 2 * 1.5 * 2) for
// each channel. After disconnecting (4), it should output 1.5 and 3.
- var context = new OfflineAudioContext(2, 44100 * testDuration, 44100);
+ var context = new OfflineAudioContext(2, renderLength, sampleRate);
var source = context.createBufferSource();
var buffer2ch = createTestingAudioBuffer(context, 2, 128);
var splitter = context.createChannelSplitter(2);
@@ -123,12 +113,11 @@
source.start();
- // Disconnect after the rendering starts. See the comment in the previous
- // test task.
- context.onstatechange = function () {
- if (context.state === 'running')
- splitter.disconnect(gain2.gain, 1);
- };
+ // Schedule the disconnect at 1 second.
+ context.suspend(1.0).then(function () {
+ splitter.disconnect(gain2.gain, 1);
+ context.resume();
+ });
context.startRendering().then(function (buffer) {

Powered by Google App Engine
This is Rietveld 408576698