From eca6442bae4093019bd221e87413c74c77c4ff5d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 16 Jan 2009 21:56:13 +0000 Subject: * Rig up enough infrastructure to actually perform a successful 'standalone' teleport unit test with checks that the scene presence disappeared from sceneA and appeared in sceneB * However, I'm not convinced that the actual process in the test completely reflects reality, and a lot of stuff had to be rigged up (which should get resolved over time) --- OpenSim/Tests/Common/Mock/TestClient.cs | 79 +++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 18 deletions(-) (limited to 'OpenSim/Tests') diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 5b3b27b..6254272 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -28,6 +28,8 @@ using System; using System.Collections.Generic; using System.Net; +using System.Reflection; +using log4net; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; @@ -37,11 +39,18 @@ namespace OpenSim.Tests.Common.Mock { public class TestClient : IClientAPI { - private Scene m_scene; - + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // Mock testing variables public List sentdatapkt = new List(); public List sentpktpkt = new List(); + + // TODO: This is a really nasty (and temporary) means of telling the test client which scene to invoke setup + // methods on when a teleport is requested + public Scene TeleportTargetScene; + private TestClient TeleportSceneClient; + + private IScene m_scene; // disable warning: public events, part of the public API #pragma warning disable 67 @@ -259,7 +268,7 @@ namespace OpenSim.Tests.Common.Mock /// /// This agent's UUID /// - private UUID myID; + private UUID m_agentId; private Vector3 startPos = new Vector3(128, 128, 2); @@ -271,7 +280,7 @@ namespace OpenSim.Tests.Common.Mock public virtual UUID AgentId { - get { return myID; } + get { return m_agentId; } } public UUID SessionId @@ -359,11 +368,14 @@ namespace OpenSim.Tests.Common.Mock /// Constructor /// /// - public TestClient(AgentCircuitData agentData) + /// + public TestClient(AgentCircuitData agentData, IScene scene) { - myID = agentData.AgentID; + m_agentId = agentData.AgentID; m_firstName = agentData.firstname; m_lastName = agentData.lastname; + m_circuitCode = agentData.circuitcode; + m_scene = scene; } /// @@ -376,6 +388,11 @@ namespace OpenSim.Tests.Common.Mock { OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16); } + + public void CompleteMovement() + { + OnCompleteMovementToRegion(); + } public virtual void ActivateGesture(UUID assetId, UUID gestureId) { @@ -465,14 +482,48 @@ namespace OpenSim.Tests.Common.Mock { } + public virtual AgentCircuitData RequestClientInfo() + { + AgentCircuitData agentData = new AgentCircuitData(); + agentData.AgentID = AgentId; + agentData.SessionID = UUID.Zero; + agentData.SecureSessionID = UUID.Zero; + agentData.circuitcode = m_circuitCode; + agentData.child = false; + agentData.firstname = m_firstName; + agentData.lastname = m_lastName; + agentData.CapsPath = m_scene.GetCapsPath(m_agentId); + agentData.ChildrenCapSeeds = new Dictionary(m_scene.GetChildrenSeeds(m_agentId)); + + return agentData; + } + public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { + m_log.DebugFormat("[TEST CLIENT]: Processing inform client of neighbour"); + + // In response to this message, we are going to make a teleport to the scene we've previous been told + // about by test code (this needs to be improved). + AgentCircuitData newAgent = RequestClientInfo(); + + // Stage 2: add the new client as a child agent to the scene + TeleportSceneClient = new TestClient(newAgent, TeleportTargetScene); + TeleportTargetScene.AddNewClient(TeleportSceneClient); + } + + public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, + uint locationID, uint flags, string capsURL) + { + m_log.DebugFormat("[TEST CLIENT]: Received SendRegionTeleport"); + + TeleportSceneClient.CompleteMovement(); + //TeleportTargetScene.AgentCrossing(newAgent.AgentID, new Vector3(90, 90, 90), false); } - public virtual AgentCircuitData RequestClientInfo() + public virtual void SendTeleportFailed(string reason) { - return new AgentCircuitData(); - } + m_log.DebugFormat("[TEST CLIENT]: Teleport failed with reason {0}", reason); + } public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL) @@ -487,15 +538,6 @@ namespace OpenSim.Tests.Common.Mock { } - public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, - uint locationID, uint flags, string capsURL) - { - } - - public virtual void SendTeleportFailed(string reason) - { - } - public virtual void SendTeleportLocationStart() { } @@ -788,6 +830,7 @@ namespace OpenSim.Tests.Common.Mock public void Close(bool ShutdownCircuit) { + m_scene.RemoveClient(AgentId); } public void Start() -- cgit v1.1