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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/audiobuffersource-late-start.html

Issue 1488693006: Fix flaky WebAudio layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Feedback from rtoy 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/audiobuffersource-late-start.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/audiobuffersource-late-start.html b/third_party/WebKit/LayoutTests/webaudio/audiobuffersource-late-start.html
index 0f61eca7ae3b7ec693f278bc04da3ea455a2a268..e48b6f96fe40284eae74f91486ebca5a32858b43 100644
--- a/third_party/WebKit/LayoutTests/webaudio/audiobuffersource-late-start.html
+++ b/third_party/WebKit/LayoutTests/webaudio/audiobuffersource-late-start.html
@@ -5,7 +5,6 @@
<script src="../resources/js-test.js"></script>
<script src="resources/compatibility.js"></script>
<script src="resources/audio-testing.js"></script>
- <script src="resources/late-start-testing.js"></script>
</head>
<body>
@@ -13,22 +12,60 @@
description('Test the late call of start(0) of BufferSource.');
window.jsTestIsAsync = true;
+ var sampleRate = 44100;
+ var renderDuration = 0.25;
+
var audit = Audit.createTaskRunner();
- var sampleRate = 44100;
+ audit.defineTask('test-late-start', function (done) {
+ var context = new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
+ var dcOffsetbuffer = createConstantBuffer(context, 1, 1.0);
+ var source = context.createBufferSource();
+ source.buffer = dcOffsetbuffer;
+ source.loop = true;
+ source.connect(context.destination);
+
+ // Schedule source.start(0) at 0.01 second. The specified timing of
+ // start() call is already passed in terms of the context time. So the
+ // argument |0| will be clamped to the current context time.
+ //
+ // With the sample rate of 44100, 0.01 second is 441 samples. Rounding
+ // it down to the render quantum gives 384 samples. This is clearly larger
+ // than a single render quantum.
+ //
+ // See issue: crbug.com/462167
+ context.suspend(0.01).then(function () {
+ source.start(0);
+ context.resume();
+ });
+
+ // Start rendering and verify result: this verifies if 1) the rendered
+ // buffer contains at least one non-zero value and 2) the non-zero value is
+ // found later than the first output sample.
+ context.startRendering().then(function (buffer) {
+
+ var channelData = buffer.getChannelData(0);
+ var nonZeroValueIndex = channelData.findIndex(function (element, index) {
+ if (element !== 0)
+ return index;
Raymond Toy 2015/12/02 19:33:41 Would it be better to return explicitly true or fa
hongchan 2015/12/03 19:28:31 Done.
+ });
+
+ if (nonZeroValueIndex === -1)
+ testFailed('The rendered buffer was all zeros.');
+ else if (nonZeroValueIndex === 0)
+ testFailed('The first sample was non-zero value. It should be zero.');
+ else
+ testPassed('The rendered buffer contains non-zero values after the first sample.');
Raymond Toy 2015/12/02 19:33:41 Should we check that the first nonZeroValueIndex i
hongchan 2015/12/03 19:28:31 Done.
- // The long render length (30 seconds) is to make sure the |onstatechange|
- // event gets fired to start the source, which can take quite a bit of time.
- var renderLength = 30;
+ }).then(done);
+ });
- var context = new OfflineAudioContext(1, sampleRate * renderLength, sampleRate);
- var dcOffsetbuffer = createConstantBuffer(context, 1000, 1.0);
- var source = context.createBufferSource();
- source.buffer = dcOffsetbuffer;
+ audit.defineTask('finish-test', function (done) {
+ done();
+ finishJSTest();
+ });
- // Test the buffer node is rendered correctly when the start time of start()
- // call is in the past in terms of the context time.
- runLateStartTest(audit, context, source);
+ audit.runTasks();
successfullyParsed = true;
</script>

Powered by Google App Engine
This is Rietveld 408576698