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

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

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and prefix use counter names with WebAudio 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: Oscillator</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 OscillatorNode()", function () {
30 node = new OscillatorNode();
31 }).throw("TypeError");
32 success = Should("new OscillatorNode(1)", function () {
33 node = new OscillatorNode(1) && success;
34 }).throw("TypeError");
35 success = Should("new OscillatorNode(context, 42)", function () {
36 node = new OscillatorNode(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 OscillatorNode(context)", function () {
52 node = new OscillatorNode(context);
53 }).notThrow();
54 success = Should("node instanceof OscillatorNode", node instanceof Oscil latorNode)
55 .beEqualTo(true) && success;
56
57 success = Should("node.type", node.type)
58 .beEqualTo("sine") && success;
59 success = Should("node.detune.value", node.detune.value)
60 .beEqualTo(0) && success;
61 success = Should("node.frequency.value", node.frequency.value)
62 .beEqualTo(440) && success;
63
64 success = Should("node.channelCount", node.channelCount)
65 .beEqualTo(2) && success;
66 success = Should("node.channelCountMode", node.channelCountMode)
67 .beEqualTo("max") && success;
68 success = Should("node.channelInterpretation", node.channelInterpretatio n)
69 .beEqualTo("speakers") && success;
70
71 Should("new OscillatorNode(context)", success)
72 .summarize(
73 "constructed node with correct attributes",
74 "did not construct correct node correctly")
75
76 taskDone();
77 });
78
79 audit.defineTask("test AudioNodeOptions", function (taskDone) {
80 testAudioNodeOptions(context, "OscillatorNode");
81 taskDone();
82 });
83
84 audit.defineTask("constructor options", function (taskDone) {
85 var node;
86 var success = true;
87 var options = {
88 type: "sawtooth",
89 detune: 7,
90 frequency: 918
91 };
92
93 success = Should("node = new OscillatorNode(c, " + JSON.stringify(option s) + ")",
94 function () {
95 node = new OscillatorNode(context, options);
96 }).notThrow();
97
98 success = Should("node.type", node.type)
99 .beEqualTo(options.type) && success;
100 success = Should("node.detune.value", node.detune.value)
101 .beEqualTo(options.detune) && success;
102 success = Should("node.frequency.value", node.frequency.value)
103 .beEqualTo(options.frequency) && success;
104
105 success = Should("node.channelCount", node.channelCount)
106 .beEqualTo(2) && success;
107 success = Should("node.channelCountMode", node.channelCountMode)
108 .beEqualTo("max") && success;
109 success = Should("node.channelInterpretation", node.channelInterpretatio n)
110 .beEqualTo("speakers") && success;
111
112 // Test that type and periodicWave options work as described.
113 options = {
114 type: "sine",
115 periodicWave: new PeriodicWave(context, {
116 real: [1, 1]
117 })
118 };
119 success = Should("new OscillatorNode(c, " + JSON.stringify(options) + ") ",
120 function () {
121 node = new OscillatorNode(context, options);
122 })
123 .throw("InvalidStateError") && success;
124
125 options = {
126 type: "custom"
127 };
128 success = Should("new OscillatorNode(c, " + JSON.stringify(options) + ") ",
129 function () {
130 node = new OscillatorNode(context, options);
131 })
132 .throw("InvalidStateError") && success;
133
134 options = {
135 type: "custom",
136 periodicWave: new PeriodicWave(context, {
137 real: [1, 1]
138 })
139 };
140 success = Should("new OscillatorNode(, " + JSON.stringify(options) + ")" ,
141 function () {
142 node = new OscillatorNode(context, options);
143 })
144 .notThrow() && success;
145
146 Should("new OscillatorNode() with options", success)
147 .summarize(
148 "constructed with correct attributes",
149 "was not constructed correctly");
150
151 taskDone();
152 });
153
154 audit.runTasks();
155 </script>
156 </body>
157 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698