OLD | NEW |
1 <!doctype html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
| 4 <title> |
| 5 Test Scheduled Sources with Huge Time Limits |
| 6 </title> |
4 <script src="../../resources/testharness.js"></script> | 7 <script src="../../resources/testharness.js"></script> |
5 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
6 <script src="../resources/audit-util.js"></script> | 9 <script src="../resources/audit-util.js"></script> |
7 <script src="../resources/audit.js"></script> | 10 <script src="../resources/audit.js"></script> |
8 <script src="../resources/audioparam-testing.js"></script> | 11 <script src="../resources/audioparam-testing.js"></script> |
9 <title>Test Scheduled Sources with Huge Time Limits</title> | |
10 </head> | 12 </head> |
| 13 <body> |
| 14 <script id="layout-test-code"> |
| 15 let sampleRate = 48000; |
| 16 let renderFrames = 1000; |
11 | 17 |
12 <body> | 18 let audit = Audit.createTaskRunner(); |
13 <script> | |
14 | 19 |
15 var sampleRate = 48000; | 20 audit.define('buffersource: huge stop time', (task, should) => { |
16 var renderFrames = 1000; | |
17 | |
18 var audit = Audit.createTaskRunner(); | |
19 | |
20 audit.define("buffersource: huge stop time", (task, should) => { | |
21 // We only need to generate a small number of frames for this test. | 21 // We only need to generate a small number of frames for this test. |
22 var context = new OfflineAudioContext(1, renderFrames, sampleRate); | 22 let context = new OfflineAudioContext(1, renderFrames, sampleRate); |
23 var src = context.createBufferSource(); | 23 let src = context.createBufferSource(); |
24 | 24 |
25 // Constant source of amplitude 1, looping. | 25 // Constant source of amplitude 1, looping. |
26 src.buffer = createConstantBuffer(context, 1, 1); | 26 src.buffer = createConstantBuffer(context, 1, 1); |
27 src.loop = true; | 27 src.loop = true; |
28 | 28 |
29 // Create the graph and go! | 29 // Create the graph and go! |
30 var endTime = 1e300; | 30 let endTime = 1e300; |
31 src.connect(context.destination); | 31 src.connect(context.destination); |
32 src.start(); | 32 src.start(); |
33 src.stop(endTime); | 33 src.stop(endTime); |
34 | 34 |
35 context.startRendering().then(function (resultBuffer) { | 35 context.startRendering() |
36 var result = resultBuffer.getChannelData(0); | 36 .then(function(resultBuffer) { |
37 should(result, | 37 let result = resultBuffer.getChannelData(0); |
38 "Output from AudioBufferSource.stop(" + endTime + ")") | 38 should( |
39 .beConstantValueOf(1); | 39 result, 'Output from AudioBufferSource.stop(' + endTime + ')') |
40 }).then(() => task.done()); | 40 .beConstantValueOf(1); |
| 41 }) |
| 42 .then(() => task.done()); |
41 }); | 43 }); |
42 | 44 |
43 | 45 |
44 audit.define("oscillator: huge stop time", (task, should) => { | 46 audit.define('oscillator: huge stop time', (task, should) => { |
45 // We only need to generate a small number of frames for this test. | 47 // We only need to generate a small number of frames for this test. |
46 var context = new OfflineAudioContext(1, renderFrames, sampleRate); | 48 let context = new OfflineAudioContext(1, renderFrames, sampleRate); |
47 var src = context.createOscillator(); | 49 let src = context.createOscillator(); |
48 | 50 |
49 // Create the graph and go! | 51 // Create the graph and go! |
50 var endTime = 1e300; | 52 let endTime = 1e300; |
51 src.connect(context.destination); | 53 src.connect(context.destination); |
52 src.start(); | 54 src.start(); |
53 src.stop(endTime); | 55 src.stop(endTime); |
54 | 56 |
55 context.startRendering().then(function (resultBuffer) { | 57 context.startRendering() |
56 var result = resultBuffer.getChannelData(0); | 58 .then(function(resultBuffer) { |
57 // The buffer should not be empty. Just find the max and verify that
it's not zero. | 59 let result = resultBuffer.getChannelData(0); |
58 var max = Math.max.apply(null, result); | 60 // The buffer should not be empty. Just find the max and verify |
59 should(max, | 61 // that it's not zero. |
60 "Peak amplitude from oscillator.stop(" + endTime + ")") | 62 let max = Math.max.apply(null, result); |
61 .beGreaterThan(0); | 63 should( |
62 }).then(() => task.done()); | 64 max, 'Peak amplitude from oscillator.stop(' + endTime + ')') |
| 65 .beGreaterThan(0); |
| 66 }) |
| 67 .then(() => task.done()); |
63 }); | 68 }); |
64 | 69 |
65 | 70 |
66 audit.run(); | 71 audit.run(); |
67 </script> | 72 </script> |
68 </body> | 73 </body> |
69 </html> | 74 </html> |
OLD | NEW |