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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioNode/audionode-connect-order.html

Issue 2651623004: Convert more AudioNode tests to use testharness (Closed)
Patch Set: Rebase Created 3 years, 11 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 <html> 3 <html>
4 <head> 4 <head>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 8 <script src="../resources/audit.js"></script>
8 </head> 9 </head>
9 10
10 <body> 11 <body>
12 <script>
13 //description("This tests that we don't trigger an assertion failure due to Audi oNode connection order.");
11 14
12 <div id="description"></div> 15 let audit = Audit.createTaskRunner();
13 <div id="console"></div> 16 let sampleRate = 44100.0;
14 17 let renderLengthSeconds = 0.125;
15 <script> 18 let delayTimeSeconds = 0.1;
16 description("This tests that we don't trigger an assertion failure due to AudioN ode connection order.");
17
18 var sampleRate = 44100.0;
19 var renderLengthSeconds = 0.125;
20 var delayTimeSeconds = 0.1;
21 19
22 function createSinWaveBuffer(context, lengthInSeconds, frequency) { 20 function createSinWaveBuffer(context, lengthInSeconds, frequency) {
23 var audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, samp leRate); 21 let audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, samp leRate);
24 22
25 var n = audioBuffer.length; 23 let n = audioBuffer.length;
26 var data = audioBuffer.getChannelData(0); 24 let data = audioBuffer.getChannelData(0);
27 25
28 for (var i = 0; i < n; ++i) { 26 for (let i = 0; i < n; ++i) {
29 data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate); 27 data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate);
30 } 28 }
31 29
32 return audioBuffer; 30 return audioBuffer;
33 } 31 }
34 32
35 function runTest() { 33 audit.define("Test connections", function (task, should) {
36 if (window.testRunner) { 34 task.describe(
37 testRunner.dumpAsText(); 35 "AudioNode connection order doesn't trigger assertion errors"
38 testRunner.waitUntilDone(); 36 );
39 }
40
41 window.jsTestIsAsync = true;
42
43 // Create offline audio context. 37 // Create offline audio context.
44 var context = new OfflineAudioContext(1, sampleRate * renderLengthSeconds, s ampleRate); 38 let context = new OfflineAudioContext(1, sampleRate *
45 var toneBuffer = createSinWaveBuffer(context, renderLengthSeconds, 880); 39 renderLengthSeconds, sampleRate);
46 40 let toneBuffer = createSinWaveBuffer(context, renderLengthSeconds,
47 var bufferSource = context.createBufferSource(); 41 880);
42
43 let bufferSource = context.createBufferSource();
48 bufferSource.buffer = toneBuffer; 44 bufferSource.buffer = toneBuffer;
49 bufferSource.connect(context.destination); 45 bufferSource.connect(context.destination);
50 46
51 var delay = context.createDelay(); 47 let delay = context.createDelay();
52 delay.delayTime.value = delayTimeSeconds; 48 delay.delayTime.value = delayTimeSeconds;
53 49
54 // We connect delay node to gain node before anything is connected to delay node itself. 50 // We connect delay node to gain node before anything is connected to delay
55 // We do this because we try to trigger the ASSERT which might be fired due to AudioNode connection order, 51 // node itself. We do this because we try to trigger the ASSERT which might
56 // especially when gain node and delay node is involved e.g. https://bugs.we bkit.org/show_bug.cgi?id=76685. 52 // be fired due to AudioNode connection order, especially when gain node and
53 // delay node is involved
54 // e.g. https://bugs.webkit.org/show_bug.cgi?id=76685.
57 55
58 var gain = context.createGain(); 56 should(() => {
59 gain.connect(context.destination); 57 let gain = context.createGain();
60 delay.connect(gain); 58 gain.connect(context.destination);
59 delay.connect(gain);
60 }, "Connecting nodes")
61 .notThrow();
61 62
62 bufferSource.start(0); 63 bufferSource.start(0);
63 64
64 context.oncomplete = finishJSTest; 65 let promise = context.startRendering();
65 context.startRendering();
66 }
67 66
68 runTest(); 67 should(promise, "OfflineContext startRendering()")
68 .beResolved()
69 .then(task.done.bind(task));
70 });
71
72 audit.run();
69 73
70 </script> 74 </script>
71 75
72 </body> 76 </body>
73 </html> 77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698