OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title> |
| 5 realtimeanalyser-fft-sizing.html |
| 6 </title> |
| 7 <script src="../../resources/testharness.js"></script> |
| 8 <script src="../../resources/testharnessreport.js"></script> |
| 9 <script src="../resources/audit-util.js"></script> |
| 10 <script src="../resources/audit.js"></script> |
| 11 </head> |
| 12 <body> |
| 13 <script id="layout-test-code"> |
| 14 let audit = Audit.createTaskRunner(); |
2 | 15 |
3 <html> | 16 function doTest(fftSize, illegal, should) { |
4 <head> | 17 let c = new OfflineAudioContext(1, 1000, 44100); |
5 <script src="../../resources/testharness.js"></script> | 18 let a = c.createAnalyser(); |
6 <script src="../../resources/testharnessreport.js"></script> | 19 let message = 'Setting fftSize to ' + fftSize; |
7 <script src="../resources/audit-util.js"></script> | 20 let tester = function() { |
8 <script src="../resources/audit.js"></script> | 21 a.fftSize = fftSize; |
9 </head> | 22 }; |
10 | 23 |
11 <body> | 24 if (illegal) { |
12 <script> | 25 should(tester, message).throw('IndexSizeError'); |
13 let audit = Audit.createTaskRunner(); | 26 } else { |
| 27 should(tester, message).notThrow(); |
| 28 } |
| 29 } |
14 | 30 |
15 function doTest(fftSize, illegal, should) { | 31 audit.define( |
16 let c = new OfflineAudioContext(1, 1000, 44100); | 32 { |
17 let a = c.createAnalyser(); | 33 label: 'FFT size test', |
18 let message = "Setting fftSize to " + fftSize; | 34 description: 'Test that re-sizing the FFT arrays does not fail.' |
19 let tester = function () { | 35 }, |
20 a.fftSize = fftSize; | 36 function(task, should) { |
21 }; | 37 doTest(-1, true, should); |
| 38 doTest(0, true, should); |
| 39 doTest(1, true, should); |
| 40 for (let i = 2; i <= 0x20000; i *= 2) { |
| 41 if (i >= 32 && i <= 32768) |
| 42 doTest(i, false, should); |
| 43 else |
| 44 doTest(i, true, should); |
| 45 doTest(i + 1, true, should); |
| 46 } |
22 | 47 |
23 if (illegal) { | 48 task.done(); |
24 should(tester, message) | 49 }); |
25 .throw("IndexSizeError"); | |
26 } else { | |
27 should(tester, message) | |
28 .notThrow(); | |
29 } | |
30 } | |
31 | 50 |
32 audit.define({ | 51 audit.run(); |
33 label: "FFT size test", | 52 </script> |
34 description: "Test that re-sizing the FFT arrays does not fail." | 53 </body> |
35 }, function (task, should) { | |
36 doTest(-1, true, should); | |
37 doTest(0, true, should); | |
38 doTest(1, true, should); | |
39 for (let i = 2; i <= 0x20000; i *= 2) { | |
40 if (i >= 32 && i <= 32768) | |
41 doTest(i, false, should); | |
42 else | |
43 doTest(i, true, should); | |
44 doTest(i + 1, true, should); | |
45 } | |
46 | |
47 task.done(); | |
48 }); | |
49 | |
50 audit.run(); | |
51 </script> | |
52 | |
53 </body> | |
54 </html> | 54 </html> |
OLD | NEW |