diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index d585a07b4c..1e56bb70a9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1909,8 +1909,19 @@ namespace OpenSim.Region.Framework.Scenes } } - public virtual void DeRezObjects(IClientAPI remoteClient, List localIDs, - UUID groupID, DeRezAction action, UUID destinationID) + /// + /// Derez one or more objects from the scene. + /// + /// + /// Won't actually remove the scene object in the case where the object is being copied to a user inventory. + /// + /// Client requesting derez + /// Local ids of root parts of objects to delete. + /// Not currently used. Here because the client passes this to us. + /// DeRezAction + /// User folder ID to place derezzed object + public virtual void DeRezObjects( + IClientAPI remoteClient, List localIDs, UUID groupID, DeRezAction action, UUID destinationID) { // First, see of we can perform the requested action and // build a list of eligible objects diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 3398a53fb8..5b334c6564 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Reflection; using System.Threading; using NUnit.Framework; @@ -33,6 +34,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -42,7 +44,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Basic scene object tests (create, read and delete but not update). /// [TestFixture] - public class SceneObjectBasicTests + public class SceneObjectBasicTests : OpenSimTestCase { // [TearDown] // public void TearDown() @@ -237,38 +239,60 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// /// Test deleting an object asynchronously to user inventory. /// - //[Test] - //public void TestDeleteSceneObjectAsyncToUserInventory() - //{ - // TestHelper.InMethod(); - // //log4net.Config.XmlConfigurator.Configure(); - - // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); - // string myObjectName = "Fred"; - - // TestScene scene = SceneSetupHelpers.SetupScene(); - // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName); - - // Assert.That( - // scene.CommsManager.UserAdminService.AddUser( - // "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), - // Is.EqualTo(agentId)); - - // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); - - // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId); - // Assert.That(userInfo, Is.Not.Null); - // Assert.That(userInfo.RootFolder, Is.Not.Null); - - // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); - - // // Check that we now have the taken part in our inventory - // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name)); - - // // Check that the taken part has actually disappeared - // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); - // Assert.That(retrievedPart, Is.Null); - //} +// [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(); + + // 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); + +// Assert.That( +// scene.CommsManager.UserAdminService.AddUser( +// "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), +// Is.EqualTo(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