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