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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioBufferSource/audiobuffersource-start.html

Issue 2599573003: Convert AudioBufferSource start and loop-comprehensive tests to testharness (Closed)
Patch Set: Address review comments and git cl format 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 <script src="../resources/audiobuffersource-testing.js"></script> 9 <script src="../resources/audiobuffersource-testing.js"></script>
9 </head> 10 </head>
10 11
11 <body> 12 <body>
12 13
13 <div id="description"></div>
14 <div id="console"></div>
15
16 <script> 14 <script>
17 description("Tests AudioBufferSourceNode start() with a variety of offsets and d urations."); 15 let audit = Audit.createTaskRunner();
18 16
19 // The following test cases assume an AudioBuffer of length 8 whose PCM data is a linear ramp, 0, 1, 2, 3,... 17 // The following test cases assume an AudioBuffer of length 8 whose PCM data is a linear ramp, 0, 1, 2, 3,...
20 18
21 var tests = [ 19 let tests = [
22 20
23 { description: "start(when): implicitly play whole buffer from beginning to end" , 21 { description: "start(when): implicitly play whole buffer from beginning to end" ,
24 offsetFrame: "none", durationFrames: "none", renderFrames: 16, playbackRate: 1 , expected: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] }, 22 offsetFrame: "none", durationFrames: "none", renderFrames: 16, playbackRate: 1 , expected: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] },
25 23
26 { description: "start(when, 0): play whole buffer from beginning to end explicit ly giving offset of 0", 24 { description: "start(when, 0): play whole buffer from beginning to end explicit ly giving offset of 0",
27 offsetFrame: 0, durationFrames: "none", renderFrames: 16, playbackRate: 1, exp ected: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] }, 25 offsetFrame: 0, durationFrames: "none", renderFrames: 16, playbackRate: 1, exp ected: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] },
28 26
29 { description: "start(when, 0, 8_frames): play whole buffer from beginning to en d explicitly giving offset of 0 and duration of 8 frames", 27 { description: "start(when, 0, 8_frames): play whole buffer from beginning to en d explicitly giving offset of 0 and duration of 8 frames",
30 offsetFrame: 0, durationFrames: 8, renderFrames: 16, playbackRate: 1, expected : [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] }, 28 offsetFrame: 0, durationFrames: 8, renderFrames: 16, playbackRate: 1, expected : [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] },
31 29
(...skipping 16 matching lines...) Expand all
48 // (This is different from the case when we're looping, which is tested in loop- comprehensive.) 46 // (This is different from the case when we're looping, which is tested in loop- comprehensive.)
49 { description: "start(when, 0, 15_frames): play with whole buffer, with long dur ation (clipped)", 47 { description: "start(when, 0, 15_frames): play with whole buffer, with long dur ation (clipped)",
50 offsetFrame: 0, durationFrames: 15, renderFrames: 16, playbackRate: 1, expecte d: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] }, 48 offsetFrame: 0, durationFrames: 15, renderFrames: 16, playbackRate: 1, expecte d: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] },
51 49
52 // Enable test when AudioBufferSourceNode hack is fixed: https://bugs.webkit.org /show_bug.cgi?id=77224 50 // Enable test when AudioBufferSourceNode hack is fixed: https://bugs.webkit.org /show_bug.cgi?id=77224
53 // { description: "start(when, 3_frames, 3_frames): play a middle section with e xplicit offset and duration", 51 // { description: "start(when, 3_frames, 3_frames): play a middle section with e xplicit offset and duration",
54 // offsetFrame: 3, durationFrames: 3, renderFrames: 16, playbackRate: 1, expec ted: [4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0] }, 52 // offsetFrame: 3, durationFrames: 3, renderFrames: 16, playbackRate: 1, expec ted: [4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0] },
55 53
56 ]; 54 ];
57 55
58 var sampleRate = 44100; 56 let sampleRate = 44100;
59 var buffer; 57 let buffer;
60 var bufferFrameLength = 8; 58 let bufferFrameLength = 8;
61 var testSpacingFrames = 32; 59 let testSpacingFrames = 32;
62 var testSpacingSeconds = testSpacingFrames / sampleRate; 60 let testSpacingSeconds = testSpacingFrames / sampleRate;
63 var totalRenderLengthFrames = tests.length * testSpacingFrames; 61 let totalRenderLengthFrames = tests.length * testSpacingFrames;
64 62
65 function runLoopTest(context, testNumber, test) { 63 function runLoopTest(context, testNumber, test) {
66 var source = context.createBufferSource(); 64 let source = context.createBufferSource();
67 65
68 source.buffer = buffer; 66 source.buffer = buffer;
69 source.playbackRate.value = test.playbackRate; 67 source.playbackRate.value = test.playbackRate;
70 68
71 source.connect(context.destination); 69 source.connect(context.destination);
72 70
73 // Render each test one after the other, spaced apart by testSpacingSeconds. 71 // Render each test one after the other, spaced apart by testSpacingSeconds.
74 var startTime = testNumber * testSpacingSeconds; 72 let startTime = testNumber * testSpacingSeconds;
75 73
76 if (test.offsetFrame == "none" && test.durationFrames == "none") { 74 if (test.offsetFrame == "none" && test.durationFrames == "none") {
77 source.start(startTime); 75 source.start(startTime);
78 } else if (test.durationFrames == "none") { 76 } else if (test.durationFrames == "none") {
79 var offset = test.offsetFrame / context.sampleRate; 77 let offset = test.offsetFrame / context.sampleRate;
80 source.start(startTime, offset); 78 source.start(startTime, offset);
81 } else { 79 } else {
82 var offset = test.offsetFrame / context.sampleRate; 80 let offset = test.offsetFrame / context.sampleRate;
83 var duration = test.durationFrames / context.sampleRate; 81 let duration = test.durationFrames / context.sampleRate;
84 source.start(startTime, offset, duration); 82 source.start(startTime, offset, duration);
85 } 83 }
86 } 84 }
87 85
88 function runTest() { 86 audit.define("Tests AudioBufferSourceNode start()", function (task, should) {
89 if (window.testRunner) {
90 testRunner.dumpAsText();
91 testRunner.waitUntilDone();
92 }
93
94 window.jsTestIsAsync = true;
95
96 // Create offline audio context. 87 // Create offline audio context.
97 var context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate ); 88 let context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate );
98 buffer = createTestBuffer(context, bufferFrameLength); 89 buffer = createTestBuffer(context, bufferFrameLength);
99 90
100 for (var i = 0; i < tests.length; ++i) 91 for (let i = 0; i < tests.length; ++i)
101 runLoopTest(context, i, tests[i]); 92 runLoopTest(context, i, tests[i]);
102 93
103 context.oncomplete = checkAllTests; 94 context.startRendering()
104 context.startRendering(); 95 .then(function (audioBuffer) {
105 } 96 checkAllTests(audioBuffer, should);
97 task.done();
98 });
99 });
106 100
107 runTest(); 101 audit.run();
108 successfullyParsed = true;
109
110 </script> 102 </script>
111 103
112 </body> 104 </body>
113 </html> 105 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698