From 4919c6056022053f8632b030a06fd8f48ac02a8e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 3 Dec 2011 18:59:54 +0000
Subject: Add beginning of
 ScenePresenceAgentTests.TestCreateChildScenePresence()

This required an option to be added to NullRegionData via ConnectionString for it to act as a non-static instance, so that regression tests (which only load this class once) don't get hopeless confused and complex to compensate.
Normal standalone operation unaffected.
---
 OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'OpenSim/Tests')

diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index d358ae8..e4640be 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -49,6 +49,7 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
 using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
 using OpenSim.Services.Interfaces;
 using OpenSim.Tests.Common.Mock;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
 
 namespace OpenSim.Tests.Common
 {
@@ -139,6 +140,7 @@ namespace OpenSim.Tests.Common
 
             testScene.RegionInfo.EstateSettings = new EstateSettings();
             testScene.LoginsDisabled = false;
+            testScene.RegisterRegionWithGrid();
 
             return testScene;
         }
@@ -222,6 +224,7 @@ namespace OpenSim.Tests.Common
             config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
             config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
             config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
+            config.Configs["GridService"].Set("ConnectionString", "!static");
 
             LocalGridServicesConnector gridService = new LocalGridServicesConnector();
             gridService.Initialise(config);
-- 
cgit v1.1


From a82aea53f863566037fa4fe3d546f57a49a126fa Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 3 Dec 2011 19:32:59 +0000
Subject: Split up test SceneHelpers to provide an AddChildScenePresence() call

---
 OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 35 ++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 10 deletions(-)

(limited to 'OpenSim/Tests')

diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index e4640be..a25eb66 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -396,27 +396,42 @@ namespace OpenSim.Tests.Common
         /// <returns></returns>
         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);
+        }
+
+        public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId)
+        {
+            AgentCircuitData acd = GenerateAgentData(agentId);
+            acd.child = true;
 
-            return scp;
+            // XXX: ViaLogin may not be correct for child agents
+            return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin);
         }
 
         /// <summary>
-- 
cgit v1.1