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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 3
4 <head> 4 <head>
5 <script src="../resources/js-test.js"></script> 5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script> 6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audio-testing.js"></script> 7 <script src="resources/audio-testing.js"></script>
8 <script src="resources/late-start-testing.js"></script>
9 </head> 8 </head>
10 9
11 <body> 10 <body>
12 <script> 11 <script>
13 description('Test the late call of start(0) of BufferSource.'); 12 description('Test the late call of start(0) of BufferSource.');
14 window.jsTestIsAsync = true; 13 window.jsTestIsAsync = true;
15 14
15 var sampleRate = 44100;
16 var renderLength = sampleRate;
17
18 var context = new OfflineAudioContext(1, renderLength, sampleRate);
19 var dcOffsetbuffer = createConstantBuffer(context, 1, 1.0);
20 var source = context.createBufferSource();
21 source.buffer = dcOffsetbuffer;
22 source.loop = true;
23 source.connect(context.destination);
24
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.
16 var audit = Audit.createTaskRunner(); 25 var audit = Audit.createTaskRunner();
17 26
18 var sampleRate = 44100; 27 // Task: define |onstatechange| and start rendering.
28 audit.defineTask('test-late-start', function (done) {
19 29
20 // The long render length (30 seconds) is to make sure the |onstatechange| 30 // Schedule source.start(0) at 0.01 second. The specified timing of
21 // event gets fired to start the source, which can take quite a bit of time. 31 // start() call is already passed in terms of the context time. So the
22 var renderLength = 30; 32 // argument |0| will be clamped to the current context time.
33 //
34 // See issue: crbug.com/462167
35 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
36 source.start(0);
37 context.resume();
38 });
23 39
24 var context = new OfflineAudioContext(1, sampleRate * renderLength, sampleRa te); 40 // Start rendering and verify result: this verifies if 1) the rendered
25 var dcOffsetbuffer = createConstantBuffer(context, 1000, 1.0); 41 // buffer contains at least one non-zero value and 2) the non-zero value i s
26 var source = context.createBufferSource(); 42 // found later than the first output sample.
27 source.buffer = dcOffsetbuffer; 43 context.startRendering().then(function (buffer) {
28 44
29 // Test the buffer node is rendered correctly when the start time of start() 45 var nonZeroValueIndex = -1;
30 // call is in the past in terms of the context time. 46 var channelData = buffer.getChannelData(0);
31 runLateStartTest(audit, context, source); 47 for (var i = 0; i < channelData.length; i++) {
48 if (channelData[i] !== 0) {
49 nonZeroValueIndex = i;
50 break;
51 }
52 }
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.
53
54 if (nonZeroValueIndex === -1)
55 testFailed('The rendered buffer was all zeros.');
56 else if (nonZeroValueIndex === 0)
57 testFailed('The first sample was non-zero value. It should be zero.');
58 else
59 testPassed('The rendered buffer contains non-zero values after the fir st sample.');
60
61 }).then(done);
62 });
63
64 audit.defineTask('finish-test', function (done) {
65 done();
66 finishJSTest();
67 });
68
69 audit.runTasks();
32 70
33 successfullyParsed = true; 71 successfullyParsed = true;
34 </script> 72 </script>
35 </body> 73 </body>
36 74
37 </html> 75 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698