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