Add TestOsNpcLoadAppearance()

0.7.4-extended
Justin Clark-Casey (justincc) 2012-10-25 00:59:27 +01:00
parent 7235a5fed4
commit 3692ff2bdb
3 changed files with 48 additions and 4 deletions

View File

@ -330,6 +330,9 @@ namespace OpenSim.Framework
SetVisualParams(visualParams); SetVisualParams(visualParams);
} }
/// <summary>
/// Set avatar height by a calculation based on their visual parameters.
/// </summary>
public virtual void SetHeight() public virtual void SetHeight()
{ {
// Start with shortest possible female avatar height // Start with shortest possible female avatar height

View File

@ -36,11 +36,12 @@ using OpenMetaverse;
using OpenMetaverse.Assets; using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Avatar.AvatarFactory; using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api; using OpenSim.Region.ScriptEngine.Shared.Api;
using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
@ -68,7 +69,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
config.Set("Enabled", "true"); config.Set("Enabled", "true");
m_scene = new SceneHelpers().SetupScene(); m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); SceneHelpers.SetupSceneModules(
m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
m_engine = new XEngine.XEngine(); m_engine = new XEngine.XEngine();
m_engine.Initialise(initConfigSource); m_engine.Initialise(initConfigSource);

View File

@ -36,6 +36,7 @@ using OpenMetaverse;
using OpenMetaverse.Assets; using OpenMetaverse.Assets;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Avatar.AvatarFactory; using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
using OpenSim.Region.OptionalModules.World.NPC; using OpenSim.Region.OptionalModules.World.NPC;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -71,7 +72,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
config.Set("Enabled", "true"); config.Set("Enabled", "true");
m_scene = new SceneHelpers().SetupScene(); m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); SceneHelpers.SetupSceneModules(
m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
m_engine = new XEngine.XEngine(); m_engine = new XEngine.XEngine();
m_engine.Initialise(initConfigSource); m_engine.Initialise(initConfigSource);
@ -147,6 +149,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
} }
[Test]
public void TestOsNpcLoadAppearance()
{
TestHelpers.InMethod();
// Store an avatar with a different height from default in a notecard.
UUID userId = TestHelpers.ParseTail(0x1);
float firstHeight = 1.9f;
float secondHeight = 2.1f;
string firstAppearanceNcName = "appearanceNc1";
string secondAppearanceNcName = "appearanceNc2";
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
sp.Appearance.AvatarHeight = firstHeight;
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
SceneObjectPart part = so.RootPart;
m_scene.AddSceneObject(so);
OSSL_Api osslApi = new OSSL_Api();
osslApi.Initialize(m_engine, part, null);
osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
string npcRaw
= osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
// Create a second appearance notecard with a different height
sp.Appearance.AvatarHeight = secondHeight;
osslApi.osOwnerSaveAppearance(secondAppearanceNcName);
osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
UUID npcId = new UUID(npcRaw);
ScenePresence npc = m_scene.GetScenePresence(npcId);
Assert.That(npc, Is.Not.Null);
Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight));
}
/// <summary> /// <summary>
/// Test removal of an owned NPC. /// Test removal of an owned NPC.
/// </summary> /// </summary>
@ -154,7 +194,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
public void TestOsNpcRemoveOwned() public void TestOsNpcRemoveOwned()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
// Store an avatar with a different height from default in a notecard. // Store an avatar with a different height from default in a notecard.
UUID userId = TestHelpers.ParseTail(0x1); UUID userId = TestHelpers.ParseTail(0x1);