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

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 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(context, options)", function () {
94 node = new OscillatorNode(context, options);
95 }).notThrow();
96
97 success = Should("node.type", node.type)
98 .beEqualTo(options.type) && success;
99 success = Should("node.detune.value", node.detune.value)
100 .beEqualTo(options.detune) && success;
101 success = Should("node.frequency.value", node.frequency.value)
102 .beEqualTo(options.frequency) && success;
103
104 success = Should("node.channelCount", node.channelCount)
105 .beEqualTo(2) && success;
106 success = Should("node.channelCountMode", node.channelCountMode)
107 .beEqualTo("max") && success;
108 success = Should("node.channelInterpretation", node.channelInterpretatio n)
109 .beEqualTo("speakers") && success;
110
111 // Test that type and periodicWave options work as described.
112 success = Should('new OscillatorNode(..., {type: "sine", periodicWave: . ..})',
113 function () {
114 node = new OscillatorNode(context, { type: "sine",
115 periodicWave: new PeriodicWave(context, [1, 1])
116 });
117 })
118 .throw("InvalidStateError") && success;
119 success = Should('new OscillatorNode(..., {type: "custom"})',
120 function () {
121 node = new OscillatorNode(context, { type: "custom" });
122 })
123 .throw("InvalidStateError") && success;
124
125 success = Should('new OscillatorNode(..., {type: "custom", periodicWave: ...})',
126 function () {
127 node = new OscillatorNode(context, { type: "custom",
128 periodicWave: new PeriodicWave(context, {real: [1, 1]})
129 });
130 })
131 .notThrow() && success;
132
133 Should("new OscillatorNode() with options", success)
134 .summarize(
135 "constructed with correct attributes",
136 "was not constructed correctly");
137
138 taskDone();
139 });
140
141 audit.runTasks();
142 </script>
143 </body>
144 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698