Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/constructor/stereopanner.html

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test Constructor: StereoPanner</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 StereoPannerNode()", function () {
30 node = new StereoPannerNode();
31 }).throw("TypeError");
32 success = Should("new StereoPannerNode(1)", function () {
33 node = new StereoPannerNode(1) && success;
34 }).throw("TypeError");
35 success = Should("new StereoPannerNode(context, 42)", function () {
36 node = new StereoPannerNode(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 StereoPannerNode(context)", function () {
52 node = new StereoPannerNode(context);
53 }).notThrow();
54 success = Should("node instanceof StereoPannerNode", node instanceof Ste reoPannerNode)
55 .beEqualTo(true) && success;
56
57 success = Should("node.pan.value", node.pan.value)
58 .beEqualTo(0) && success;
59
60 Should("new StereoPannerNode(context)", success)
61 .summarize(
62 "constructed node with correct attributes",
63 "did not construct correct node correctly")
64
65 taskDone();
66 });
67
68 audit.defineTask("test AudioNodeOptions", function (taskDone) {
69 // Can't use testAudioNodeOptions because the constraints for this node
70 // are not supported there.
71 var node;
72 var success = true;
73
74 // Test that we can set the channel count to 1 or 2.
75 success = Should("new StereoPannerNode(c, {channelCount: 1})",
hongchan 2016/09/13 22:13:22 Let's use JSON.stringify() for the options.
Raymond Toy 2016/09/14 18:02:23 Done.
76 function () {
77 node = new StereoPannerNode(context, {
78 channelCount: 1
79 });
80 }).notThrow() && success;
81 success = Should("node.channelCount", node.channelCount)
82 .beEqualTo(1) && success;
83
84 success = Should("new StereoPannerNode(c, {channelCount: 2})",
85 function () {
86 node = new StereoPannerNode(context, {
87 channelCount: 2
88 });
89 }).notThrow() && success;
90 success = Should("node.channelCount", node.channelCount)
91 .beEqualTo(2) && success;
92
93 // Test that other channel counts throw an error
94 success = Should("new StereoPannerNode(c, {channelCount: 0})",
95 function () {
96 node = new StereoPannerNode(context, {
97 channelCount: 0
98 });
99 }).throw("NotSupportedError") && success;
100 success = Should("new StereoPannerNode(c, {channelCount: 3})",
101 function () {
102 node = new StereoPannerNode(context, {
103 channelCount: 3
104 });
105 }).throw("NotSupportedError") && success;
106 success = Should("new StereoPannerNode(c, {channelCount: 99})",
107 function () {
108 node = new StereoPannerNode(context, {
109 channelCount: 99
110 });
111 }).throw("NotSupportedError") && success;
112
113 // Test channelCountMode. A mode of "max" is illegal, but others are ok .
114 success = Should('new StereoPannerNode(c, {channelCountMode: "clamped-ma x"})',
115 function () {
116 node = new StereoPannerNode(context, {
117 channelCountMode: "clamped-max"
118 });
119 }).notThrow() && success;
120 success = Should("node.channelCountMode", node.channelCountMode)
121 .beEqualTo("clamped-max") && success;
122
123 success = Should('new StereoPannerNode(c, {channelCountMode: "explicit"} )',
124 function () {
125 node = new StereoPannerNode(context, {
126 channelCountMode: "explicit"
127 });
128 }).notThrow() && success;
129 success = Should("node.channelCountMode", node.channelCountMode)
130 .beEqualTo("explicit") && success;
131
132 success = Should('new StereoPannerNode(c, {channelCountMode: "max"})',
133 function () {
134 node = new StereoPannerNode(context, {
135 channelCountMode: "max"
136 });
137 }).throw("NotSupportedError") && success;
138 success = Should('new StereoPannerNode(c, {channelCountMode: "foobar"})' ,
139 function () {
140 node = new StereoPannerNode(context, {
141 channelCountMode: "foobar"
142 });
143 }).throw("TypeError") && success;
144
145 // Test channelInterpretation.
146 success = Should('new StereoPannerNode(c, {channelInterpretation: "speak ers"})',
147 function () {
148 node = new StereoPannerNode(context, {
149 channelInterpretation: "speakers"
150 });
151 }).notThrow() && success;
152 success = Should("node.channelInterpretation", node.channelInterpretatio n)
153 .beEqualTo("speakers") && success;
154 success = Should('new StereoPannerNode(c, {channelInterpretation: "discr ete"})',
155 function () {
156 node = new StereoPannerNode(context, {
157 channelInterpretation: "discrete"
158 });
159 }).notThrow() && success;
160 success = Should("node.channelInterpretation", node.channelInterpretatio n)
161 .beEqualTo("discrete") && success;
162 success = Should('new StereoPannerNode(c, {channelInterpretation: "fooba r"})',
163 function () {
164 node = new StereoPannerNode(context, {
165 channelInterpretation: "foobar"
166 });
167 }).throw("TypeError") && success;
168
169 Should("AudioNodeOptions for StereoPannerNode", success)
170 .summarize(
171 "were correctly handled",
172 "were not correctly handled");
173
174 taskDone();
175 });
176
177 audit.defineTask("constructor with options", function (taskDone) {
178 var node;
179 var success = true;
180 var options = {
181 pan: 0.75,
182 };
183
184 success = Should("node = new StereoPannerNode(context, <options>)", func tion () {
185 node = new StereoPannerNode(context, options);
186 }).notThrow();
187 success = Should("node instanceof StereoPannerNode", node instanceof Ste reoPannerNode)
188 .beEqualTo(true) && success;
189
190 success = Should("node.pan.value", node.pan.value)
191 .beEqualTo(options.pan) && success;
192
193 Should("new StereoPannerNode() with options", success)
194 .summarize(
195 "constructed with correct attributes",
196 "was not constructed correctly");
197
198 taskDone();
199 });
200
201 audit.runTasks();
202 </script>
203 </body>
204 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698