diff options
author | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
---|---|---|
committer | Melanie Thielker | 2014-06-21 00:39:55 +0200 |
commit | 159fcbf150b7da0e229b29aa7b94793484543d12 (patch) | |
tree | b8c0ff3b4c758a3fba8315b556c923ef4c02a185 /OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs | |
parent | Merge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.zip opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2 opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz |
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs | 399 |
1 files changed, 399 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs new file mode 100644 index 0000000..ed61dc0 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs | |||
@@ -0,0 +1,399 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
45 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | using OpenSim.Tests.Common; | ||
48 | using OpenSim.Tests.Common.Mock; | ||
49 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
50 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
51 | |||
52 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
53 | { | ||
54 | [TestFixture] | ||
55 | public class LSL_ApiObjectTests : OpenSimTestCase | ||
56 | { | ||
57 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; | ||
58 | private const float FLOAT_ACCURACY = 0.00005f; | ||
59 | |||
60 | protected Scene m_scene; | ||
61 | protected XEngine.XEngine m_engine; | ||
62 | |||
63 | [SetUp] | ||
64 | public override void SetUp() | ||
65 | { | ||
66 | base.SetUp(); | ||
67 | |||
68 | IConfigSource initConfigSource = new IniConfigSource(); | ||
69 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
70 | config.Set("Enabled", "true"); | ||
71 | |||
72 | m_scene = new SceneHelpers().SetupScene(); | ||
73 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | ||
74 | |||
75 | m_engine = new XEngine.XEngine(); | ||
76 | m_engine.Initialise(initConfigSource); | ||
77 | m_engine.AddRegion(m_scene); | ||
78 | } | ||
79 | |||
80 | [Test] | ||
81 | public void TestllGetLinkPrimitiveParams() | ||
82 | { | ||
83 | TestHelpers.InMethod(); | ||
84 | TestHelpers.EnableLogging(); | ||
85 | |||
86 | UUID ownerId = TestHelpers.ParseTail(0x1); | ||
87 | |||
88 | SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); | ||
89 | grp1.AbsolutePosition = new Vector3(10, 11, 12); | ||
90 | m_scene.AddSceneObject(grp1); | ||
91 | |||
92 | LSL_Api apiGrp1 = new LSL_Api(); | ||
93 | apiGrp1.Initialize(m_engine, grp1.RootPart, null, null); | ||
94 | |||
95 | // Check simple 1 prim case | ||
96 | { | ||
97 | LSL_List resList | ||
98 | = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
99 | |||
100 | Assert.That(resList.Length, Is.EqualTo(1)); | ||
101 | } | ||
102 | |||
103 | // Check 2 prim case | ||
104 | { | ||
105 | LSL_List resList | ||
106 | = apiGrp1.llGetLinkPrimitiveParams( | ||
107 | 1, | ||
108 | new LSL_List( | ||
109 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), | ||
110 | new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), | ||
111 | new LSL_Integer(2), | ||
112 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
113 | |||
114 | Assert.That(resList.Length, Is.EqualTo(2)); | ||
115 | } | ||
116 | |||
117 | // Check invalid parameters are ignored | ||
118 | { | ||
119 | LSL_List resList | ||
120 | = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
121 | |||
122 | Assert.That(resList.Length, Is.EqualTo(0)); | ||
123 | } | ||
124 | |||
125 | // Check all parameters are ignored if an initial bad link is given | ||
126 | { | ||
127 | LSL_List resList | ||
128 | = apiGrp1.llGetLinkPrimitiveParams( | ||
129 | 3, | ||
130 | new LSL_List( | ||
131 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), | ||
132 | new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), | ||
133 | new LSL_Integer(1), | ||
134 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
135 | |||
136 | Assert.That(resList.Length, Is.EqualTo(0)); | ||
137 | } | ||
138 | |||
139 | // Check only subsequent parameters are ignored when we hit the first bad link number | ||
140 | { | ||
141 | LSL_List resList | ||
142 | = apiGrp1.llGetLinkPrimitiveParams( | ||
143 | 1, | ||
144 | new LSL_List( | ||
145 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), | ||
146 | new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), | ||
147 | new LSL_Integer(3), | ||
148 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
149 | |||
150 | Assert.That(resList.Length, Is.EqualTo(1)); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | [Test] | ||
155 | // llSetPrimitiveParams and llGetPrimitiveParams test. | ||
156 | public void TestllSetPrimitiveParams() | ||
157 | { | ||
158 | TestHelpers.InMethod(); | ||
159 | |||
160 | // Create Prim1. | ||
161 | Scene scene = new SceneHelpers().SetupScene(); | ||
162 | string obj1Name = "Prim1"; | ||
163 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | ||
164 | SceneObjectPart part1 = | ||
165 | new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, | ||
166 | Vector3.Zero, Quaternion.Identity, | ||
167 | Vector3.Zero) { Name = obj1Name, UUID = objUuid }; | ||
168 | Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); | ||
169 | |||
170 | LSL_Api apiGrp1 = new LSL_Api(); | ||
171 | apiGrp1.Initialize(m_engine, part1, null, null); | ||
172 | |||
173 | // Note that prim hollow check is passed with the other prim params in order to allow the | ||
174 | // specification of a different check value from the prim param. A cylinder, prism, sphere, | ||
175 | // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below | ||
176 | // specifies a value of 95% and checks to see if 70% was properly returned. | ||
177 | |||
178 | // Test a sphere. | ||
179 | CheckllSetPrimitiveParams( | ||
180 | apiGrp1, | ||
181 | "test 1", // Prim test identification string | ||
182 | new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size | ||
183 | ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type | ||
184 | ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type | ||
185 | new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut | ||
186 | 0.80f, // Prim hollow | ||
187 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
188 | new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple | ||
189 | 0.80f); // Prim hollow check | ||
190 | |||
191 | // Test a prism. | ||
192 | CheckllSetPrimitiveParams( | ||
193 | apiGrp1, | ||
194 | "test 2", // Prim test identification string | ||
195 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
196 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
197 | ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type | ||
198 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
199 | 0.90f, // Prim hollow | ||
200 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
201 | new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper | ||
202 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
203 | 0.90f); // Prim hollow check | ||
204 | |||
205 | // Test a box. | ||
206 | CheckllSetPrimitiveParams( | ||
207 | apiGrp1, | ||
208 | "test 3", // Prim test identification string | ||
209 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
210 | ScriptBaseClass.PRIM_TYPE_BOX, // Prim type | ||
211 | ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type | ||
212 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
213 | 0.95f, // Prim hollow | ||
214 | new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist | ||
215 | new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper | ||
216 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
217 | 0.95f); // Prim hollow check | ||
218 | |||
219 | // Test a tube. | ||
220 | CheckllSetPrimitiveParams( | ||
221 | apiGrp1, | ||
222 | "test 4", // Prim test identification string | ||
223 | new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size | ||
224 | ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type | ||
225 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
226 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
227 | 0.00f, // Prim hollow | ||
228 | new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist | ||
229 | new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size | ||
230 | // Expression for y selected to test precision problems during byte | ||
231 | // cast in SetPrimitiveShapeParams. | ||
232 | new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear | ||
233 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut | ||
234 | // Expression for y selected to test precision problems during sbyte | ||
235 | // cast in SetPrimitiveShapeParams. | ||
236 | new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper | ||
237 | 1.11f, // Prim revolutions | ||
238 | 0.88f, // Prim radius | ||
239 | 0.95f, // Prim skew | ||
240 | 0.00f); // Prim hollow check | ||
241 | |||
242 | // Test a prism. | ||
243 | CheckllSetPrimitiveParams( | ||
244 | apiGrp1, | ||
245 | "test 5", // Prim test identification string | ||
246 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
247 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
248 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
249 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
250 | 0.95f, // Prim hollow | ||
251 | // Expression for x selected to test precision problems during sbyte | ||
252 | // cast in SetPrimitiveShapeBlockParams. | ||
253 | new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist | ||
254 | // Expression for y selected to test precision problems during sbyte | ||
255 | // cast in SetPrimitiveShapeParams. | ||
256 | new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper | ||
257 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
258 | 0.70f); // Prim hollow check | ||
259 | |||
260 | // Test a sculpted prim. | ||
261 | CheckllSetPrimitiveParams( | ||
262 | apiGrp1, | ||
263 | "test 6", // Prim test identification string | ||
264 | new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size | ||
265 | ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type | ||
266 | "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map | ||
267 | ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type | ||
268 | } | ||
269 | |||
270 | // Set prim params for a box, cylinder or prism and check results. | ||
271 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
272 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
273 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, | ||
274 | float primHollowCheck) | ||
275 | { | ||
276 | // Set the prim params. | ||
277 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
278 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
279 | primCut, primHollow, primTwist, primTaper, primShear)); | ||
280 | |||
281 | // Get params for prim to validate settings. | ||
282 | LSL_Types.list primParams = | ||
283 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
284 | |||
285 | // Validate settings. | ||
286 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
287 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
288 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
289 | Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), | ||
290 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
291 | CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
292 | Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
293 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
294 | CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
295 | CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 6), primTest + " prim taper"); | ||
296 | CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
297 | } | ||
298 | |||
299 | // Set prim params for a sphere and check results. | ||
300 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
301 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
302 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) | ||
303 | { | ||
304 | // Set the prim params. | ||
305 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
306 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
307 | primCut, primHollow, primTwist, primDimple)); | ||
308 | |||
309 | // Get params for prim to validate settings. | ||
310 | LSL_Types.list primParams = | ||
311 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
312 | |||
313 | // Validate settings. | ||
314 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
315 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
316 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
317 | Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), | ||
318 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
319 | CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
320 | Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
321 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
322 | CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
323 | CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple"); | ||
324 | } | ||
325 | |||
326 | // Set prim params for a torus, tube or ring and check results. | ||
327 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
328 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
329 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, | ||
330 | LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, | ||
331 | float primRev, float primRadius, float primSkew, float primHollowCheck) | ||
332 | { | ||
333 | // Set the prim params. | ||
334 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
335 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
336 | primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, | ||
337 | primTaper, primRev, primRadius, primSkew)); | ||
338 | |||
339 | // Get params for prim to validate settings. | ||
340 | LSL_Types.list primParams = | ||
341 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
342 | |||
343 | // Valdate settings. | ||
344 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
345 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
346 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
347 | Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), | ||
348 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
349 | CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
350 | Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
351 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
352 | CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
353 | CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size"); | ||
354 | CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
355 | CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut"); | ||
356 | CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper"); | ||
357 | Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY, | ||
358 | "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); | ||
359 | Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY, | ||
360 | "TestllSetPrimitiveParams " + primTest + " prim radius fail"); | ||
361 | Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY, | ||
362 | "TestllSetPrimitiveParams " + primTest + " prim skew fail"); | ||
363 | } | ||
364 | |||
365 | // Set prim params for a sculpted prim and check results. | ||
366 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
367 | LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) | ||
368 | { | ||
369 | // Set the prim params. | ||
370 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
371 | ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); | ||
372 | |||
373 | // Get params for prim to validate settings. | ||
374 | LSL_Types.list primParams = | ||
375 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
376 | |||
377 | // Validate settings. | ||
378 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
379 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
380 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
381 | Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2), | ||
382 | "TestllSetPrimitiveParams " + primTest + " prim map check fail"); | ||
383 | Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3), | ||
384 | "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); | ||
385 | } | ||
386 | |||
387 | public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) | ||
388 | { | ||
389 | // Check each vector component against expected result. | ||
390 | Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, | ||
391 | "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); | ||
392 | Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, | ||
393 | "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); | ||
394 | Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, | ||
395 | "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); | ||
396 | } | ||
397 | |||
398 | } | ||
399 | } \ No newline at end of file | ||