diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs (renamed from OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs) | 128 |
2 files changed, 88 insertions, 60 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 1e09610..97a1be6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
101 | /// <param name="silent"></param> | 101 | /// <param name="silent"></param> |
102 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) | 102 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) |
103 | { | 103 | { |
104 | m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); | 104 | // m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); |
105 | 105 | ||
106 | try | 106 | try |
107 | { | 107 | { |
@@ -226,9 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
226 | public UUID RezSingleAttachmentFromInventory( | 226 | public UUID RezSingleAttachmentFromInventory( |
227 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) | 227 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) |
228 | { | 228 | { |
229 | m_log.DebugFormat( | 229 | // m_log.DebugFormat( |
230 | "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", | 230 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", |
231 | (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); | 231 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); |
232 | 232 | ||
233 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 233 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
234 | // be removed when that functionality is implemented in opensim | 234 | // be removed when that functionality is implemented in opensim |
@@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
261 | false, false, remoteClient.AgentId, true); | 261 | false, false, remoteClient.AgentId, true); |
262 | 262 | ||
263 | // m_log.DebugFormat( | 263 | // m_log.DebugFormat( |
264 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | 264 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", |
265 | // objatt.Name, remoteClient.Name, AttachmentPt); | 265 | // objatt.Name, remoteClient.Name, AttachmentPt); |
266 | 266 | ||
267 | if (objatt != null) | 267 | if (objatt != null) |
@@ -466,7 +466,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
466 | { | 466 | { |
467 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); | 467 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); |
468 | group.DetachToInventoryPrep(); | 468 | group.DetachToInventoryPrep(); |
469 | m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); | 469 | // m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); |
470 | 470 | ||
471 | // If an item contains scripts, it's always changed. | 471 | // If an item contains scripts, it's always changed. |
472 | // This ensures script state is saved on detach | 472 | // This ensures script state is saved on detach |
@@ -501,10 +501,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
501 | /// <summary> | 501 | /// <summary> |
502 | /// Update the attachment asset for the new sog details if they have changed. | 502 | /// Update the attachment asset for the new sog details if they have changed. |
503 | /// </summary> | 503 | /// </summary> |
504 | /// | 504 | /// <remarks> |
505 | /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, | 505 | /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects, |
506 | /// these details are not stored on the region. | 506 | /// these details are not stored on the region. |
507 | /// | 507 | /// </remarks> |
508 | /// <param name="remoteClient"></param> | 508 | /// <param name="remoteClient"></param> |
509 | /// <param name="grp"></param> | 509 | /// <param name="grp"></param> |
510 | /// <param name="itemID"></param> | 510 | /// <param name="itemID"></param> |
@@ -566,8 +566,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
566 | /// <param name="silent"></param> | 566 | /// <param name="silent"></param> |
567 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | 567 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) |
568 | { | 568 | { |
569 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, | 569 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", |
570 | attachmentpoint, attachOffset, so.RootPart.AttachedPos); | 570 | // so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); |
571 | 571 | ||
572 | so.DetachFromBackup(); | 572 | so.DetachFromBackup(); |
573 | 573 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 5586c65..5bac4c6 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -37,104 +37,132 @@ using NUnit.Framework; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.CoreModules.Avatar.Attachments; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
42 | using OpenSim.Region.CoreModules.World.Serialiser; | 42 | using OpenSim.Region.CoreModules.World.Serialiser; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
45 | using OpenSim.Tests.Common.Mock; | 47 | using OpenSim.Tests.Common.Mock; |
46 | 48 | ||
47 | namespace OpenSim.Region.Framework.Scenes.Tests | 49 | namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests |
48 | { | 50 | { |
49 | /// <summary> | 51 | /// <summary> |
50 | /// Attachment tests | 52 | /// Attachment tests |
51 | /// </summary> | 53 | /// </summary> |
52 | [TestFixture] | 54 | [TestFixture] |
53 | public class AttachmentTests | 55 | public class AttachmentsModuleTests |
54 | { | 56 | { |
55 | public Scene scene, scene2; | 57 | public Scene scene; |
56 | public UUID agent1; | 58 | public UUID agent1; |
57 | public static Random random; | 59 | public static Random random; |
58 | public ulong region1, region2; | ||
59 | public AgentCircuitData acd1; | 60 | public AgentCircuitData acd1; |
60 | public SceneObjectGroup sog1, sog2, sog3; | 61 | public SceneObjectGroup sog1, sog2; |
61 | 62 | ||
62 | [TestFixtureSetUp] | 63 | [SetUp] |
63 | public void Init() | 64 | public void Init() |
64 | { | 65 | { |
65 | TestHelper.InMethod(); | 66 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. |
66 | 67 | Util.FireAndForgetMethod = FireAndForgetMethod.None; | |
67 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | 68 | |
68 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | 69 | IConfigSource config = new IniConfigSource(); |
70 | config.AddConfig("Modules"); | ||
71 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
69 | 72 | ||
70 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | 73 | scene = SceneHelpers.SetupScene(); |
71 | interregionComms.Initialise(new IniConfigSource()); | 74 | SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); |
72 | interregionComms.PostInitialise(); | ||
73 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | ||
74 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); | ||
75 | 75 | ||
76 | agent1 = UUID.Random(); | 76 | agent1 = UUID.Random(); |
77 | random = new Random(); | 77 | random = new Random(); |
78 | sog1 = NewSOG(UUID.Random(), scene, agent1); | 78 | sog1 = NewSOG(UUID.Random(), scene, agent1); |
79 | sog2 = NewSOG(UUID.Random(), scene, agent1); | 79 | sog2 = NewSOG(UUID.Random(), scene, agent1); |
80 | sog3 = NewSOG(UUID.Random(), scene, agent1); | 80 | } |
81 | 81 | ||
82 | //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | 82 | [TearDown] |
83 | region1 = scene.RegionInfo.RegionHandle; | 83 | public void TearDown() |
84 | region2 = scene2.RegionInfo.RegionHandle; | 84 | { |
85 | 85 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | |
86 | SceneSetupHelpers.AddClient(scene, agent1); | 86 | // threads. Possibly, later tests should be rewritten not to worry about such things. |
87 | } | 87 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
88 | } | ||
88 | 89 | ||
89 | [Test] | 90 | [Test] |
90 | public void T030_TestAddAttachments() | 91 | public void TestAddAttachments() |
91 | { | 92 | { |
92 | TestHelper.InMethod(); | 93 | TestHelpers.InMethod(); |
93 | |||
94 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
95 | 94 | ||
95 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); | ||
96 | presence.AddAttachment(sog1); | 96 | presence.AddAttachment(sog1); |
97 | presence.AddAttachment(sog2); | 97 | presence.AddAttachment(sog2); |
98 | presence.AddAttachment(sog3); | ||
99 | 98 | ||
100 | Assert.That(presence.HasAttachments(), Is.True); | 99 | Assert.That(presence.HasAttachments(), Is.True); |
101 | Assert.That(presence.ValidateAttachments(), Is.True); | 100 | Assert.That(presence.ValidateAttachments(), Is.True); |
102 | } | 101 | } |
103 | 102 | ||
104 | [Test] | 103 | [Test] |
105 | public void T031_RemoveAttachments() | 104 | public void TestRemoveAttachments() |
106 | { | 105 | { |
107 | TestHelper.InMethod(); | 106 | TestHelpers.InMethod(); |
108 | 107 | ||
109 | ScenePresence presence = scene.GetScenePresence(agent1); | 108 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); |
109 | presence.AddAttachment(sog1); | ||
110 | presence.AddAttachment(sog2); | ||
110 | presence.RemoveAttachment(sog1); | 111 | presence.RemoveAttachment(sog1); |
111 | presence.RemoveAttachment(sog2); | 112 | presence.RemoveAttachment(sog2); |
112 | presence.RemoveAttachment(sog3); | ||
113 | Assert.That(presence.HasAttachments(), Is.False); | 113 | Assert.That(presence.HasAttachments(), Is.False); |
114 | } | 114 | } |
115 | 115 | ||
116 | // I'm commenting this test because scene setup NEEDS InventoryService to | 116 | [Test] |
117 | // be non-null | 117 | public void TestRezAttachmentsOnAvatarEntrance() |
118 | //[Test] | ||
119 | public void T032_CrossAttachments() | ||
120 | { | 118 | { |
121 | TestHelper.InMethod(); | 119 | TestHelpers.InMethod(); |
120 | // log4net.Config.XmlConfigurator.Configure(); | ||
121 | |||
122 | UUID userId = TestHelpers.ParseTail(0x1); | ||
123 | UUID attItemId = TestHelpers.ParseTail(0x2); | ||
124 | UUID attAssetId = TestHelpers.ParseTail(0x3); | ||
125 | string attName = "att"; | ||
122 | 126 | ||
123 | ScenePresence presence = scene.GetScenePresence(agent1); | 127 | UserAccountHelpers.CreateUserWithInventory(scene, userId); |
124 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | 128 | InventoryItemBase attItem |
125 | presence2.AddAttachment(sog1); | 129 | = UserInventoryHelpers.CreateInventoryItem( |
126 | presence2.AddAttachment(sog2); | 130 | scene, attName, attItemId, attAssetId, userId, InventoryType.Object); |
127 | 131 | ||
128 | ISharedRegionModule serialiser = new SerialiserModule(); | 132 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
129 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | 133 | acd.Appearance = new AvatarAppearance(); |
130 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | 134 | acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); |
135 | ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); | ||
131 | 136 | ||
132 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | 137 | Assert.That(presence.HasAttachments(), Is.True); |
138 | List<SceneObjectGroup> attachments = presence.Attachments; | ||
139 | |||
140 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
141 | Assert.That(attachments[0].Name, Is.EqualTo(attName)); | ||
142 | } | ||
133 | 143 | ||
134 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | 144 | // I'm commenting this test because scene setup NEEDS InventoryService to |
135 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | 145 | // be non-null |
136 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | 146 | //[Test] |
137 | } | 147 | // public void T032_CrossAttachments() |
148 | // { | ||
149 | // TestHelpers.InMethod(); | ||
150 | // | ||
151 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
152 | // ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
153 | // presence2.AddAttachment(sog1); | ||
154 | // presence2.AddAttachment(sog2); | ||
155 | // | ||
156 | // ISharedRegionModule serialiser = new SerialiserModule(); | ||
157 | // SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
158 | // SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
159 | // | ||
160 | // Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
161 | // | ||
162 | // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
163 | // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
164 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
165 | // } | ||
138 | 166 | ||
139 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | 167 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) |
140 | { | 168 | { |