OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test Constructor: AudioBufferSource</title> |
| 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../resources/compatibility.js"></script> |
| 8 </head> |
| 9 |
| 10 <body> |
| 11 <script> |
| 12 var context; |
| 13 |
| 14 test(function () { |
| 15 context = new OfflineAudioContext(1, 1, 48000); |
| 16 assert_true(context instanceof AudioContext, |
| 17 "context created successfully"); |
| 18 }, "Construct offline context"); |
| 19 |
| 20 test(function () { |
| 21 assert_throws(null, |
| 22 function () { |
| 23 return new AudioBufferSourceNode(); |
| 24 }, "One argument required"); |
| 25 assert_throws(null, |
| 26 function () { |
| 27 return new AudioBufferSourceNode(1); |
| 28 }, "Invalid context argument"); |
| 29 assert_throws(null, |
| 30 function () { |
| 31 return new AudioBufferSourceNode(context, 42); |
| 32 }, "Second argument must be an object"); |
| 33 }); |
| 34 |
| 35 test(function () { |
| 36 // Construct a default AnalyserNode |
| 37 var node = new AudioBufferSourceNode(context); |
| 38 assert_true(node instanceof AudioBufferSourceNode, |
| 39 "new AudioBufferSourceNode(context)"); |
| 40 }, "Construct basic AudioBufferSourceNode"); |
| 41 |
| 42 test(function () { |
| 43 // Construct an AudioBufferSourceNode with options |
| 44 var buf = context.createBuffer(1, 1, context.sampleRate); |
| 45 var options = { |
| 46 buffer: buf, |
| 47 detune: 1, |
| 48 loop: true, |
| 49 loopEnd: 0.5, |
| 50 loopStart: 1.0, |
| 51 playbackRate: .25 |
| 52 }; |
| 53 var node = new AudioBufferSourceNode(context, options); |
| 54 assert_true(node instanceof AudioBufferSourceNode, |
| 55 "new AudioBufferSourceNode(context, options)"); |
| 56 // Verify node has the correct values. |
| 57 assert_equals(node.buffer, options.buffer); |
| 58 assert_equals(node.detune.value, options.detune); |
| 59 assert_equals(node.loop, options.loop); |
| 60 assert_equals(node.loopEnd, options.loopEnd); |
| 61 assert_equals(node.loopStart, options.loopStart); |
| 62 assert_equals(node.playbackRate.value, options.playbackRate); |
| 63 }, "Construct AudioBufferSourceNode with options"); |
| 64 </script> |
| 65 </body> |
| 66 </html> |
OLD | NEW |