OLD | NEW |
---|---|
(Empty) | |
1 <!doctype html> | |
2 <html> | |
3 <head> | |
4 <title>Test Constructor: ChannelMerger</title> | |
5 <script src="../../resources/testharness.js"></script> | |
6 <script src="../../resources/testharnessreport.js"></script> | |
7 <script src="../resources/audio-testing.js"></script> | |
8 <script src="audionodeoptions.js"></script> | |
9 </head> | |
10 | |
11 <body> | |
12 <script> | |
13 var context; | |
14 | |
15 var audit = Audit.createTaskRunner(); | |
16 | |
17 audit.defineTask("initialize", function (taskDone) { | |
18 Should("context = new OfflineAudioContext(...)", function () { | |
19 context = new OfflineAudioContext(1, 1, 48000); | |
20 }).notThrow(); | |
21 | |
22 taskDone(); | |
23 }); | |
24 | |
25 audit.defineTask("invalid constructor", function (taskDone) { | |
26 var node; | |
27 var success = true; | |
28 | |
29 success = Should("new ChannelMergerNode()", function () { | |
30 node = new ChannelMergerNode(); | |
31 }).throw("TypeError"); | |
32 success = Should("new ChannelMergerNode(1)", function () { | |
33 node = new ChannelMergerNode(1) && success; | |
34 }).throw("TypeError"); | |
35 success = Should("new ChannelMergerNode(context, 42)", function () { | |
36 node = new ChannelMergerNode(context, 42) && success; | |
37 }).throw("TypeError"); | |
38 | |
39 Should("Invalid constructors", success) | |
40 .summarize( | |
41 "correctly threw errors", | |
42 "did not throw errors in all cases"); | |
43 | |
44 taskDone(); | |
45 }); | |
46 | |
47 audit.defineTask("default constructor", function (taskDone) { | |
48 var node; | |
49 var success = true; | |
50 | |
51 success = Should("node = new ChannelMergerNode(context)", function () { | |
52 node = new ChannelMergerNode(context); | |
53 }).notThrow(); | |
54 success = Should("node instanceof ChannelMergerNode", node instanceof Ch annelMergerNode) | |
55 .beEqualTo(true) && success; | |
56 | |
57 success = Should("node.numberOfInputs", node.numberOfInputs) | |
58 .beEqualTo(6) && success; | |
59 success = Should("node.numberOfOutputs", node.numberOfOutputs) | |
60 .beEqualTo(1) && success; | |
61 success = Should("node.channelCount", node.channelCount) | |
62 .beEqualTo(1) && success; | |
63 success = Should("node.channelCountMode", node.channelCountMode) | |
64 .beEqualTo("explicit") && success; | |
65 success = Should("node.channelInterpretation", node.channelInterpretatio n) | |
66 .beEqualTo("speakers") && success; | |
67 | |
68 Should("new ChannelMergerNode(context)", success) | |
69 .summarize( | |
70 "constructed node with correct attributes", | |
71 "did not construct correct node correctly") | |
72 | |
73 taskDone(); | |
74 }); | |
75 | |
76 audit.defineTask("test AudioNodeOptions", function (taskDone) { | |
77 testAudioNodeOptions(context, "ChannelMergerNode", { | |
78 expectedChannelCount: { | |
79 value: 1, | |
80 isFixed: true, | |
81 errorType: "InvalidStateError" | |
82 }, | |
83 expectedChannelCountMode: { | |
84 value: "explicit", | |
85 isFixed: true, | |
86 errorType: "InvalidStateError" | |
87 } | |
88 }); | |
89 taskDone(); | |
90 }); | |
91 | |
92 audit.defineTask("constructor options", function (taskDone) { | |
93 var node; | |
94 var success = true; | |
95 var options = { | |
96 numberOfInputs: 3, | |
97 numberOfOutputs: 9, | |
98 channelInterpretation: "discrete" | |
99 }; | |
100 | |
101 success = Should("node = new ChannelMergerNode(context, <options>)", fun ction () { | |
102 node = new ChannelMergerNode(context, options); | |
103 }).notThrow(); | |
104 | |
105 success = Should("node.numberOfInputs", node.numberOfInputs) | |
106 .beEqualTo(options.numberOfInputs) && success; | |
107 success = Should("node.numberOfOutputs", node.numberOfOutputs) | |
108 .beEqualTo(1) && success; | |
109 success = Should("node.channelInterpretation", node.channelInterpretatio n) | |
110 .beEqualTo(options.channelInterpretation) && success; | |
111 | |
112 success = Should("new ChannelMergerNode(..., { numberOfInputs: 99 }", | |
hongchan
2016/09/13 22:13:22
We can use the same technique for { numberOfInputs
Raymond Toy
2016/09/14 18:02:22
Done.
| |
113 function () { | |
114 node = new ChannelMergerNode(context, { | |
115 numberOfInputs: 99 | |
116 }); | |
117 }) | |
118 .throw("IndexSizeError") && success; | |
119 success = Should("new ChannelMergerNode(..., { channelCount: 3 }", | |
120 function () { | |
121 node = new ChannelMergerNode(context, { | |
122 channelCount: 3 | |
123 }); | |
124 }) | |
125 .throw("InvalidStateError") && success; | |
126 success = Should('new ChannelMergerNode(..., { channelCountMode: "max"} ', | |
127 function () { | |
128 node = new ChannelMergerNode(context, { | |
129 channelCountMode: "max" | |
130 }); | |
131 }) | |
132 .throw("InvalidStateError") && success; | |
133 | |
134 Should("new ChannelMergerNode() with options", success) | |
135 .summarize( | |
136 "constructed with correct attributes", | |
137 "was not constructed correctly"); | |
138 | |
139 taskDone(); | |
140 }); | |
141 | |
142 audit.runTasks(); | |
143 </script> | |
144 </body> | |
145 </html> | |
OLD | NEW |