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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-grain.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 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Start Grain with Delayed Buffer Setting </title> 4 <title>
5 Test Start Grain with Delayed Buffer Setting
6 </title>
5 <script src="../../resources/testharness.js"></script> 7 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 8 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 9 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 10 <script src="../resources/audit.js"></script>
9 </head> 11 </head>
10
11 <body> 12 <body>
12 <script> 13 <script id="layout-test-code">
13 let audit = Audit.createTaskRunner(); 14 let audit = Audit.createTaskRunner();
14 let context; 15 let context;
15 let source; 16 let source;
16 let buffer; 17 let buffer;
17 let renderedData; 18 let renderedData;
18 19
19 let sampleRate = 44100; 20 let sampleRate = 44100;
20 21
21 let testDurationSec = 1; 22 let testDurationSec = 1;
22 let testDurationSamples = testDurationSec * sampleRate; 23 let testDurationSamples = testDurationSec * sampleRate;
23 let startTime = 0.9 * testDurationSec; 24 let startTime = 0.9 * testDurationSec;
24 25
25 audit.define("Test setting the source buffer after starting the grain", 26 audit.define(
26 function (task, should) { 27 'Test setting the source buffer after starting the grain',
27 context = new OfflineAudioContext(1, testDurationSamples, 28 function(task, should) {
28 sampleRate); 29 context =
30 new OfflineAudioContext(1, testDurationSamples, sampleRate);
29 31
30 buffer = createConstantBuffer(context, testDurationSamples, 1); 32 buffer = createConstantBuffer(context, testDurationSamples, 1);
31 source = context.createBufferSource(); 33 source = context.createBufferSource();
32 source.connect(context.destination); 34 source.connect(context.destination);
33 35
34 // Start the source BEFORE we set the buffer. The grain offset and dur ation aren't 36 // Start the source BEFORE we set the buffer. The grain offset and
35 // important, as long as we specify some offset. 37 // duration aren't important, as long as we specify some offset.
36 source.start(startTime, .1); 38 source.start(startTime, .1);
37 source.buffer = buffer; 39 source.buffer = buffer;
38 40
39 // Render it! 41 // Render it!
40 context.startRendering() 42 context.startRendering()
41 .then(function (buffer) { 43 .then(function(buffer) {
42 checkResult(buffer, should); 44 checkResult(buffer, should);
43 }) 45 })
44 .then(task.done.bind(task));; 46 .then(task.done.bind(task));
45 }); 47 ;
48 });
46 49
47 function checkResult(buffer, should) { 50 function checkResult(buffer, should) {
48 let success = false; 51 let success = false;
49 52
50 renderedData = buffer.getChannelData(0); 53 renderedData = buffer.getChannelData(0);
51 54
52 // Check that the rendered data is not all zeroes. Any non-zero data me ans the test 55 // Check that the rendered data is not all zeroes. Any non-zero data
53 // passed. 56 // means the test passed.
54 let startFrame = Math.round(startTime * sampleRate); 57 let startFrame = Math.round(startTime * sampleRate);
55 for (k = 0; k < renderedData.length; ++k) { 58 for (k = 0; k < renderedData.length; ++k) {
56 if (renderedData[k]) { 59 if (renderedData[k]) {
57 success = true; 60 success = true;
58 break; 61 break;
59 } 62 }
60 } 63 }
61 64
62 should(success, "Buffer was played").beTrue(); 65 should(success, 'Buffer was played').beTrue();
63 } 66 }
64 67
65 audit.run(); 68 audit.run();
66 </script> 69 </script>
67 </body> 70 </body>
68 </html> 71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698