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

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

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments, rebase, and JSON.stringify the things 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: Convolver</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 taskDone();
22 });
23
24 audit.defineTask("invalid constructor", function (taskDone) {
25 var node;
26 var success = true;
27
28 succes = Should("new ConvolverNode()", function () {
29 node = new ConvolverNode();
30 }).throw("TypeError");
31 success = Should("new ConvolverNode(1)", function () {
32 node = new ConvolverNode(1);
33 }).throw("TypeError") && success;
34 success = Should("new ConvolverNode(context, 42)", function () {
35 node = new ConvolverNode(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 });
44
45 audit.defineTask("default constructor", function (taskDone) {
46 var node;
47 var success = true;
48
49 success = Should("node = new ConvolverNode(context)", function () {
50 node = new ConvolverNode(context);
51 }).notThrow();
52 success = Should("node instanceOf ConvolverNode", node instanceof Convol verNode)
53 .beEqualTo(true) && success;
54 success = Should("node.normalize", node.normalize)
55 .beEqualTo(true) && success;
56
57 success = Should("node.channelCount", node.channelCount)
58 .beEqualTo(2) && success;
59 success = Should("node.channelCountMode", node.channelCountMode)
60 .beEqualTo("clamped-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 });
71
72 audit.defineTask("test AudioNodeOptions", function (taskDone) {
73 testAudioNodeOptions(context, "ConvolverNode");
74 taskDone();
75 });
76
77 audit.defineTask("construct with options", function (taskDone) {
78 var buf = context.createBuffer(1, 1, context.sampleRate);
79 var options = {
80 buffer: buf,
81 disableNormalization: false
82 };
83
84 var message = "node = new ConvolverNode(c, " + JSON.stringify(options) + ")";
85
86 var node;
87 success = Should(message, function () {
88 node = new ConvolverNode(context, options);
89 }).notThrow();
90
91 success = Should("node instanceOf ConvolverNode", node instanceof Convol verNode)
92 .beEqualTo(true) && success;
93 success = Should("node.buffer === <buf>", node.buffer ===
94 options.buffer)
95 .beEqualTo(true) && success;
96 success = Should("node.normalize", node.normalize)
97 .beEqualTo(!options.disableNormalization) && success;
98
99 options.buffer = null;
100 options.disableNormalization = true;
101
102 message = "node = new ConvolverNode(, " + JSON.stringify(options) + ")";
103
104 success = Should(message, function () {
105 node = new ConvolverNode(context, options);
106 }).notThrow() && success;
107 success = Should("node.buffer", node.buffer).beEqualTo(null) && success;
108 success = Should("node.normalize", node.normalize)
109 .beEqualTo(!options.disableNormalization) && success;
110
111 options.disableNormalization = false;
112 message = "node = new ConvolverNode(context, " + JSON.stringify(options) + "";
hongchan 2016/09/14 17:40:07 Perhaps this empty quote is a mistake?
Raymond Toy 2016/09/14 18:02:23 Fixed. It should be ")"
113
114 success = Should(message, function () {
115 node = new ConvolverNode(context, options);
116 }).notThrow() && success;
117 success = Should("node.buffer", node.buffer).beEqualTo(null) && success;
118 success = Should("node.normalize", node.normalize)
119 .beEqualTo(!options.disableNormalization) && success;
120
121 Should("new ConvolverNode() with options", success)
122 .summarize(
123 "constructed with correct attributes",
124 "was not constructed correctly");
125
126 taskDone();
127 });
128
129 audit.runTasks();
130 </script>
131 </body>
132 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698