aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs77
1 files changed, 77 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 78296a4..3bd43b4 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using log4net; 31using log4net;
31using Nini.Config; 32using Nini.Config;
@@ -33,7 +34,9 @@ using NUnit.Framework;
33using OpenMetaverse; 34using OpenMetaverse;
34using OpenSim.Framework; 35using OpenSim.Framework;
35using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Region.CoreModules.Avatar.Attachments;
36using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 38using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
39using OpenSim.Region.CoreModules.Framework.InventoryAccess;
37using OpenSim.Region.CoreModules.Framework.UserManagement; 40using OpenSim.Region.CoreModules.Framework.UserManagement;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; 41using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
39using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
@@ -47,6 +50,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
47 [TestFixture] 50 [TestFixture]
48 public class NPCModuleTests 51 public class NPCModuleTests
49 { 52 {
53 [SetUp]
54 public void Init()
55 {
56 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
57 Util.FireAndForgetMethod = FireAndForgetMethod.None;
58 }
59
50 [Test] 60 [Test]
51 public void TestCreate() 61 public void TestCreate()
52 { 62 {
@@ -88,6 +98,73 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
88 } 98 }
89 99
90 [Test] 100 [Test]
101 public void TestAttachments()
102 {
103 TestHelpers.InMethod();
104// log4net.Config.XmlConfigurator.Configure();
105
106 IConfigSource config = new IniConfigSource();
107 config.AddConfig("NPC");
108 config.Configs["NPC"].Set("Enabled", "true");
109 config.AddConfig("Modules");
110 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
111
112 AvatarFactoryModule afm = new AvatarFactoryModule();
113 UserManagementModule umm = new UserManagementModule();
114 AttachmentsModule am = new AttachmentsModule();
115
116 TestScene scene = SceneHelpers.SetupScene();
117 SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule());
118
119 UUID userId = TestHelpers.ParseTail(0x1);
120 UserAccountHelpers.CreateUserWithInventory(scene, userId);
121 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
122// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
123
124 // 8 is the index of the first baked texture in AvatarAppearance
125// UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
126// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
127// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
128// originalTef.TextureID = originalFace8TextureId;
129
130 // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
131 // ScenePresence.SendInitialData() to reset our entire appearance.
132// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
133//
134// afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
135
136 UUID attItemId = TestHelpers.ParseTail(0x2);
137 UUID attAssetId = TestHelpers.ParseTail(0x3);
138 string attName = "att";
139
140 UserInventoryHelpers.CreateInventoryItem(
141 scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
142
143 am.RezSingleAttachmentFromInventory(
144 sp.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
145
146 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
147 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
148
149 ScenePresence npc = scene.GetScenePresence(npcId);
150
151 // Check scene presence status
152 Assert.That(npc.HasAttachments(), Is.True);
153 List<SceneObjectGroup> attachments = npc.GetAttachments();
154 Assert.That(attachments.Count, Is.EqualTo(1));
155 SceneObjectGroup attSo = attachments[0];
156
157 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
158 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
159// Assert.That(attSo.Name, Is.EqualTo(attName));
160 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
161 Assert.That(attSo.IsAttachment);
162 Assert.That(attSo.UsesPhysics, Is.False);
163 Assert.That(attSo.IsTemporary, Is.False);
164 Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
165 }
166
167 [Test]
91 public void TestMove() 168 public void TestMove()
92 { 169 {
93 TestHelpers.InMethod(); 170 TestHelpers.InMethod();