OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 | |
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 <script> | |
13 description("Basic tests for PannerNode."); | |
14 window.jsTestIsAsync = true; | |
15 | |
16 var context; | |
17 var panner; | |
18 var audit = Audit.createTaskRunner(); | |
19 | |
20 audit.defineTask("initialize", function (done) { | |
21 context = new AudioContext(); | |
22 panner = context.createPanner(); | |
23 done(); | |
24 }); | |
25 | |
26 audit.defineTask("basic", function (done) { | |
27 var success = true; | |
28 | |
29 success = Should("panner.numberOfInputs", panner.numberOfInputs) | |
30 .beEqualTo(1) && success; | |
31 success = Should("panner.numberOfOutputs", panner.numberOfOutputs) | |
32 .beEqualTo(1) && success; | |
33 success = Should("panner.refDistance", panner.refDistance) | |
34 .beEqualTo(1) && success; | |
35 panner.refDistance = 270.5; | |
36 success = Should("panner.refDistance = 270.5", panner.refDistance) | |
37 .beEqualTo(270.5) && success; | |
38 success = Should("panner.maxDistance", panner.maxDistance) | |
39 .beEqualTo(10000) && success; | |
40 panner.maxDistance = 100.5; | |
41 success = Should("panner.maxDistance = 100.5", panner.maxDistance) | |
42 .beEqualTo(100.5) && success; | |
43 success = Should("panner.rolloffFactor", panner.rolloffFactor) | |
44 .beEqualTo(1) && success; | |
45 panner.rolloffFactor = 0.75; | |
46 success = Should("panner.rolloffFactor = 0.75", panner.rolloffFactor) | |
47 .beEqualTo(0.75) && success; | |
48 success = Should("panner.coneInnerAngle", panner.coneInnerAngle) | |
49 .beEqualTo(360) && success; | |
50 panner.coneInnerAngle = 240.5; | |
51 success = Should("panner.coneInnerAngle = 240.5", panner.coneInnerAngle) | |
52 .beEqualTo(240.5) && success; | |
53 success = Should("panner.coneOuterAngle", panner.coneOuterAngle) | |
54 .beEqualTo(360) && success; | |
55 panner.coneOuterAngle = 166.5; | |
56 success = Should("panner.coneOuterAngle = 166.5", panner.coneOuterAngle) | |
57 .beEqualTo(166.5) && success; | |
58 success = Should("panner.coneOuterGain", panner.coneOuterGain) | |
59 .beEqualTo(0) && success; | |
60 panner.coneOuterGain = 0.25; | |
61 success = Should("panner.coneOuterGain = 0.25", panner.coneOuterGain) | |
62 .beEqualTo(0.25) && success; | |
63 success = Should("panner.panningModel", panner.panningModel) | |
64 .beEqualTo("equalpower") && success; | |
65 success = Should("panner.distanceModel", panner.distanceModel) | |
66 .beEqualTo("inverse") && success; | |
67 | |
68 success = Should("panner.positionX", panner.positionX.value) | |
69 .beEqualTo(0) && success; | |
70 success = Should("panner.positionY", panner.positionY.value) | |
71 .beEqualTo(0) && success; | |
72 success = Should("panner.positionZ", panner.positionZ.value) | |
73 .beEqualTo(0) && success; | |
74 success = Should("panner.orientationX", panner.orientationX.value) | |
75 .beEqualTo(1) && success; | |
76 success = Should("panner.orientationY", panner.orientationY.value) | |
77 .beEqualTo(0) && success; | |
78 success = Should("panner.orientationZ", panner.orientationZ.value) | |
79 .beEqualTo(0) && success; | |
80 | |
81 if (success) | |
82 testPassed("Basic Panner attribute tests.\n"); | |
83 else | |
84 testFailed("Basic Panner attribute tests.\n"); | |
85 | |
86 done(); | |
87 }); | |
88 | |
89 audit.defineTask("listener", function (done) { | |
90 var success = true; | |
91 | |
92 success = Should("listener.positionX", context.listener.positionX.value) | |
93 .beEqualTo(0) && success; | |
94 success = Should("listener.positionY", context.listener.positionY.value) | |
95 .beEqualTo(0) && success; | |
96 success = Should("listener.positionZ", context.listener.positionZ.value) | |
97 .beEqualTo(0) && success; | |
98 success = Should("listener.forwardX", context.listener.forwardX.value) | |
99 .beEqualTo(0) && success; | |
100 success = Should("listener.forwardY", context.listener.forwardY.value) | |
101 .beEqualTo(0) && success; | |
102 success = Should("listener.forwardZ", context.listener.forwardZ.value) | |
103 .beEqualTo(-1) && success; | |
104 success = Should("listener.upX", context.listener.upX.value) | |
105 .beEqualTo(0) && success; | |
106 success = Should("listener.upY", context.listener.upY.value) | |
107 .beEqualTo(1) && success; | |
108 success = Should("listener.upZ", context.listener.upZ.value) | |
109 .beEqualTo(0) && success; | |
110 | |
111 if (success) | |
112 testPassed("Basic AudioListener attribute tests.\n"); | |
113 else | |
114 testFailed("Basic AudioListener attribute tests.\n"); | |
115 done(); | |
116 }); | |
117 | |
118 audit.defineTask("panning models", function (done) { | |
119 // Check that the .panningModel attribute can be set to all legal values
. | |
120 var panningModels = ["equalpower", "HRTF"]; | |
121 | |
122 var success = true; | |
123 for (var i = 0; i < panningModels.length; ++i) { | |
124 success = Should('panner.panningModel = "' + panningModels[i] + '"', f
unction () { | |
125 panner.panningModel = panningModels[i]; | |
126 }).notThrow() && success; | |
127 | |
128 success = Should('panner.panningModel = "' + panningModels[i] + '"', p
anner.panningModel) | |
129 .beEqualTo(panningModels[i]) && success; | |
130 } | |
131 | |
132 success = Should('panner.panningModel = "invalid"', function () { | |
133 panner.panningModel = "invalid"; | |
134 }).notThrow() && success; | |
135 | |
136 success = Should("panner.panningModel", panner.panningModel) | |
137 .beEqualTo("HRTF") && success; | |
138 | |
139 // Check that numerical values are no longer supported. We shouldn't th
row and the value | |
140 // shouldn't be changed. | |
141 panner.panningModel = "HRTF"; | |
142 success = Should('panner.panningModel = 1', function () { | |
143 panner.panningModel = 1; | |
144 }).notThrow() && success; | |
145 | |
146 success = Should('panner.panningModel', panner.panningModel) | |
147 .beEqualTo("HRTF") && success; | |
148 | |
149 if (success) | |
150 testPassed("Basic Panner panning models tests.\n"); | |
151 else | |
152 testFailed("Basic Panner panning models tests.\n"); | |
153 done(); | |
154 }); | |
155 | |
156 audit.defineTask("distance models", function (done) { | |
157 // Check that the .panningModel attribute can be set to all legal values
. | |
158 var distanceModels = ["linear", "inverse", "exponential"]; | |
159 | |
160 var success = true; | |
161 for (var i = 0; i < distanceModels.length; ++i) { | |
162 success = Should('panner.distanceModel = "' + distanceModels[i] + '"', | |
163 function () { | |
164 panner.distanceModel = distanceModels[i]; | |
165 }).notThrow() && success; | |
166 | |
167 success = Should('panner.distanceModel = "' + distanceModels[i] + '"',
panner | |
168 .distanceModel) | |
169 .beEqualTo(distanceModels[i]) && success; | |
170 } | |
171 | |
172 success = Should('panner.distanceModel = "invalid"', function () { | |
173 panner.distanceModel = "invalid"; | |
174 }).notThrow() && success; | |
175 | |
176 success = Should("panner.distanceModel", panner.distanceModel) | |
177 .beEqualTo("exponential") && success; | |
178 | |
179 if (success) | |
180 testPassed("Basic Panner distance models tests.\n"); | |
181 else | |
182 testFailed("Basic Panner distance models tests.\n"); | |
183 done(); | |
184 }); | |
185 | |
186 audit.defineTask("finish", function (done) { | |
187 finishJSTest(); | |
188 done(); | |
189 }); | |
190 | |
191 | |
192 audit.runTasks(); | |
193 </script> | |
194 | |
195 </body> | |
196 | |
197 </html> | |
OLD | NEW |