Set input method state when webpage move by history
[framework/web/webkit-efl.git] / LayoutTests / webaudio / audiobuffersource-start.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
6 <script src="resources/audio-testing.js"></script>
7 <script src="resources/audiobuffersource-testing.js"></script>
8 <script src="../fast/js/resources/js-test-pre.js"></script>
9 </head>
10
11 <body>
12
13 <div id="description"></div>
14 <div id="console"></div>
15
16 <script>
17 description("Tests AudioBufferSourceNode start() with a variety of offsets and durations.");
18
19 // The following test cases assume an AudioBuffer of length 8 whose PCM data is a linear ramp, 0, 1, 2, 3,...
20
21 var tests = [
22
23 { 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] },
25
26 { description: "start(when, 0): play whole buffer from beginning to end explicitly giving offset of 0",
27   offsetFrame: 0, durationFrames: "none", renderFrames: 16, playbackRate: 1, expected: [0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,0] },
28
29 { description: "start(when, 0, 8_frames): play whole buffer from beginning to end 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] },
31
32 { description: "start(when, 4_frames): play with explicit non-zero offset",
33   offsetFrame: 4, durationFrames: "none", renderFrames: 16, playbackRate: 1, expected: [4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0] },
34
35 { description: "start(when, 4_frames, 4_frames): play with explicit non-zero offset and duration",
36   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] },
37
38 // Enable test when AudioBufferSourceNode hack is fixed: https://bugs.webkit.org/show_bug.cgi?id=77224
39 // { description: "start(when, 3_frames, 3_frames): play a middle section with explicit offset and duration",
40 //   offsetFrame: 3, durationFrames: 3, renderFrames: 16, playbackRate: 1, expected: [4,5,6,7,0,0,0,0,0,0,0,0,0,0,0,0] },
41
42 ];
43
44 var sampleRate = 44100;
45 var buffer;
46 var bufferFrameLength = 8;
47 var testSpacingFrames = 32;
48 var testSpacingSeconds = testSpacingFrames / sampleRate;
49 var totalRenderLengthFrames = tests.length * testSpacingFrames;
50
51 function runLoopTest(context, testNumber, test) {
52     var source = context.createBufferSource();
53
54     source.buffer = buffer;
55     source.playbackRate.value = test.playbackRate;
56
57     source.connect(context.destination);
58
59     // Render each test one after the other, spaced apart by testSpacingSeconds.
60     var startTime = testNumber * testSpacingSeconds;
61
62     if (test.offsetFrame == "none" && test.durationFrames == "none") {
63         source.start(startTime);
64     } else if (test.durationFrames == "none") {
65         var offset = test.offsetFrame / context.sampleRate;
66         source.start(startTime, offset);
67     } else {
68         var offset = test.offsetFrame / context.sampleRate;
69         var duration = test.durationFrames / context.sampleRate;
70         source.start(startTime, offset, duration);
71     }
72 }
73
74 function runTest() {
75     if (window.testRunner) {
76         testRunner.dumpAsText();
77         testRunner.waitUntilDone();
78     }
79
80     window.jsTestIsAsync = true;
81
82     // Create offline audio context.
83     var context = new webkitOfflineAudioContext(1, totalRenderLengthFrames, sampleRate);
84     buffer = createTestBuffer(context, bufferFrameLength);
85
86     for (var i = 0; i < tests.length; ++i)
87         runLoopTest(context, i, tests[i]);
88
89     context.oncomplete = checkAllTests;
90     context.startRendering();
91 }
92
93 runTest();
94 successfullyParsed = true;
95
96 </script>
97
98 <script src="../fast/js/resources/js-test-post.js"></script>
99 </body>
100 </html>