OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test Constructor: ConstantSource</title> | 4 <title>Test Constructor: ConstantSource</title> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
7 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
8 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audit.js"></script> |
| 9 <script src="new-audionodeoptions.js"></script> |
9 </head> | 10 </head> |
10 | 11 |
11 <body> | 12 <body> |
12 <script> | 13 <script> |
13 var context; | 14 var context; |
14 | 15 |
15 var audit = Audit.createTaskRunner(); | 16 var audit = Audit.createTaskRunner(); |
16 | 17 |
17 audit.defineTask("initialize", function (taskDone) { | 18 audit.define('initialize', (task, should) => { |
18 Should("context = new OfflineAudioContext(...)", function () { | 19 context = initializeContext(should); |
19 context = new OfflineAudioContext(1, 1, 48000); | 20 task.done(); |
20 }).notThrow(); | |
21 taskDone(); | |
22 }); | 21 }); |
23 | 22 |
24 audit.defineTask("invalid constructor", function (taskDone) { | 23 audit.define('invalid constructor', (task, should) => { |
25 var node; | 24 testInvalidConstructor(should, 'ConstantSourceNode', context); |
26 var success = true; | 25 task.done(); |
27 | |
28 succes = Should("new ConstantSourceNode()", function () { | |
29 node = new ConstantSourceNode(); | |
30 }).throw("TypeError"); | |
31 success = Should("new ConstantSourceNode(1)", function () { | |
32 node = new ConstantSourceNode(1); | |
33 }).throw("TypeError") && success; | |
34 success = Should("new ConstantSourceNode(context, 42)", function () { | |
35 node = new ConstantSourceNode(context, 42); | |
36 }).throw("TypeError") && success; | |
37 | |
38 Should("*** Invalid constructors", success) | |
39 .summarize( | |
40 "correctly threw errors", | |
41 "did not throw errors in all cases"); | |
42 taskDone(); | |
43 }); | 26 }); |
44 | 27 |
45 audit.defineTask("default constructor", function (taskDone) { | 28 audit.define('default constructor', (task, should) => { |
46 var node; | 29 let prefix = 'node0'; |
47 var success = true; | 30 let node = |
| 31 testDefaultConstructor(should, 'ConstantSourceNode', context, { |
| 32 prefix: prefix, |
| 33 numberOfInputs: 0, |
| 34 numberOfOutputs: 1, |
| 35 channelCount: 2, |
| 36 channelCountMode: 'max', |
| 37 channelInterpretation: 'speakers' |
| 38 }); |
48 | 39 |
49 success = Should("node = new ConstantSourceNode(context)", function () { | 40 testDefaultAttributes( |
50 node = new ConstantSourceNode(context); | 41 should, node, prefix, [{name: 'offset', value: 1}]); |
51 }).notThrow(); | |
52 success = Should("node instanceOf ConstantSourceNode", node instanceof C
onstantSourceNode) | |
53 .beEqualTo(true) && success; | |
54 success = Should("node.offset.value", node.offset.value) | |
55 .beEqualTo(1) && success; | |
56 | 42 |
57 success = Should("node.channelCount", node.channelCount) | 43 task.done(); |
58 .beEqualTo(2) && success; | |
59 success = Should("node.channelCountMode", node.channelCountMode) | |
60 .beEqualTo("max") && success; | |
61 success = Should("node.channelInterpretation", node.channelInterpretatio
n) | |
62 .beEqualTo("speakers") && success; | |
63 | |
64 success = Should("*** new AnalyserNode(context)", success) | |
65 .summarize( | |
66 "constructed node with correct attributes", | |
67 "did not construct correct node correctly") | |
68 | |
69 taskDone(); | |
70 }); | 44 }); |
71 | 45 |
72 audit.runTasks(); | 46 audit.run(); |
73 </script> | 47 </script> |
74 </body> | 48 </body> |
75 </html> | 49 </html> |
OLD | NEW |