Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / automatic-pull-node.html
blob085b27b06fb8118618fb52989b9dd85d47973bc5
1 <!DOCTYPE html>
3 <html>
4 <head>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/compatibility.js"></script>
7 <script type="text/javascript" src="resources/audio-testing.js"></script>
8 </head>
10 <body>
12 <div id="description"></div>
13 <div id="console"></div>
15 <script>
16 description("This test verifies that the AudioBasicInspectorNode based nodes work correctly.");
18 var sampleRate = 44100.0;
19 // We carefully arrange the renderLengthInFrames to be a multiple of the AudioNode rendering quantum (AudioNode::ProcessingSizeInFrames)
20 // so that AudioSourceNode will not feed tailing zeroes into the context and fail this test.
21 var renderLengthInFrames = 256;
22 var fftSize = 64;
24 var audioDataOne = 255; // Audio data 1.0 in Uint8 format will be 255.
25 var audioDataZero = 128; // Audio data 0 in Uint8 format will be 128.
27 var context;
28 var constantBuffer;
29 var bufferSource;
30 var analyser;
32 function constructCommonGraph() {
33 // Create offline audio context.
34 context = new OfflineAudioContext(1, renderLengthInFrames, sampleRate);
35 constantBuffer = createConstantBuffer(context, renderLengthInFrames, 1);
37 bufferSource = context.createBufferSource();
38 bufferSource.buffer = constantBuffer;
40 analyser = context.createAnalyser();
41 analyser.fftSize = fftSize;
43 bufferSource.connect(analyser);
46 function test1Finished() {
47 var timeDomainData = new Uint8Array(fftSize);
48 analyser.getByteTimeDomainData(timeDomainData);
50 if (timeDomainData[0] >= audioDataOne)
51 testPassed("RealtimeAnalyserNode got pulled when connected from upstream node but not to downstream node.");
52 else
53 testFailed("RealtimeAnalyserNode failed to get pulled when connected from upstream node but not to downstream node.");
55 test2();
58 // To verify the realtimeAnalyser can pull data when there is an upstream node connected to it
59 // but it's not connected to a downstream node.
60 function test1() {
61 constructCommonGraph();
63 bufferSource.start(0);
65 context.oncomplete = test1Finished;
66 context.startRendering();
69 function test2Finished() {
70 var timeDomainData = new Uint8Array(fftSize);
71 analyser.getByteTimeDomainData(timeDomainData);
73 if (timeDomainData[0] >= audioDataOne)
74 testPassed("RealtimeAnalyserNode got pulled when connected from upstream node and to destination node.");
75 else
76 testFailed("RealtimeAnalyserNode failed to be pulled when connected by upstream node and to destination node.");
78 test3();
81 // To verify the realtimeAnalyser can process normally when there is an upstream node connected to it
82 // and it's also connected to a downstream node which ultimately connect to audio destination.
83 function test2() {
84 constructCommonGraph();
86 analyser.connect(context.destination);
88 bufferSource.start(0);
90 context.oncomplete = test2Finished;
91 context.startRendering();
94 function test3Finished() {
95 var timeDomainData = new Uint8Array(fftSize);
96 analyser.getByteTimeDomainData(timeDomainData);
98 // If realtimeAnalyser hasn't pulled any data, the data in buffer will be 0.
99 if (timeDomainData[0] == audioDataZero)
100 testPassed("RealtimeAnalyserNode didn't get pulled when it should not.");
101 else
102 testFailed("RealtimeAnalyserNode been pulled when it should not.");
104 finishJSTest();
107 // To verify the realtimeAnalyser will stop pulling if it is connected to a downstream node
108 // which is not ultimatly connected to any audio destination.
109 function test3() {
110 constructCommonGraph();
112 var gain = context.createGain();
113 analyser.connect(gain);
115 bufferSource.start(0);
117 context.oncomplete = test3Finished;
118 context.startRendering();
121 function runTest() {
122 if (window.testRunner) {
123 testRunner.dumpAsText();
124 testRunner.waitUntilDone();
127 window.jsTestIsAsync = true;
129 test1();
132 runTest();
134 </script>
136 </body>
137 </html>