| OLD | NEW |
| 1 <!doctype html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test Constructor: Oscillator</title> | 4 <title> |
| 5 Test Constructor: Oscillator |
| 6 </title> |
| 5 <script src="../../resources/testharness.js"></script> | 7 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../resources/audit-util.js"></script> | 9 <script src="../resources/audit-util.js"></script> |
| 8 <script src="../resources/audit.js"></script> | 10 <script src="../resources/audit.js"></script> |
| 9 <script src="audionodeoptions.js"></script> | 11 <script src="audionodeoptions.js"></script> |
| 10 </head> | 12 </head> |
| 13 <body> |
| 14 <script id="layout-test-code"> |
| 15 let context; |
| 11 | 16 |
| 12 <body> | 17 let audit = Audit.createTaskRunner(); |
| 13 <script> | |
| 14 var context; | |
| 15 | |
| 16 var audit = Audit.createTaskRunner(); | |
| 17 | 18 |
| 18 audit.define('initialize', (task, should) => { | 19 audit.define('initialize', (task, should) => { |
| 19 context = initializeContext(should); | 20 context = initializeContext(should); |
| 20 task.done(); | 21 task.done(); |
| 21 }); | 22 }); |
| 22 | 23 |
| 23 audit.define('invalid constructor', (task, should) => { | 24 audit.define('invalid constructor', (task, should) => { |
| 24 testInvalidConstructor(should, 'OscillatorNode', context); | 25 testInvalidConstructor(should, 'OscillatorNode', context); |
| 25 task.done(); | 26 task.done(); |
| 26 }); | 27 }); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 | 43 |
| 43 task.done(); | 44 task.done(); |
| 44 }); | 45 }); |
| 45 | 46 |
| 46 audit.define('test AudioNodeOptions', (task, should) => { | 47 audit.define('test AudioNodeOptions', (task, should) => { |
| 47 testAudioNodeOptions(should, context, 'OscillatorNode'); | 48 testAudioNodeOptions(should, context, 'OscillatorNode'); |
| 48 task.done(); | 49 task.done(); |
| 49 }); | 50 }); |
| 50 | 51 |
| 51 audit.define('constructor options', (task, should) => { | 52 audit.define('constructor options', (task, should) => { |
| 52 var node; | 53 let node; |
| 53 var options = {type: 'sawtooth', detune: 7, frequency: 918}; | 54 let options = {type: 'sawtooth', detune: 7, frequency: 918}; |
| 54 | 55 |
| 55 should( | 56 should( |
| 56 () => { | 57 () => { |
| 57 node = new OscillatorNode(context, options); | 58 node = new OscillatorNode(context, options); |
| 58 }, | 59 }, |
| 59 'node1 = new OscillatorNode(c, ' + JSON.stringify(options) + ')') | 60 'node1 = new OscillatorNode(c, ' + JSON.stringify(options) + ')') |
| 60 .notThrow(); | 61 .notThrow(); |
| 61 | 62 |
| 62 should(node.type, 'node1.type').beEqualTo(options.type); | 63 should(node.type, 'node1.type').beEqualTo(options.type); |
| 63 should(node.detune.value, 'node1.detune.value') | 64 should(node.detune.value, 'node1.detune.value') |
| 64 .beEqualTo(options.detune); | 65 .beEqualTo(options.detune); |
| 65 should(node.frequency.value, 'node1.frequency.value') | 66 should(node.frequency.value, 'node1.frequency.value') |
| 66 .beEqualTo(options.frequency); | 67 .beEqualTo(options.frequency); |
| 67 | 68 |
| 68 should(node.channelCount, 'node1.channelCount').beEqualTo(2); | 69 should(node.channelCount, 'node1.channelCount').beEqualTo(2); |
| 69 should(node.channelCountMode, 'node1.channelCountMode') | 70 should(node.channelCountMode, 'node1.channelCountMode') |
| 70 .beEqualTo('max'); | 71 .beEqualTo('max'); |
| 71 should(node.channelInterpretation, 'node1.channelInterpretation') | 72 should(node.channelInterpretation, 'node1.channelInterpretation') |
| 72 .beEqualTo('speakers'); | 73 .beEqualTo('speakers'); |
| 73 | 74 |
| 74 // Test that type and periodicWave options work as described. | 75 // Test that type and periodicWave options work as described. |
| 75 options = { | 76 options = { |
| 76 type: 'sine', | 77 type: 'sine', |
| 77 periodicWave: new PeriodicWave(context, {real: [1, 1]}) | 78 periodicWave: new PeriodicWave(context, {real: [1, 1]}) |
| 78 }; | 79 }; |
| 79 should( | 80 should(() => { |
| 80 () => { | 81 node = new OscillatorNode(context, options); |
| 81 node = new OscillatorNode(context, options); | 82 }, 'new OscillatorNode(c, ' + JSON.stringify(options) + ')').notThrow(); |
| 82 }, | |
| 83 'new OscillatorNode(c, ' + JSON.stringify(options) + ')') | |
| 84 .notThrow(); | |
| 85 | 83 |
| 86 options = {type: 'custom'}; | 84 options = {type: 'custom'}; |
| 87 should( | 85 should( |
| 88 () => { | 86 () => { |
| 89 node = new OscillatorNode(context, options); | 87 node = new OscillatorNode(context, options); |
| 90 }, | 88 }, |
| 91 'new OscillatorNode(c, ' + JSON.stringify(options) + ')') | 89 'new OscillatorNode(c, ' + JSON.stringify(options) + ')') |
| 92 .throw('InvalidStateError'); | 90 .throw('InvalidStateError'); |
| 93 | 91 |
| 94 options = { | 92 options = { |
| 95 type: 'custom', | 93 type: 'custom', |
| 96 periodicWave: new PeriodicWave(context, {real: [1, 1]}) | 94 periodicWave: new PeriodicWave(context, {real: [1, 1]}) |
| 97 }; | 95 }; |
| 98 should(() => { | 96 should(() => { |
| 99 node = new OscillatorNode(context, options); | 97 node = new OscillatorNode(context, options); |
| 100 }, 'new OscillatorNode(, ' + JSON.stringify(options) + ')').notThrow(); | 98 }, 'new OscillatorNode(, ' + JSON.stringify(options) + ')').notThrow(); |
| 101 | 99 |
| 102 task.done(); | 100 task.done(); |
| 103 }); | 101 }); |
| 104 | 102 |
| 105 audit.run(); | 103 audit.run(); |
| 106 </script> | 104 </script> |
| 107 </body> | 105 </body> |
| 108 </html> | 106 </html> |
| OLD | NEW |