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

Unified Diff: LayoutTests/webaudio/oscillator-basic.html

Issue 209423006: WebAudio: Remove legacy support for numerical values for Oscillator types. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 8 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 | LayoutTests/webaudio/oscillator-basic-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/webaudio/oscillator-basic.html
diff --git a/LayoutTests/webaudio/oscillator-basic.html b/LayoutTests/webaudio/oscillator-basic.html
index 2414fd183d5a75de0405b8a7ce2b4e0cccdb3198..8a04ccbfc324d10a2a234b288d7b44c4acdcb1d3 100644
--- a/LayoutTests/webaudio/oscillator-basic.html
+++ b/LayoutTests/webaudio/oscillator-basic.html
@@ -20,11 +20,7 @@ description("Basic test of setting Oscillator node types.");
var sampleRate = 44100;
var renderLengthSeconds = 0.25;
-var oscTypes = [{type: "sine", integerType: 0, name: "SINE"},
- {type: "square", integerType: 1, name: "SQUARE"},
- {type: "sawtooth", integerType: 2, name: "SAWTOOTH"},
- {type: "triangle", integerType: 3, name: "TRIANGLE"},
- {type: "custom", integerType: 4, name: "CUSTOM"}];
+var oscTypes = ["sine", "square", "sawtooth", "triangle", "custom"];
function runTest()
{
@@ -42,22 +38,21 @@ function runTest()
// Set each possible oscillator type (except CUSTOM) and verify that the type is correct.
// Here we're setting the type using WebIDL enum values which are strings.
for (var k = 0; k < oscTypes.length - 1; ++k) {
- osc.type = oscTypes[k].type;
- if (osc.type == oscTypes[k].type)
- testPassed("Oscillator correctly set to " + oscTypes[k].name + " type.");
+ osc.type = oscTypes[k];
+ if (osc.type == oscTypes[k])
+ testPassed('Oscillator correctly set to "' + oscTypes[k] + '" type.');
else
- testFailed("Oscillator set to " + oscTypes[k].name + " type, but returns " + oscTypes[osc.type].name + " type.");
+ testFailed('Oscillator set to "' + oscTypes[k] + '" type, but returns "' + osc.type + '" type.');
}
- // For legacy support, verify that we can set the type attribute as an integer value and
- // verify that this translates correctly to the WebIDL enum value.
- for (var k = 0; k < oscTypes.length - 1; ++k) {
- osc.type = oscTypes[k].integerType;
- if (osc.type == oscTypes[k].type)
- testPassed("Oscillator correctly set to " + oscTypes[k].name + " type using legacy integer value.");
- else
- testFailed("Oscillator set to " + oscTypes[k].name + " type, but returns " + oscTypes[osc.type].name + " type using legacy integer value.");
- }
+ // Verify that setting a custom type directly does not set the custom type. This test has to be
+ // done before using setPeriodicWave.
+
+ osc.type = "custom";
+ if (osc.type == "custom")
+ testFailed('Directly setting oscillator type to "custom" incorrectly succeeded.');
+ else
+ testPassed('Directly setting oscillator type to "custom" correctly failed.');
// Now set a custom oscillator
var coeffA = new Float32Array([0, 1, 0.5]);
@@ -65,29 +60,17 @@ function runTest()
var wave = context.createPeriodicWave(coeffA, coeffB);
osc.setPeriodicWave(wave);
if (osc.type == "custom")
- testPassed("Oscillator correctly set to CUSTOM type using setPeriodicWave.");
+ testPassed('Oscillator correctly set to "custom" type using setPeriodicWave.');
else
- testFailed("Oscillator set to CUSTOM type, but returns " + oscTypes[osc.type].name + " type.");
+ testFailed('Oscillator set to "custom" type, but returns "' + osc.type + '" type.');
- // Try setting some invalid types
- try {
- osc.type = "custom";
- testFailed("Directly setting oscillator type to CUSTOM did not throw exception.");
- } catch (e) {
- testPassed("Directly setting oscillator type to CUSTOM correctly throws exception.");
- }
-
- var oscType = osc.CUSTOM + 1;
- try {
- osc.type = oscType;
- testFailed("Setting oscillator to invalid type " + oscType + " did not throw exception.");
- } catch (e) {
- testPassed("Setting oscillator to invalid type " + oscType + " correctly throws exception.");
- }
-
- // Check specifically that we throw a TypeError.
- shouldThrowTypeError(function() { osc.type = "xyz12349jfksd"; }, "Setting .type to illegal string value");
- shouldThrowTypeError(function() { osc.type = new Float32Array(1); }, "Setting .type to illegal type of Float32Array");
+
+ // Check that numerical values are no longer supported
+ osc.type = 0;
+ if (osc.type == 0)
+ testFailed("Oscillator incorrectly set to 0.")
+ else
+ testPassed("Oscillator correctly not set to 0.");
finishJSTest();
}
« no previous file with comments | « no previous file | LayoutTests/webaudio/oscillator-basic-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698