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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/automatic-pull-node.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 </head>
10
11 <body>
12
13 <div id="description"></div>
14 <div id="console"></div>
15
16 <script>
17 description("This test verifies that the AudioBasicInspectorNode based nodes wor k correctly.");
18
19 var sampleRate = 44100.0;
20 // We carefully arrange the renderLengthInFrames to be a multiple of the AudioNo de rendering quantum (AudioNode::ProcessingSizeInFrames)
21 // so that AudioSourceNode will not feed tailing zeroes into the context and fai l this test.
22 var renderLengthInFrames = 256;
23 var fftSize = 64;
24
25 var audioDataOne = 255; // Audio data 1.0 in Uint8 format will be 255.
26 var audioDataZero = 128; // Audio data 0 in Uint8 format will be 128.
27
28 var context;
29 var constantBuffer;
30 var bufferSource;
31 var analyser;
32
33 function constructCommonGraph() {
34 // Create offline audio context.
35 context = new OfflineAudioContext(1, renderLengthInFrames, sampleRate);
36 constantBuffer = createConstantBuffer(context, renderLengthInFrames, 1);
37
38 bufferSource = context.createBufferSource();
39 bufferSource.buffer = constantBuffer;
40
41 analyser = context.createAnalyser();
42 analyser.fftSize = fftSize;
43
44 bufferSource.connect(analyser);
45 }
46
47 function test1Finished() {
48 var timeDomainData = new Uint8Array(fftSize);
49 analyser.getByteTimeDomainData(timeDomainData);
50
51 if (timeDomainData[0] >= audioDataOne)
52 testPassed("RealtimeAnalyserNode got pulled when connected from upstream node but not to downstream node.");
53 else
54 testFailed("RealtimeAnalyserNode failed to get pulled when connected fro m upstream node but not to downstream node.");
55
56 test2();
57 }
58
59 // To verify the realtimeAnalyser can pull data when there is an upstream node c onnected to it
60 // but it's not connected to a downstream node.
61 function test1() {
62 constructCommonGraph();
63
64 bufferSource.start(0);
65
66 context.oncomplete = test1Finished;
67 context.startRendering();
68 }
69
70 function test2Finished() {
71 var timeDomainData = new Uint8Array(fftSize);
72 analyser.getByteTimeDomainData(timeDomainData);
73
74 if (timeDomainData[0] >= audioDataOne)
75 testPassed("RealtimeAnalyserNode got pulled when connected from upstream node and to destination node.");
76 else
77 testFailed("RealtimeAnalyserNode failed to be pulled when connected by u pstream node and to destination node.");
78
79 test3();
80 }
81
82 // To verify the realtimeAnalyser can process normally when there is an upstream node connected to it
83 // and it's also connected to a downstream node which ultimately connect to audi o destination.
84 function test2() {
85 constructCommonGraph();
86
87 analyser.connect(context.destination);
88
89 bufferSource.start(0);
90
91 context.oncomplete = test2Finished;
92 context.startRendering();
93 }
94
95 function test3Finished() {
96 var timeDomainData = new Uint8Array(fftSize);
97 analyser.getByteTimeDomainData(timeDomainData);
98
99 // If realtimeAnalyser hasn't pulled any data, the data in buffer will be 0.
100 if (timeDomainData[0] == audioDataZero)
101 testPassed("RealtimeAnalyserNode didn't get pulled when it should not.") ;
102 else
103 testFailed("RealtimeAnalyserNode been pulled when it should not.");
104
105 finishJSTest();
106 }
107
108 // To verify the realtimeAnalyser will stop pulling if it is connected to a down stream node
109 // which is not ultimatly connected to any audio destination.
110 function test3() {
111 constructCommonGraph();
112
113 var gain = context.createGain();
114 analyser.connect(gain);
115
116 bufferSource.start(0);
117
118 context.oncomplete = test3Finished;
119 context.startRendering();
120 }
121
122 function runTest() {
123 if (window.testRunner) {
124 testRunner.dumpAsText();
125 testRunner.waitUntilDone();
126 }
127
128 window.jsTestIsAsync = true;
129
130 test1();
131 }
132
133 runTest();
134
135 </script>
136
137 </body>
138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698