From a82aea53f863566037fa4fe3d546f57a49a126fa Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 3 Dec 2011 19:32:59 +0000 Subject: [PATCH] Split up test SceneHelpers to provide an AddChildScenePresence() call --- .../Scenes/Tests/ScenePresenceAgentTests.cs | 1 + OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 35 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 946481c7ea..d4c299f996 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs @@ -166,6 +166,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests /// /// /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields. + /// INCOMPLETE /// [Test] public void TestChildAgentEstablishedInNeighbour() diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index e4640be04b..a25eb66751 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -396,27 +396,42 @@ namespace OpenSim.Tests.Common /// public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) { - string reason; - // We emulate the proper login sequence here by doing things in four stages - // Stage 0: log the presence + // Stage 0: login scene.PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); - // Stage 1: simulate login by telling the scene to expect a new user connection - if (!scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) + // Stages 1 & 2 + ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); + + // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. + sp.CompleteMovement(sp.ControllingClient, true); + + return sp; + } + + private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) + { + string reason; + + // Stage 1: tell the scene to expect a new user connection + if (!scene.NewUserConnection(agentData, (uint)tf, out reason)) Console.WriteLine("NewUserConnection failed: " + reason); // Stage 2: add the new client as a child agent to the scene TestClient client = new TestClient(agentData, scene); scene.AddNewClient(client, PresenceType.User); - // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. - ScenePresence scp = scene.GetScenePresence(agentData.AgentID); - scp.CompleteMovement(client, true); - //scp.MakeRootAgent(new Vector3(90, 90, 90), true); + return scene.GetScenePresence(agentData.AgentID); + } - return scp; + public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) + { + AgentCircuitData acd = GenerateAgentData(agentId); + acd.child = true; + + // XXX: ViaLogin may not be correct for child agents + return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); } ///