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

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

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

Powered by Google App Engine
This is Rietveld 408576698