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

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: Fix typo 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
15 var sampleRate = 44100; 13 var sampleRate = 44100;
16 var renderDuration = 0.5; 14 var renderDuration = 0.5;
17 15
18 // The threshold for glitch detection. This was experimentally determined. 16 // The threshold for glitch detection. This was experimentally determined.
19 var GLITCH_THRESHOLD = 0.0005; 17 var GLITCH_THRESHOLD = 0.0005;
20 18
21 // The maximum threshold for the error between the actual and the expected 19 // The maximum threshold for the error between the actual and the expected
22 // sample values. Experimentally determined. 20 // sample values. Experimentally determined.
23 var MAX_ERROR_ALLOWED = 0.0000001; 21 var MAX_ERROR_ALLOWED = 0.0000001;
24 22
(...skipping 10 matching lines...) Expand all
35 function extractPanningTransition(input) { 33 function extractPanningTransition(input) {
36 var chanL = input.getChannelData(0); 34 var chanL = input.getChannelData(0);
37 var chanR = input.getChannelData(1); 35 var chanR = input.getChannelData(1);
38 var start, end; 36 var start, end;
39 var index = 1; 37 var index = 1;
40 38
41 // Find transition by comparing two consecutive samples. If two consecutiv e 39 // Find transition by comparing two consecutive samples. If two consecutiv e
42 // samples are identical, the transition has not started. 40 // samples are identical, the transition has not started.
43 while (chanL[index-1] === chanL[index] || chanR[index-1] === chanR[index]) { 41 while (chanL[index-1] === chanL[index] || chanR[index-1] === chanR[index]) {
44 if (++index >= input.length) { 42 if (++index >= input.length) {
45 testFailed('No transition found in the channel data.'); 43 Should(false, 'Transition in the channel data')
44 .summarize('found', 'not found');
46 return null; 45 return null;
47 } 46 }
48 } 47 }
49 start = index - 1; 48 start = index - 1;
50 49
51 // Find the end of transition. If two consecutive samples are not equal, 50 // Find the end of transition. If two consecutive samples are not equal,
52 // the transition is still ongoing. 51 // the transition is still ongoing.
53 while (chanL[index-1] !== chanL[index] || chanR[index-1] !== chanR[index]) { 52 while (chanL[index-1] !== chanL[index] || chanR[index-1] !== chanR[index]) {
54 if (++index >= input.length) { 53 if (++index >= input.length) {
55 testFailed('A transition found but the buffer ended prematurely.'); 54 Should(false, 'Transition found')
55 .summarize('', 'but the buffer ended prematurely');
56 return null; 56 return null;
57 } 57 }
58 } 58 }
59 end = index; 59 end = index;
60 60
61 testPassed('Transition found between sample #' + start + ' and #' + end + '.'); 61 Should('Transition found between sample #' + start + ' and #' + end,
62 true)
63 .summarize('correctly', 'incorrectly');
62 64
63 return { 65 return {
64 left: chanL.subarray(start, end), 66 left: chanL.subarray(start, end),
65 right: chanR.subarray(start, end), 67 right: chanR.subarray(start, end),
66 length: end - start 68 length: end - start
67 }; 69 };
68 } 70 }
69 71
70 // JS implementation of stereo equal power panning. 72 // JS implementation of stereo equal power panning.
71 function panStereoEqualPower(pan, inputL, inputR) { 73 function panStereoEqualPower(pan, inputL, inputR) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 166
165 167
166 // Task: move pan from positive (0.1) to negative (-0.1) value to check if 168 // Task: move pan from positive (0.1) to negative (-0.1) value to check if
167 // there is a glitch during the transition. 169 // there is a glitch during the transition.
168 audit.defineTask('positive-to-negative', function (done) { 170 audit.defineTask('positive-to-negative', function (done) {
169 panAndVerify({ startPanValue: 0.1, endPanValue: -0.1 }, done); 171 panAndVerify({ startPanValue: 0.1, endPanValue: -0.1 }, done);
170 }); 172 });
171 173
172 audit.defineTask('finish-test', function (done) { 174 audit.defineTask('finish-test', function (done) {
173 done(); 175 done();
174 finishJSTest();
175 }); 176 });
176 177
177 audit.runTasks( 178 audit.runTasks(
178 'negative-to-positive', 179 'negative-to-positive',
179 'positive-to-negative', 180 'positive-to-negative',
180 'finish-test' 181 'finish-test'
181 ); 182 );
182
183 successfullyParsed = true;
184 </script> 183 </script>
185 </body> 184 </body>
186 185
187 </html> 186 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698