diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 76 |
1 files changed, 27 insertions, 49 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 4e9d3f9..d9a619d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -62,10 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
62 | public class AttachmentsModuleTests : OpenSimTestCase | 62 | public class AttachmentsModuleTests : OpenSimTestCase |
63 | { | 63 | { |
64 | private AutoResetEvent m_chatEvent = new AutoResetEvent(false); | 64 | private AutoResetEvent m_chatEvent = new AutoResetEvent(false); |
65 | // private OSChatMessage m_osChatMessageReceived; | 65 | private OSChatMessage m_osChatMessageReceived; |
66 | |||
67 | // Used to test whether the operations have fired the attach event. Must be reset after each test. | ||
68 | private int m_numberOfAttachEventsFired; | ||
69 | 66 | ||
70 | [TestFixtureSetUp] | 67 | [TestFixtureSetUp] |
71 | public void FixtureInit() | 68 | public void FixtureInit() |
@@ -86,7 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
86 | { | 83 | { |
87 | // Console.WriteLine("Got chat [{0}]", oscm.Message); | 84 | // Console.WriteLine("Got chat [{0}]", oscm.Message); |
88 | 85 | ||
89 | // m_osChatMessageReceived = oscm; | 86 | m_osChatMessageReceived = oscm; |
90 | m_chatEvent.Set(); | 87 | m_chatEvent.Set(); |
91 | } | 88 | } |
92 | 89 | ||
@@ -102,8 +99,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
102 | "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); | 99 | "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); |
103 | SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); | 100 | SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); |
104 | 101 | ||
105 | scene.EventManager.OnAttach += (localID, itemID, avatarID) => m_numberOfAttachEventsFired++; | ||
106 | |||
107 | return scene; | 102 | return scene; |
108 | } | 103 | } |
109 | 104 | ||
@@ -186,8 +181,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
186 | TestHelpers.InMethod(); | 181 | TestHelpers.InMethod(); |
187 | // TestHelpers.EnableLogging(); | 182 | // TestHelpers.EnableLogging(); |
188 | 183 | ||
189 | m_numberOfAttachEventsFired = 0; | ||
190 | |||
191 | Scene scene = CreateTestScene(); | 184 | Scene scene = CreateTestScene(); |
192 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 185 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
193 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 186 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
@@ -196,7 +189,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
196 | 189 | ||
197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 190 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
198 | 191 | ||
199 | m_numberOfAttachEventsFired = 0; | ||
200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); | 192 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); |
201 | 193 | ||
202 | // Check status on scene presence | 194 | // Check status on scene presence |
@@ -224,8 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
224 | 216 | ||
225 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 217 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
226 | 218 | ||
227 | // Check events | 219 | // TestHelpers.DisableLogging(); |
228 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
229 | } | 220 | } |
230 | 221 | ||
231 | /// <summary> | 222 | /// <summary> |
@@ -237,8 +228,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
237 | TestHelpers.InMethod(); | 228 | TestHelpers.InMethod(); |
238 | // TestHelpers.EnableLogging(); | 229 | // TestHelpers.EnableLogging(); |
239 | 230 | ||
240 | m_numberOfAttachEventsFired = 0; | ||
241 | |||
242 | Scene scene = CreateTestScene(); | 231 | Scene scene = CreateTestScene(); |
243 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 232 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
244 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 233 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
@@ -258,9 +247,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
258 | 247 | ||
259 | Assert.That(sp.HasAttachments(), Is.False); | 248 | Assert.That(sp.HasAttachments(), Is.False); |
260 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 249 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
261 | |||
262 | // Check events | ||
263 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
264 | } | 250 | } |
265 | 251 | ||
266 | [Test] | 252 | [Test] |
@@ -275,7 +261,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
275 | 261 | ||
276 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | 262 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
277 | 263 | ||
278 | m_numberOfAttachEventsFired = 0; | ||
279 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 264 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
280 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 265 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
281 | 266 | ||
@@ -295,9 +280,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
295 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | 280 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
296 | 281 | ||
297 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 282 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
298 | |||
299 | // Check events | ||
300 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
301 | } | 283 | } |
302 | 284 | ||
303 | /// <summary> | 285 | /// <summary> |
@@ -356,8 +338,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
356 | ISceneEntity so | 338 | ISceneEntity so |
357 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 339 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
358 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 340 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
359 | |||
360 | m_numberOfAttachEventsFired = 0; | ||
361 | scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId); | 341 | scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId); |
362 | 342 | ||
363 | // Check scene presence status | 343 | // Check scene presence status |
@@ -373,9 +353,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
373 | 353 | ||
374 | // Check object in scene | 354 | // Check object in scene |
375 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); | 355 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); |
376 | |||
377 | // Check events | ||
378 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
379 | } | 356 | } |
380 | 357 | ||
381 | [Test] | 358 | [Test] |
@@ -392,8 +369,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
392 | SceneObjectGroup so | 369 | SceneObjectGroup so |
393 | = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 370 | = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
394 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 371 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
395 | |||
396 | m_numberOfAttachEventsFired = 0; | ||
397 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so); | 372 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so); |
398 | 373 | ||
399 | // Check status on scene presence | 374 | // Check status on scene presence |
@@ -405,9 +380,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
405 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); | 380 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); |
406 | 381 | ||
407 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0)); | 382 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0)); |
408 | |||
409 | // Check events | ||
410 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
411 | } | 383 | } |
412 | 384 | ||
413 | /// <summary> | 385 | /// <summary> |
@@ -489,14 +461,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
489 | 461 | ||
490 | SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; | 462 | SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; |
491 | 463 | ||
492 | m_numberOfAttachEventsFired = 0; | 464 | scene.IncomingCloseAgent(presence.UUID); |
493 | scene.IncomingCloseAgent(presence.UUID, false); | ||
494 | 465 | ||
495 | // Check that we can't retrieve this attachment from the scene. | 466 | // Check that we can't retrieve this attachment from the scene. |
496 | Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); | 467 | Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); |
497 | |||
498 | // Check events | ||
499 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
500 | } | 468 | } |
501 | 469 | ||
502 | [Test] | 470 | [Test] |
@@ -512,8 +480,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
512 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); | 480 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); |
513 | acd.Appearance = new AvatarAppearance(); | 481 | acd.Appearance = new AvatarAppearance(); |
514 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 482 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
515 | |||
516 | m_numberOfAttachEventsFired = 0; | ||
517 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | 483 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); |
518 | 484 | ||
519 | Assert.That(presence.HasAttachments(), Is.True); | 485 | Assert.That(presence.HasAttachments(), Is.True); |
@@ -536,9 +502,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
536 | Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | 502 | Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
537 | 503 | ||
538 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 504 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
539 | |||
540 | // Check events. We expect OnAttach to fire on login. | ||
541 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
542 | } | 505 | } |
543 | 506 | ||
544 | [Test] | 507 | [Test] |
@@ -559,14 +522,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
559 | 522 | ||
560 | Vector3 newPosition = new Vector3(1, 2, 4); | 523 | Vector3 newPosition = new Vector3(1, 2, 4); |
561 | 524 | ||
562 | m_numberOfAttachEventsFired = 0; | ||
563 | scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient); | 525 | scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient); |
564 | 526 | ||
565 | Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition)); | 527 | Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition)); |
566 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); | 528 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); |
567 | |||
568 | // Check events | ||
569 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
570 | } | 529 | } |
571 | 530 | ||
572 | [Test] | 531 | [Test] |
@@ -615,7 +574,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
615 | Vector3 teleportPosition = new Vector3(10, 11, 12); | 574 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
616 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | 575 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
617 | 576 | ||
618 | m_numberOfAttachEventsFired = 0; | ||
619 | sceneA.RequestTeleportLocation( | 577 | sceneA.RequestTeleportLocation( |
620 | beforeTeleportSp.ControllingClient, | 578 | beforeTeleportSp.ControllingClient, |
621 | sceneB.RegionInfo.RegionHandle, | 579 | sceneB.RegionInfo.RegionHandle, |
@@ -658,9 +616,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
658 | Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); | 616 | Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); |
659 | 617 | ||
660 | Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); | 618 | Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); |
661 | |||
662 | // Check events | ||
663 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
664 | } | 619 | } |
620 | |||
621 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
622 | // be non-null | ||
623 | //[Test] | ||
624 | // public void T032_CrossAttachments() | ||
625 | // { | ||
626 | // TestHelpers.InMethod(); | ||
627 | // | ||
628 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
629 | // ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
630 | // presence2.AddAttachment(sog1); | ||
631 | // presence2.AddAttachment(sog2); | ||
632 | // | ||
633 | // ISharedRegionModule serialiser = new SerialiserModule(); | ||
634 | // SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
635 | // SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
636 | // | ||
637 | // Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
638 | // | ||
639 | // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
640 | // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
641 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
642 | // } | ||
665 | } | 643 | } |
666 | } | 644 | } |