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..63ea8668e56e368158113060b8c6919807342716 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/webaudio/constructor/audiobuffersource.html |
@@ -0,0 +1,144 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>Test Constructor: AudioBufferSource</title> |
+ <script src="../../resources/testharness.js"></script> |
+ <script src="../../resources/testharnessreport.js"></script> |
+ <script src="../resources/audio-testing.js"></script> |
+ <script src="audionodeoptions.js"></script> |
+ </head> |
+ |
+ <body> |
+ <script> |
+ var context; |
+ |
+ var audit = Audit.createTaskRunner(); |
+ |
+ audit.defineTask("initialize", function (taskDone) { |
+ Should("context = new OfflineAudioContext(...)", function () { |
+ context = new OfflineAudioContext(1, 1, 48000); |
+ }).notThrow(); |
+ |
+ taskDone(); |
+ }); |
+ |
+ audit.defineTask("invalid constructor", function (taskDone) { |
+ var node; |
+ var success = true; |
+ |
+ success = Should("new AudioBufferSourceNode()", function () { |
+ node = new AudioBufferSourceNode(); |
+ }).throw("TypeError"); |
+ success = Should("new AudioBufferSourceNode(1)", function () { |
+ node = new AudioBufferSourceNode(1) && success; |
+ }).throw("TypeError"); |
+ success = Should("new AudioBufferSourceNode(context, 42)", function () { |
+ node = new AudioBufferSourceNode(context, 42) && success; |
+ }).throw("TypeError"); |
+ |
+ Should("Invalid constructors", success) |
+ .summarize( |
+ "correctly threw errors", |
+ "did not throw errors in all cases"); |
+ |
+ taskDone(); |
+ }); |
+ |
+ audit.defineTask("default constructor", function (taskDone) { |
+ var node; |
+ var success = true; |
+ |
+ success = Should("node = new AudioBufferSourceNode(context)", function () { |
+ node = new AudioBufferSourceNode(context); |
+ }).notThrow() && success; |
+ |
+ success = Should("node instanceof AudioBufferSourceNode", |
+ node instanceof AudioBufferSourceNode).beEqualTo(true) && success; |
+ |
+ success = Should("node.buffer === null", node.buffer === null) |
+ .beEqualTo(true) && success; |
+ |
+ // This node using the factory method is used as a reference for the |
+ // defautl values. |
+ var factoryNode = context.createBufferSource(); |
+ |
+ var testAttributes = ["buffer", "detune", "loop", "loopEnd", "loopStart", |
+ "playbackRate"]; |
+ |
+ for (var index in testAttributes) { |
+ var name = testAttributes[index]; |
+ |
+ if (node[name] instanceof AudioParam) { |
+ success = Should("node." + name + ".value", node[name].value) |
+ .beEqualTo(factoryNode[name].value) && success; |
+ } else { |
+ success = Should("node." + name, node[name]) |
+ .beEqualTo(factoryNode[name]) && success; |
+ } |
+ } |
+ |
+ Should("AudioBufferSourceNode constructed", success) |
+ .summarize("correctly", "incorrectly"); |
+ |
+ taskDone(); |
+ }); |
+ |
+ audit.defineTask("constructor options", function (taskDone) { |
+ var node; |
+ var success = true; |
+ |
+ var buffer = context.createBuffer(2, 1000, context.sampleRate); |
+ |
+ var options = { |
+ buffer: buffer, |
+ detune: .5, |
+ loop: true, |
+ loopEnd: (buffer.length / 2) / context.sampleRate, |
+ loopStart: 5 / context.sampleRate, |
+ playbackRate: .75 |
+ } |
hongchan
2016/09/13 22:13:22
missing ;
Raymond Toy
2016/09/14 18:02:22
Done.
|
+ |
+ message = "node = new AudioBufferSourceNode(context, {"; |
hongchan
2016/09/13 22:13:22
Let's not repeat |message| here and on.
Raymond Toy
2016/09/14 18:02:22
Using JSON.stringify instead.
|
+ message += "buffer: buffer"; |
+ message += ", detune: " + options.detune; |
+ message += ", loop: " + options.loop; |
+ message += ", loopEnd: " + options.loopEnd; |
+ message += ", loopStart: " + options.loopStart; |
+ message += ", playbackRate: " + options.playbackRate; |
+ message += "})"; |
+ |
+ success = Should(message, function () { |
+ node = new AudioBufferSourceNode(context, options); |
+ }).notThrow(); |
+ |
+ var factoryNode = context.createBufferSource(); |
+ factoryNode.buffer = options.buffer; |
+ factoryNode.detune.value = options.detune; |
+ factoryNode.loop = options.loop; |
+ factoryNode.loopEnd = options.loopEnd; |
+ factoryNode.loopStart = options.loopStart; |
+ factoryNode.playbackRate.value = options.playbackRate; |
+ |
+ success = Should("node.buffer === buffer", node.buffer === buffer) |
+ .beEqualTo(true) && success; |
+ success = Should("node.detune.value", node.detune.value) |
+ .beEqualTo(factoryNode.detune.value) && success; |
+ success = Should("node.loop", node.loop) |
+ .beEqualTo(factoryNode.loop) && success; |
+ success = Should("node.loopEnd", node.loopEnd) |
+ .beEqualTo(factoryNode.loopEnd) && success; |
+ success = Should("node.loopStart", node.loopStart) |
+ .beEqualTo(factoryNode.loopStart) && success; |
+ success = Should("node.playbackRate.value", node.playbackRate.value) |
+ .beEqualTo(factoryNode.playbackRate.value) && success; |
+ |
+ Should("AudioBufferSource with options cosntructed", success) |
+ .summarize("correctly", "incorrectly"); |
+ |
+ taskDone(); |
+ }); |
+ |
+ audit.runTasks(); |
+ </script> |
+ </body> |
+</html> |