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

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

Issue 2581463002: Refactor WebAudio test directory (Closed)
Patch Set: Use correct path for wav result files 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
(Empty)
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audit-util.js"></script>
8 <script src="resources/audio-testing.js"></script>
9 <script src="resources/audiobuffersource-testing.js"></script>
10 </head>
11
12 <body>
13
14 <div id="description"></div>
15 <div id="console"></div>
16
17 <script>
18 description("Tests AudioBufferSourceNode start() with a variety of offsets and d urations.");
19
20 // The following test cases assume an AudioBuffer of length 8 whose PCM data is a linear ramp, 0, 1, 2, 3,...
21
22 var tests = [
23
24 { description: "start(when): implicitly play whole buffer from beginning to end" ,
25 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] },
26
27 { description: "start(when, 0): play whole buffer from beginning to end explicit ly giving offset of 0",
28 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] },
29
30 { description: "start(when, 0, 8_frames): play whole buffer from beginning to en d explicitly giving offset of 0 and duration of 8 frames",
31 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] },
32
33 { description: "start(when, 4_frames): play with explicit non-zero offset",
34 offsetFrame: 4, durationFrames: "none", renderFrames: 16, playbackRate: 1, exp ected: [4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0] },
35
36 { description: "start(when, 4_frames, 4_frames): play with explicit non-zero off set and duration",
37 offsetFrame: 4, durationFrames: 4, renderFrames: 16, playbackRate: 1, expected : [4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0] },
38
39 { description: "start(when, 7_frames): play with explicit non-zero offset near e nd of buffer",
40 offsetFrame: 7, durationFrames: 1, renderFrames: 16, playbackRate: 1, expected : [7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] },
41
42 { description: "start(when, 8_frames): play with explicit offset at end of buffe r",
43 offsetFrame: 8, durationFrames: 0, renderFrames: 16, playbackRate: 1, expected : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] },
44
45 { description: "start(when, 9_frames): play with explicit offset past end of buf fer",
46 offsetFrame: 8, durationFrames: 0, renderFrames: 16, playbackRate: 1, expected : [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] },
47
48 // When the duration exceeds the buffer, just play to the end of the buffer.
49 // (This is different from the case when we're looping, which is tested in loop- comprehensive.)
50 { description: "start(when, 0, 15_frames): play with whole buffer, with long dur ation (clipped)",
51 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] },
52
53 // Enable test when AudioBufferSourceNode hack is fixed: https://bugs.webkit.org /show_bug.cgi?id=77224
54 // { description: "start(when, 3_frames, 3_frames): play a middle section with e xplicit offset and duration",
55 // 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] },
56
57 ];
58
59 var sampleRate = 44100;
60 var buffer;
61 var bufferFrameLength = 8;
62 var testSpacingFrames = 32;
63 var testSpacingSeconds = testSpacingFrames / sampleRate;
64 var totalRenderLengthFrames = tests.length * testSpacingFrames;
65
66 function runLoopTest(context, testNumber, test) {
67 var source = context.createBufferSource();
68
69 source.buffer = buffer;
70 source.playbackRate.value = test.playbackRate;
71
72 source.connect(context.destination);
73
74 // Render each test one after the other, spaced apart by testSpacingSeconds.
75 var startTime = testNumber * testSpacingSeconds;
76
77 if (test.offsetFrame == "none" && test.durationFrames == "none") {
78 source.start(startTime);
79 } else if (test.durationFrames == "none") {
80 var offset = test.offsetFrame / context.sampleRate;
81 source.start(startTime, offset);
82 } else {
83 var offset = test.offsetFrame / context.sampleRate;
84 var duration = test.durationFrames / context.sampleRate;
85 source.start(startTime, offset, duration);
86 }
87 }
88
89 function runTest() {
90 if (window.testRunner) {
91 testRunner.dumpAsText();
92 testRunner.waitUntilDone();
93 }
94
95 window.jsTestIsAsync = true;
96
97 // Create offline audio context.
98 var context = new OfflineAudioContext(1, totalRenderLengthFrames, sampleRate );
99 buffer = createTestBuffer(context, bufferFrameLength);
100
101 for (var i = 0; i < tests.length; ++i)
102 runLoopTest(context, i, tests[i]);
103
104 context.oncomplete = checkAllTests;
105 context.startRendering();
106 }
107
108 runTest();
109 successfullyParsed = true;
110
111 </script>
112
113 </body>
114 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698