Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / webaudio / stereo2mono-down-mixing.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 </head>
8
9 <body>
10
11 <div id="description"></div>
12 <div id="console"></div>
13
14 <script>
15 description("This test verifies whether down mixing from stereo to mono will cause assertion error.");
16
17 var sampleRate = 44100.0;
18 var renderLengthSeconds = 0.1;
19
20 var context;
21 var toneBuffer;
22 var bufferSource;
23
24 function createDataBuffer(context, lengthInSeconds) {
25     var audioBuffer = context.createBuffer(2, lengthInSeconds * sampleRate, sampleRate);
26
27     var n = audioBuffer.length;
28     var data0 = audioBuffer.getChannelData(0);
29     var data1 = audioBuffer.getChannelData(1);
30
31     for (var i = 0; i < n; ++i) {
32         data0[i] = 1.0;
33         data1[i] = 1.0;
34     }
35
36     return audioBuffer;
37 }
38
39 function testFinished() {
40     testPassed("Test no ASSERT error.");
41     finishJSTest();
42 }
43
44 function runTest() {
45     window.jsTestIsAsync = true;
46
47     // Create offline audio context, the destination is mono.
48     context = new webkitOfflineAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
49     // Create a stereo AudioBuffer.
50     toneBuffer = createDataBuffer(context, renderLengthSeconds);
51
52     bufferSource = context.createBufferSource();
53     bufferSource.buffer = toneBuffer;
54
55     bufferSource.connect(context.destination);
56
57     bufferSource.start(0);
58
59     context.oncomplete = testFinished;
60     context.startRendering();
61 }
62
63
64 runTest();
65
66 </script>
67 </body>
68 </html>