diff options
author | Justin Clark-Casey (justincc) | 2011-08-11 21:43:26 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-11 21:43:26 +0100 |
commit | 50945dd56029a1280c581ea9b29213ab0e162a0a (patch) | |
tree | 826067de13242de2e3137ef68cfae4f87c6c59b8 /OpenSim/Region/ScriptEngine/Shared | |
parent | Split out to-be-common setup stuff from TestOsOwnerSaveAppearance() (diff) | |
download | opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.zip opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.gz opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.bz2 opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.xz |
add regression test for osNpcCreate when cloning an in-region avatar
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | 79 |
2 files changed, 77 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 91ac3b7..b18aa3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2135,11 +2135,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2135 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2135 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2136 | if (module != null) | 2136 | if (module != null) |
2137 | { | 2137 | { |
2138 | ScenePresence clonePresence = World.GetScenePresence(new UUID(cloneFrom.m_string)); | ||
2139 | if (clonePresence == null) | ||
2140 | return new LSL_Key(UUID.Zero.ToString()); | ||
2141 | |||
2138 | UUID x = module.CreateNPC(firstname, | 2142 | UUID x = module.CreateNPC(firstname, |
2139 | lastname, | 2143 | lastname, |
2140 | new Vector3((float) position.x, (float) position.y, (float) position.z), | 2144 | new Vector3((float) position.x, (float) position.y, (float) position.z), |
2141 | World, | 2145 | World, |
2142 | new UUID(cloneFrom)); | 2146 | clonePresence.Appearance); |
2143 | 2147 | ||
2144 | return new LSL_Key(x.ToString()); | 2148 | return new LSL_Key(x.ToString()); |
2145 | } | 2149 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 2218a1f..7f778d7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -27,7 +27,9 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | ||
30 | using System.Text; | 31 | using System.Text; |
32 | using log4net; | ||
31 | using Nini.Config; | 33 | using Nini.Config; |
32 | using NUnit.Framework; | 34 | using NUnit.Framework; |
33 | using OpenMetaverse; | 35 | using OpenMetaverse; |
@@ -35,6 +37,7 @@ using OpenMetaverse.Assets; | |||
35 | using OpenMetaverse.StructuredData; | 37 | using OpenMetaverse.StructuredData; |
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
37 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
38 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Region.ScriptEngine.Shared; | 42 | using OpenSim.Region.ScriptEngine.Shared; |
40 | using OpenSim.Region.ScriptEngine.Shared.Api; | 43 | using OpenSim.Region.ScriptEngine.Shared.Api; |
@@ -61,9 +64,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
61 | config.Set("Enabled", "true"); | 64 | config.Set("Enabled", "true"); |
62 | config.Set("AllowOSFunctions", "true"); | 65 | config.Set("AllowOSFunctions", "true"); |
63 | config.Set("OSFunctionThreatLevel", "Severe"); | 66 | config.Set("OSFunctionThreatLevel", "Severe"); |
67 | config = initConfigSource.AddConfig("NPC"); | ||
68 | config.Set("Enabled", "true"); | ||
64 | 69 | ||
65 | m_scene = SceneHelpers.SetupScene(); | 70 | m_scene = SceneHelpers.SetupScene(); |
66 | SceneHelpers.SetupSceneModules(m_scene, new AvatarFactoryModule()); | 71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
67 | 72 | ||
68 | m_engine = new XEngine.XEngine(); | 73 | m_engine = new XEngine.XEngine(); |
69 | m_engine.Initialise(initConfigSource); | 74 | m_engine.Initialise(initConfigSource); |
@@ -73,12 +78,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
73 | /// <summary> | 78 | /// <summary> |
74 | /// Test creation of an NPC where the appearance data comes from a notecard | 79 | /// Test creation of an NPC where the appearance data comes from a notecard |
75 | /// </summary> | 80 | /// </summary> |
76 | // [Test] | 81 | //[Test] |
77 | // public void TestOsNpcCreateFromNotecard() | 82 | public void TestOsNpcCreateFromNotecard() |
78 | // { | 83 | { |
79 | // TestHelpers.InMethod(); | 84 | TestHelpers.InMethod(); |
80 | //// log4net.Config.XmlConfigurator.Configure(); | 85 | log4net.Config.XmlConfigurator.Configure(); |
81 | // } | 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 | } | ||
82 | 147 | ||
83 | [Test] | 148 | [Test] |
84 | public void TestOsOwnerSaveAppearance() | 149 | public void TestOsOwnerSaveAppearance() |