From 85e07c78fbed9e85c142c0f565c27015ad95769d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 6 Aug 2011 02:17:41 +0100 Subject: [PATCH] refactor: Change SceneHelpers.AddClient() to AddScenePresence(). This seems to make more sense as we can get SP.ControllingClient --- .../Tests/AvatarFactoryModuleTests.cs | 2 +- .../Framework/Scenes/Tests/AttachmentTests.cs | 2 +- .../Scenes/Tests/SceneObjectBasicTests.cs | 2 +- .../Scenes/Tests/SceneObjectDeRezTests.cs | 4 +- .../Scenes/Tests/SceneObjectUserGroupTests.cs | 2 +- .../Scenes/Tests/ScenePresenceAgentTests.cs | 72 +++++++++++-------- .../Tests/ScenePresenceTeleportTests.cs | 2 +- .../World/NPC/Tests/NPCModuleTests.cs | 4 +- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 8 +-- 9 files changed, 54 insertions(+), 44 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 4e83fa7799..1bd3b6e5e9 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, afm); - TestClient tc = SceneHelpers.AddClient(scene, userId); + IClientAPI tc = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; for (byte i = 0; i < visualParams.Length; i++) diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs index fb28397f1e..07b30f40c0 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests region1 = scene.RegionInfo.RegionHandle; region2 = scene2.RegionInfo.RegionHandle; - SceneHelpers.AddClient(scene, agent1); + SceneHelpers.AddScenePresence(scene, agent1); } [Test] diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index ff55680c6c..1ea2329b36 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs @@ -139,7 +139,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests SceneObjectPart part = SceneHelpers.AddSceneObject(scene); - IClientAPI client = SceneHelpers.AddClient(scene, agentId); + IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; scene.DeRezObjects(client, new System.Collections.Generic.List() { part.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index c8a9ca3b15..654b1a2cc6 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests IConfig config = configSource.AddConfig("Startup"); config.Set("serverside_object_permissions", true); SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() }); - TestClient client = SceneHelpers.AddClient(scene, userId); + IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; @@ -105,7 +105,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests IConfig config = configSource.AddConfig("Startup"); config.Set("serverside_object_permissions", true); SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() }); - TestClient client = SceneHelpers.AddClient(scene, userId); + IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index e604885546..c13d82e16d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs @@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests new GroupsModule(), new MockGroupsServicesConnector() }); - TestClient client = SceneHelpers.AddClient(scene, userId); + IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; IGroupsModule groupsModule = scene.RequestModuleInterface(); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 04f58174ba..73acf2821e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -93,6 +93,47 @@ namespace OpenSim.Region.Framework.Scenes.Tests region3 = scene3.RegionInfo.RegionHandle; } +// [Test] +// public void TestLogout() +// { +// TestHelpers.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); +// +// TestScene scene = SceneHelpers.SetupScene(); +// SceneHelpers. +// } + + /// + /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region + /// + /// + /// Please note that unlike the other tests here, this doesn't rely on structures + /// + [Test] + public void TestChildAgentEstablished() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); + + TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); +// TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); + + IConfigSource configSource = new IniConfigSource(); + configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); + EntityTransferModule etm = new EntityTransferModule(); + + SceneHelpers.SetupSceneModules(myScene1, configSource, etm); + + SceneHelpers.AddScenePresence(myScene1, agent1Id); +// ScenePresence childPresence = myScene2.GetScenePresence(agent1); + + // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents +// Assert.That(childPresence, Is.Not.Null); +// Assert.That(childPresence.IsChildAgent, Is.True); + } + /// /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene. /// @@ -190,37 +231,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests CompleteAvatarMovement */ } - - /// - /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region - /// - /// - /// Please note that unlike the other tests here, this doesn't rely on structures - /// - [Test] - public void TestChildAgentEstablished() - { - TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); - - TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); - TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); - - IConfigSource configSource = new IniConfigSource(); - configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); - EntityTransferModule etm = new EntityTransferModule(); - - SceneHelpers.SetupSceneModules(myScene1, configSource, etm); - - SceneHelpers.AddClient(myScene1, agent1Id); - ScenePresence childPresence = myScene2.GetScenePresence(agent1); - - // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents -// Assert.That(childPresence, Is.Not.Null); -// Assert.That(childPresence.IsChildAgent, Is.True); - } // I'm commenting this test because it does not represent // crossings. The Thread.Sleep's in here are not meaningful mocks, diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 4765a861b9..39bb43a628 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs @@ -125,7 +125,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests sceneA.RegisterRegionWithGrid(); UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); - TestClient client = SceneHelpers.AddClient(sceneA, agentId); + TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient; ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface(); diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 28fa8a20e4..a0260a5bd3 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); - TestClient originalClient = SceneHelpers.AddClient(scene, TestHelpers.ParseTail(0x1)); + IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); // 8 is the index of the first baked texture in AvatarAppearance @@ -96,7 +96,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); - TestClient originalClient = SceneHelpers.AddClient(scene, TestHelpers.ParseTail(0x1)); + IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); Vector3 startPos = new Vector3(128, 128, 30); diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 55b638b3bf..070e390b63 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -341,9 +341,9 @@ namespace OpenSim.Tests.Common /// /// /// - public static TestClient AddClient(Scene scene, UUID agentId) + public static ScenePresence AddScenePresence(Scene scene, UUID agentId) { - return AddClient(scene, GenerateAgentData(agentId)); + return AddScenePresence(scene, GenerateAgentData(agentId)); } /// @@ -364,7 +364,7 @@ namespace OpenSim.Tests.Common /// /// /// - public static TestClient AddClient(Scene scene, AgentCircuitData agentData) + public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) { string reason; @@ -386,7 +386,7 @@ namespace OpenSim.Tests.Common scp.CompleteMovement(client); //scp.MakeRootAgent(new Vector3(90, 90, 90), true); - return client; + return scp; } ///