aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-11 21:43:26 +0100
committerJustin Clark-Casey (justincc)2011-08-11 21:43:26 +0100
commit50945dd56029a1280c581ea9b29213ab0e162a0a (patch)
tree826067de13242de2e3137ef68cfae4f87c6c59b8 /OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
parentSplit out to-be-common setup stuff from TestOsOwnerSaveAppearance() (diff)
downloadopensim-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/Tests/OSSL_ApiAppearanceTest.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs79
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
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
30using System.Text; 31using System.Text;
32using log4net;
31using Nini.Config; 33using Nini.Config;
32using NUnit.Framework; 34using NUnit.Framework;
33using OpenMetaverse; 35using OpenMetaverse;
@@ -35,6 +37,7 @@ using OpenMetaverse.Assets;
35using OpenMetaverse.StructuredData; 37using OpenMetaverse.StructuredData;
36using OpenSim.Framework; 38using OpenSim.Framework;
37using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC;
38using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.ScriptEngine.Shared; 42using OpenSim.Region.ScriptEngine.Shared;
40using OpenSim.Region.ScriptEngine.Shared.Api; 43using 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()