diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 373094bd5b..a07d64c18b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -34,7 +34,6 @@ using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Region.CoreModules.Framework.InventoryAccess; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; @@ -184,6 +183,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// /// Test deleting an object from a scene. /// + /// + /// This is the most basic form of delete. For all more sophisticated forms of derez (done asynchrnously + /// and where object can be taken to user inventory, etc.), see SceneObjectDeRezTests. + /// [Test] public void TestDeleteSceneObject() { @@ -202,103 +205,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(retrievedPart, Is.Null); } - /// - /// Test deleting an object asynchronously - /// - [Test] - public void TestDeleteSceneObjectAsync() - { - TestHelpers.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); - - UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - - TestScene scene = new SceneHelpers().SetupScene(); - - // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. - AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; - sogd.Enabled = false; - - SceneObjectGroup so = SceneHelpers.AddSceneObject(scene); - - IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; - scene.DeRezObjects(client, new System.Collections.Generic.List() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); - - SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); - - Assert.That(retrievedPart, Is.Not.Null); - - Assert.That(so.IsDeleted, Is.False); - - sogd.InventoryDeQueueAndDelete(); - - Assert.That(so.IsDeleted, Is.True); - - SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); - Assert.That(retrievedPart2, Is.Null); - } - - /// - /// Test deleting an object asynchronously to user inventory. - /// - [Test] - public void TestDeleteSceneObjectAsyncToUserInventory() - { - TestHelpers.InMethod(); -// TestHelpers.EnableLogging(); - - UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - string myObjectName = "Fred"; - - TestScene scene = new SceneHelpers().SetupScene(); - - IConfigSource configSource = new IniConfigSource(); - IConfig config = configSource.AddConfig("Modules"); - config.Set("InventoryAccessModule", "BasicInventoryAccessModule"); - SceneHelpers.SetupSceneModules( - scene, configSource, new object[] { new BasicInventoryAccessModule() }); - - SceneHelpers.SetupSceneModules(scene, new object[] { }); - - // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. - AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; - sogd.Enabled = false; - - SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId); - - UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); - InventoryFolderBase folder1 - = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1"); - - IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; - scene.DeRezObjects(client, new List() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); - - SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); - - Assert.That(retrievedPart, Is.Not.Null); - Assert.That(so.IsDeleted, Is.False); - - sogd.InventoryDeQueueAndDelete(); - - Assert.That(so.IsDeleted, Is.True); - - SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); - Assert.That(retrievedPart2, Is.Null); - -// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); - - InventoryItemBase retrievedItem - = UserInventoryHelpers.GetInventoryItem( - scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName); - - // Check that we now have the taken part in our inventory - Assert.That(retrievedItem, Is.Not.Null); - - // Check that the taken part has actually disappeared -// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); -// Assert.That(retrievedPart, Is.Null); - } - /// /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by @@ -334,4 +240,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(sog.Parts.Length, Is.EqualTo(2)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 4f15791f10..c1522e7b61 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs @@ -33,19 +33,21 @@ using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Region.CoreModules.Framework.InventoryAccess; using OpenSim.Region.CoreModules.World.Permissions; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests { /// - /// Tests derez of scene objects by users. + /// Tests derez of scene objects. /// /// /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. - /// TODO: These tests are very incomplete - they only test for a few conditions. + /// TODO: These tests are incomplete - need to test more kinds of derez (e.g. return object). /// [TestFixture] public class SceneObjectDeRezTests : OpenSimTestCase @@ -76,14 +78,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); part.Name = "obj1"; scene.AddNewSceneObject(new SceneObjectGroup(part), false); + List localIds = new List(); localIds.Add(part.LocalId); - scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); + + // Check that object isn't deleted until we crank the sogd handle. + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); + sogd.InventoryDeQueueAndDelete(); - SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); - Assert.That(retrievedPart, Is.Null); + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); + Assert.That(retrievedPart2, Is.Null); } /// @@ -124,6 +132,67 @@ namespace OpenSim.Region.Framework.Scenes.Tests // Object should still be in the scene. SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); - } + } + + /// + /// Test deleting an object asynchronously to user inventory. + /// + [Test] + public void TestDeleteSceneObjectAsyncToUserInventory() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + string myObjectName = "Fred"; + + TestScene scene = new SceneHelpers().SetupScene(); + + IConfigSource configSource = new IniConfigSource(); + IConfig config = configSource.AddConfig("Modules"); + config.Set("InventoryAccessModule", "BasicInventoryAccessModule"); + SceneHelpers.SetupSceneModules( + scene, configSource, new object[] { new BasicInventoryAccessModule() }); + + SceneHelpers.SetupSceneModules(scene, new object[] { }); + + // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. + AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; + sogd.Enabled = false; + + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId); + + UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); + InventoryFolderBase folder1 + = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1"); + + IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; + scene.DeRezObjects(client, new List() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); + + SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); + + Assert.That(retrievedPart, Is.Not.Null); + Assert.That(so.IsDeleted, Is.False); + + sogd.InventoryDeQueueAndDelete(); + + Assert.That(so.IsDeleted, Is.True); + + SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); + Assert.That(retrievedPart2, Is.Null); + +// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); + + InventoryItemBase retrievedItem + = UserInventoryHelpers.GetInventoryItem( + scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName); + + // Check that we now have the taken part in our inventory + Assert.That(retrievedItem, Is.Not.Null); + + // Check that the taken part has actually disappeared +// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); +// Assert.That(retrievedPart, Is.Null); + } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs index 5cf62c25a5..abaa1d1d75 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs @@ -48,8 +48,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests UUID m_ownerId = TestHelpers.ParseTail(0x1); [SetUp] - public void SetUp() + public override void SetUp() { + base.SetUp(); + m_scene = new SceneHelpers().SetupScene(); }