aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Tests
diff options
context:
space:
mode:
authorTom2011-09-04 07:06:36 -0700
committerTom2011-09-04 07:06:36 -0700
commit66dec3b8742eff04fbbcc6e3249fe4ba87986500 (patch)
tree76cc708a821d35fac5cdbbce2de304b47064e732 /OpenSim/Region/ScriptEngine/Shared/Tests
parentGuard another nullref (diff)
parentFixed BulletSim config files for Linux *.so libraries. (diff)
downloadopensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.zip
opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.gz
opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.bz2
opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.xz
Resolve merge commits, stage 1
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Tests')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs232
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs229
2 files changed, 459 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index 80b60a4..8cd1e84 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -27,11 +27,13 @@
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Framework;
30using OpenSim.Tests.Common; 31using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared; 32using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using Nini.Config; 34using Nini.Config;
34using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
36using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
35using OpenMetaverse; 37using OpenMetaverse;
36using System; 38using System;
37using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
@@ -47,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
47 49
48 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; 50 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
49 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; 51 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
52 private const double FLOAT_ACCURACY = 0.00005d;
50 private LSL_Api m_lslApi; 53 private LSL_Api m_lslApi;
51 54
52 [SetUp] 55 [SetUp]
@@ -57,8 +60,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
57 IConfig config = initConfigSource.AddConfig("XEngine"); 60 IConfig config = initConfigSource.AddConfig("XEngine");
58 config.Set("Enabled", "true"); 61 config.Set("Enabled", "true");
59 62
60 Scene scene = SceneSetupHelpers.SetupScene(); 63 Scene scene = SceneHelpers.SetupScene();
61 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); 64 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
62 65
63 XEngine.XEngine engine = new XEngine.XEngine(); 66 XEngine.XEngine engine = new XEngine.XEngine();
64 engine.Initialise(initConfigSource); 67 engine.Initialise(initConfigSource);
@@ -166,6 +169,231 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
166 } 169 }
167 170
168 [Test] 171 [Test]
172 // llSetPrimitiveParams and llGetPrimitiveParams test.
173 public void TestllSetPrimitiveParams()
174 {
175 // Create Prim1.
176 Scene scene = SceneHelpers.SetupScene();
177 string obj1Name = "Prim1";
178 UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
179 SceneObjectPart part1 =
180 new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
181 Vector3.Zero, Quaternion.Identity,
182 Vector3.Zero) { Name = obj1Name, UUID = objUuid };
183 Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);
184
185 // Note that prim hollow check is passed with the other prim params in order to allow the
186 // specification of a different check value from the prim param. A cylinder, prism, sphere,
187 // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below
188 // specifies a value of 95% and checks to see if 70% was properly returned.
189
190 // Test a sphere.
191 CheckllSetPrimitiveParams(
192 "test 1", // Prim test identification string
193 new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
194 ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
195 ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
196 new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
197 0.80d, // Prim hollow
198 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
199 new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple
200 0.80d); // Prim hollow check
201
202 // Test a prism.
203 CheckllSetPrimitiveParams(
204 "test 2", // Prim test identification string
205 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
206 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
207 ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
208 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
209 0.90d, // Prim hollow
210 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
211 new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
212 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
213 0.90d); // Prim hollow check
214
215 // Test a box.
216 CheckllSetPrimitiveParams(
217 "test 3", // Prim test identification string
218 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
219 ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
220 ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
221 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
222 0.95d, // Prim hollow
223 new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
224 new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
225 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
226 0.95d); // Prim hollow check
227
228 // Test a tube.
229 CheckllSetPrimitiveParams(
230 "test 4", // Prim test identification string
231 new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size
232 ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type
233 ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
234 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
235 0.00d, // Prim hollow
236 new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
237 new LSL_Types.Vector3(1.0d, 0.5d, 0.0d), // Prim hole size
238 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
239 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
240 new LSL_Types.Vector3(-1.0d, 1.0d, 0.0d), // Prim taper
241 1.0d, // Prim revolutions
242 1.0d, // Prim radius
243 0.0d, // Prim skew
244 0.00d); // Prim hollow check
245
246 // Test a prism.
247 CheckllSetPrimitiveParams(
248 "test 5", // Prim test identification string
249 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
250 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
251 ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
252 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
253 0.95d, // Prim hollow
254 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
255 new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
256 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
257 0.70d); // Prim hollow check
258
259 // Test a sculpted prim.
260 CheckllSetPrimitiveParams(
261 "test 6", // Prim test identification string
262 new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size
263 ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type
264 "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map
265 ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type
266 }
267
268 // Set prim params for a box, cylinder or prism and check results.
269 public void CheckllSetPrimitiveParams(string primTest,
270 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
271 double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear,
272 double primHollowCheck)
273 {
274 // Set the prim params.
275 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
276 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
277 primCut, primHollow, primTwist, primTaper, primShear));
278
279 // Get params for prim to validate settings.
280 LSL_Types.list primParams =
281 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
282
283 // Validate settings.
284 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
285 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
286 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
287 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
288 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
289 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
290 Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
291 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
292 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
293 CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper");
294 CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
295 }
296
297 // Set prim params for a sphere and check results.
298 public void CheckllSetPrimitiveParams(string primTest,
299 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
300 double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, double primHollowCheck)
301 {
302 // Set the prim params.
303 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
304 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
305 primCut, primHollow, primTwist, primDimple));
306
307 // Get params for prim to validate settings.
308 LSL_Types.list primParams =
309 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
310
311 // Validate settings.
312 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
313 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
314 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
315 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
316 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
317 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
318 Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
319 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
320 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
321 CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple");
322 }
323
324 // Set prim params for a torus, tube or ring and check results.
325 public void CheckllSetPrimitiveParams(string primTest,
326 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
327 double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
328 LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
329 double primRev, double primRadius, double primSkew, double primHollowCheck)
330 {
331 // Set the prim params.
332 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
333 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
334 primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
335 primTaper, primRev, primRadius, primSkew));
336
337 // Get params for prim to validate settings.
338 LSL_Types.list primParams =
339 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
340
341 // Valdate settings.
342 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
343 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
344 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
345 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
346 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
347 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
348 Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
349 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
350 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
351 CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size");
352 CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
353 CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut");
354 CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper");
355 Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY,
356 "TestllSetPrimitiveParams " + primTest + " prim revolution fail");
357 Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY,
358 "TestllSetPrimitiveParams " + primTest + " prim radius fail");
359 Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY,
360 "TestllSetPrimitiveParams " + primTest + " prim skew fail");
361 }
362
363 // Set prim params for a sculpted prim and check results.
364 public void CheckllSetPrimitiveParams(string primTest,
365 LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType)
366 {
367 // Set the prim params.
368 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
369 ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType));
370
371 // Get params for prim to validate settings.
372 LSL_Types.list primParams =
373 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
374
375 // Validate settings.
376 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
377 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
378 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
379 Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2),
380 "TestllSetPrimitiveParams " + primTest + " prim map check fail");
381 Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3),
382 "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail");
383 }
384
385 public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
386 {
387 // Check each vector component against expected result.
388 Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
389 "TestllSetPrimitiveParams " + msg + " vector check fail on x component");
390 Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
391 "TestllSetPrimitiveParams " + msg + " vector check fail on y component");
392 Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
393 "TestllSetPrimitiveParams " + msg + " vector check fail on z component");
394 }
395
396 [Test]
169 // llVecNorm test. 397 // llVecNorm test.
170 public void TestllVecNorm() 398 public void TestllVecNorm()
171 { 399 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
new file mode 100644
index 0000000..7573dff
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -0,0 +1,229 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47
48namespace OpenSim.Region.ScriptEngine.Shared.Tests
49{
50 /// <summary>
51 /// Tests for OSSL_Api
52 /// </summary>
53 [TestFixture]
54 public class OSSL_ApiAppearanceTest
55 {
56 protected Scene m_scene;
57 protected XEngine.XEngine m_engine;
58
59 [SetUp]
60 public void SetUp()
61 {
62 IConfigSource initConfigSource = new IniConfigSource();
63 IConfig config = initConfigSource.AddConfig("XEngine");
64 config.Set("Enabled", "true");
65 config.Set("AllowOSFunctions", "true");
66 config.Set("OSFunctionThreatLevel", "Severe");
67 config = initConfigSource.AddConfig("NPC");
68 config.Set("Enabled", "true");
69
70 m_scene = SceneHelpers.SetupScene();
71 SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
72
73 m_engine = new XEngine.XEngine();
74 m_engine.Initialise(initConfigSource);
75 m_engine.AddRegion(m_scene);
76 }
77
78 /// <summary>
79 /// Test creation of an NPC where the appearance data comes from a notecard
80 /// </summary>
81 [Test]
82 public void TestOsNpcCreateFromNotecard()
83 {
84 TestHelpers.InMethod();
85// log4net.Config.XmlConfigurator.Configure();
86
87 // Store an avatar with a different height from default in a notecard.
88 UUID userId = TestHelpers.ParseTail(0x1);
89 float newHeight = 1.9f;
90
91 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
92 sp.Appearance.AvatarHeight = newHeight;
93 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
94 SceneObjectPart part = so.RootPart;
95 m_scene.AddSceneObject(so);
96
97 OSSL_Api osslApi = new OSSL_Api();
98 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
99
100 string notecardName = "appearanceNc";
101 osslApi.osOwnerSaveAppearance(notecardName);
102
103 // Try creating a bot using the appearance in the notecard.
104 string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
105 Assert.That(npcRaw, Is.Not.Null);
106
107 UUID npcId = new UUID(npcRaw);
108 ScenePresence npc = m_scene.GetScenePresence(npcId);
109 Assert.That(npc, Is.Not.Null);
110 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
111 }
112
113 /// <summary>
114 /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
115 /// </summary>
116 [Test]
117 public void TestOsNpcCreateFromAvatar()
118 {
119 TestHelpers.InMethod();
120// log4net.Config.XmlConfigurator.Configure();
121
122 // Store an avatar with a different height from default in a notecard.
123 UUID userId = TestHelpers.ParseTail(0x1);
124 float newHeight = 1.9f;
125
126 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
127 sp.Appearance.AvatarHeight = newHeight;
128 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
129 SceneObjectPart part = so.RootPart;
130 m_scene.AddSceneObject(so);
131
132 OSSL_Api osslApi = new OSSL_Api();
133 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
134
135 string notecardName = "appearanceNc";
136 osslApi.osOwnerSaveAppearance(notecardName);
137
138 // Try creating a bot using the existing avatar's appearance
139 string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
140 Assert.That(npcRaw, Is.Not.Null);
141
142 UUID npcId = new UUID(npcRaw);
143 ScenePresence npc = m_scene.GetScenePresence(npcId);
144 Assert.That(npc, Is.Not.Null);
145 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
146 }
147
148 [Test]
149 public void TestOsOwnerSaveAppearance()
150 {
151 TestHelpers.InMethod();
152// log4net.Config.XmlConfigurator.Configure();
153
154 UUID userId = TestHelpers.ParseTail(0x1);
155 float newHeight = 1.9f;
156
157 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
158 sp.Appearance.AvatarHeight = newHeight;
159 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
160 SceneObjectPart part = so.RootPart;
161 m_scene.AddSceneObject(so);
162
163 OSSL_Api osslApi = new OSSL_Api();
164 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
165
166 string notecardName = "appearanceNc";
167
168 osslApi.osOwnerSaveAppearance(notecardName);
169
170 IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
171 Assert.That(items.Count, Is.EqualTo(1));
172
173 TaskInventoryItem ncItem = items[0];
174 Assert.That(ncItem.Name, Is.EqualTo(notecardName));
175
176 AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
177 Assert.That(ncAsset, Is.Not.Null);
178
179 AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
180 anc.Decode();
181 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
182 AvatarAppearance savedAppearance = new AvatarAppearance();
183 savedAppearance.Unpack(appearanceOsd);
184
185 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
186 }
187
188 [Test]
189 public void TestOsAgentSaveAppearance()
190 {
191 TestHelpers.InMethod();
192// log4net.Config.XmlConfigurator.Configure();
193
194 UUID ownerId = TestHelpers.ParseTail(0x1);
195 UUID nonOwnerId = TestHelpers.ParseTail(0x2);
196 float newHeight = 1.9f;
197
198 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId);
199 sp.Appearance.AvatarHeight = newHeight;
200 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
201 SceneObjectPart part = so.RootPart;
202 m_scene.AddSceneObject(so);
203
204 OSSL_Api osslApi = new OSSL_Api();
205 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
206
207 string notecardName = "appearanceNc";
208
209 osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName);
210
211 IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName);
212 Assert.That(items.Count, Is.EqualTo(1));
213
214 TaskInventoryItem ncItem = items[0];
215 Assert.That(ncItem.Name, Is.EqualTo(notecardName));
216
217 AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString());
218 Assert.That(ncAsset, Is.Not.Null);
219
220 AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data);
221 anc.Decode();
222 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText);
223 AvatarAppearance savedAppearance = new AvatarAppearance();
224 savedAppearance.Unpack(appearanceOsd);
225
226 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
227 }
228 }
229} \ No newline at end of file