diff options
author | Tom | 2011-09-14 19:11:32 -0700 |
---|---|---|
committer | Tom | 2011-09-14 19:11:32 -0700 |
commit | 5484c9b585a2a6289456e9492ac2989d489b555c (patch) | |
tree | c9b79199722fe09c993c237dce40febf731264e3 /OpenSim/Region/OptionalModules/World | |
parent | Merge fixes, and fix the build (diff) | |
parent | Don't try and delete attachments for child agent close (diff) | |
download | opensim-SC_OLD-5484c9b585a2a6289456e9492ac2989d489b555c.zip opensim-SC_OLD-5484c9b585a2a6289456e9492ac2989d489b555c.tar.gz opensim-SC_OLD-5484c9b585a2a6289456e9492ac2989d489b555c.tar.bz2 opensim-SC_OLD-5484c9b585a2a6289456e9492ac2989d489b555c.tar.xz |
Bring us up to date.
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 94 |
1 files changed, 80 insertions, 14 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 78296a4..246bc34 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
@@ -33,7 +34,9 @@ using NUnit.Framework; | |||
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 36 | using OpenSim.Framework.Communications; |
37 | using OpenSim.Region.CoreModules.Avatar.Attachments; | ||
36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 38 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
39 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
37 | using OpenSim.Region.CoreModules.Framework.UserManagement; | 40 | using OpenSim.Region.CoreModules.Framework.UserManagement; |
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; | 41 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; |
39 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
@@ -47,21 +50,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
47 | [TestFixture] | 50 | [TestFixture] |
48 | public class NPCModuleTests | 51 | public class NPCModuleTests |
49 | { | 52 | { |
50 | [Test] | 53 | private TestScene scene; |
51 | public void TestCreate() | 54 | private AvatarFactoryModule afm; |
55 | private UserManagementModule umm; | ||
56 | private AttachmentsModule am; | ||
57 | |||
58 | [TestFixtureSetUp] | ||
59 | public void FixtureInit() | ||
52 | { | 60 | { |
53 | TestHelpers.InMethod(); | 61 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. |
54 | // log4net.Config.XmlConfigurator.Configure(); | 62 | Util.FireAndForgetMethod = FireAndForgetMethod.None; |
63 | } | ||
55 | 64 | ||
65 | [TestFixtureTearDown] | ||
66 | public void TearDown() | ||
67 | { | ||
68 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
69 | // threads. Possibly, later tests should be rewritten not to worry about such things. | ||
70 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
71 | } | ||
72 | |||
73 | [SetUp] | ||
74 | public void Init() | ||
75 | { | ||
56 | IConfigSource config = new IniConfigSource(); | 76 | IConfigSource config = new IniConfigSource(); |
57 | config.AddConfig("NPC"); | 77 | config.AddConfig("NPC"); |
58 | config.Configs["NPC"].Set("Enabled", "true"); | 78 | config.Configs["NPC"].Set("Enabled", "true"); |
79 | config.AddConfig("Modules"); | ||
80 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
59 | 81 | ||
60 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 82 | afm = new AvatarFactoryModule(); |
61 | UserManagementModule umm = new UserManagementModule(); | 83 | umm = new UserManagementModule(); |
84 | am = new AttachmentsModule(); | ||
85 | |||
86 | scene = SceneHelpers.SetupScene(); | ||
87 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); | ||
88 | } | ||
89 | |||
90 | [Test] | ||
91 | public void TestCreate() | ||
92 | { | ||
93 | TestHelpers.InMethod(); | ||
94 | // log4net.Config.XmlConfigurator.Configure(); | ||
62 | 95 | ||
63 | TestScene scene = SceneHelpers.SetupScene(); | ||
64 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); | ||
65 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 96 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
66 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 97 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
67 | 98 | ||
@@ -88,18 +119,53 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
88 | } | 119 | } |
89 | 120 | ||
90 | [Test] | 121 | [Test] |
91 | public void TestMove() | 122 | public void TestAttachments() |
92 | { | 123 | { |
93 | TestHelpers.InMethod(); | 124 | TestHelpers.InMethod(); |
94 | // log4net.Config.XmlConfigurator.Configure(); | 125 | // log4net.Config.XmlConfigurator.Configure(); |
95 | 126 | ||
96 | IConfigSource config = new IniConfigSource(); | 127 | UUID userId = TestHelpers.ParseTail(0x1); |
128 | UserAccountHelpers.CreateUserWithInventory(scene, userId); | ||
129 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | ||
97 | 130 | ||
98 | config.AddConfig("NPC"); | 131 | UUID attItemId = TestHelpers.ParseTail(0x2); |
99 | config.Configs["NPC"].Set("Enabled", "true"); | 132 | UUID attAssetId = TestHelpers.ParseTail(0x3); |
133 | string attName = "att"; | ||
134 | |||
135 | UserInventoryHelpers.CreateInventoryItem( | ||
136 | scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object); | ||
137 | |||
138 | am.RezSingleAttachmentFromInventory( | ||
139 | sp.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); | ||
140 | |||
141 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | ||
142 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); | ||
143 | |||
144 | ScenePresence npc = scene.GetScenePresence(npcId); | ||
145 | |||
146 | // Check scene presence status | ||
147 | Assert.That(npc.HasAttachments(), Is.True); | ||
148 | List<SceneObjectGroup> attachments = npc.GetAttachments(); | ||
149 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
150 | SceneObjectGroup attSo = attachments[0]; | ||
151 | |||
152 | // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item | ||
153 | // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. | ||
154 | // Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
155 | |||
156 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
157 | Assert.That(attSo.IsAttachment); | ||
158 | Assert.That(attSo.UsesPhysics, Is.False); | ||
159 | Assert.That(attSo.IsTemporary, Is.False); | ||
160 | Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID)); | ||
161 | } | ||
162 | |||
163 | [Test] | ||
164 | public void TestMove() | ||
165 | { | ||
166 | TestHelpers.InMethod(); | ||
167 | // log4net.Config.XmlConfigurator.Configure(); | ||
100 | 168 | ||
101 | TestScene scene = SceneHelpers.SetupScene(); | ||
102 | SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); | ||
103 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 169 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
104 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 170 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
105 | 171 | ||