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

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

Issue 2595633002: Convert Analyser tests to use testharness (Closed)
Patch Set: Created 3 years, 12 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/js-test.js"></script> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../resources/compatibility.js"></script> 6 <script src="../resources/compatibility.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/audio-testing.js"></script>
8 <title>Test Multiple Calls to getFloatFrequencyData</title> 9 <title>Test Multiple Calls to getFloatFrequencyData</title>
9 </head> 10 </head>
10 11
11 <body> 12 <body>
12 <script> 13 <script>
13 description("Test AnalyserNode getFloatFrequencyData and getByteFrequencyD ata");
14 window.jsTestIsAsync = true; 14 window.jsTestIsAsync = true;
hongchan 2016/12/20 23:04:31 ditto.
15 15
16 var sampleRate = 48000; 16 var sampleRate = 48000;
17 // Render enough data to run the test. 17 // Render enough data to run the test.
18 var renderFrames = 2*1024; 18 var renderFrames = 2*1024;
19 var renderDuration = renderFrames / sampleRate; 19 var renderDuration = renderFrames / sampleRate;
20 20
21 var audit = Audit.createTaskRunner(); 21 var audit = Audit.createTaskRunner();
22 22
23 audit.defineTask("test", function (done) { 23 audit.defineTask("test", function (done) {
24 24
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 "Output of getFloatFrequenycData (converted to byte) after getByte FrequencyData", 100 "Output of getFloatFrequenycData (converted to byte) after getByte FrequencyData",
101 f1) 101 f1)
102 .beEqualToArray(byteValuesFromFloat) && success; 102 .beEqualToArray(byteValuesFromFloat) && success;
103 }).then(context.resume.bind(context)); 103 }).then(context.resume.bind(context));
104 104
105 osc.start(); 105 osc.start();
106 context.startRendering().then(done); 106 context.startRendering().then(done);
107 }); 107 });
108 108
109 audit.defineTask("finish", function (done) { 109 audit.defineTask("finish", function (done) {
110 finishJSTest();
111 done(); 110 done();
112 }); 111 });
113 112
114 audit.runTasks(); 113 audit.runTasks();
115 114
116 // Convert the float frequency data (in dB), |floatFreqData|, to byte valu es using the dB 115 // Convert the float frequency data (in dB), |floatFreqData|, to byte valu es using the dB
117 // limits |minDecibels| and |maxDecibels|. The new byte array is returned . 116 // limits |minDecibels| and |maxDecibels|. The new byte array is returned .
118 function convertFloatToByte(floatFreqData, minDecibels, maxDecibels) { 117 function convertFloatToByte(floatFreqData, minDecibels, maxDecibels) {
119 var scale = 255 / (maxDecibels - minDecibels); 118 var scale = 255 / (maxDecibels - minDecibels);
120 119
121 return floatFreqData.map(function (x) { 120 return floatFreqData.map(function (x) {
122 var value = Math.floor(scale * (x - minDecibels)); 121 var value = Math.floor(scale * (x - minDecibels));
123 return Math.min(255, Math.max(0, value)); 122 return Math.min(255, Math.max(0, value));
124 }); 123 });
125 } 124 }
126 </script> 125 </script>
127 </body> 126 </body>
128 </html> 127 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698