aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs133
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs5
2 files changed, 120 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 8f4a807..695994f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -38,6 +38,8 @@ using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Region.CoreModules.Avatar.Attachments; 40using OpenSim.Region.CoreModules.Avatar.Attachments;
41using OpenSim.Region.CoreModules.Framework;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer;
41using OpenSim.Region.CoreModules.Framework.InventoryAccess; 43using OpenSim.Region.CoreModules.Framework.InventoryAccess;
42using OpenSim.Region.CoreModules.World.Serialiser; 44using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
@@ -54,7 +56,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
54 [TestFixture] 56 [TestFixture]
55 public class AttachmentsModuleTests 57 public class AttachmentsModuleTests
56 { 58 {
57 private Scene scene;
58 private AttachmentsModule m_attMod; 59 private AttachmentsModule m_attMod;
59 private ScenePresence m_presence; 60 private ScenePresence m_presence;
60 61
@@ -80,24 +81,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
80 Util.FireAndForgetMethod = FireAndForgetMethod.None; 81 Util.FireAndForgetMethod = FireAndForgetMethod.None;
81 } 82 }
82 83
83 [SetUp] 84 [TestFixtureTearDown]
84 public void Init() 85 public void TearDown()
86 {
87 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
88 // threads. Possibly, later tests should be rewritten not to worry about such things.
89 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
90 }
91
92 private Scene CreateDefaultTestScene()
85 { 93 {
86 IConfigSource config = new IniConfigSource(); 94 IConfigSource config = new IniConfigSource();
87 config.AddConfig("Modules"); 95 config.AddConfig("Modules");
88 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); 96 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
89 97
90 scene = new SceneHelpers().SetupScene(); 98 Scene scene = new SceneHelpers().SetupScene();
91 m_attMod = new AttachmentsModule(); 99 m_attMod = new AttachmentsModule();
92 SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); 100 SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule());
93 }
94 101
95 [TestFixtureTearDown] 102 return scene;
96 public void TearDown()
97 {
98 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
99 // threads. Possibly, later tests should be rewritten not to worry about such things.
100 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
101 } 103 }
102 104
103 /// <summary> 105 /// <summary>
@@ -109,11 +111,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
109 /// <returns> 111 /// <returns>
110 /// The attachment item. 112 /// The attachment item.
111 /// </returns> 113 /// </returns>
114 /// <param name='scene'></param>
112 /// <param name='userId'></param> 115 /// <param name='userId'></param>
113 /// <param name='attName'></param> 116 /// <param name='attName'></param>
114 /// <param name='rawItemId'></param> 117 /// <param name='rawItemId'></param>
115 /// <param name='rawAssetId'></param> 118 /// <param name='rawAssetId'></param>
116 private InventoryItemBase CreateAttachmentItem(UUID userId, string attName, int rawItemId, int rawAssetId) 119 private InventoryItemBase CreateAttachmentItem(
120 Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId)
117 { 121 {
118 return UserInventoryHelpers.CreateInventoryItem( 122 return UserInventoryHelpers.CreateInventoryItem(
119 scene, 123 scene,
@@ -130,6 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
130 TestHelpers.InMethod(); 134 TestHelpers.InMethod();
131// TestHelpers.EnableLogging(); 135// TestHelpers.EnableLogging();
132 136
137 Scene scene = CreateDefaultTestScene();
133 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 138 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
134 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 139 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
135 140
@@ -171,10 +176,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
171 TestHelpers.InMethod(); 176 TestHelpers.InMethod();
172// log4net.Config.XmlConfigurator.Configure(); 177// log4net.Config.XmlConfigurator.Configure();
173 178
179 Scene scene = CreateDefaultTestScene();
174 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 180 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
175 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 181 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
176 182
177 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 183 InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
178 184
179 m_attMod.RezSingleAttachmentFromInventory( 185 m_attMod.RezSingleAttachmentFromInventory(
180 m_presence, attItem.ID, (uint)AttachmentPoint.Chest); 186 m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
@@ -201,10 +207,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
201 TestHelpers.InMethod(); 207 TestHelpers.InMethod();
202// log4net.Config.XmlConfigurator.Configure(); 208// log4net.Config.XmlConfigurator.Configure();
203 209
210 Scene scene = CreateDefaultTestScene();
204 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 211 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
205 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 212 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
206 213
207 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 214 InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
208 215
209 ISceneEntity so 216 ISceneEntity so
210 = m_attMod.RezSingleAttachmentFromInventory( 217 = m_attMod.RezSingleAttachmentFromInventory(
@@ -232,10 +239,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
232 TestHelpers.InMethod(); 239 TestHelpers.InMethod();
233// log4net.Config.XmlConfigurator.Configure(); 240// log4net.Config.XmlConfigurator.Configure();
234 241
242 Scene scene = CreateDefaultTestScene();
235 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 243 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
236 m_presence = SceneHelpers.AddScenePresence(scene, m_userId); 244 m_presence = SceneHelpers.AddScenePresence(scene, m_userId);
237 245
238 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 246 InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
239 247
240 m_attMod.RezSingleAttachmentFromInventory( 248 m_attMod.RezSingleAttachmentFromInventory(
241 m_presence, attItem.ID, (uint)AttachmentPoint.Chest); 249 m_presence, attItem.ID, (uint)AttachmentPoint.Chest);
@@ -259,8 +267,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
259 TestHelpers.InMethod(); 267 TestHelpers.InMethod();
260// log4net.Config.XmlConfigurator.Configure(); 268// log4net.Config.XmlConfigurator.Configure();
261 269
270 Scene scene = CreateDefaultTestScene();
262 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 271 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
263 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 272 InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
264 273
265 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); 274 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
266 acd.Appearance = new AvatarAppearance(); 275 acd.Appearance = new AvatarAppearance();
@@ -281,8 +290,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
281 TestHelpers.InMethod(); 290 TestHelpers.InMethod();
282// log4net.Config.XmlConfigurator.Configure(); 291// log4net.Config.XmlConfigurator.Configure();
283 292
293 Scene scene = CreateDefaultTestScene();
284 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 294 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
285 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 295 InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
286 296
287 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); 297 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
288 acd.Appearance = new AvatarAppearance(); 298 acd.Appearance = new AvatarAppearance();
@@ -314,8 +324,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
314 { 324 {
315 TestHelpers.InMethod(); 325 TestHelpers.InMethod();
316 326
327 Scene scene = CreateDefaultTestScene();
317 UserAccountHelpers.CreateUserWithInventory(scene, m_userId); 328 UserAccountHelpers.CreateUserWithInventory(scene, m_userId);
318 InventoryItemBase attItem = CreateAttachmentItem(m_userId, "att", 0x10, 0x20); 329 InventoryItemBase attItem = CreateAttachmentItem(scene, m_userId, "att", 0x10, 0x20);
319 330
320 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId); 331 AgentCircuitData acd = SceneHelpers.GenerateAgentData(m_userId);
321 acd.Appearance = new AvatarAppearance(); 332 acd.Appearance = new AvatarAppearance();
@@ -332,6 +343,92 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
332 Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); 343 Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition));
333 } 344 }
334 345
346 [Test]
347 public void TestSameSimulatorNeighbouringRegionsTeleport()
348 {
349 TestHelpers.InMethod();
350// TestHelpers.EnableLogging();
351
352 AttachmentsModule attModA = new AttachmentsModule();
353 AttachmentsModule attModB = new AttachmentsModule();
354 EntityTransferModule etmA = new EntityTransferModule();
355 EntityTransferModule etmB = new EntityTransferModule();
356 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
357
358 IConfigSource config = new IniConfigSource();
359 IConfig modulesConfig = config.AddConfig("Modules");
360 modulesConfig.Set("EntityTransferModule", etmA.Name);
361 modulesConfig.Set("SimulationServices", lscm.Name);
362 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
363
364 // In order to run a single threaded regression test we do not want the entity transfer module waiting
365 // for a callback from the destination scene before removing its avatar data.
366 entityTransferConfig.Set("wait_for_callback", false);
367
368 SceneHelpers sh = new SceneHelpers();
369 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
370 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
371
372 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
373 SceneHelpers.SetupSceneModules(
374 sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
375 SceneHelpers.SetupSceneModules(
376 sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());
377
378 UserAccountHelpers.CreateUserWithInventory(sceneA, m_userId);
379 ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, m_userId, sh.SceneManager);
380 beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);
381
382 InventoryItemBase attItem = CreateAttachmentItem(sceneA, m_userId, "att", 0x10, 0x20);
383
384 m_attMod.RezSingleAttachmentFromInventory(
385 beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);
386
387 Vector3 teleportPosition = new Vector3(10, 11, 12);
388 Vector3 teleportLookAt = new Vector3(20, 21, 22);
389
390 sceneA.RequestTeleportLocation(
391 beforeTeleportSp.ControllingClient,
392 sceneB.RegionInfo.RegionHandle,
393 teleportPosition,
394 teleportLookAt,
395 (uint)TeleportFlags.ViaLocation);
396
397 ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide();
398
399 // Check attachments have made it into sceneB
400 ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(m_userId);
401
402 // This is appearance data, as opposed to actually rezzed attachments
403 List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
404 Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
405 Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
406 Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
407 Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
408 Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
409
410 // This is the actual attachment
411 List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
412 Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
413 SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
414 Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
415 Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
416
417 // Check attachments have been removed from sceneA
418 ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(m_userId);
419
420 // Since this is appearance data, it is still present on the child avatar!
421 List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
422 Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
423 Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
424
425 // This is the actual attachment, which should no longer exist
426 List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
427 Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));
428
429// TestHelpers.DisableLogging();
430 }
431
335 // I'm commenting this test because scene setup NEEDS InventoryService to 432 // I'm commenting this test because scene setup NEEDS InventoryService to
336 // be non-null 433 // be non-null
337 //[Test] 434 //[Test]
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index f5ebe97..46738f6 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -709,6 +709,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
709 agent.CallbackURI, region.RegionName); 709 agent.CallbackURI, region.RegionName);
710 } 710 }
711 711
712 /// <summary>
713 /// Clean up operations once an agent has moved away through cross or teleport.
714 /// </summary>
715 /// <param name='sp'></param>
716 /// <param name='logout'></param>
712 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) 717 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout)
713 { 718 {
714 if (sp.Scene.AttachmentsModule != null) 719 if (sp.Scene.AttachmentsModule != null)