Index: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5d023c4762fe123da87dacd193d63576f0bf971e |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html |
@@ -0,0 +1,82 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>Test Constructor: AudioBuffer</title> |
+ <script src="../../resources/testharness.js"></script> |
+ <script src="../../resources/testharnessreport.js"></script> |
+ <script src="../resources/compatibility.js"></script> |
+ </head> |
+ |
+ <body> |
+ <script> |
+ var context; |
+ |
+ test(function () { |
hongchan
2016/09/08 21:41:11
Are you keeping the test in this way? This is okay
Raymond Toy
2016/09/08 21:58:00
Oops. I forgot to rewrite these.
|
+ context = new OfflineAudioContext(1, 1, 48000); |
+ assert_true(context instanceof AudioContext, |
+ "context created successfully"); |
+ }, "Construct offline context"); |
+ |
+ test(function () { |
+ assert_throws(null, |
+ function () { |
+ var node = new AudioBuffer(context); |
+ }, "Two arguments required"); |
+ |
+ assert_throws(null, |
+ function () { |
+ return new AudioBuffer(42, {}) |
+ }, "First argument must be a context"); |
+ |
+ assert_throws(null, |
+ function () { |
+ return new AudioBuffer(context, 42); |
+ }, "Second arg must be an object"); |
+ }, "Test argument count and type"); |
+ |
+ test(function () { |
+ assert_throws("NotFoundError", |
+ function () { |
+ var buffer = new AudioBuffer(context, {}); |
+ }, "Empty options"); |
+ |
+ assert_throws("NotFoundError", |
+ function () { |
+ var buffer = new AudioBuffer(context, { |
+ numberOfChannels: 1 |
+ }); |
+ }, "Include numberOfChannels"); |
+ |
+ assert_throws("NotFoundError", |
+ function () { |
+ var buffer = new AudioBuffer(context, { |
+ length: 10 |
+ }); |
+ }, "Include numberOfChannels"); |
+ |
+ }, "Construct AudioBuffer without required values, throwing errors"); |
+ |
+ test(function () { |
+ var options = { |
+ numberOfChannels: 3, |
+ length: 42, |
+ sampleRate: 16000 |
+ }; |
+ var buffer = new AudioBuffer(context, options); |
+ |
+ assert_equals(buffer.numberOfChannels, options.numberOfChannels); |
+ assert_equals(buffer.length, options.length); |
+ assert_equals(buffer.sampleRate, options.sampleRate); |
+ |
+ buffer = new AudioBuffer(context, { |
+ numberOfChannels: 3, |
+ length: 42 |
+ }); |
+ |
+ assert_equals(buffer.sampleRate, context.sampleRate); |
+ |
+ }, "Construct valid AudioBuffer and check values"); |
+ |
+ </script> |
+ </body> |
+</html> |