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