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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Analyser/realtimeanalyser-zero.html

Issue 2777983002: Convert Analyser tests to use new Audit. (Closed)
Patch Set: Remove console.logs Created 3 years, 8 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 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/testharness.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script> 5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/audit-util.js"></script> 6 <script src="../resources/audit-util.js"></script>
7 <script src="../resources/audio-testing.js"></script> 7 <script src="../resources/audit.js"></script>
8 <title>Test getFloatFrequencyData With Zero Inputs</title> 8 <title>Test getFloatFrequencyData With Zero Inputs</title>
9 </head> 9 </head>
10 10
11 <body> 11 <body>
12 <script> 12 <script>
13 var sampleRate = 48000; 13 var sampleRate = 48000;
14 14
15 // Render enough data to run the test. 15 // Render enough data to run the test.
16 var renderFrames = 2*1024; 16 var renderFrames = 2*1024;
17 var renderDuration = renderFrames / sampleRate; 17 var renderDuration = renderFrames / sampleRate;
18 18
19 var audit = Audit.createTaskRunner(); 19 var audit = Audit.createTaskRunner();
20 20
21 21
22 // Test that getFloatFrequencyData returns -Infinity when the input is all -zeroes. 22 // Test that getFloatFrequencyData returns -Infinity when the input is all -zeroes.
23 audit.defineTask("zero input", function (done) { 23 audit.define("zero input", (task, should) => {
24 var context = new OfflineAudioContext(1, renderFrames, sampleRate); 24 var context = new OfflineAudioContext(1, renderFrames, sampleRate);
25 25
26 // Constant source of 0's. 26 // Constant source of 0's.
27 var source = context.createBufferSource(); 27 var source = context.createBufferSource();
28 source.buffer = createConstantBuffer(context, 1, 0); 28 source.buffer = createConstantBuffer(context, 1, 0);
29 source.loop = true; 29 source.loop = true;
30 30
31 // Create analyser and use some non-default minDecibels value. 31 // Create analyser and use some non-default minDecibels value.
32 var analyser = context.createAnalyser(); 32 var analyser = context.createAnalyser();
33 analyser.minDecibels = -123; 33 analyser.minDecibels = -123;
34 34
35 source.connect(analyser); 35 source.connect(analyser);
36 analyser.connect(context.destination); 36 analyser.connect(context.destination);
37 37
38 source.start(); 38 source.start();
39 39
40 // Suspend after some number of frames and grab the float frequency data . 40 // Suspend after some number of frames and grab the float frequency data .
41 context.suspend(1024 / sampleRate).then(function () { 41 context.suspend(1024 / sampleRate).then(function () {
42 var f = new Float32Array(analyser.frequencyBinCount); 42 var f = new Float32Array(analyser.frequencyBinCount);
43 analyser.getFloatFrequencyData(f); 43 analyser.getFloatFrequencyData(f);
44 44
45 Should("getFloatFrequencyData() with zero-valued input", f) 45 should(f, "getFloatFrequencyData() with zero-valued input")
46 .beConstantValueOf(-Infinity); 46 .beConstantValueOf(-Infinity);
47 }).then(context.resume.bind(context)); 47 }).then(context.resume.bind(context));
48 48
49 context.startRendering().then(done); 49 context.startRendering().then(() => task.done());
50 }); 50 });
51 51
52 audit.defineTask("finish", function (done) { 52 audit.run();
53 done();
54 });
55
56 audit.runTasks();
57 53
58 </script> 54 </script>
59 </body> 55 </body>
60 </html> 56 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698