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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/resources/late-start-testing.js

Issue 2693853004: Fix flakiness in webaudio/Oscillator/oscillator-late-start.html (Closed)
Patch Set: Remove |Should| from test function arguments Created 3 years, 10 months 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
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/Oscillator/oscillator-late-start-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 function runLateStartTest(audit, context, node) { 1 function runLateStartTest(audit, context, node) {
2 2
3 // Set up a dummy signal path to keep the audio context running and spend 3 // Set up a dummy signal path to keep the audio context running and spend
4 // processing time before calling start(0). 4 // processing time before calling start(0).
5 var osc = context.createOscillator(); 5 var osc = context.createOscillator();
6 var silent = context.createGain(); 6 var silent = context.createGain();
7 7
8 osc.connect(silent); 8 osc.connect(silent);
9 silent.connect(context.destination); 9 silent.connect(context.destination);
10 silent.gain.setValueAtTime(0.0, 0); 10 silent.gain.setValueAtTime(0.0, 0);
11 osc.start(); 11 osc.start();
12 12
13 node.connect(context.destination); 13 node.connect(context.destination);
14 14
15 // Task: define |onstatechange| and start rendering. 15 // Task: schedule a suspend and start rendering.
16 audit.defineTask('test-late-start', function (done) { 16 audit.defineTask('test-late-start', function (done) {
17 17 // The node's start time will be clamped to the render quantum boundary
18 // Trigger playback at 0 second. The assumptions are: 18 // >0.1 sec. Thus the rendered buffer will have non-zero frames.
19 //
20 // 1) The specified timing of start() call is already passed in terms of
21 // the context time. So the argument |0| will be clamped to the current
22 // context time.
23 // 2) The |onstatechange| event will be fired later than the 0 second
24 // context time.
25 //
26 // See issue: crbug.com/462167 19 // See issue: crbug.com/462167
27 context.onstatechange = function () { 20 context.suspend(0.1).then(() => {
28 if (context.state === 'running') { 21 node.start(0);
29 node.start(0); 22 context.resume();
30 } 23 });
31 };
32 24
33 // Start rendering and verify result: this verifies if 1) the rendered 25 // Start rendering and verify result: this verifies if 1) the rendered
34 // buffer contains at least one non-zero value and 2) the non-zero value is 26 // buffer contains at least one non-zero value and 2) the non-zero value is
35 // found later than the first output sample. 27 // found later than the first output sample.
36 context.startRendering().then(function (buffer) { 28 context.startRendering().then(function (buffer) {
37
38 var nonZeroValueIndex = -1; 29 var nonZeroValueIndex = -1;
39 var channelData = buffer.getChannelData(0); 30 var channelData = buffer.getChannelData(0);
40 for (var i = 0; i < channelData.length; i++) { 31 for (var i = 0; i < channelData.length; i++) {
41 if (channelData[i] !== 0) { 32 if (channelData[i] !== 0) {
42 nonZeroValueIndex = i; 33 nonZeroValueIndex = i;
43 break; 34 break;
44 } 35 }
45 } 36 }
46 37
47 if (nonZeroValueIndex === -1) { 38 var success = Should('Non-zero value index', nonZeroValueIndex)
48 testFailed('The rendered buffer was all zeros.'); 39 .notBeEqualTo(-1);
Raymond Toy 2017/02/13 22:13:01 Nit: this is not a great message to print out. Don
hongchan 2017/02/13 22:33:58 Done.
49 } else if (nonZeroValueIndex === 0) { 40 success = Should('Non-zero value index', nonZeroValueIndex)
50 testFailed('The first sample was non-zero value. It should be zero.'); 41 .notBeEqualTo(0) && success;
Raymond Toy 2017/02/13 22:13:02 Maybe say 'First non-zero value found at index'. O
hongchan 2017/02/13 22:33:58 I changed it in a slightly different way.
51 } else { 42 Should('The rendered buffer', success)
52 testPassed('The rendered buffer contains non-zero values after the first sample.'); 43 .summarize('contains non-zero values after the first sample',
53 } 44 'was all zeros or has non-zero first sample.');
54 45
55 done(); 46 done();
56 }); 47 });
57 }); 48 });
58 49
59 audit.defineTask('finish-test', function (done) { 50 audit.defineTask('finish-test', function (done) {
60 done(); 51 done();
61 finishJSTest(); 52 finishJSTest();
62 }); 53 });
63 54
64 audit.runTasks( 55 audit.runTasks(
65 'test-late-start', 56 'test-late-start',
66 'finish-test' 57 'finish-test'
67 ); 58 );
68 59
69 } 60 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/Oscillator/oscillator-late-start-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698