diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | 79 |
1 files changed, 72 insertions, 7 deletions
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() |