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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.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/audiochannelmerger-disconnect.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html b/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
index c100b8f4d629e8f188ba8484cd97c2aba019e9a7..c9724cb8d0246e5508414de4332ba946fa398062 100644
--- a/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
+++ b/third_party/WebKit/LayoutTests/webaudio/audiochannelmerger-disconnect.html
@@ -12,29 +12,24 @@
description('Test ChannelMergerNode behavior on dynamic input change.');
window.jsTestIsAsync = true;
- var sampleRate = 44100;
var numberOfChannels = 2;
-
- // The test needs the long render length (20 seconds) to capture the
- // disconnection which happens after starting the rendering.
- var renderLength = sampleRate * 20;
+ var sampleRate = 44100;
+ var renderLength = 2 * sampleRate;
var audit = Audit.createTaskRunner();
// Task: Check if the merger outputs a silent channel when an input is
// disconnected.
audit.defineTask('silent-disconnect', function (done) {
- var context = new OfflineAudioContext(
- numberOfChannels, renderLength, sampleRate
- );
+ var context = new OfflineAudioContext(numberOfChannels, renderLength, sampleRate);
var merger = context.createChannelMerger();
var source1 = context.createBufferSource();
var source2 = context.createBufferSource();
- // Create and assign a mono testing buffer.
- var bufferDCOffset = createTestingAudioBuffer(context, 1, renderLength);
- source1.buffer = bufferDCOffset;
- source2.buffer = bufferDCOffset;
+ // Create and assign a constant buffer.
+ var bufferDCOffset = createConstantBuffer(context, 1, 1);
+ source1.buffer = source2.buffer = bufferDCOffset;
+ source1.loop = source2.loop = true;
// Connect the output of source into the 4th input of merger. The merger
// should produce 6 channel output.
@@ -43,23 +38,20 @@
merger.connect(context.destination);
source1.start();
source2.start();
-
- // When the rendering begins, disconnect |source2| as soon as possible.
- context.onstatechange = function () {
- if (context.state === 'running')
- source2.disconnect();
- };
+
+ // Schedule the disconnection of |source2| at 1 second.
Raymond Toy 2015/12/01 22:14:37 We could make this test much faster if we didn't r
hongchan 2015/12/02 18:58:31 I thought you'd ask! I will reduce the render leng
Raymond Toy 2015/12/02 19:37:50 Seems to me that you did 1/2 sec for the tests. T
+ context.suspend(1.0).then(function () {
+ source2.disconnect();
+ context.resume();
+ });
context.startRendering().then(function (buffer) {
-
// The entire first channel of the output should be 1.
Should('Channel #0', buffer.getChannelData(0)).beConstantValueOf(1);
// The second channel should contain 1, and 0 after the disconnection.
Raymond Toy 2015/12/01 22:14:37 Now that we know exactly when the disconnect happe
hongchan 2015/12/02 18:58:31 Done.
Should('Channel #1', buffer.getChannelData(1)).containValues([1, 0]);
-
- done();
- });
+ }).then(done);
});
audit.defineTask('finish', function (done) {
@@ -67,10 +59,7 @@
done();
});
- audit.runTasks(
- 'silent-disconnect',
- 'finish'
- );
+ audit.runTasks();
successfullyParsed = true;
</script>

Powered by Google App Engine
This is Rietveld 408576698