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

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

Issue 2831953003: Convert constructor/analyser test to new Audit (Closed)
Patch Set: Address review comments Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/constructor/new-audionodeoptions.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Constructor: AnalyserNode</title> 4 <title>Test Constructor: AnalyserNode</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="audionodeoptions.js"></script> 9 <script src="new-audionodeoptions.js"></script>
10 </head> 10 </head>
11 11
12 <body> 12 <body>
13 <script> 13 <script>
14 var context; 14 var context;
15 15
16 var audit = Audit.createTaskRunner(); 16 var audit = Audit.createTaskRunner();
17 17
18 audit.defineTask("initialize", function (taskDone) { 18 audit.define('initialize', (task, should) => {
19 Should("context = new OfflineAudioContext(...)", function () { 19 context = initializeContext(should);
20 context = new OfflineAudioContext(1, 1, 48000); 20 task.done();
21 }).notThrow();
22
23 taskDone();
24 }); 21 });
25 22
26 audit.defineTask("invalid constructor", function (taskDone) { 23 audit.define('invalid constructor', (task, should) => {
27 var node; 24 testInvalidConstructor(should, 'AnalyserNode', context);
28 var success = true; 25 task.done();
29
30 success = Should("new AnalyserNode()", function () {
31 node = new AnalyserNode();
32 }).throw("TypeError");
33 success = Should("new AnalyserNode(1)", function () {
34 node = new AnalyserNode(1) && success;
35 }).throw("TypeError");
36 success = Should("new AnalyserNode(c, 42)", function () {
37 node = new AnalyserNode(context, 42) && success;
38 }).throw("TypeError");
39
40 Should("Invalid constructors", success)
41 .summarize(
42 "correctly threw errors",
43 "did not throw errors in all cases");
44
45 taskDone();
46 }); 26 });
47 27
48 audit.defineTask("default constructor", function (taskDone) { 28 audit.define('default constructor', (task, should) => {
49 var node; 29 let prefix = 'node0';
50 var success = true; 30 let node = testDefaultConstructor(should, 'AnalyserNode', context, {
31 prefix: prefix,
32 numberOfInputs: 1,
33 numberOfOutputs: 1,
34 // TODO(crbug.com/706610)
35 channelCount: 2,
36 channelCountMode: 'max',
37 channelInterpretation: 'speakers'
38 });
51 39
52 success = Should("node1 = new AnalyserNode(c)", function () { 40 testDefaultAttributes(should, node, prefix, [
53 node = new AnalyserNode(context); 41 {name: 'fftSize', value: 2048},
54 }).notThrow(); 42 {name: 'frequencyBinCount', value: 1024},
55 success = Should("node0 instanceof AnalyserNode", node instanceof Analys erNode) 43 {name: 'minDecibels', value: -100}, {name: 'maxDecibels', value: -30},
56 .beEqualTo(true) && success; 44 {
57 success = Should("node0.fftSize", node.fftSize).beEqualTo(2048) && succe ss; 45 // Compare against the single-precision float value since 0.8 isn't
58 success = Should("node0.frequencyBinCount", 46 // exactly representable as a float.
59 node.frequencyBinCount).beEqualTo(1024) && success; 47 name: 'smoothingTimeConstant',
60 success = Should("node0.minDecibels", node.minDecibels).beEqualTo(-100) && success; 48 value: Math.fround(0.8)
61 success = Should("node0.maxDecibels", node.maxDecibels).beEqualTo(-30) & & success; 49 }
62 // All AudioParams are stored as single precision values. Compare 50 ]);
63 // against the single-precision float value.
64 success = Should("node0.smoothingTimeConstant", node.smoothingTimeConsta nt)
65 .beEqualTo(Math.fround(0.8)) && success;
66 51
67 Should("new AnalyserNode(c)", success) 52 task.done();
68 .summarize(
69 "constructed node with correct attributes",
70 "did not construct correct node correctly")
71
72 taskDone();
73 }); 53 });
74 54
75 audit.defineTask("test AudioNodeOptions", function (taskDone) { 55 audit.define('test AudioNodeOptions', (task, should) => {
76 testAudioNodeOptions(context, "AnalyserNode"); 56 testAudioNodeOptions(should, context, 'AnalyserNode');
77 taskDone(); 57 task.done();
78 }); 58 });
79 59
80 audit.defineTask("constructor with options", function (taskDone) { 60 audit.define('constructor with options', (task, should) => {
81 var options = { 61 var options = {
82 fftSize: 32, 62 fftSize: 32,
83 maxDecibels: 1, 63 maxDecibels: 1,
84 minDecibels: -13, 64 minDecibels: -13,
85 // Choose a value that can be represented the same as a float and as a 65 // Choose a value that can be represented the same as a float and as a
86 // double. 66 // double.
87 smoothingTimeConstant: 0.125 67 smoothingTimeConstant: 0.125
88 }; 68 };
89 69
90 var node; 70 var node;
91 var success = true; 71 should(() => {
92 success = Should("node1 = new AnalyserNode(c, " + JSON.stringify(options ) + ")", function () { 72 node = new AnalyserNode(context, options);
93 node = new AnalyserNode(context, options); 73 },
94 }).notThrow(); 74 'node1 = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
75 .notThrow();
95 76
96 success = Should("node1 instanceof AnalyserNode", node instanceof Analys erNode) 77 should(node instanceof AnalyserNode, 'node1 instanceof AnalyserNode')
97 .beEqualTo(true) && success; 78 .beEqualTo(true);
98 success = Should("node1.fftSize", node.fftSize) 79 should(node.fftSize, 'node1.fftSize').beEqualTo(options.fftSize);
99 .beEqualTo(options.fftSize) && success; 80 should(node.maxDecibels, 'node1.maxDecibels')
100 success = Should("node1.maxDecibels", node.maxDecibels) 81 .beEqualTo(options.maxDecibels);
101 .beEqualTo(options.maxDecibels) && success; 82 should(node.minDecibels, 'node1.minDecibels')
102 success = Should("node1.minDecibels", node.minDecibels) 83 .beEqualTo(options.minDecibels);
103 .beEqualTo(options.minDecibels) && success; 84 should(node.smoothingTimeConstant, 'node1.smoothingTimeConstant')
104 success = Should("node1.smoothingTimeConstant", node.smoothingTimeConsta nt) 85 .beEqualTo(options.smoothingTimeConstant);
105 .beEqualTo(options.smoothingTimeConstant) && success;
106 86
107 Should("new AnalyserNode() with options", success) 87 task.done();
108 .summarize(
109 "constructed with correct attributes",
110 "was not constructed correctly");
111
112 taskDone();
113 }); 88 });
114 89
115 audit.defineTask("construct invalid options", function (taskDone) { 90 audit.define('construct invalid options', (task, should) => {
116 var node; 91 var node;
117 var success = true;
118 92
119 success = Should("node = new AnalyserNode(c, { fftSize: 33 })", function () { 93 should(() => {
120 node = new AnalyserNode(context, { 94 node = new AnalyserNode(context, {fftSize: 33});
121 fftSize: 33 95 },
122 }); 96 'node = new AnalyserNode(c, { fftSize: 33 })')
123 }).throw("IndexSizeError") && success; 97 .throw('IndexSizeError');
124 success = Should("node = new AnalyserNode(c, { maxDecibels: -500 })", fu nction () { 98 should(() => {
125 node = new AnalyserNode(context, { 99 node = new AnalyserNode(context, {maxDecibels: -500});
126 maxDecibels: -500 100 },
127 }); 101 'node = new AnalyserNode(c, { maxDecibels: -500 })')
128 }).throw("IndexSizeError") && success; 102 .throw('IndexSizeError');
129 success = Should("node = new AnalyserNode(c, { minDecibels: -10 })", fun ction () { 103 should(() => {
130 node = new AnalyserNode(context, { 104 node = new AnalyserNode(context, {minDecibels: -10});
131 minDecibels: -10 105 },
132 }); 106 'node = new AnalyserNode(c, { minDecibels: -10 })')
133 }).throw("IndexSizeError") && success; 107 .throw('IndexSizeError');
134 success = Should("node = new AnalyserNode(c, { smoothingTimeConstant: 2 })", function () { 108 should(() => {
135 node = new AnalyserNode(context, { 109 node = new AnalyserNode(context, {smoothingTimeConstant: 2});
136 smoothingTimeConstant: 2 110 },
137 }); 111 'node = new AnalyserNode(c, { smoothingTimeConstant: 2 })')
138 }).throw("IndexSizeError") && success; 112 .throw('IndexSizeError');
139 success = Should("node = new AnalyserNode(c, { frequencyBinCount: 33 })" , function () { 113 should(function() {
140 node = new AnalyserNode(context, { 114 node = new AnalyserNode(context, {frequencyBinCount: 33});
141 frequencyBinCount: 33 115 }, 'node = new AnalyserNode(c, { frequencyBinCount: 33 })').notThrow();
142 }); 116 should(node.frequencyBinCount, 'node.frequencyBinCount')
143 }).notThrow() && success; 117 .beEqualTo(1024);
144 success = Should("node.frequencyBinCount", node.frequencyBinCount).beEqu alTo(1024) &&
145 success;
146 118
147 Should("new AnalyserNode() with invalid option values", success) 119 task.done();
148 .summarize(
149 "correctly handled",
150 "was not correctly handled");
151
152 taskDone();
153 }); 120 });
154 121
155 audit.defineTask("setting min/max", function (taskDone) { 122 audit.define('setting min/max', (task, should) => {
156 var node; 123 var node;
157 var success = true;
158 124
159 // Recall the default values of minDecibels and maxDecibels are -100, 125 // Recall the default values of minDecibels and maxDecibels are -100,
160 // and -30, respectively. Setting both values in the constructor should 126 // and -30, respectively. Setting both values in the constructor should
161 // not signal an error in any of the following cases. 127 // not signal an error in any of the following cases.
162 var options = { 128 var options = {minDecibels: -10, maxDecibels: 20};
163 minDecibels: -10, 129 should(() => {
164 maxDecibels: 20 130 node = new AnalyserNode(context, options);
165 }; 131 },
166 success = Should("node = new AnalyserNode(c, " + JSON.stringify(options) + ")", 132 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
167 function () { 133 .notThrow();
168 node = new AnalyserNode(context, options);
169 }).notThrow() && success;
170 134
171 options = { 135 options = {maxDecibels: 20, minDecibels: -10};
172 maxDecibels: 20, 136 should(() => {
173 minDecibels: -10 137 node = new AnalyserNode(context, options);
174 }; 138 },
175 success = Should("node = new AnalyserNode(c, " + JSON.stringify(options) + ")", 139 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
176 function () { 140 .notThrow();
177 node = new AnalyserNode(context, options);
178 }).notThrow() && success;
179 141
180 options = { 142 options = {minDecibels: -200, maxDecibels: -150};
181 minDecibels: -200, 143 should(() => {
182 maxDecibels: -150 144 node = new AnalyserNode(context, options);
183 }; 145 },
184 success = Should("node = new AnalyserNode(c, " + JSON.stringify(options) + ")", 146 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
185 function () { 147 .notThrow();
186 node = new AnalyserNode(context, options);
187 }).notThrow() && success;
188 148
189 options = { 149 options = {maxDecibels: -150, minDecibels: -200};
190 maxDecibels: -150, 150 should(() => {
191 minDecibels: -200 151 node = new AnalyserNode(context, options);
192 }; 152 },
193 success = Should("node = new AnalyserNode(c, " + JSON.stringify(options) + ")", 153 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
194 function () { 154 .notThrow();
195 node = new AnalyserNode(context, options);
196 }).notThrow() && success;
197 155
198 // But these should signal because minDecibel > maxDecibel 156 // But these should signal because minDecibel > maxDecibel
199 options = { 157 options = {maxDecibels: -150, minDecibels: -10};
200 maxDecibels: -150, 158 should(() => {
201 minDecibels: -10 159 node = new AnalyserNode(context, options);
202 }; 160 },
203 success = Should("node = new AnalyserNode(c, " + JSON.stringify(options) + ")", 161 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
204 function () { 162 .throw('IndexSizeError');
205 node = new AnalyserNode(context, options);
206 }).throw("IndexSizeError") && success;
207 163
208 options = { 164 options = {minDecibels: -10, maxDecibels: -150};
209 minDecibels: -10, 165 should(() => {
210 maxDecibels: -150 166 node = new AnalyserNode(context, options);
211 }; 167 },
212 success = Should("node = new AnalyserNode(c, " + JSON.stringify(options) + ")", 168 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')')
213 function () { 169 .throw('IndexSizeError');
214 node = new AnalyserNode(context, options);
215 }).throw("IndexSizeError") && success;
216 170
217 Should("new AnalyserNode with minDecibels/maxDecibels options values", s uccess) 171 task.done();
218 .summarize( 172 });
219 "correctly handled",
220 "incorrectly handled");
221 173
222 taskDone(); 174 audit.run();
223 });
224 audit.runTasks();
225 </script> 175 </script>
226 </body> 176 </body>
227 </html> 177 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/constructor/new-audionodeoptions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698