From 049987925d6293bd5a7367e86c1256febe60a229 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 Nov 2012 02:05:30 +0000 Subject: Add regression test for checking scene close when SceneManager is asked to close --- .../Framework/Scenes/Tests/SceneManagerTests.cs | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs (limited to 'OpenSim/Region/Framework/Scenes/Tests') diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs new file mode 100644 index 0000000..ab56f4e --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using NUnit.Framework; +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; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + [TestFixture] + public class SceneManagerTests + { + [Test] + public void TestClose() + { + TestHelpers.InMethod(); + + SceneHelpers sh = new SceneHelpers(); + Scene scene = sh.SetupScene(); + + sh.SceneManager.Close(); + Assert.That(scene.ShuttingDown, Is.True); + } + } +} \ No newline at end of file -- cgit v1.1 From 22d4c52ffc374e167cb674e0e20815615d8a6927 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 Nov 2012 03:15:24 +0000 Subject: Consistenly make NUnit test cases inherit from OpenSimTestCase which automatically turns off any logging enabled between tests --- OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 2 +- OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Tests') diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index 4a21dc9..e209221 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs @@ -37,7 +37,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class BorderTests + public class BorderTests : OpenSimTestCase { [Test] public void TestCross() diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index ea9fc93..766ce83 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs @@ -41,7 +41,7 @@ using OpenSim.Tests.Common; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture, LongRunning] - public class EntityManagerTests + public class EntityManagerTests : OpenSimTestCase { static public Random random; SceneObjectGroup found; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index d23c965..575a081 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs @@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class SceneGraphTests + public class SceneGraphTests : OpenSimTestCase { [Test] public void TestDuplicateObject() diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs index ab56f4e..2d831fa 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs @@ -41,7 +41,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class SceneManagerTests + public class SceneManagerTests : OpenSimTestCase { [Test] public void TestClose() diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 0076f41..4f15791 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// TODO: These tests are very incomplete - they only test for a few conditions. /// [TestFixture] - public class SceneObjectDeRezTests + public class SceneObjectDeRezTests : OpenSimTestCase { /// /// Test deleting an object from a scene. diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index 0e525c9..9378e20 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs @@ -40,7 +40,7 @@ using log4net; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class SceneObjectLinkingTests + public class SceneObjectLinkingTests : OpenSimTestCase { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 89647d6..c264433 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Basic scene object resize tests /// [TestFixture] - public class SceneObjectResizeTests + public class SceneObjectResizeTests : OpenSimTestCase { /// /// Test resizing an object diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs index d2361f8..a58e735 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs @@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class SceneObjectScriptTests + public class SceneObjectScriptTests : OpenSimTestCase { [Test] public void TestAddScript() diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs index 6d255aa..5cf62c2 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) /// [TestFixture] - public class SceneObjectSpatialTests + public class SceneObjectSpatialTests : OpenSimTestCase { TestScene m_scene; UUID m_ownerId = TestHelpers.ParseTail(0x1); diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 742c769..093cbd2 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Basic scene object status tests /// [TestFixture] - public class SceneObjectStatusTests + public class SceneObjectStatusTests : OpenSimTestCase { private TestScene m_scene; private UUID m_ownerId = TestHelpers.ParseTail(0x1); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs index 646e5fa..1cd8ae9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Scene presence animation tests /// [TestFixture] - public class ScenePresenceAnimationTests + public class ScenePresenceAnimationTests : OpenSimTestCase { [Test] public void TestFlyingAnimation() diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs index 1d1ff88..d80afd3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs @@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class ScenePresenceAutopilotTests + public class ScenePresenceAutopilotTests : OpenSimTestCase { private TestScene m_scene; diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index 493ab70..acaeb90 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs @@ -43,7 +43,7 @@ using System.Threading; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class ScenePresenceSitTests + public class ScenePresenceSitTests : OpenSimTestCase { private TestScene m_scene; private ScenePresence m_sp; diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 37b5184..8dd1f3d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Teleport tests in a standalone OpenSim /// [TestFixture] - public class ScenePresenceTeleportTests + public class ScenePresenceTeleportTests : OpenSimTestCase { [TestFixtureSetUp] public void FixtureInit() diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index ac3da1e..9d8eb0b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// Scene presence tests /// [TestFixture] - public class SceneTests + public class SceneTests : OpenSimTestCase { /// /// Very basic scene update test. Should become more elaborate with time. diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index a51e4e3..0b461f5 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs @@ -50,7 +50,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Tests { [TestFixture] - public class TaskInventoryTests + public class TaskInventoryTests : OpenSimTestCase { [Test] public void TestAddTaskInventoryItem() diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 198e487..dd27294 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -38,7 +38,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests { [TestFixture] - public class UuidGathererTests + public class UuidGathererTests : OpenSimTestCase { protected IAssetService m_assetService; protected UuidGatherer m_uuidGatherer; -- cgit v1.1 From a4ce63d0cd5dacdd33c6563bbc1af29ef5d36755 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 Nov 2012 03:38:15 +0000 Subject: Fix regression TestDeleteSceneObjectAsyncToUserInventory by adding a BasicInventoryAccessModule() and re-enable in test suite. --- .../Framework/Scenes/Tests/SceneObjectBasicTests.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 5b334c6..373094b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -29,10 +29,12 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Threading; +using Nini.Config; 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; @@ -239,28 +241,31 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// /// Test deleting an object asynchronously to user inventory. /// -// [Test] + [Test] public void TestDeleteSceneObjectAsyncToUserInventory() { TestHelpers.InMethod(); - TestHelpers.EnableLogging(); +// 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); -// 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"); -- cgit v1.1 From 02db8b9adbfd69d117bc54288473f5240de46918 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 Nov 2012 03:49:23 +0000 Subject: Combine TestDeleteSceneObjectAsync() with TestDeRezSceneObject() as they are functionally identical. Move TestDeleteSceneObjectAsync() and TestDeleteSceneObjectAsyncToUserInventory() from SceneObjectBasicTests -> SceneObjectDeRezTests --- .../Scenes/Tests/SceneObjectBasicTests.cs | 104 +-------------------- .../Scenes/Tests/SceneObjectDeRezTests.cs | 81 ++++++++++++++-- .../Scenes/Tests/SceneObjectSpatialTests.cs | 4 +- 3 files changed, 83 insertions(+), 106 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 373094b..a07d64c 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() { @@ -203,103 +206,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests } /// - /// 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 /// OpenSim. @@ -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 4f15791..c1522e7 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 5cf62c2..abaa1d1 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(); } -- cgit v1.1