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

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

Issue 2491653002: Add constructors for WebAudio events (Closed)
Patch Set: Rebase Created 4 years 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 Event Constructors</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="resources/audio-testing.js"></script>
8 </head>
9
10 <body>
11 <script>
12 var audit = Audit.createTaskRunner();
hongchan 2016/12/02 18:07:17 Can we make a 'TODO' here so we can revisit this w
Raymond Toy 2016/12/02 18:50:00 No, I don't want that. This CL was written before
13
14 audit.defineTask("offline-constructor", function (taskDone) {
15 var success = true;
16
17 success = Should("new OfflineAudioCompletionEvent()", function () {
18 new OfflineAudioCompletionEvent();
19 }).throw("TypeError") && success;
20
21 success = Should('new OfflineAudioCompletionEvent("complete")',
22 function () {
23 new OfflineAudioCompletionEvent("complete");
24 }).throw("TypeError") && success;
25
26 success = Should('new OfflineAudioCompletionEvent("complete", {})',
27 function () {
28 new OfflineAudioCompletionEvent("complete", {});
29 }).throw("TypeError") && success;
30
31 success = Should(
32 'new OfflineAudioCompletionEvent("complete", {foo: 42})',
33 function () {
34 new OfflineAudioCompletionEvent("complete", {
35 foo: 42
36 });
37 }).throw("TypeError") && success;
38
39 var context = new OfflineAudioContext(1, 100, 48000);
40 var buffer = new AudioBuffer(context, {
41 length: 42
42 });
43
44 success = Should(
45 'new OfflineAudioCompletionEvent("complete", {renderedBuffer: buffer}) ',
46 function () {
47 new OfflineAudioCompletionEvent("complete", {
48 renderedBuffer: buffer
49 });
50 }).notThrow() && success;
51
52 Should("OfflineAudioCompletionEvent construction handled", success)
53 .summarize("correctly", "incorrectly");
54
55 taskDone();
56 });
57
58 audit.defineTask("offline-event", function (taskDone) {
59 // Only need the context for constructing the AudioBuffers for the
60 // tests.
61 var context = new OfflineAudioContext(1, 100, 48000);
62
63 var success = true;
64
65 // Just an arbitrary AudioBuffer.
66 var buffer = new AudioBuffer(context, {
67 length: 10
68 });
69
70 var event;
71 success = Should("new OfflineAudioCompletionEvent()", function () {
72 event = new OfflineAudioCompletionEvent("foo", {
73 renderedBuffer: buffer
74 });
75 }).notThrow() && success;
76
77 success = Should("event.renderedBuffer == buffer", event.renderedBuffer ==
78 buffer)
79 .beEqualTo(true) && success;
80
81 Should("OfflineAudioCompletionEvent constructed", success)
82 .summarize("correctly",
83 "incorrectly");
84
85 taskDone();
86 });
87
88 audit.defineTask("audio-processing", function (taskDone) {
89 // Only need the context for constructing the AudioBuffers for the
90 // tests.
91 var context = new OfflineAudioContext(1, 100, 48000);
92
93 // Fairly arbitrary buffers and time
94 var input = new AudioBuffer(context, {
95 length: 10
96 });
97 var output = new AudioBuffer(context, {
98 length: 20
99 });
100 var time = Math.PI;
101
102 var success = true;
103
104 // Verify required arguments.
105 success = Should("new AudioProcessingEvent()", function () {
106 new AudioProcessingEvent();
107 }).throw("TypeError") && success;
108
109 success = Should('new AudioProcessingEvent("proc")', function () {
110 new AudioProcessingEvent("proc");
111 }).throw("TypeError") && success;
112
113 success = Should('new AudioProcessingEvent("proc", {foo: 99})',
114 function () {
115 new AudioProcessingEvent("proc", {
116 foo: 99
117 });
118 }).throw("TypeError") && success;
119
120 success = Should(
121 'new AudioProcessingEvent("proc", {inputBuffer: input, outputBuffer: o utput})',
122 function () {
123 new AudioProcessingEvent("proc", {
124 inputBuffer: input,
125 outputBuffer: output
126 });
127 }).throw("TypeError") && success;
128
129 success = Should(
130 'new AudioProcessingEvent("proc", {inputBuffer: input, playbackTime: t ime})',
131 function () {
132 new AudioProcessingEvent("proc", {
133 inputBuffer: input,
134 playbackTime: time
135 });
136 }).throw("TypeError") && success;
137
138 success = Should(
139 'new AudioProcessingEvent("proc", {outputBuffer: output, playbackTime: time})',
140 function () {
141 new AudioProcessingEvent("proc", {
142 outputBuffer: output,
143 playbackTime: time
144 });
145 }).throw("TypeError") && success;
146
147
148 // Finally test valid call
149 var event;
150 success = Should(
151 'new AudioProcessingEvent("proc", {inputBuffer: input, outputBuffer: o utput, playbackTime: time})',
152 function () {
153 event = new AudioProcessingEvent("proc", {
154 inputBuffer: input,
155 outputBuffer: output,
156 playbackTime: time
157 });
158 }).notThrow() && success;
159
160 success = Should("event.playbackTime", event.playbackTime)
161 .beEqualTo(time) && success;
162
163 success = Should("event.inputBuffer == input", event.inputBuffer ==
164 input)
165 .beEqualTo(true) && success;
166
167 success = Should("event.outputBuffer == output", event.outputBuffer ==
168 output)
169 .beEqualTo(true) && success;
170
171 Should("AudioProcessingEvent construction handled", success)
172 .summarize("correctly", "incorrectly");
173
174 taskDone();
175 });
176
177 audit.runTasks();
178 </script>
179 </body>
180 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698