From 66eb537d0cedfd017fd8872fb1b60ed15d871d2b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 21:56:56 +0100 Subject: relocate AttachmentTests.cs to AttachmentsModuleTests.cs --- .../Attachments/Tests/AttachmentsModuleTests.cs | 172 +++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs new file mode 100644 index 0000000..cc810d7 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -0,0 +1,172 @@ +/* + * 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.Text; +using System.Threading; +using System.Timers; +using Timer=System.Timers.Timer; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.CoreModules.World.Serialiser; +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests +{ + /// + /// Attachment tests + /// + [TestFixture] + public class AttachmentsModuleTests + { + public Scene scene, scene2; + public UUID agent1; + public static Random random; + public ulong region1, region2; + public AgentCircuitData acd1; + public SceneObjectGroup sog1, sog2, sog3; + + [TestFixtureSetUp] + public void Init() + { + TestHelpers.InMethod(); + + scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); + scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); + + ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); + interregionComms.Initialise(new IniConfigSource()); + interregionComms.PostInitialise(); + SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); + SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); + + agent1 = UUID.Random(); + random = new Random(); + sog1 = NewSOG(UUID.Random(), scene, agent1); + sog2 = NewSOG(UUID.Random(), scene, agent1); + sog3 = NewSOG(UUID.Random(), scene, agent1); + + //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); + region1 = scene.RegionInfo.RegionHandle; + region2 = scene2.RegionInfo.RegionHandle; + + SceneHelpers.AddScenePresence(scene, agent1); + } + + [Test] + public void T030_TestAddAttachments() + { + TestHelpers.InMethod(); + + ScenePresence presence = scene.GetScenePresence(agent1); + + presence.AddAttachment(sog1); + presence.AddAttachment(sog2); + presence.AddAttachment(sog3); + + Assert.That(presence.HasAttachments(), Is.True); + Assert.That(presence.ValidateAttachments(), Is.True); + } + + [Test] + public void T031_RemoveAttachments() + { + TestHelpers.InMethod(); + + ScenePresence presence = scene.GetScenePresence(agent1); + presence.RemoveAttachment(sog1); + presence.RemoveAttachment(sog2); + presence.RemoveAttachment(sog3); + Assert.That(presence.HasAttachments(), Is.False); + } + + // I'm commenting this test because scene setup NEEDS InventoryService to + // be non-null + //[Test] + public void T032_CrossAttachments() + { + TestHelpers.InMethod(); + + ScenePresence presence = scene.GetScenePresence(agent1); + ScenePresence presence2 = scene2.GetScenePresence(agent1); + presence2.AddAttachment(sog1); + presence2.AddAttachment(sog2); + + ISharedRegionModule serialiser = new SerialiserModule(); + SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); + SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); + + Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); + + //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); + Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); + Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); + } + + private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) + { + SceneObjectPart sop = new SceneObjectPart(); + sop.Name = RandomName(); + sop.Description = RandomName(); + sop.Text = RandomName(); + sop.SitName = RandomName(); + sop.TouchName = RandomName(); + sop.UUID = uuid; + sop.Shape = PrimitiveBaseShape.Default; + sop.Shape.State = 1; + sop.OwnerID = agent; + + SceneObjectGroup sog = new SceneObjectGroup(sop); + sog.SetScene(scene); + + return sog; + } + + private static string RandomName() + { + StringBuilder name = new StringBuilder(); + int size = random.Next(5,12); + char ch; + for (int i = 0; i < size; i++) + { + ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; + name.Append(ch); + } + + return name.ToString(); + } + } +} \ No newline at end of file -- cgit v1.1 From 601257f8b6ff7ad97f62e0ab2a428912095bf6dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 21:58:52 +0100 Subject: remove setting up of second scene in attachments since it's not currently used --- .../Attachments/Tests/AttachmentsModuleTests.cs | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index cc810d7..b008499 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -52,10 +52,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - public Scene scene, scene2; + public Scene scene; public UUID agent1; public static Random random; - public ulong region1, region2; + public ulong region1; public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2, sog3; @@ -65,13 +65,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); - scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); interregionComms.Initialise(new IniConfigSource()); interregionComms.PostInitialise(); SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); - SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); agent1 = UUID.Random(); random = new Random(); @@ -81,7 +79,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); region1 = scene.RegionInfo.RegionHandle; - region2 = scene2.RegionInfo.RegionHandle; SceneHelpers.AddScenePresence(scene, agent1); } @@ -116,25 +113,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null //[Test] - public void T032_CrossAttachments() - { - TestHelpers.InMethod(); - - ScenePresence presence = scene.GetScenePresence(agent1); - ScenePresence presence2 = scene2.GetScenePresence(agent1); - presence2.AddAttachment(sog1); - presence2.AddAttachment(sog2); - - ISharedRegionModule serialiser = new SerialiserModule(); - SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); - SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); - - Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); - - //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); - Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); - Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); - } +// public void T032_CrossAttachments() +// { +// TestHelpers.InMethod(); +// +// ScenePresence presence = scene.GetScenePresence(agent1); +// ScenePresence presence2 = scene2.GetScenePresence(agent1); +// presence2.AddAttachment(sog1); +// presence2.AddAttachment(sog2); +// +// ISharedRegionModule serialiser = new SerialiserModule(); +// SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); +// SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); +// +// Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); +// +// //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); +// Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); +// Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); +// } private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) { -- cgit v1.1 From c58b32e7baf199fd2168851a1f718d5650f31423 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 22:09:13 +0100 Subject: drop number of attachments in test from 3 to 2 to reduce text complexity --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b008499..2e32377 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public static Random random; public ulong region1; public AgentCircuitData acd1; - public SceneObjectGroup sog1, sog2, sog3; + public SceneObjectGroup sog1, sog2; [TestFixtureSetUp] public void Init() @@ -75,7 +75,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); - sog3 = NewSOG(UUID.Random(), scene, agent1); //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); region1 = scene.RegionInfo.RegionHandle; @@ -92,7 +91,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests presence.AddAttachment(sog1); presence.AddAttachment(sog2); - presence.AddAttachment(sog3); Assert.That(presence.HasAttachments(), Is.True); Assert.That(presence.ValidateAttachments(), Is.True); @@ -106,7 +104,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests ScenePresence presence = scene.GetScenePresence(agent1); presence.RemoveAttachment(sog1); presence.RemoveAttachment(sog2); - presence.RemoveAttachment(sog3); Assert.That(presence.HasAttachments(), Is.False); } -- cgit v1.1 From 0bbf7c21d719de19d517417523e36bc25ac6ad70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 22:13:13 +0100 Subject: Isolate existing incomplete attachments tests rather than have them rely on each other. Much easier to debug this way. --- .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 2e32377..d182996 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -59,11 +59,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2; - [TestFixtureSetUp] + [SetUp] public void Init() { - TestHelpers.InMethod(); - scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); @@ -83,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void T030_TestAddAttachments() + public void TestAddAttachments() { TestHelpers.InMethod(); @@ -97,11 +95,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void T031_RemoveAttachments() + public void TestRemoveAttachments() { TestHelpers.InMethod(); ScenePresence presence = scene.GetScenePresence(agent1); + presence.AddAttachment(sog1); + presence.AddAttachment(sog2); presence.RemoveAttachment(sog1); presence.RemoveAttachment(sog2); Assert.That(presence.HasAttachments(), Is.False); -- cgit v1.1 From d3c10e609e2862165c3a9a4e1f436634191201d3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 22:27:52 +0100 Subject: Move some previously common code back into separate tests. Remove unused region handle from test. --- .../Attachments/Tests/AttachmentsModuleTests.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index d182996..c524090 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -55,7 +55,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public Scene scene; public UUID agent1; public static Random random; - public ulong region1; public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2; @@ -73,11 +72,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); - - //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); - region1 = scene.RegionInfo.RegionHandle; - - SceneHelpers.AddScenePresence(scene, agent1); } [Test] @@ -85,8 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { TestHelpers.InMethod(); - ScenePresence presence = scene.GetScenePresence(agent1); - + ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); presence.AddAttachment(sog1); presence.AddAttachment(sog2); @@ -99,14 +92,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { TestHelpers.InMethod(); - ScenePresence presence = scene.GetScenePresence(agent1); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); presence.AddAttachment(sog1); - presence.AddAttachment(sog2); + presence.AddAttachment(sog2); presence.RemoveAttachment(sog1); presence.RemoveAttachment(sog2); Assert.That(presence.HasAttachments(), Is.False); } +// [Test] +// public void TestRezAttachmentsOnAvatarEntrance() +// { +// ScenePresence presence = scene.GetScenePresence(agent1); +// } + // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null //[Test] -- cgit v1.1 From 57e54d84d641787d40a2b45549f6f2d373c5f2f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Aug 2011 23:05:08 +0100 Subject: Add new FireAndForgetMethod.None. This executes the callback on the same thread that made the request. Designed for use only by regression tests that rely on a predicable event ordering. --- .../Attachments/Tests/AttachmentsModuleTests.cs | 46 ++++++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index c524090..7f25864 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -37,10 +37,11 @@ using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.CoreModules.Avatar.Attachments; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -61,18 +62,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [SetUp] public void Init() { - scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); + // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. + Util.FireAndForgetMethod = FireAndForgetMethod.None; - ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); - interregionComms.Initialise(new IniConfigSource()); - interregionComms.PostInitialise(); - SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); + scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); + SceneHelpers.SetupSceneModules(scene, new AttachmentsModule()); agent1 = UUID.Random(); random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); - } + } + + [TearDown] + public void TearDown() + { + // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple + // threads. Possibly, later tests should be rewritten not to worry about such things. + Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; + } [Test] public void TestAddAttachments() @@ -100,11 +108,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(presence.HasAttachments(), Is.False); } -// [Test] -// public void TestRezAttachmentsOnAvatarEntrance() -// { -// ScenePresence presence = scene.GetScenePresence(agent1); -// } + [Test] + public void TestRezAttachmentsOnAvatarEntrance() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID spId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + + AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId); + acd.Appearance = new AvatarAppearance(); + acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); + +// Assert.That(presence.HasAttachments(), Is.True); + } // I'm commenting this test because scene setup NEEDS InventoryService to // be non-null -- cgit v1.1 From 696bd448334c89607c95385f05a53e2ab72cb984 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 00:37:33 +0100 Subject: Add new regression TestRezAttachmentsOnAvatarEntrance() to do simple attachments check --- .../Attachments/Tests/AttachmentsModuleTests.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 7f25864..8c79ab4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -38,6 +38,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.CoreModules.Avatar.Attachments; +using OpenSim.Region.CoreModules.Framework.InventoryAccess; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.Framework.Scenes; @@ -65,8 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. Util.FireAndForgetMethod = FireAndForgetMethod.None; - scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); - SceneHelpers.SetupSceneModules(scene, new AttachmentsModule()); + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); + + scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); agent1 = UUID.Random(); random = new Random(); @@ -114,16 +119,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID spId = TestHelpers.ParseTail(0x1); + UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); - AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId); + UserAccountHelpers.CreateUserWithInventory(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, "att", attItemId, attAssetId, userId, InventoryType.Object); + + AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); acd.Appearance = new AvatarAppearance(); - acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId); + acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); -// Assert.That(presence.HasAttachments(), Is.True); + Assert.That(presence.HasAttachments(), Is.True); } // I'm commenting this test because scene setup NEEDS InventoryService to -- cgit v1.1 From bd5d35ee323df9b15d5303c2dcad7e29a4f3e0eb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 00:42:58 +0100 Subject: extend test to check that there is one attachment and that it has the right name --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8c79ab4..5bac4c6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -122,11 +122,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; UserAccountHelpers.CreateUserWithInventory(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, "att", attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); acd.Appearance = new AvatarAppearance(); @@ -134,6 +135,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); Assert.That(presence.HasAttachments(), Is.True); + List attachments = presence.Attachments; + + Assert.That(attachments.Count, Is.EqualTo(1)); + Assert.That(attachments[0].Name, Is.EqualTo(attName)); } // I'm commenting this test because scene setup NEEDS InventoryService to -- cgit v1.1