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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-one-sample-loop.html

Issue 2591383002: Convert audiobuffersource-one-sample-loop to testharness (Closed)
Patch Set: Simplify test 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-one-sample-loop-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer</title > 4 <title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer</title >
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>
11 <script> 12 <script>
12 description("Test AudioBufferSourceNode With Looping a Single-Sample Buffe r"); 13 let audit = Audit.createTaskRunner();
13 14
14 var context; 15 let sampleRate = 44100;
15 var source; 16 let testDurationSamples = 1000;
16 var buffer;
17 var renderedData;
18 17
19 var sampleRate = 44100; 18 audit.define("one-sample-loop", function (task, should) {
20 var testDurationSamples = 1000; 19 // Create the offline context for the test.
20 let context = new OfflineAudioContext(1, testDurationSamples,
21 sampleRate);
21 22
22 function checkResult (event) { 23 // Create the single sample buffer
23 var success = true; 24 let buffer = createConstantBuffer(context, 1, 1);
24 25
25 renderedData = event.renderedBuffer.getChannelData(0); 26 // Create the source and connect it to the destination
26 // Check that the rendered data is all ones, like the buffer source. 27 let source = context.createBufferSource();
27 for (k = 0; k < renderedData.length; ++k) { 28 source.buffer = buffer;
28 if (renderedData[k] != 1) { 29 source.loop = true;
29 success = false; 30 source.connect(context.destination);
30 testFailed("Expected all ones, but sample " + k + " is " + ren deredData[k]); 31 source.start();
31 break;
32 }
33 }
34 if (success)
35 testPassed("All samples equal to 1");
36 finishJSTest();
37 }
38 32
39 function runTest() { 33 // Render it!
40 window.jsTestIsAsync = true; 34 context.startRendering()
35 .then(function(audioBuffer) {
36 should(audioBuffer.getChannelData(0), "Rendered data")
37 .beConstantValueOf(1);
38 })
39 .then(task.done.bind(task));;
40 });
41 41
42 // Create the offline context for the test. 42 audit.run();
43 context = new OfflineAudioContext(1, testDurationSamples, sampleRate);
44 context.oncomplete = checkResult;
45
46 // Create the single sample buffer
47 buffer = createConstantBuffer(context, 1, 1);
48
49 // Create the source and connect it to the destination
50 source = context.createBufferSource();
51 source.buffer = buffer;
52 source.loop = true;
53 source.connect(context.destination);
54 source.start();
55
56 // Render it!
57 context.startRendering();
58 }
59
60 runTest();
61 succesfullyParsed = true;
62 </script> 43 </script>
63 </body> 44 </body>
64 </html> 45 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-one-sample-loop-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698