extract common ScenePresence setup code into Init() method for ScenePresenceSitTests
parent
84ad23234b
commit
6adaf1be74
|
@ -45,11 +45,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
public class ScenePresenceSitTests
|
public class ScenePresenceSitTests
|
||||||
{
|
{
|
||||||
private TestScene m_scene;
|
private TestScene m_scene;
|
||||||
|
private ScenePresence m_sp;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
m_scene = SceneHelpers.SetupScene();
|
m_scene = SceneHelpers.SetupScene();
|
||||||
|
m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -58,18 +60,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// 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)
|
// More than 10 meters away from 0, 0, 0 (default part position)
|
||||||
Vector3 startPos = new Vector3(10.1f, 0, 0);
|
Vector3 startPos = new Vector3(10.1f, 0, 0);
|
||||||
sp.AbsolutePosition = startPos;
|
m_sp.AbsolutePosition = startPos;
|
||||||
|
|
||||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
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(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
|
||||||
Assert.That(sp.ParentID, Is.EqualTo(0));
|
Assert.That(m_sp.ParentID, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -78,18 +78,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// 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)
|
// Less than 10 meters away from 0, 0, 0 (default part position)
|
||||||
Vector3 startPos = new Vector3(9.9f, 0, 0);
|
Vector3 startPos = new Vector3(9.9f, 0, 0);
|
||||||
sp.AbsolutePosition = startPos;
|
m_sp.AbsolutePosition = startPos;
|
||||||
|
|
||||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
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(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
|
||||||
Assert.That(sp.ParentID, Is.EqualTo(part.LocalId));
|
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -98,33 +96,31 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
|
|
||||||
|
|
||||||
// Make sure we're within range to sit
|
// Make sure we're within range to sit
|
||||||
Vector3 startPos = new Vector3(1, 1, 1);
|
Vector3 startPos = new Vector3(1, 1, 1);
|
||||||
sp.AbsolutePosition = startPos;
|
m_sp.AbsolutePosition = startPos;
|
||||||
|
|
||||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
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(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
|
||||||
Assert.That(sp.ParentID, Is.EqualTo(part.LocalId));
|
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
|
||||||
Assert.That(sp.PhysicsActor, Is.Null);
|
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
|
// FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
|
||||||
// default avatar.
|
// default avatar.
|
||||||
// Curiously, Vector3.ToString() will not display the last two places of the float. For example,
|
// 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>
|
// printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337>
|
||||||
Assert.That(
|
Assert.That(
|
||||||
sp.AbsolutePosition,
|
m_sp.AbsolutePosition,
|
||||||
Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f)));
|
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(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
|
||||||
Assert.That(sp.ParentID, Is.EqualTo(0));
|
Assert.That(m_sp.ParentID, Is.EqualTo(0));
|
||||||
Assert.That(sp.PhysicsActor, Is.Not.Null);
|
Assert.That(m_sp.PhysicsActor, Is.Not.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -133,29 +129,27 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// 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
|
// If a prim has a sit target then we can sit from any distance away
|
||||||
Vector3 startPos = new Vector3(128, 128, 30);
|
Vector3 startPos = new Vector3(128, 128, 30);
|
||||||
sp.AbsolutePosition = startPos;
|
m_sp.AbsolutePosition = startPos;
|
||||||
|
|
||||||
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
|
||||||
part.SitTargetPosition = new Vector3(0, 0, 1);
|
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(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID));
|
||||||
Assert.That(sp.ParentID, Is.EqualTo(part.LocalId));
|
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
|
||||||
Assert.That(
|
Assert.That(
|
||||||
sp.AbsolutePosition,
|
m_sp.AbsolutePosition,
|
||||||
Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
|
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(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
|
||||||
Assert.That(sp.ParentID, Is.EqualTo(0));
|
Assert.That(m_sp.ParentID, Is.EqualTo(0));
|
||||||
Assert.That(sp.PhysicsActor, Is.Not.Null);
|
Assert.That(m_sp.PhysicsActor, Is.Not.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -164,21 +158,19 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// 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
|
// If a prim has a sit target then we can sit from any distance away
|
||||||
// Vector3 startPos = new Vector3(128, 128, 30);
|
// Vector3 startPos = new Vector3(128, 128, 30);
|
||||||
// sp.AbsolutePosition = startPos;
|
// sp.AbsolutePosition = startPos;
|
||||||
|
|
||||||
sp.HandleAgentSitOnGround();
|
m_sp.HandleAgentSitOnGround();
|
||||||
|
|
||||||
Assert.That(sp.SitGround, Is.True);
|
Assert.That(m_sp.SitGround, Is.True);
|
||||||
Assert.That(sp.PhysicsActor, Is.Null);
|
Assert.That(m_sp.PhysicsActor, Is.Null);
|
||||||
|
|
||||||
sp.StandUp();
|
m_sp.StandUp();
|
||||||
|
|
||||||
Assert.That(sp.SitGround, Is.False);
|
Assert.That(m_sp.SitGround, Is.False);
|
||||||
Assert.That(sp.PhysicsActor, Is.Not.Null);
|
Assert.That(m_sp.PhysicsActor, Is.Not.Null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue