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..c2d60261ec5f359264cdc4f702d5ca22cbff90b5 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,61 @@ |
description('Test the late call of start(0) of BufferSource.'); |
window.jsTestIsAsync = true; |
- var audit = Audit.createTaskRunner(); |
- |
var sampleRate = 44100; |
+ var renderLength = sampleRate; |
- // 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; |
- |
- var context = new OfflineAudioContext(1, sampleRate * renderLength, sampleRate); |
- var dcOffsetbuffer = createConstantBuffer(context, 1000, 1.0); |
+ var context = new OfflineAudioContext(1, renderLength, sampleRate); |
+ var dcOffsetbuffer = createConstantBuffer(context, 1, 1.0); |
var source = context.createBufferSource(); |
source.buffer = dcOffsetbuffer; |
+ source.loop = true; |
+ source.connect(context.destination); |
+ |
Raymond Toy
2015/12/01 22:14:37
Since you only have one task now, I'd put all of t
hongchan
2015/12/02 18:58:31
Done.
|
+ var audit = Audit.createTaskRunner(); |
+ |
+ // Task: define |onstatechange| and start rendering. |
+ audit.defineTask('test-late-start', function (done) { |
+ |
+ // 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. |
+ // |
+ // See issue: crbug.com/462167 |
+ context.suspend(0.01).then(function () { |
Raymond Toy
2015/12/01 22:14:37
Does it matter that 0.01 gets quantized to a rende
hongchan
2015/12/02 18:58:31
With the sample rate of 44100, 0.01 second is abou
|
+ 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 nonZeroValueIndex = -1; |
+ var channelData = buffer.getChannelData(0); |
+ for (var i = 0; i < channelData.length; i++) { |
+ if (channelData[i] !== 0) { |
+ nonZeroValueIndex = i; |
+ break; |
+ } |
+ } |
Raymond Toy
2015/12/01 22:14:37
Can you use ES6 findIndex() to find the non-zero v
hongchan
2015/12/02 18:58:31
NEAT! 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.'); |
+ |
+ }).then(done); |
+ }); |
+ |
+ 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> |