Chromium Code Reviews

Unified Diff: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffer.html

Issue 2102133002: Add constructors for WebAudio nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update files to the right GN files. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
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>

Powered by Google App Engine