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

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

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 1 <!DOCTYPE html>
2
3 <!-- 2 <!--
4 Create an oscillator of each type and verify that the type is set correctly. 3 Create an oscillator of each type and verify that the type is set correctly.
5 --> 4 -->
6 <html> 5 <html>
7 <head> 6 <head>
8 <script src="../../resources/testharness.js"></script> 7 <title>
9 <script src="../../resources/testharnessreport.js"></script> 8 oscillator-basic.html
10 <script src="../resources/audit-util.js"></script> 9 </title>
11 <script src="../resources/audit.js"></script> 10 <script src="../../resources/testharness.js"></script>
12 </head> 11 <script src="../../resources/testharnessreport.js"></script>
12 <script src="../resources/audit-util.js"></script>
13 <script src="../resources/audit.js"></script>
14 </head>
15 <body>
16 <script id="layout-test-code">
17 let sampleRate = 44100;
18 let renderLengthSeconds = 0.25;
13 19
14 <body> 20 let oscTypes = ['sine', 'square', 'sawtooth', 'triangle', 'custom'];
15 <script>
16 var sampleRate = 44100;
17 var renderLengthSeconds = 0.25;
18 21
19 var oscTypes = ["sine", "square", "sawtooth", "triangle", "custom"]; 22 let audit = Audit.createTaskRunner();
20 23
21 let audit = Audit.createTaskRunner(); 24 audit.define('basic osc tests', (task, should) => {
22 25 // Create offline audio context.
23 audit.define("basic osc tests", (task, should) => { 26 let context = new OfflineAudioContext(
24 // Create offline audio context. 27 2, sampleRate * renderLengthSeconds, sampleRate);
25 var context = new OfflineAudioContext(2, sampleRate * 28 let osc = context.createOscillator();
26 renderLengthSeconds, sampleRate);
27 var osc = context.createOscillator();
28 29
29 // Set each possible oscillator type (except CUSTOM) and verify that the 30 // Set each possible oscillator type (except CUSTOM) and verify that the
30 // type is correct. Here we're setting the type using WebIDL enum values 31 // type is correct. Here we're setting the type using WebIDL enum
31 // which are strings. 32 // values which are strings.
32 for (var k = 0; k < oscTypes.length - 1; ++k) { 33 for (let k = 0; k < oscTypes.length - 1; ++k) {
33 osc.type = oscTypes[k]; 34 osc.type = oscTypes[k];
34 should(osc.type, "osc.type = '" + oscTypes[k] + "'") 35 should(osc.type, 'osc.type = \'' + oscTypes[k] + '\'')
35 .beEqualTo(oscTypes[k]); 36 .beEqualTo(oscTypes[k]);
36 } 37 }
37 38
38 // Verify that setting a custom type directly does not set the custom 39 // Verify that setting a custom type directly does not set the custom
39 // type. This test has to be done before using setPeriodicWave. 40 // type. This test has to be done before using setPeriodicWave.
40 41
41 should(function () { 42 should(function() {
42 osc.type = "custom"; 43 osc.type = 'custom';
43 }, "osc.type = 'custom'") 44 }, 'osc.type = \'custom\'').throw('InvalidStateError');
44 .throw('InvalidStateError');
45 45
46 // Now set a custom oscillator 46 // Now set a custom oscillator
47 var coeffA = new Float32Array([0, 1, 0.5]); 47 let coeffA = new Float32Array([0, 1, 0.5]);
48 var coeffB = new Float32Array([0, 0, 0]); 48 let coeffB = new Float32Array([0, 0, 0]);
49 var wave = context.createPeriodicWave(coeffA, coeffB); 49 let wave = context.createPeriodicWave(coeffA, coeffB);
50 50
51 should(function () { 51 should(function() {
52 osc.setPeriodicWave(wave); 52 osc.setPeriodicWave(wave);
53 }, "osc.setPeriodicWave(wave)").notThrow(); 53 }, 'osc.setPeriodicWave(wave)').notThrow();
54 should(osc.type, "After setting periodicWave, osc.type") 54 should(osc.type, 'After setting periodicWave, osc.type')
55 .beEqualTo("custom"); 55 .beEqualTo('custom');
56 56
57 // Check that numerical values are no longer supported 57 // Check that numerical values are no longer supported
58 var oldType = osc.type; 58 let oldType = osc.type;
59 osc.type = 0; 59 osc.type = 0;
60 should(osc.type, "osc.type = 0").notBeEqualTo(0); 60 should(osc.type, 'osc.type = 0').notBeEqualTo(0);
61 should(osc.type, "osc.type").beEqualTo(oldType); 61 should(osc.type, 'osc.type').beEqualTo(oldType);
62 62
63 task.done(); 63 task.done();
64 }); 64 });
65 65
66 audit.run(); 66 audit.run();
67 </script> 67 </script>
68 68 </body>
69
70 </body>
71 </html> 69 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698