diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 240 |
1 files changed, 2 insertions, 238 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index c41d1e7..d929da8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -33,10 +33,10 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Region.ScriptEngine.Shared.Api; | 35 | using OpenSim.Region.ScriptEngine.Shared.Api; |
36 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
36 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | 37 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
38 | using System; | 39 | using System; |
39 | using OpenSim.Tests.Common.Mock; | ||
40 | 40 | ||
41 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 41 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
42 | { | 42 | { |
@@ -46,9 +46,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
46 | [TestFixture, LongRunning] | 46 | [TestFixture, LongRunning] |
47 | public class LSL_ApiTest | 47 | public class LSL_ApiTest |
48 | { | 48 | { |
49 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; | ||
50 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; | 49 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; |
51 | private const float FLOAT_ACCURACY = 0.00005f; | 50 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; |
52 | private LSL_Api m_lslApi; | 51 | private LSL_Api m_lslApi; |
53 | 52 | ||
54 | [SetUp] | 53 | [SetUp] |
@@ -254,241 +253,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
254 | } | 253 | } |
255 | 254 | ||
256 | [Test] | 255 | [Test] |
257 | // llSetPrimitiveParams and llGetPrimitiveParams test. | ||
258 | public void TestllSetPrimitiveParams() | ||
259 | { | ||
260 | TestHelpers.InMethod(); | ||
261 | |||
262 | // Create Prim1. | ||
263 | Scene scene = new SceneHelpers().SetupScene(); | ||
264 | string obj1Name = "Prim1"; | ||
265 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | ||
266 | SceneObjectPart part1 = | ||
267 | new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, | ||
268 | Vector3.Zero, Quaternion.Identity, | ||
269 | Vector3.Zero) { Name = obj1Name, UUID = objUuid }; | ||
270 | Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); | ||
271 | |||
272 | // Note that prim hollow check is passed with the other prim params in order to allow the | ||
273 | // specification of a different check value from the prim param. A cylinder, prism, sphere, | ||
274 | // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below | ||
275 | // specifies a value of 95% and checks to see if 70% was properly returned. | ||
276 | |||
277 | // Test a sphere. | ||
278 | CheckllSetPrimitiveParams( | ||
279 | "test 1", // Prim test identification string | ||
280 | new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size | ||
281 | ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type | ||
282 | ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type | ||
283 | new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut | ||
284 | 0.80f, // Prim hollow | ||
285 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
286 | new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple | ||
287 | 0.80f); // Prim hollow check | ||
288 | |||
289 | // Test a prism. | ||
290 | CheckllSetPrimitiveParams( | ||
291 | "test 2", // Prim test identification string | ||
292 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
293 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
294 | ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type | ||
295 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
296 | 0.90f, // Prim hollow | ||
297 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
298 | new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper | ||
299 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
300 | 0.90f); // Prim hollow check | ||
301 | |||
302 | // Test a box. | ||
303 | CheckllSetPrimitiveParams( | ||
304 | "test 3", // Prim test identification string | ||
305 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
306 | ScriptBaseClass.PRIM_TYPE_BOX, // Prim type | ||
307 | ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type | ||
308 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
309 | 0.95f, // Prim hollow | ||
310 | new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist | ||
311 | new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper | ||
312 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
313 | 0.95f); // Prim hollow check | ||
314 | |||
315 | // Test a tube. | ||
316 | CheckllSetPrimitiveParams( | ||
317 | "test 4", // Prim test identification string | ||
318 | new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size | ||
319 | ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type | ||
320 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
321 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
322 | 0.00f, // Prim hollow | ||
323 | new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist | ||
324 | new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size | ||
325 | // Expression for y selected to test precision problems during byte | ||
326 | // cast in SetPrimitiveShapeParams. | ||
327 | new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear | ||
328 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut | ||
329 | // Expression for y selected to test precision problems during sbyte | ||
330 | // cast in SetPrimitiveShapeParams. | ||
331 | new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper | ||
332 | 1.11f, // Prim revolutions | ||
333 | 0.88f, // Prim radius | ||
334 | 0.95f, // Prim skew | ||
335 | 0.00f); // Prim hollow check | ||
336 | |||
337 | // Test a prism. | ||
338 | CheckllSetPrimitiveParams( | ||
339 | "test 5", // Prim test identification string | ||
340 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
341 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
342 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
343 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
344 | 0.95f, // Prim hollow | ||
345 | // Expression for x selected to test precision problems during sbyte | ||
346 | // cast in SetPrimitiveShapeBlockParams. | ||
347 | new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist | ||
348 | // Expression for y selected to test precision problems during sbyte | ||
349 | // cast in SetPrimitiveShapeParams. | ||
350 | new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper | ||
351 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
352 | 0.70f); // Prim hollow check | ||
353 | |||
354 | // Test a sculpted prim. | ||
355 | CheckllSetPrimitiveParams( | ||
356 | "test 6", // Prim test identification string | ||
357 | new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size | ||
358 | ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type | ||
359 | "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map | ||
360 | ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type | ||
361 | } | ||
362 | |||
363 | // Set prim params for a box, cylinder or prism and check results. | ||
364 | public void CheckllSetPrimitiveParams(string primTest, | ||
365 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
366 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, | ||
367 | float primHollowCheck) | ||
368 | { | ||
369 | // Set the prim params. | ||
370 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
371 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
372 | primCut, primHollow, primTwist, primTaper, primShear)); | ||
373 | |||
374 | // Get params for prim to validate settings. | ||
375 | LSL_Types.list primParams = | ||
376 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
377 | |||
378 | // Validate settings. | ||
379 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
380 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
381 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
382 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
383 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
384 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
385 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
386 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
387 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
388 | CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); | ||
389 | CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
390 | } | ||
391 | |||
392 | // Set prim params for a sphere and check results. | ||
393 | public void CheckllSetPrimitiveParams(string primTest, | ||
394 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
395 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) | ||
396 | { | ||
397 | // Set the prim params. | ||
398 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
399 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
400 | primCut, primHollow, primTwist, primDimple)); | ||
401 | |||
402 | // Get params for prim to validate settings. | ||
403 | LSL_Types.list primParams = | ||
404 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
405 | |||
406 | // Validate settings. | ||
407 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
408 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
409 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
410 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
411 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
412 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
413 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
414 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
415 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
416 | CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); | ||
417 | } | ||
418 | |||
419 | // Set prim params for a torus, tube or ring and check results. | ||
420 | public void CheckllSetPrimitiveParams(string primTest, | ||
421 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
422 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, | ||
423 | LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, | ||
424 | float primRev, float primRadius, float primSkew, float primHollowCheck) | ||
425 | { | ||
426 | // Set the prim params. | ||
427 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
428 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
429 | primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, | ||
430 | primTaper, primRev, primRadius, primSkew)); | ||
431 | |||
432 | // Get params for prim to validate settings. | ||
433 | LSL_Types.list primParams = | ||
434 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
435 | |||
436 | // Valdate settings. | ||
437 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
438 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
439 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
440 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
441 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
442 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
443 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
444 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
445 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
446 | CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); | ||
447 | CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
448 | CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut"); | ||
449 | CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper"); | ||
450 | Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY, | ||
451 | "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); | ||
452 | Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY, | ||
453 | "TestllSetPrimitiveParams " + primTest + " prim radius fail"); | ||
454 | Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY, | ||
455 | "TestllSetPrimitiveParams " + primTest + " prim skew fail"); | ||
456 | } | ||
457 | |||
458 | // Set prim params for a sculpted prim and check results. | ||
459 | public void CheckllSetPrimitiveParams(string primTest, | ||
460 | LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) | ||
461 | { | ||
462 | // Set the prim params. | ||
463 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
464 | ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); | ||
465 | |||
466 | // Get params for prim to validate settings. | ||
467 | LSL_Types.list primParams = | ||
468 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
469 | |||
470 | // Validate settings. | ||
471 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
472 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
473 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
474 | Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2), | ||
475 | "TestllSetPrimitiveParams " + primTest + " prim map check fail"); | ||
476 | Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3), | ||
477 | "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); | ||
478 | } | ||
479 | |||
480 | public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) | ||
481 | { | ||
482 | // Check each vector component against expected result. | ||
483 | Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, | ||
484 | "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); | ||
485 | Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, | ||
486 | "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); | ||
487 | Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, | ||
488 | "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); | ||
489 | } | ||
490 | |||
491 | [Test] | ||
492 | public void TestllVecNorm() | 256 | public void TestllVecNorm() |
493 | { | 257 | { |
494 | TestHelpers.InMethod(); | 258 | TestHelpers.InMethod(); |