Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / audiochannelmerger-input.html
blob2ece46cdccf4c5a47121f7610f6afa9ea7423970
1 <!DOCTYPE html>
2 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script src="resources/audio-testing.js"></script>
8 <script src="resources/merger-testing.js"></script>
9 </head>
11 <body>
12 <script>
13 description('Test input handling behavior of ChannelMergerNode.');
14 window.jsTestIsAsync = true;
16 var audit = Audit.createTaskRunner();
18 // Task: Check if an inactive input renders a silent mono channel in the
19 // output.
20 audit.defineTask('silent-channel', function (done) {
21 testMergerInput({
22 numberOfChannels: 6,
24 // Create a mono source buffer filled with '1'.
25 testBufferChannelCount: 1,
27 // Connect the output of source into the 4th input of merger.
28 mergerInputIndex: 3,
30 // All channels should contain 0, except channel 4 which should be 1.
31 expected: [0, 0, 0, 1, 0, 0],
32 }, done);
33 });
36 // Task: Check if a stereo input is being down-mixed to mono channel
37 // correctly based on the mixing rule.
38 audit.defineTask('stereo-down-mixing', function (done) {
39 testMergerInput({
40 numberOfChannels: 6,
42 // Create a stereo buffer filled with '1' and '2' for left and right
43 // channels respectively.
44 testBufferChannelCount: 2,
46 // Connect the output of source into the 1st input of merger.
47 mergerInputIndex: undefined,
49 // The result of summed and down-mixed stereo audio should be 1.5.
50 // (= 1 * 0.5 + 2 * 0.5)
51 expected: [1.5, 0, 0, 0, 0, 0],
52 }, done);
53 });
56 // Task: Check if 3-channel input gets processed by the 'discrete' mixing
57 // rule.
58 audit.defineTask('undefined-channel-layout', function (done) {
59 testMergerInput({
60 numberOfChannels: 6,
62 // Create a 3-channel buffer filled with '1', '2', and '3' respectively.
63 testBufferChannelCount: 3,
65 // Connect the output of source into the 1st input of merger.
66 mergerInputIndex: undefined,
68 // The result of summed stereo audio should be 1 because 3-channel is
69 // not a canonical layout, so the input channel 2 and 3 should be
70 // dropped by 'discrete' mixing rule.
71 expected: [1, 0, 0, 0, 0, 0],
72 }, done);
73 });
76 // Task: Merging two inputs into a single stereo stream.
77 audit.defineTask('merging-to-stereo', function (done) {
79 // For this test, the number of channel should be 2.
80 var context = new OfflineAudioContext(2, 128, 44100);
81 var merger = context.createChannelMerger();
82 var source1 = context.createBufferSource();
83 var source2 = context.createBufferSource();
85 // Create a DC offset buffer (mono) filled with 1 and assign it to BS
86 // nodes.
87 var positiveDCOffset = createConstantBuffer(context, 128, 1);
88 var negativeDCOffset = createConstantBuffer(context, 128, -1);
89 source1.buffer = positiveDCOffset;
90 source2.buffer = negativeDCOffset;
92 // Connect: BS#1 => merger_input#0, BS#2 => Inverter => merger_input#1
93 source1.connect(merger, 0, 0);
94 source2.connect(merger, 0, 1);
95 merger.connect(context.destination);
96 source1.start();
97 source2.start();
99 context.startRendering().then(function (buffer) {
101 // Channel#0 = 1, Channel#1 = -1
102 Should('Channel #0', buffer.getChannelData(0)).beConstantValueOf(1);
103 Should('Channel #1', buffer.getChannelData(1)).beConstantValueOf(-1);
105 done();
110 audit.defineTask('finish', function (done) {
111 finishJSTest();
112 done();
115 audit.runTasks(
116 'silent-channel',
117 'stereo-down-mixing',
118 'undefined-channel-layout',
119 'merging-to-stereo',
120 'finish'
123 successfullyParsed = true;
124 </script>
125 </body>
127 </html>