From de88227bc486788197b3a7c842c8b60f82b0a29b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:29:27 +0000 Subject: refactor: simplify part of AddSceneObject() test setup by moving sog construction into SceneSetupHelpers.CreateSceneObject() --- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'OpenSim/Tests/Common') diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index aa4b285..b7b7383 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -465,5 +465,37 @@ namespace OpenSim.Tests.Common.Setup return part; } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// + /// UUID always starts at 00000000-0000-0000-0000-000000000001 + /// + /// The number of parts that should be in the scene object + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) + { + SceneObjectPart rootPart + = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = "part1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; + SceneObjectGroup sog = new SceneObjectGroup(rootPart); + + if (parts > 1) + { + for (int i = 2; i <= parts; i++) + { + sog.AddPart( + new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { + Name = string.Format("obj{0}", i), + UUID = new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)) + }); + } + } + + return sog; + } } } -- cgit v1.1 From d5c7ae5c6b55ae794f630ae55a100b19eef2362c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:40:23 +0000 Subject: refactor common sop setup parts into a single method --- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 40 ++++++++++++++----------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'OpenSim/Tests/Common') diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index b7b7383..87b6389 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -454,9 +454,7 @@ namespace OpenSim.Tests.Common.Setup /// public static SceneObjectPart AddSceneObject(Scene scene, string name) { - SceneObjectPart part - = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); - part.Name = name; + SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero); //part.UpdatePrimFlags(false, false, true); //part.ObjectFlags |= (uint)PrimFlags.Phantom; @@ -467,6 +465,20 @@ namespace OpenSim.Tests.Common.Setup } /// + /// Create a scene object part. + /// + /// + /// + /// + /// + public static SceneObjectPart CreateSceneObjectPart(string name, UUID id, UUID ownerId) + { + return new SceneObjectPart( + ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) + { Name = name, UUID = id }; + } + + /// /// Create a scene object but do not add it to the scene. /// /// @@ -477,25 +489,19 @@ namespace OpenSim.Tests.Common.Setup /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) { - SceneObjectPart rootPart - = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { Name = "part1", UUID = new UUID("00000000-0000-0000-0000-000000000001") }; - SceneObjectGroup sog = new SceneObjectGroup(rootPart); + SceneObjectGroup sog + = new SceneObjectGroup( + CreateSceneObjectPart("part1", new UUID("00000000-0000-0000-0000-000000000001"), ownerId)); if (parts > 1) - { for (int i = 2; i <= parts; i++) - { sog.AddPart( - new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) - { - Name = string.Format("obj{0}", i), - UUID = new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)) - }); - } - } + CreateSceneObjectPart( + string.Format("obj{0}", i), + new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)), + ownerId)); return sog; } } -} +} \ No newline at end of file -- cgit v1.1 From ebbe3afaf15fa07f4a8d1c2db8795065b852ec8d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 23:14:55 +0000 Subject: Add PrimCountModuleTests.TestRemoveOwnerObject(). Also adds SceneSetupHelpers methods to easily create sogs with different part UUIDs --- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 27 ++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'OpenSim/Tests/Common') diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index 87b6389..57850c1 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -488,20 +488,37 @@ namespace OpenSim.Tests.Common.Setup /// /// public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) - { + { + return CreateSceneObject(parts, ownerId, 0x1); + } + + /// + /// Create a scene object but do not add it to the scene. + /// + /// The number of parts that should be in the scene object + /// + /// + /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" + /// will be given to the root part, and incremented for each part thereafter. + /// + /// + public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) + { + string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); + SceneObjectGroup sog = new SceneObjectGroup( - CreateSceneObjectPart("part1", new UUID("00000000-0000-0000-0000-000000000001"), ownerId)); + CreateSceneObjectPart("part0", new UUID(rawSogId), ownerId)); if (parts > 1) - for (int i = 2; i <= parts; i++) + for (int i = 1; i < parts; i++) sog.AddPart( CreateSceneObjectPart( string.Format("obj{0}", i), - new UUID(string.Format("00000000-0000-0000-0000-{0:D12}", i)), + new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), ownerId)); return sog; - } + } } } \ No newline at end of file -- cgit v1.1