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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-multi-channels.html

Issue 2714853005: Convert remaining AudioBufferSource tests to testharness (Closed)
Patch Set: Remove use of finishAudioTest 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 2
3 <!-- 3 <!--
4 Test AudioBufferSourceNode supports 5.1 channel. 4 Test AudioBufferSourceNode supports 5.1 channel.
5 --> 5 -->
6 6
7 <html> 7 <html>
8 <head> 8 <head>
9 <script src="../../resources/testharness.js"></script>
10 <script src="../../resources/testharnessreport.js"></script>
9 <script src="../resources/audit-util.js"></script> 11 <script src="../resources/audit-util.js"></script>
10 <script src="../resources/audio-testing.js"></script> 12 <script src="../resources/audit.js"></script>
11 <script type="text/javascript" src="../resources/mix-testing.js"></script> 13 <script src="../resources/mix-testing.js"></script>
12 </head> 14 </head>
13 <body> 15 <body>
14 16
15 <script> 17 <script>
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());
16 39
17 function runTest() { 40 });
18 if (!window.testRunner)
19 return;
20 41
21 testRunner.waitUntilDone(); 42 audit.define(
43 {label: 'test', description: 'AudioBufferSource with 5.1 buffer'},
44 (task, should) => {
45 let toneBuffer = createToneBuffer(context, 440, toneLengthSeconds, 6);
22 46
23 window.jsTestAsync = true; 47 let source = context.createBufferSource();
48 source.buffer = toneBuffer;
24 49
25 // Create offline audio context 50 source.connect(context.destination);
26 var sampleRate = 44100.0; 51 source.start(0);
27 var context = new OfflineAudioContext(6, sampleRate * toneLengthSeconds, sam pleRate);
28 var toneBuffer = createToneBuffer(context, 440, toneLengthSeconds, 6);
29 52
30 var source = context.createBufferSource(); 53 context.startRendering()
31 source.buffer = toneBuffer; 54 .then(renderedAudio => {
55 // Compute a threshold based on the maximum error, |maxUlp|, in ULP.
56 // This is experimentally determined. Assuming that the reference
57 // file is a 16-bit wav file, the max values in the wave file
58 // are +/- 32768.
59 let maxUlp = 1;
60 let threshold = maxUlp / 32768;
32 61
33 source.connect(context.destination); 62 for (let k = 0; k < renderedAudio.numberOfChannels; ++k) {
34 source.start(0); 63 should(
64 renderedAudio.getChannelData(k),
65 'Rendered audio for channel ' + k)
66 .beCloseToArray(
67 expectedAudio.getChannelData(k),
68 {absoluteThreshold: threshold});
69 }
70 })
71 .then(() => task.done());
72 });
35 73
36 context.oncomplete = finishAudioTest; 74 audit.run();
37 context.startRendering();
38 }
39
40 runTest();
41 </script> 75 </script>
42 76
43 </body> 77 </body>
44 </html> 78 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698