From 6adaf1be74436395b03519f6105454a5afcd8004 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 11 Nov 2011 23:36:35 +0000 Subject: extract common ScenePresence setup code into Init() method for ScenePresenceSitTests --- .../Scenes/Tests/ScenePresenceSitTests.cs | 70 ++++++++++------------ 1 file changed, 31 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index fa308b4..b7b8db4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs @@ -45,11 +45,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests public class ScenePresenceSitTests { private TestScene m_scene; + private ScenePresence m_sp; [SetUp] public void Init() { m_scene = SceneHelpers.SetupScene(); + m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); } [Test] @@ -58,18 +60,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - // More than 10 meters away from 0, 0, 0 (default part position) Vector3 startPos = new Vector3(10.1f, 0, 0); - sp.AbsolutePosition = startPos; + m_sp.AbsolutePosition = startPos; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); - sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); + m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); - Assert.That(sp.ParentID, Is.EqualTo(0)); + Assert.That(m_sp.ParentID, Is.EqualTo(0)); } [Test] @@ -78,18 +78,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - // Less than 10 meters away from 0, 0, 0 (default part position) Vector3 startPos = new Vector3(9.9f, 0, 0); - sp.AbsolutePosition = startPos; + m_sp.AbsolutePosition = startPos; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); - sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); + m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); - Assert.That(sp.ParentID, Is.EqualTo(part.LocalId)); + Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); } [Test] @@ -98,33 +96,31 @@ namespace OpenSim.Region.Framework.Scenes.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - // Make sure we're within range to sit Vector3 startPos = new Vector3(1, 1, 1); - sp.AbsolutePosition = startPos; + m_sp.AbsolutePosition = startPos; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); - sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); + m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); - Assert.That(sp.ParentID, Is.EqualTo(part.LocalId)); - Assert.That(sp.PhysicsActor, Is.Null); + Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); + Assert.That(m_sp.PhysicsActor, Is.Null); // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the // default avatar. // Curiously, Vector3.ToString() will not display the last two places of the float. For example, // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> Assert.That( - sp.AbsolutePosition, + m_sp.AbsolutePosition, Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); - sp.StandUp(); + m_sp.StandUp(); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); - Assert.That(sp.ParentID, Is.EqualTo(0)); - Assert.That(sp.PhysicsActor, Is.Not.Null); + Assert.That(m_sp.ParentID, Is.EqualTo(0)); + Assert.That(m_sp.PhysicsActor, Is.Not.Null); } [Test] @@ -133,29 +129,27 @@ namespace OpenSim.Region.Framework.Scenes.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - // If a prim has a sit target then we can sit from any distance away Vector3 startPos = new Vector3(128, 128, 30); - sp.AbsolutePosition = startPos; + m_sp.AbsolutePosition = startPos; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); part.SitTargetPosition = new Vector3(0, 0, 1); - sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); + m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); - Assert.That(part.SitTargetAvatar, Is.EqualTo(sp.UUID)); - Assert.That(sp.ParentID, Is.EqualTo(part.LocalId)); + Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); + Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); Assert.That( - sp.AbsolutePosition, + m_sp.AbsolutePosition, Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); - Assert.That(sp.PhysicsActor, Is.Null); + Assert.That(m_sp.PhysicsActor, Is.Null); - sp.StandUp(); + m_sp.StandUp(); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); - Assert.That(sp.ParentID, Is.EqualTo(0)); - Assert.That(sp.PhysicsActor, Is.Not.Null); + Assert.That(m_sp.ParentID, Is.EqualTo(0)); + Assert.That(m_sp.PhysicsActor, Is.Not.Null); } [Test] @@ -164,21 +158,19 @@ namespace OpenSim.Region.Framework.Scenes.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); - // If a prim has a sit target then we can sit from any distance away // Vector3 startPos = new Vector3(128, 128, 30); // sp.AbsolutePosition = startPos; - sp.HandleAgentSitOnGround(); + m_sp.HandleAgentSitOnGround(); - Assert.That(sp.SitGround, Is.True); - Assert.That(sp.PhysicsActor, Is.Null); + Assert.That(m_sp.SitGround, Is.True); + Assert.That(m_sp.PhysicsActor, Is.Null); - sp.StandUp(); + m_sp.StandUp(); - Assert.That(sp.SitGround, Is.False); - Assert.That(sp.PhysicsActor, Is.Not.Null); + Assert.That(m_sp.SitGround, Is.False); + Assert.That(m_sp.PhysicsActor, Is.Not.Null); } } } \ No newline at end of file -- cgit v1.1