diff options
author | Justin Clark-Casey (justincc) | 2012-10-25 01:07:06 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-25 01:07:06 +0100 |
commit | ae662b54ea972e4da4f805fe38b5714d595e032a (patch) | |
tree | bbb79e30a6b42e25b5edec4abc6c56e5432cb4ea /OpenSim/Region/ScriptEngine/Shared/Tests | |
parent | Add TestOsNpcLoadAppearance() (diff) | |
download | opensim-SC_OLD-ae662b54ea972e4da4f805fe38b5714d595e032a.zip opensim-SC_OLD-ae662b54ea972e4da4f805fe38b5714d595e032a.tar.gz opensim-SC_OLD-ae662b54ea972e4da4f805fe38b5714d595e032a.tar.bz2 opensim-SC_OLD-ae662b54ea972e4da4f805fe38b5714d595e032a.tar.xz |
Make osNpcCreate() return UUID.Zero instead of throwing an exception if notecard name is invalid. Make osNpcLoadAppearance() fail silently in same circumstance rather than throwing exception.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | 54 |
2 files changed, 56 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index eb51c4e..c401794 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -36,12 +36,11 @@ using OpenMetaverse; | |||
36 | using OpenMetaverse.Assets; | 36 | using OpenMetaverse.Assets; |
37 | using OpenMetaverse.StructuredData; | 37 | using OpenMetaverse.StructuredData; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Region.CoreModules.Avatar.Attachments; | ||
40 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.ScriptEngine.Shared; | 42 | using OpenSim.Region.ScriptEngine.Shared; |
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | 43 | using OpenSim.Region.ScriptEngine.Shared.Api; |
44 | using OpenSim.Region.OptionalModules.World.NPC; | ||
45 | using OpenSim.Services.Interfaces; | 44 | using OpenSim.Services.Interfaces; |
46 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
47 | using OpenSim.Tests.Common.Mock; | 46 | using OpenSim.Tests.Common.Mock; |
@@ -69,8 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
69 | config.Set("Enabled", "true"); | 68 | config.Set("Enabled", "true"); |
70 | 69 | ||
71 | m_scene = new SceneHelpers().SetupScene(); | 70 | m_scene = new SceneHelpers().SetupScene(); |
72 | SceneHelpers.SetupSceneModules( | 71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
73 | m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule()); | ||
74 | 72 | ||
75 | m_engine = new XEngine.XEngine(); | 73 | m_engine = new XEngine.XEngine(); |
76 | m_engine.Initialise(initConfigSource); | 74 | m_engine.Initialise(initConfigSource); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 0a3a75d..4e58315 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -114,6 +114,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
114 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); | 114 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); |
115 | } | 115 | } |
116 | 116 | ||
117 | [Test] | ||
118 | public void TestOsNpcCreateNotExistingNotecard() | ||
119 | { | ||
120 | TestHelpers.InMethod(); | ||
121 | |||
122 | UUID userId = TestHelpers.ParseTail(0x1); | ||
123 | |||
124 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
125 | m_scene.AddSceneObject(so); | ||
126 | |||
127 | OSSL_Api osslApi = new OSSL_Api(); | ||
128 | osslApi.Initialize(m_engine, so.RootPart, null); | ||
129 | |||
130 | string npcRaw | ||
131 | = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name"); | ||
132 | |||
133 | UUID npcId = new UUID(npcRaw); | ||
134 | Assert.That(npcId, Is.EqualTo(UUID.Zero)); | ||
135 | } | ||
136 | |||
117 | /// <summary> | 137 | /// <summary> |
118 | /// Test creation of an NPC where the appearance data comes from an avatar already in the region. | 138 | /// Test creation of an NPC where the appearance data comes from an avatar already in the region. |
119 | /// </summary> | 139 | /// </summary> |
@@ -187,6 +207,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
187 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight)); | 207 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight)); |
188 | } | 208 | } |
189 | 209 | ||
210 | [Test] | ||
211 | public void TestOsNpcLoadAppearanceNotExistingNotecard() | ||
212 | { | ||
213 | TestHelpers.InMethod(); | ||
214 | |||
215 | // Store an avatar with a different height from default in a notecard. | ||
216 | UUID userId = TestHelpers.ParseTail(0x1); | ||
217 | float firstHeight = 1.9f; | ||
218 | float secondHeight = 2.1f; | ||
219 | string firstAppearanceNcName = "appearanceNc1"; | ||
220 | string secondAppearanceNcName = "appearanceNc2"; | ||
221 | |||
222 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
223 | sp.Appearance.AvatarHeight = firstHeight; | ||
224 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
225 | SceneObjectPart part = so.RootPart; | ||
226 | m_scene.AddSceneObject(so); | ||
227 | |||
228 | OSSL_Api osslApi = new OSSL_Api(); | ||
229 | osslApi.Initialize(m_engine, part, null); | ||
230 | |||
231 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); | ||
232 | |||
233 | string npcRaw | ||
234 | = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); | ||
235 | |||
236 | osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); | ||
237 | |||
238 | UUID npcId = new UUID(npcRaw); | ||
239 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
240 | Assert.That(npc, Is.Not.Null); | ||
241 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight)); | ||
242 | } | ||
243 | |||
190 | /// <summary> | 244 | /// <summary> |
191 | /// Test removal of an owned NPC. | 245 | /// Test removal of an owned NPC. |
192 | /// </summary> | 246 | /// </summary> |