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

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

Issue 2491653002: Add constructors for WebAudio events (Closed)
Patch Set: Remove unnecessary blank lines 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/modules_idl_files.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/event-constructor.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/event-constructor.html b/third_party/WebKit/LayoutTests/webaudio/event-constructor.html
new file mode 100644
index 0000000000000000000000000000000000000000..190f8ba1d651d25a1ad27d3a51ffdb69e60df227
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webaudio/event-constructor.html
@@ -0,0 +1,180 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Test Event Constructors</title>
+ <script src="../resources/testharness.js"></script>
+ <script src="../resources/testharnessreport.js"></script>
+ <script src="resources/audio-testing.js"></script>
+ </head>
+
+ <body>
+ <script>
+ var audit = Audit.createTaskRunner();
+
+ audit.defineTask("offline-constructor", function (taskDone) {
+ var success = true;
+
+ success = Should("new OfflineAudioCompletionEvent()", function () {
+ new OfflineAudioCompletionEvent();
+ }).throw("TypeError") && success;
+
+ success = Should('new OfflineAudioCompletionEvent("complete")',
+ function () {
+ new OfflineAudioCompletionEvent("complete");
+ }).throw("TypeError") && success;
+
+ success = Should('new OfflineAudioCompletionEvent("complete", {})',
+ function () {
+ new OfflineAudioCompletionEvent("complete", {});
+ }).throw("TypeError") && success;
+
+ success = Should(
+ 'new OfflineAudioCompletionEvent("complete", {foo: 42})',
+ function () {
+ new OfflineAudioCompletionEvent("complete", {
+ foo: 42
+ });
+ }).throw("TypeError") && success;
+
+ var context = new OfflineAudioContext(1, 100, 48000);
+ var buffer = new AudioBuffer(context, {
+ length: 42
+ });
+
+ success = Should(
+ 'new OfflineAudioCompletionEvent("complete", {renderedBuffer: buffer})',
+ function () {
+ new OfflineAudioCompletionEvent("complete", {
+ renderedBuffer: buffer
+ });
+ }).notThrow() && success;
+
+ Should("OfflineAudioCompletionEvent construction handled", success)
+ .summarize("correctly", "incorrectly");
+
+ taskDone();
+ });
+
+ audit.defineTask("offline-event", function (taskDone) {
+ // Only need the context for constructing the AudioBuffers for the
+ // tests.
+ var context = new OfflineAudioContext(1, 100, 48000);
+
+ var success = true;
+
+ // Just an arbitrary AudioBuffer.
+ var buffer = new AudioBuffer(context, {
+ length: 10
+ });
+
+ var event;
+ success = Should("new OfflineAudioCompletionEvent()", function () {
+ event = new OfflineAudioCompletionEvent("foo", {
+ renderedBuffer: buffer
+ });
+ }).notThrow() && success;
+
+ success = Should("event.renderedBuffer == buffer", event.renderedBuffer ==
+ buffer)
+ .beEqualTo(true) && success;
+
+ Should("OfflineAudioCompletionEvent constructed", success)
+ .summarize("correctly",
+ "incorrectly");
+
+ taskDone();
+ });
+
+ audit.defineTask("audio-processing", function (taskDone) {
+ // Only need the context for constructing the AudioBuffers for the
+ // tests.
+ var context = new OfflineAudioContext(1, 100, 48000);
+
+ // Fairly arbitrary buffers and time
+ var input = new AudioBuffer(context, {
+ length: 10
+ });
+ var output = new AudioBuffer(context, {
+ length: 20
+ });
+ var time = Math.PI;
+
+ var success = true;
+
+ // Verify required arguments.
+ success = Should("new AudioProcessingEvent()", function () {
+ new AudioProcessingEvent();
+ }).throw("TypeError") && success;
+
+ success = Should('new AudioProcessingEvent("proc")', function () {
+ new AudioProcessingEvent("proc");
+ }).throw("TypeError") && success;
+
+ success = Should('new AudioProcessingEvent("proc", {foo: 99})',
+ function () {
+ new AudioProcessingEvent("proc", {
+ foo: 99
+ });
+ }).throw("TypeError") && success;
+
+ success = Should(
+ 'new AudioProcessingEvent("proc", {inputBuffer: input, outputBuffer: output})',
+ function () {
+ new AudioProcessingEvent("proc", {
+ inputBuffer: input,
+ outputBuffer: output
+ });
+ }).throw("TypeError") && success;
+
+ success = Should(
+ 'new AudioProcessingEvent("proc", {inputBuffer: input, playbackTime: time})',
+ function () {
+ new AudioProcessingEvent("proc", {
+ inputBuffer: input,
+ playbackTime: time
+ });
+ }).throw("TypeError") && success;
+
+ success = Should(
+ 'new AudioProcessingEvent("proc", {outputBuffer: output, playbackTime: time})',
+ function () {
+ new AudioProcessingEvent("proc", {
+ outputBuffer: output,
+ playbackTime: time
+ });
+ }).throw("TypeError") && success;
+
+
+ // Finally test valid call
+ var event;
+ success = Should(
+ 'new AudioProcessingEvent("proc", {inputBuffer: input, outputBuffer: output, playbackTime: time})',
+ function () {
+ event = new AudioProcessingEvent("proc", {
+ inputBuffer: input,
+ outputBuffer: output,
+ playbackTime: time
+ });
+ }).notThrow() && success;
+
+ success = Should("event.playbackTime", event.playbackTime)
+ .beEqualTo(time) && success;
+
+ success = Should("event.inputBuffer == input", event.inputBuffer ==
+ input)
+ .beEqualTo(true) && success;
+
+ success = Should("event.outputBuffer == output", event.outputBuffer ==
+ output)
+ .beEqualTo(true) && success;
+
+ Should("AudioProcessingEvent construction handled", success)
+ .summarize("correctly", "incorrectly");
+
+ taskDone();
+ });
+
+ audit.runTasks();
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/modules_idl_files.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698