diff options
author | Melanie | 2012-09-29 19:21:07 +0100 |
---|---|---|
committer | Melanie | 2012-09-29 19:21:07 +0100 |
commit | 71dd55a1ce8560dba3fbab76e25bbeaf974f422a (patch) | |
tree | b1c3759d25e29b8ab9b2c61da3f408c6aa7803f4 /OpenSim/Region/CoreModules/Avatar/Attachments/Tests | |
parent | Merge branch 'avination' into careminster (diff) | |
parent | Get rid of some unnecessary casts in RemoteAdminPlugin. (diff) | |
download | opensim-SC_OLD-71dd55a1ce8560dba3fbab76e25bbeaf974f422a.zip opensim-SC_OLD-71dd55a1ce8560dba3fbab76e25bbeaf974f422a.tar.gz opensim-SC_OLD-71dd55a1ce8560dba3fbab76e25bbeaf974f422a.tar.bz2 opensim-SC_OLD-71dd55a1ce8560dba3fbab76e25bbeaf974f422a.tar.xz |
Merge branch 'master' into careminster
Conflicts:
CONTRIBUTORS.txt
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
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 | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b7a1169..4e9d3f9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -64,6 +64,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
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 | 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 | |||
67 | [TestFixtureSetUp] | 70 | [TestFixtureSetUp] |
68 | public void FixtureInit() | 71 | public void FixtureInit() |
69 | { | 72 | { |
@@ -99,6 +102,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
99 | "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); | 102 | "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); |
100 | SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); | 103 | SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); |
101 | 104 | ||
105 | scene.EventManager.OnAttach += (localID, itemID, avatarID) => m_numberOfAttachEventsFired++; | ||
106 | |||
102 | return scene; | 107 | return scene; |
103 | } | 108 | } |
104 | 109 | ||
@@ -181,6 +186,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
181 | TestHelpers.InMethod(); | 186 | TestHelpers.InMethod(); |
182 | // TestHelpers.EnableLogging(); | 187 | // TestHelpers.EnableLogging(); |
183 | 188 | ||
189 | m_numberOfAttachEventsFired = 0; | ||
190 | |||
184 | Scene scene = CreateTestScene(); | 191 | Scene scene = CreateTestScene(); |
185 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 192 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
186 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 193 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
@@ -189,6 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
189 | 196 | ||
190 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
191 | 198 | ||
199 | m_numberOfAttachEventsFired = 0; | ||
192 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); | 200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); |
193 | 201 | ||
194 | // Check status on scene presence | 202 | // Check status on scene presence |
@@ -216,7 +224,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
216 | 224 | ||
217 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 225 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
218 | 226 | ||
219 | // TestHelpers.DisableLogging(); | 227 | // Check events |
228 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
220 | } | 229 | } |
221 | 230 | ||
222 | /// <summary> | 231 | /// <summary> |
@@ -228,6 +237,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
228 | TestHelpers.InMethod(); | 237 | TestHelpers.InMethod(); |
229 | // TestHelpers.EnableLogging(); | 238 | // TestHelpers.EnableLogging(); |
230 | 239 | ||
240 | m_numberOfAttachEventsFired = 0; | ||
241 | |||
231 | Scene scene = CreateTestScene(); | 242 | Scene scene = CreateTestScene(); |
232 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 243 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
233 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 244 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
@@ -247,6 +258,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
247 | 258 | ||
248 | Assert.That(sp.HasAttachments(), Is.False); | 259 | Assert.That(sp.HasAttachments(), Is.False); |
249 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 260 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
261 | |||
262 | // Check events | ||
263 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
250 | } | 264 | } |
251 | 265 | ||
252 | [Test] | 266 | [Test] |
@@ -261,6 +275,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
261 | 275 | ||
262 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | 276 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
263 | 277 | ||
278 | m_numberOfAttachEventsFired = 0; | ||
264 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 279 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
265 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 280 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
266 | 281 | ||
@@ -280,6 +295,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
280 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | 295 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
281 | 296 | ||
282 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 297 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
298 | |||
299 | // Check events | ||
300 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
283 | } | 301 | } |
284 | 302 | ||
285 | /// <summary> | 303 | /// <summary> |
@@ -338,6 +356,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
338 | ISceneEntity so | 356 | ISceneEntity so |
339 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 357 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
340 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 358 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
359 | |||
360 | m_numberOfAttachEventsFired = 0; | ||
341 | scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId); | 361 | scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId); |
342 | 362 | ||
343 | // Check scene presence status | 363 | // Check scene presence status |
@@ -353,6 +373,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
353 | 373 | ||
354 | // Check object in scene | 374 | // Check object in scene |
355 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); | 375 | Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); |
376 | |||
377 | // Check events | ||
378 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
356 | } | 379 | } |
357 | 380 | ||
358 | [Test] | 381 | [Test] |
@@ -369,6 +392,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
369 | SceneObjectGroup so | 392 | SceneObjectGroup so |
370 | = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 393 | = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
371 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 394 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
395 | |||
396 | m_numberOfAttachEventsFired = 0; | ||
372 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so); | 397 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so); |
373 | 398 | ||
374 | // Check status on scene presence | 399 | // Check status on scene presence |
@@ -380,6 +405,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
380 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); | 405 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0)); |
381 | 406 | ||
382 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0)); | 407 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0)); |
408 | |||
409 | // Check events | ||
410 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
383 | } | 411 | } |
384 | 412 | ||
385 | /// <summary> | 413 | /// <summary> |
@@ -461,10 +489,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
461 | 489 | ||
462 | SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; | 490 | SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; |
463 | 491 | ||
492 | m_numberOfAttachEventsFired = 0; | ||
464 | scene.IncomingCloseAgent(presence.UUID, false); | 493 | scene.IncomingCloseAgent(presence.UUID, false); |
465 | 494 | ||
466 | // Check that we can't retrieve this attachment from the scene. | 495 | // Check that we can't retrieve this attachment from the scene. |
467 | Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); | 496 | Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); |
497 | |||
498 | // Check events | ||
499 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
468 | } | 500 | } |
469 | 501 | ||
470 | [Test] | 502 | [Test] |
@@ -480,6 +512,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
480 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); | 512 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); |
481 | acd.Appearance = new AvatarAppearance(); | 513 | acd.Appearance = new AvatarAppearance(); |
482 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); | 514 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
515 | |||
516 | m_numberOfAttachEventsFired = 0; | ||
483 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | 517 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); |
484 | 518 | ||
485 | Assert.That(presence.HasAttachments(), Is.True); | 519 | Assert.That(presence.HasAttachments(), Is.True); |
@@ -502,6 +536,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
502 | Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | 536 | Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); |
503 | 537 | ||
504 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 538 | 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)); | ||
505 | } | 542 | } |
506 | 543 | ||
507 | [Test] | 544 | [Test] |
@@ -522,10 +559,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
522 | 559 | ||
523 | Vector3 newPosition = new Vector3(1, 2, 4); | 560 | Vector3 newPosition = new Vector3(1, 2, 4); |
524 | 561 | ||
562 | m_numberOfAttachEventsFired = 0; | ||
525 | scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient); | 563 | scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient); |
526 | 564 | ||
527 | Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition)); | 565 | Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition)); |
528 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); | 566 | Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); |
567 | |||
568 | // Check events | ||
569 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); | ||
529 | } | 570 | } |
530 | 571 | ||
531 | [Test] | 572 | [Test] |
@@ -574,6 +615,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
574 | Vector3 teleportPosition = new Vector3(10, 11, 12); | 615 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
575 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | 616 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
576 | 617 | ||
618 | m_numberOfAttachEventsFired = 0; | ||
577 | sceneA.RequestTeleportLocation( | 619 | sceneA.RequestTeleportLocation( |
578 | beforeTeleportSp.ControllingClient, | 620 | beforeTeleportSp.ControllingClient, |
579 | sceneB.RegionInfo.RegionHandle, | 621 | sceneB.RegionInfo.RegionHandle, |
@@ -616,29 +658,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
616 | Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); | 658 | Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); |
617 | 659 | ||
618 | Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); | 660 | Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); |
619 | } | ||
620 | 661 | ||
621 | // I'm commenting this test because scene setup NEEDS InventoryService to | 662 | // Check events |
622 | // be non-null | 663 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); |
623 | //[Test] | 664 | } |
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 | // } | ||
643 | } | 665 | } |
644 | } | 666 | } |