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

Unified Diff: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.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. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html
new file mode 100644
index 0000000000000000000000000000000000000000..d7c198386600d16a7a3f505eb636f942317f154d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Test Constructor: AudioBufferSource</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 () {
+ context = new OfflineAudioContext(1, 1, 48000);
+ assert_true(context instanceof AudioContext,
+ "context created successfully");
+ }, "Construct offline context");
+
+ test(function () {
+ assert_throws(null,
+ function () {
+ return new AudioBufferSourceNode();
+ }, "One argument required");
+ assert_throws(null,
+ function () {
+ return new AudioBufferSourceNode(1);
+ }, "Invalid context argument");
+ assert_throws(null,
+ function () {
+ return new AudioBufferSourceNode(context, 42);
+ }, "Second argument must be an object");
+ });
+
+ test(function () {
+ // Construct a default AnalyserNode
+ var node = new AudioBufferSourceNode(context);
+ assert_true(node instanceof AudioBufferSourceNode,
+ "new AudioBufferSourceNode(context)");
+ }, "Construct basic AudioBufferSourceNode");
+
+ test(function () {
+ // Construct an AudioBufferSourceNode with options
+ var buf = context.createBuffer(1, 1, context.sampleRate);
+ var options = {
+ buffer: buf,
+ detune: 1,
+ loop: true,
+ loopEnd: 0.5,
+ loopStart: 1.0,
+ playbackRate: .25
+ };
+ var node = new AudioBufferSourceNode(context, options);
+ assert_true(node instanceof AudioBufferSourceNode,
+ "new AudioBufferSourceNode(context, options)");
+ // Verify node has the correct values.
+ assert_equals(node.buffer, options.buffer);
+ assert_equals(node.detune.value, options.detune);
+ assert_equals(node.loop, options.loop);
+ assert_equals(node.loopEnd, options.loopEnd);
+ assert_equals(node.loopStart, options.loopStart);
+ assert_equals(node.playbackRate.value, options.playbackRate);
+ }, "Construct AudioBufferSourceNode with options");
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698