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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/StereoPanner/stereopannernode-no-glitch.html

Issue 2695113003: Convert StereoPanner Audit tests to testharness (Closed)
Patch Set: Convert stereopannernode-basic.html 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
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/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audio-testing.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
11 <script> 12 <script>
12 description('Test if StereoPannerNode producing glitches by crossing zero.') ;
13 window.jsTestIsAsync = true;
14 13
hongchan 2017/02/17 18:36:19 I prefer to remove this empty line.
15 var sampleRate = 44100; 14 var sampleRate = 44100;
16 var renderDuration = 0.5; 15 var renderDuration = 0.5;
17 16
18 // The threshold for glitch detection. This was experimentally determined. 17 // The threshold for glitch detection. This was experimentally determined.
19 var GLITCH_THRESHOLD = 0.0005; 18 var GLITCH_THRESHOLD = 0.0005;
20 19
21 // The maximum threshold for the error between the actual and the expected 20 // The maximum threshold for the error between the actual and the expected
22 // sample values. Experimentally determined. 21 // sample values. Experimentally determined.
23 var MAX_ERROR_ALLOWED = 0.0000001; 22 var MAX_ERROR_ALLOWED = 0.0000001;
24 23
(...skipping 10 matching lines...) Expand all
35 function extractPanningTransition(input) { 34 function extractPanningTransition(input) {
36 var chanL = input.getChannelData(0); 35 var chanL = input.getChannelData(0);
37 var chanR = input.getChannelData(1); 36 var chanR = input.getChannelData(1);
38 var start, end; 37 var start, end;
39 var index = 1; 38 var index = 1;
40 39
41 // Find transition by comparing two consecutive samples. If two consecutiv e 40 // Find transition by comparing two consecutive samples. If two consecutiv e
42 // samples are identical, the transition has not started. 41 // samples are identical, the transition has not started.
43 while (chanL[index-1] === chanL[index] || chanR[index-1] === chanR[index]) { 42 while (chanL[index-1] === chanL[index] || chanR[index-1] === chanR[index]) {
44 if (++index >= input.length) { 43 if (++index >= input.length) {
44 // TODO(rtoy): Replace this
hongchan 2017/02/17 18:36:19 Not sure what this means. Replace how?
Raymond Toy 2017/02/17 19:18:41 Replaced with Should().summarize().
45 testFailed('No transition found in the channel data.'); 45 testFailed('No transition found in the channel data.');
46 return null; 46 return null;
47 } 47 }
48 } 48 }
49 start = index - 1; 49 start = index - 1;
50 50
51 // Find the end of transition. If two consecutive samples are not equal, 51 // Find the end of transition. If two consecutive samples are not equal,
52 // the transition is still ongoing. 52 // the transition is still ongoing.
53 while (chanL[index-1] !== chanL[index] || chanR[index-1] !== chanR[index]) { 53 while (chanL[index-1] !== chanL[index] || chanR[index-1] !== chanR[index]) {
54 if (++index >= input.length) { 54 if (++index >= input.length) {
55 // TODO(rtoy): Replace this
55 testFailed('A transition found but the buffer ended prematurely.'); 56 testFailed('A transition found but the buffer ended prematurely.');
56 return null; 57 return null;
57 } 58 }
58 } 59 }
59 end = index; 60 end = index;
60 61
61 testPassed('Transition found between sample #' + start + ' and #' + end + '.'); 62 //testPassed('Transition found between sample #' + start + ' and #' + end + '.');
hongchan 2017/02/17 18:36:19 Commented out, so we should remove this before lan
Raymond Toy 2017/02/17 19:18:41 Done.
63
64 Should('Transition found between sample #' + start + ' and #' + end,
65 true)
66 .summarize('correctly', 'incorrectly');
62 67
63 return { 68 return {
64 left: chanL.subarray(start, end), 69 left: chanL.subarray(start, end),
65 right: chanR.subarray(start, end), 70 right: chanR.subarray(start, end),
66 length: end - start 71 length: end - start
67 }; 72 };
68 } 73 }
69 74
70 // JS implementation of stereo equal power panning. 75 // JS implementation of stereo equal power panning.
71 function panStereoEqualPower(pan, inputL, inputR) { 76 function panStereoEqualPower(pan, inputL, inputR) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 169
165 170
166 // Task: move pan from positive (0.1) to negative (-0.1) value to check if 171 // Task: move pan from positive (0.1) to negative (-0.1) value to check if
167 // there is a glitch during the transition. 172 // there is a glitch during the transition.
168 audit.defineTask('positive-to-negative', function (done) { 173 audit.defineTask('positive-to-negative', function (done) {
169 panAndVerify({ startPanValue: 0.1, endPanValue: -0.1 }, done); 174 panAndVerify({ startPanValue: 0.1, endPanValue: -0.1 }, done);
170 }); 175 });
171 176
172 audit.defineTask('finish-test', function (done) { 177 audit.defineTask('finish-test', function (done) {
173 done(); 178 done();
174 finishJSTest();
175 }); 179 });
176 180
177 audit.runTasks( 181 audit.runTasks(
178 'negative-to-positive', 182 'negative-to-positive',
179 'positive-to-negative', 183 'positive-to-negative',
180 'finish-test' 184 'finish-test'
181 ); 185 );
182 186
183 successfullyParsed = true; 187 successfullyParsed = true;
184 </script> 188 </script>
185 </body> 189 </body>
186 190
187 </html> 191 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698