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

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

Issue 2712933003: PeriodicWave returns sine wave generator if no coefficients given (Closed)
Patch Set: Refactor and add test Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html
diff --git a/third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html b/third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html
index 06fac7961382293e841aedefd4736b682c646904..3688addc45b48d630d84a716340622328b46f0e2 100644
--- a/third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html
+++ b/third_party/WebKit/LayoutTests/webaudio/constructor/periodicwave.html
@@ -51,13 +51,13 @@
success = Should("node = new PeriodicWave(context)", function () {
node = new PeriodicWave(context);
- }).throw("InvalidStateError");
+ }).notThrow();
taskDone();
});
audit.defineTask("constructor with options", function (taskDone) {
- var node;
+ var node1;
var success = true;
var options = {
@@ -65,30 +65,32 @@
};
success = Should("node = new PeriodicWave(context, " + JSON.stringify(options) + ")",
function () {
- node = new PeriodicWave(context, options);
+ node1 = new PeriodicWave(context, options);
}).notThrow();
- success = Should("node instanceof PeriodicWave", node instanceof PeriodicWave)
+ success = Should("node1 instanceof PeriodicWave", node1 instanceof PeriodicWave)
.beEqualTo(true) && success;
+ var node2;
options = {
imag: [1, 1]
};
- success = Should("node = new PeriodicWave(context, " + JSON.stringify(options) + ")",
+ success = Should("node2 = new PeriodicWave(context, " + JSON.stringify(options) + ")",
function () {
- node = new PeriodicWave(context, options);
+ node2 = new PeriodicWave(context, options);
}).notThrow();
- success = Should("node instanceof PeriodicWave", node instanceof PeriodicWave)
+ success = Should("node2 instanceof PeriodicWave", node2 instanceof PeriodicWave)
.beEqualTo(true) && success;
+ var node3;
options = {
real: [1, 2],
imag: [1, 1]
};
- success = Should("node = new PeriodicWave(context, " + JSON.stringify(options) + ")",
+ success = Should("node3 = new PeriodicWave(context, " + JSON.stringify(options) + ")",
function () {
- node = new PeriodicWave(context, options);
+ node3 = new PeriodicWave(context, options);
}).notThrow();
- success = Should("node instanceof PeriodicWave", node instanceof PeriodicWave)
+ success = Should("node3 instanceof PeriodicWave", node3 instanceof PeriodicWave)
.beEqualTo(true) && success;
Should("new PeriodicWave() with options", success)
@@ -288,6 +290,54 @@
});
}
+ function sineWaveTest(waveFun, message) {
+ // Verify that the default PeriodicWave produces a sine wave. Use a
+ // 2-channel context to verify this. Channel 0 is the output from the
+ // PeriodicWave, and channel 1 is the reference oscillator output.
+ let context = new OfflineAudioContext(2, 40000, 40000);
+ let oscRef =
+ new OscillatorNode(context, {type: 'sine', frequency: 440});
+ let wave = waveFun(context);
+ let oscTest =
+ new OscillatorNode(context, {frequency: 440, periodicWave: wave});
+
+ let merger = new ChannelMergerNode(context, {numberOfInputs: 2});
+
+ oscRef.connect(merger, 0, 1);
+ oscTest.connect(merger, 0, 0);
+
+ merger.connect(context.destination);
+
+ oscRef.start();
+ oscTest.start();
+
+ return context.startRendering().then(output => {
+ // The output from the two channels MUST match exactly.
+ let actual = output.getChannelData(0);
+ let ref = output.getChannelData(1);
+
+ Should(message, actual).beEqualToArray(ref);
+ })
hongchan 2017/03/16 21:50:21 A missing semicolon!
Raymond Toy 2017/03/16 22:18:17 Done.
+ }
+
+ audit.defineTask('default wave', function(taskDone) {
+ // Verify that the default PeriodicWave produces a sine wave.
+ sineWaveTest(
+ (context) => new PeriodicWave(context),
+ 'new PeriodicWave(context) output')
+ .then(taskDone);
hongchan 2017/03/16 21:50:21 Is this indentation from clang-format? If so, clan
Raymond Toy 2017/03/16 22:18:17 Yes, clang format. And rerunning after fixing the
+ });
+
+ audit.defineTask('default wave (with dict)', function(taskDone) {
+ // Verify that the default PeriodicWave produces a sine wave when the
+ // PeriodicWaveOptions dictionary is given, but real and imag members
+ // are not set.
+ sineWaveTest(
+ (context) => new PeriodicWave(context, {foo: 42}),
+ 'new PeriodicWave(context, {foo: 42}) output')
+ .then(taskDone);
+ });
+
audit.runTasks();
</script>
</body>
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/PeriodicWave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698