From c94240ba5b0f3ca77abc42245b3f2c6d0af9a138 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 10 Nov 2012 05:43:57 +0000 Subject: Uncomment SceneObjectBasicTests.TestDeleteSceneObjectAsyncToUserInventory() and make it compile again Not currently in test suite since not yet working. Also add method doc to Scene.DeRezObjects() --- .../Scenes/Tests/SceneObjectBasicTests.cs | 90 ++++++++++++++-------- 1 file changed, 57 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Tests') diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 3398a53..5b334c6 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 -- cgit v1.1