aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs115
1 files changed, 115 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
new file mode 100644
index 0000000..c4832c9
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
45using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48
49namespace OpenSim.Region.ScriptEngine.Shared.Tests
50{
51 /// <summary>
52 /// Tests for OSSL NPC API
53 /// </summary>
54 [TestFixture]
55 public class OSSL_NpcApiAppearanceTest
56 {
57 protected Scene m_scene;
58 protected XEngine.XEngine m_engine;
59
60 [SetUp]
61 public void SetUp()
62 {
63 IConfigSource initConfigSource = new IniConfigSource();
64 IConfig config = initConfigSource.AddConfig("XEngine");
65 config.Set("Enabled", "true");
66 config.Set("AllowOSFunctions", "true");
67 config.Set("OSFunctionThreatLevel", "Severe");
68 config = initConfigSource.AddConfig("NPC");
69 config.Set("Enabled", "true");
70
71 m_scene = SceneHelpers.SetupScene();
72 SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule());
73
74 m_engine = new XEngine.XEngine();
75 m_engine.Initialise(initConfigSource);
76 m_engine.AddRegion(m_scene);
77 }
78
79 /// <summary>
80 /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
81 /// </summary>
82 [Test]
83 public void TestOsNpcRemove()
84 {
85 TestHelpers.InMethod();
86// log4net.Config.XmlConfigurator.Configure();
87
88 // Store an avatar with a different height from default in a notecard.
89 UUID userId = TestHelpers.ParseTail(0x1);
90 float newHeight = 1.9f;
91
92 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
93 sp.Appearance.AvatarHeight = newHeight;
94 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
95 SceneObjectPart part = so.RootPart;
96 m_scene.AddSceneObject(so);
97
98 OSSL_Api osslApi = new OSSL_Api();
99 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID);
100
101 string notecardName = "appearanceNc";
102 osslApi.osOwnerSaveAppearance(notecardName);
103
104 string npcRaw
105 = osslApi.osNpcCreate(
106 "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED);
107
108 osslApi.osNpcRemove(npcRaw);
109
110 UUID npcId = new UUID(npcRaw);
111 ScenePresence npc = m_scene.GetScenePresence(npcId);
112 Assert.That(npc, Is.Null);
113 }
114 }
115} \ No newline at end of file