From ba0c65e028ecd3c19a11e6e5557fb004f9dc6c01 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 00:25:51 +0100 Subject: extend npc move test to check a second movement --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- .../World/NPC/Tests/NPCModuleTests.cs | 23 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e90e7fd..54ef039 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1075,7 +1075,7 @@ namespace OpenSim.Region.Framework.Scenes SendTerseUpdateToAllClients(); } - + public void StopFlying() { ControllingClient.StopFlying(this); diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 57847f7..545819f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests scene.Update(); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); - Vector3 targetPos = new Vector3(128, 128, 40); + Vector3 targetPos = startPos + new Vector3(0, 0, 10); npcModule.MoveToTarget(npc.UUID, scene, targetPos); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); @@ -129,7 +129,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests scene.Update(); double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); - Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position"); + Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); + + // Try a second movement + startPos = npc.AbsolutePosition; + targetPos = startPos + new Vector3(10, 0, 0); + npcModule.MoveToTarget(npc.UUID, scene, targetPos); + + scene.Update(); + + // We should really check the exact figure. + Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X)); + Assert.That(npc.AbsolutePosition.X, Is.LessThan(targetPos.X)); + Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y)); + Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); + + for (int i = 0; i < 10; i++) + scene.Update(); + + distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); + Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move"); } } } \ No newline at end of file -- cgit v1.1