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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/oscillator-basic.html

Issue 2581463002: Refactor WebAudio test directory (Closed)
Patch Set: Use correct path for wav result files Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3 <!--
4 Create an oscillator of each type and verify that the type is set correctly.
5 -->
6 <html>
7 <head>
8 <script src="../resources/js-test.js"></script>
9 <script src="resources/compatibility.js"></script>
10 <script src="resources/audit-util.js"></script>
11 <script src="resources/audio-testing.js"></script>
12 </head>
13
14 <body>
15 <div id="description"></div>
16 <div id="console"></div>
17
18 <script>
19 description("Basic test of setting Oscillator node types.");
20
21 var sampleRate = 44100;
22 var renderLengthSeconds = 0.25;
23
24 var oscTypes = ["sine", "square", "sawtooth", "triangle", "custom"];
25
26 function runTest()
27 {
28 if (window.testRunner) {
29 testRunner.dumpAsText();
30 testRunner.waitUntilDone();
31 }
32
33 window.jsTestIsAsync = true;
34
35 // Create offline audio context.
36 var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, s ampleRate);
37 var osc = context.createOscillator();
38
39 // Set each possible oscillator type (except CUSTOM) and verify that the typ e is correct.
40 // Here we're setting the type using WebIDL enum values which are strings.
41 for (var k = 0; k < oscTypes.length - 1; ++k) {
42 osc.type = oscTypes[k];
43 Should("osc.type = '" + oscTypes[k] + "'", osc.type).beEqualTo(oscTypes[ k]);
44 }
45
46 // Verify that setting a custom type directly does not set the custom type. This test has to be
47 // done before using setPeriodicWave.
48
49 Should("osc.type = 'custom'", function () {
50 osc.type = "custom";
51 }).throw('InvalidStateError');
52
53 // Now set a custom oscillator
54 var coeffA = new Float32Array([0, 1, 0.5]);
55 var coeffB = new Float32Array([0, 0, 0]);
56 var wave = context.createPeriodicWave(coeffA, coeffB);
57
58 Should("osc.setPeriodicWave(wave)", function () {
59 osc.setPeriodicWave(wave);
60 }).notThrow();
61 Should("osc.type", osc.type).beEqualTo("custom");
62
63 // Check that numerical values are no longer supported
64 var oldType = osc.type;
65 osc.type = 0;
66 Should("osc.type = 0", osc.type).notBeEqualTo(0);
67 Should("osc.type", osc.type).beEqualTo(oldType);
68
69 finishJSTest();
70 }
71
72 runTest();
73 successfullyParsed = true;
74
75 </script>
76
77
78 </body>
79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698