diff options
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 233 |
1 files changed, 156 insertions, 77 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8969006..1c10422 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -38,11 +38,14 @@ using OpenMetaverse; | |||
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Region.CoreModules.Avatar.Attachments; | 40 | using OpenSim.Region.CoreModules.Avatar.Attachments; |
41 | using OpenSim.Region.CoreModules.Framework; | ||
42 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
41 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | 43 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
42 | using OpenSim.Region.CoreModules.World.Serialiser; | 44 | using OpenSim.Region.CoreModules.World.Serialiser; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
44 | using OpenSim.Region.Framework.Scenes; | 46 | using OpenSim.Region.Framework.Scenes; |
45 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Tests.Common; | 49 | using OpenSim.Tests.Common; |
47 | using OpenSim.Tests.Common.Mock; | 50 | using OpenSim.Tests.Common.Mock; |
48 | 51 | ||
@@ -52,27 +55,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
52 | /// Attachment tests | 55 | /// Attachment tests |
53 | /// </summary> | 56 | /// </summary> |
54 | [TestFixture] | 57 | [TestFixture] |
55 | public class AttachmentsModuleTests | 58 | public class AttachmentsModuleTests : OpenSimTestCase |
56 | { | 59 | { |
57 | private Scene scene; | ||
58 | private AttachmentsModule m_attMod; | ||
59 | private ScenePresence m_presence; | ||
60 | |||
61 | /// <summary> | ||
62 | /// Standard user ID | ||
63 | /// </summary> | ||
64 | private UUID m_userId = TestHelpers.ParseTail(0x1); | ||
65 | |||
66 | // /// <summary> | ||
67 | // /// Standard attachment item ID | ||
68 | // /// </summary> | ||
69 | // private UUID m_attItemId = TestHelpers.ParseTail(0x10); | ||
70 | // | ||
71 | // /// <summary> | ||
72 | // /// Standard attachment asset ID | ||
73 | // /// </summary> | ||
74 | // private UUID m_attAssetId = TestHelpers.ParseTail(0x11); | ||
75 | |||
76 | [TestFixtureSetUp] | 60 | [TestFixtureSetUp] |
77 | public void FixtureInit() | 61 | public void FixtureInit() |
78 | { | 62 | { |
@@ -80,18 +64,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
80 | Util.FireAndForgetMethod = FireAndForgetMethod.None; | 64 | Util.FireAndForgetMethod = FireAndForgetMethod.None; |
81 | } | 65 | } |
82 | 66 | ||
83 | [SetUp] | ||
84 | public void Init() | ||
85 | { | ||
86 | IConfigSource config = new IniConfigSource(); | ||
87 | config.AddConfig("Modules"); | ||
88 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
89 | |||
90 | scene = new SceneHelpers().SetupScene(); | ||
91 | m_attMod = new AttachmentsModule(); | ||
92 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); | ||
93 | } | ||
94 | |||
95 | [TestFixtureTearDown] | 67 | [TestFixtureTearDown] |
96 | public void TearDown() | 68 | public void TearDown() |
97 | { | 69 | { |
@@ -100,6 +72,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
100 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 72 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
101 | } | 73 | } |
102 | 74 | ||
75 | private Scene CreateDefaultTestScene() | ||
76 | { | ||
77 | IConfigSource config = new IniConfigSource(); | ||
78 | config.AddConfig("Modules"); | ||
79 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
80 | |||
81 | Scene scene = new SceneHelpers().SetupScene(); | ||
82 | SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); | ||
83 | |||
84 | return scene; | ||
85 | } | ||
86 | |||
103 | /// <summary> | 87 | /// <summary> |
104 | /// Creates an attachment item in the given user's inventory. Does not attach. | 88 | /// Creates an attachment item in the given user's inventory. Does not attach. |
105 | /// </summary> | 89 | /// </summary> |
@@ -109,11 +93,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
109 | /// <returns> | 93 | /// <returns> |
110 | /// The attachment item. | 94 | /// The attachment item. |
111 | /// </returns> | 95 | /// </returns> |
96 | /// <param name='scene'></param> | ||
112 | /// <param name='userId'></param> | 97 | /// <param name='userId'></param> |
113 | /// <param name='attName'></param> | 98 | /// <param name='attName'></param> |
114 | /// <param name='rawItemId'></param> | 99 | /// <param name='rawItemId'></param> |
115 | /// <param name='rawAssetId'></param> | 100 | /// <param name='rawAssetId'></param> |
116 | private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId) | 101 | private InventoryItemBase CreateAttachmentItem( |
102 | Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId) | ||
117 | { | 103 | { |
118 | return UserInventoryHelpers.CreateInventoryItem( | 104 | return UserInventoryHelpers.CreateInventoryItem( |
119 | scene, | 105 | scene, |
@@ -130,18 +116,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
130 | TestHelpers.InMethod(); | 116 | TestHelpers.InMethod(); |
131 | // TestHelpers.EnableLogging(); | 117 | // TestHelpers.EnableLogging(); |
132 | 118 | ||
133 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 119 | Scene scene = CreateDefaultTestScene(); |
134 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | 120 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
121 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | ||
135 | 122 | ||
136 | string attName = "att"; | 123 | string attName = "att"; |
137 | 124 | ||
138 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, m_presence.UUID).ParentGroup; | 125 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup; |
139 | 126 | ||
140 | m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false, false); | 127 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); |
141 | 128 | ||
142 | // Check status on scene presence | 129 | // Check status on scene presence |
143 | Assert.That(m_presence.HasAttachments(), Is.True); | 130 | Assert.That(sp.HasAttachments(), Is.True); |
144 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | 131 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
145 | Assert.That(attachments.Count, Is.EqualTo(1)); | 132 | Assert.That(attachments.Count, Is.EqualTo(1)); |
146 | SceneObjectGroup attSo = attachments[0]; | 133 | SceneObjectGroup attSo = attachments[0]; |
147 | Assert.That(attSo.Name, Is.EqualTo(attName)); | 134 | Assert.That(attSo.Name, Is.EqualTo(attName)); |
@@ -152,14 +139,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
152 | 139 | ||
153 | // Check item status | 140 | // Check item status |
154 | Assert.That( | 141 | Assert.That( |
155 | m_presence.Appearance.GetAttachpoint(attSo.FromItemID), | 142 | sp.Appearance.GetAttachpoint(attSo.FromItemID), |
156 | Is.EqualTo((int)AttachmentPoint.Chest)); | 143 | Is.EqualTo((int)AttachmentPoint.Chest)); |
157 | 144 | ||
158 | InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); | 145 | InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); |
159 | Assert.That(attachmentItem, Is.Not.Null); | 146 | Assert.That(attachmentItem, Is.Not.Null); |
160 | Assert.That(attachmentItem.Name, Is.EqualTo(attName)); | 147 | Assert.That(attachmentItem.Name, Is.EqualTo(attName)); |
161 | 148 | ||
162 | InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(m_presence.UUID, AssetType.Object); | 149 | InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object); |
163 | Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); | 150 | Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); |
164 | 151 | ||
165 | // TestHelpers.DisableLogging(); | 152 | // TestHelpers.DisableLogging(); |
@@ -171,17 +158,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
171 | TestHelpers.InMethod(); | 158 | TestHelpers.InMethod(); |
172 | // log4net.Config.XmlConfigurator.Configure(); | 159 | // log4net.Config.XmlConfigurator.Configure(); |
173 | 160 | ||
174 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 161 | Scene scene = CreateDefaultTestScene(); |
175 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | 162 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
163 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | ||
176 | 164 | ||
177 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | 165 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
178 | 166 | ||
179 | m_attMod.RezSingleAttachmentFromInventory( | 167 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
180 | m_presence, attItem.ID, (uint)AttachmentPoint.Chest); | 168 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
181 | 169 | ||
182 | // Check scene presence status | 170 | // Check scene presence status |
183 | Assert.That(m_presence.HasAttachments(), Is.True); | 171 | Assert.That(sp.HasAttachments(), Is.True); |
184 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | 172 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
185 | Assert.That(attachments.Count, Is.EqualTo(1)); | 173 | Assert.That(attachments.Count, Is.EqualTo(1)); |
186 | SceneObjectGroup attSo = attachments[0]; | 174 | SceneObjectGroup attSo = attachments[0]; |
187 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); | 175 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); |
@@ -191,8 +179,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
191 | Assert.That(attSo.IsTemporary, Is.False); | 179 | Assert.That(attSo.IsTemporary, Is.False); |
192 | 180 | ||
193 | // Check appearance status | 181 | // Check appearance status |
194 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); | 182 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); |
195 | Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | 183 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
196 | } | 184 | } |
197 | 185 | ||
198 | [Test] | 186 | [Test] |
@@ -201,23 +189,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
201 | TestHelpers.InMethod(); | 189 | TestHelpers.InMethod(); |
202 | // log4net.Config.XmlConfigurator.Configure(); | 190 | // log4net.Config.XmlConfigurator.Configure(); |
203 | 191 | ||
204 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 192 | Scene scene = CreateDefaultTestScene(); |
205 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | 193 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
194 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | ||
206 | 195 | ||
207 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | 196 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
208 | 197 | ||
209 | ISceneEntity so | 198 | ISceneEntity so |
210 | = m_attMod.RezSingleAttachmentFromInventory( | 199 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
211 | m_presence, attItem.ID, (uint)AttachmentPoint.Chest); | 200 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
212 | m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); | 201 | scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId); |
213 | 202 | ||
214 | // Check scene presence status | 203 | // Check scene presence status |
215 | Assert.That(m_presence.HasAttachments(), Is.False); | 204 | Assert.That(sp.HasAttachments(), Is.False); |
216 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | 205 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
217 | Assert.That(attachments.Count, Is.EqualTo(0)); | 206 | Assert.That(attachments.Count, Is.EqualTo(0)); |
218 | 207 | ||
219 | // Check appearance status | 208 | // Check appearance status |
220 | Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); | 209 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(0)); |
221 | 210 | ||
222 | // Check item status | 211 | // Check item status |
223 | Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null); | 212 | Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null); |
@@ -232,22 +221,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
232 | TestHelpers.InMethod(); | 221 | TestHelpers.InMethod(); |
233 | // log4net.Config.XmlConfigurator.Configure(); | 222 | // log4net.Config.XmlConfigurator.Configure(); |
234 | 223 | ||
235 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 224 | Scene scene = CreateDefaultTestScene(); |
236 | m_presence = SceneHelpers.AddScenePresence(scene, m_userId); | 225 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
226 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | ||
237 | 227 | ||
238 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | 228 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
239 | 229 | ||
240 | m_attMod.RezSingleAttachmentFromInventory( | 230 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
241 | m_presence, attItem.ID, (uint)AttachmentPoint.Chest); | 231 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
242 | m_attMod.DetachSingleAttachmentToInv(m_presence, attItem.ID); | 232 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, attItem.ID); |
243 | 233 | ||
244 | // Check status on scene presence | 234 | // Check status on scene presence |
245 | Assert.That(m_presence.HasAttachments(), Is.False); | 235 | Assert.That(sp.HasAttachments(), Is.False); |
246 | List<SceneObjectGroup> attachments = m_presence.GetAttachments(); | 236 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
247 | Assert.That(attachments.Count, Is.EqualTo(0)); | 237 | Assert.That(attachments.Count, Is.EqualTo(0)); |
248 | 238 | ||
249 | // Check item status | 239 | // Check item status |
250 | Assert.That(m_presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); | 240 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); |
251 | } | 241 | } |
252 | 242 | ||
253 | /// <summary> | 243 | /// <summary> |
@@ -259,10 +249,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
259 | TestHelpers.InMethod(); | 249 | TestHelpers.InMethod(); |
260 | // log4net.Config.XmlConfigurator.Configure(); | 250 | // log4net.Config.XmlConfigurator.Configure(); |
261 | 251 | ||
262 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 252 | Scene scene = CreateDefaultTestScene(); |
263 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | 253 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
254 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | ||
264 | 255 | ||
265 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); | 256 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); |
266 | acd.Appearance = new AvatarAppearance(); | 257 | acd.Appearance = new AvatarAppearance(); |
267 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 258 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
268 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | 259 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); |
@@ -281,10 +272,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
281 | TestHelpers.InMethod(); | 272 | TestHelpers.InMethod(); |
282 | // log4net.Config.XmlConfigurator.Configure(); | 273 | // log4net.Config.XmlConfigurator.Configure(); |
283 | 274 | ||
284 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 275 | Scene scene = CreateDefaultTestScene(); |
285 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | 276 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
277 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | ||
286 | 278 | ||
287 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); | 279 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); |
288 | acd.Appearance = new AvatarAppearance(); | 280 | acd.Appearance = new AvatarAppearance(); |
289 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 281 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
290 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | 282 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); |
@@ -314,10 +306,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
314 | { | 306 | { |
315 | TestHelpers.InMethod(); | 307 | TestHelpers.InMethod(); |
316 | 308 | ||
317 | UserAccountHelpers.CreateUserWithInventory(scene, m_userId); | 309 | Scene scene = CreateDefaultTestScene(); |
318 | InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); | 310 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
311 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | ||
319 | 312 | ||
320 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); | 313 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); |
321 | acd.Appearance = new AvatarAppearance(); | 314 | acd.Appearance = new AvatarAppearance(); |
322 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 315 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
323 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); | 316 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); |
@@ -332,6 +325,92 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
332 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); | 325 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); |
333 | } | 326 | } |
334 | 327 | ||
328 | [Test] | ||
329 | public void TestSameSimulatorNeighbouringRegionsTeleport() | ||
330 | { | ||
331 | TestHelpers.InMethod(); | ||
332 | // TestHelpers.EnableLogging(); | ||
333 | |||
334 | AttachmentsModule attModA = new AttachmentsModule(); | ||
335 | AttachmentsModule attModB = new AttachmentsModule(); | ||
336 | EntityTransferModule etmA = new EntityTransferModule(); | ||
337 | EntityTransferModule etmB = new EntityTransferModule(); | ||
338 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | ||
339 | |||
340 | IConfigSource config = new IniConfigSource(); | ||
341 | IConfig modulesConfig = config.AddConfig("Modules"); | ||
342 | modulesConfig.Set("EntityTransferModule", etmA.Name); | ||
343 | modulesConfig.Set("SimulationServices", lscm.Name); | ||
344 | IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); | ||
345 | |||
346 | // In order to run a single threaded regression test we do not want the entity transfer module waiting | ||
347 | // for a callback from the destination scene before removing its avatar data. | ||
348 | entityTransferConfig.Set("wait_for_callback", false); | ||
349 | |||
350 | modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
351 | |||
352 | SceneHelpers sh = new SceneHelpers(); | ||
353 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); | ||
354 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); | ||
355 | |||
356 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | ||
357 | SceneHelpers.SetupSceneModules( | ||
358 | sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule()); | ||
359 | SceneHelpers.SetupSceneModules( | ||
360 | sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); | ||
361 | |||
362 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); | ||
363 | ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager); | ||
364 | beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); | ||
365 | |||
366 | InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); | ||
367 | |||
368 | sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( | ||
369 | beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); | ||
370 | |||
371 | Vector3 teleportPosition = new Vector3(10, 11, 12); | ||
372 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | ||
373 | |||
374 | sceneA.RequestTeleportLocation( | ||
375 | beforeTeleportSp.ControllingClient, | ||
376 | sceneB.RegionInfo.RegionHandle, | ||
377 | teleportPosition, | ||
378 | teleportLookAt, | ||
379 | (uint)TeleportFlags.ViaLocation); | ||
380 | |||
381 | ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide(); | ||
382 | |||
383 | // Check attachments have made it into sceneB | ||
384 | ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); | ||
385 | |||
386 | // This is appearance data, as opposed to actually rezzed attachments | ||
387 | List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); | ||
388 | Assert.That(sceneBAttachments.Count, Is.EqualTo(1)); | ||
389 | Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); | ||
390 | Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID)); | ||
391 | Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); | ||
392 | Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
393 | |||
394 | // This is the actual attachment | ||
395 | List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments(); | ||
396 | Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1)); | ||
397 | SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0]; | ||
398 | Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name)); | ||
399 | Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); | ||
400 | |||
401 | // Check attachments have been removed from sceneA | ||
402 | ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID); | ||
403 | |||
404 | // Since this is appearance data, it is still present on the child avatar! | ||
405 | List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); | ||
406 | Assert.That(sceneAAttachments.Count, Is.EqualTo(1)); | ||
407 | Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
408 | |||
409 | // This is the actual attachment, which should no longer exist | ||
410 | List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); | ||
411 | Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); | ||
412 | } | ||
413 | |||
335 | // I'm commenting this test because scene setup NEEDS InventoryService to | 414 | // I'm commenting this test because scene setup NEEDS InventoryService to |
336 | // be non-null | 415 | // be non-null |
337 | //[Test] | 416 | //[Test] |