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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.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> 1 <!DOCTYPE html>
2
3 <!-- 2 <!--
4 Test AudioBufferSourceNode supports 5.1 channel. 3 Test AudioBufferSourceNode supports 5.1 channel.
5 --> 4 -->
5 <html>
6 <head>
7 <title>
8 audiobuffersource-multi-channels.html
9 </title>
10 <script src="../../resources/testharness.js"></script>
11 <script src="../../resources/testharnessreport.js"></script>
12 <script src="../resources/audit-util.js"></script>
13 <script src="../resources/audit.js"></script>
14 <script src="../resources/mix-testing.js"></script>
15 </head>
16 <body>
17 <script id="layout-test-code">
18 let audit = Audit.createTaskRunner();
19 let context;
20 let expectedAudio;
6 21
7 <html> 22 audit.define('initialize', (task, should) => {
8 <head> 23 // Create offline audio context
9 <script src="../../resources/testharness.js"></script> 24 let sampleRate = 44100.0;
10 <script src="../../resources/testharnessreport.js"></script> 25 should(() => {
11 <script src="../resources/audit-util.js"></script> 26 context = new OfflineAudioContext(
12 <script src="../resources/audit.js"></script> 27 6, sampleRate * toneLengthSeconds, sampleRate);
13 <script src="../resources/mix-testing.js"></script> 28 }, 'Creating context for testing').notThrow();
14 </head> 29 should(
15 <body> 30 Audit
31 .loadFileFromUrl(
32 'audiobuffersource-multi-channels-expected.wav')
33 .then(arrayBuffer => {
34 context.decodeAudioData(arrayBuffer).then(audioBuffer => {
35 expectedAudio = audioBuffer;
36 });
37 }),
38 'Fetching expected audio')
39 .beResolved()
40 .then(() => task.done());
16 41
17 <script> 42 });
18 let audit = Audit.createTaskRunner();
19 let context;
20 let expectedAudio;
21
22 audit.define('initialize', (task, should) => {
23 // Create offline audio context
24 let sampleRate = 44100.0;
25 should(() => {
26 context =
27 new OfflineAudioContext(6, sampleRate * toneLengthSeconds, sampleRate);
28 }, 'Creating context for testing').notThrow();
29 should(
30 Audit.loadFileFromUrl('audiobuffersource-multi-channels-expected.wav')
31 .then(arrayBuffer => {
32 context.decodeAudioData(arrayBuffer).then(audioBuffer => {
33 expectedAudio = audioBuffer;
34 });
35 }),
36 'Fetching expected audio')
37 .beResolved()
38 .then(() => task.done());
39 43
40 }); 44 audit.define(
45 {label: 'test', description: 'AudioBufferSource with 5.1 buffer'},
46 (task, should) => {
47 let toneBuffer =
48 createToneBuffer(context, 440, toneLengthSeconds, 6);
41 49
42 audit.define( 50 let source = context.createBufferSource();
43 {label: 'test', description: 'AudioBufferSource with 5.1 buffer'}, 51 source.buffer = toneBuffer;
44 (task, should) => {
45 let toneBuffer = createToneBuffer(context, 440, toneLengthSeconds, 6);
46 52
47 let source = context.createBufferSource(); 53 source.connect(context.destination);
48 source.buffer = toneBuffer; 54 source.start(0);
49 55
50 source.connect(context.destination); 56 context.startRendering()
51 source.start(0); 57 .then(renderedAudio => {
58 // Compute a threshold based on the maximum error, |maxUlp|,
59 // in ULP. This is experimentally determined. Assuming that
60 // the reference file is a 16-bit wav file, the max values in
61 // the wave file are +/- 32768.
62 let maxUlp = 1;
63 let threshold = maxUlp / 32768;
52 64
53 context.startRendering() 65 for (let k = 0; k < renderedAudio.numberOfChannels; ++k) {
54 .then(renderedAudio => { 66 should(
55 // Compute a threshold based on the maximum error, |maxUlp|, in ULP. 67 renderedAudio.getChannelData(k),
56 // This is experimentally determined. Assuming that the reference 68 'Rendered audio for channel ' + k)
57 // file is a 16-bit wav file, the max values in the wave file 69 .beCloseToArray(
58 // are +/- 32768. 70 expectedAudio.getChannelData(k),
59 let maxUlp = 1; 71 {absoluteThreshold: threshold});
60 let threshold = maxUlp / 32768; 72 }
73 })
74 .then(() => task.done());
75 });
61 76
62 for (let k = 0; k < renderedAudio.numberOfChannels; ++k) { 77 audit.run();
63 should( 78 </script>
64 renderedAudio.getChannelData(k), 79 </body>
65 'Rendered audio for channel ' + k)
66 .beCloseToArray(
67 expectedAudio.getChannelData(k),
68 {absoluteThreshold: threshold});
69 }
70 })
71 .then(() => task.done());
72 });
73
74 audit.run();
75 </script>
76
77 </body>
78 </html> 80 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698