diff options
author | Justin Clark-Casey (justincc) | 2014-04-29 19:29:16 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-04-29 19:29:16 +0100 |
commit | 2dbc18054e354a17519f84c0b3294094fae3b5b2 (patch) | |
tree | 83cc0d4f25e711464fad07ae28da56dfe278c498 /OpenSim/Region/OptionalModules | |
parent | Improved HTTP logging (diff) | |
download | opensim-SC_OLD-2dbc18054e354a17519f84c0b3294094fae3b5b2.zip opensim-SC_OLD-2dbc18054e354a17519f84c0b3294094fae3b5b2.tar.gz opensim-SC_OLD-2dbc18054e354a17519f84c0b3294094fae3b5b2.tar.bz2 opensim-SC_OLD-2dbc18054e354a17519f84c0b3294094fae3b5b2.tar.xz |
Add regression test for NPC movement on a variable region.
Extends basic physics to allow av movement on a varregion (basic physics is only really useful for regression test purposes).
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index c65794e..ddd4525 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -71,11 +71,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
71 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 71 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
72 | } | 72 | } |
73 | 73 | ||
74 | [SetUp] | 74 | public void SetUpScene() |
75 | public void Init() | ||
76 | { | 75 | { |
77 | base.SetUp(); | 76 | SetUpScene(256, 256); |
77 | } | ||
78 | 78 | ||
79 | public void SetUpScene(uint sizeX, uint sizeY) | ||
80 | { | ||
79 | IConfigSource config = new IniConfigSource(); | 81 | IConfigSource config = new IniConfigSource(); |
80 | config.AddConfig("NPC"); | 82 | config.AddConfig("NPC"); |
81 | config.Configs["NPC"].Set("Enabled", "true"); | 83 | config.Configs["NPC"].Set("Enabled", "true"); |
@@ -87,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
87 | m_attMod = new AttachmentsModule(); | 89 | m_attMod = new AttachmentsModule(); |
88 | m_npcMod = new NPCModule(); | 90 | m_npcMod = new NPCModule(); |
89 | 91 | ||
90 | m_scene = new SceneHelpers().SetupScene(); | 92 | m_scene = new SceneHelpers().SetupScene("test scene", UUID.Random(), 1000, 1000, sizeX, sizeY, config); |
91 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); | 93 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); |
92 | } | 94 | } |
93 | 95 | ||
@@ -97,6 +99,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
97 | TestHelpers.InMethod(); | 99 | TestHelpers.InMethod(); |
98 | // log4net.Config.XmlConfigurator.Configure(); | 100 | // log4net.Config.XmlConfigurator.Configure(); |
99 | 101 | ||
102 | SetUpScene(); | ||
103 | |||
100 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 104 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
101 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 105 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
102 | 106 | ||
@@ -133,6 +137,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
133 | TestHelpers.InMethod(); | 137 | TestHelpers.InMethod(); |
134 | // log4net.Config.XmlConfigurator.Configure(); | 138 | // log4net.Config.XmlConfigurator.Configure(); |
135 | 139 | ||
140 | SetUpScene(); | ||
141 | |||
136 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 142 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
137 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 143 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
138 | 144 | ||
@@ -157,6 +163,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
157 | TestHelpers.InMethod(); | 163 | TestHelpers.InMethod(); |
158 | // TestHelpers.EnableLogging(); | 164 | // TestHelpers.EnableLogging(); |
159 | 165 | ||
166 | SetUpScene(); | ||
167 | |||
160 | UUID userId = TestHelpers.ParseTail(0x1); | 168 | UUID userId = TestHelpers.ParseTail(0x1); |
161 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); | 169 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); |
162 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | 170 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); |
@@ -196,6 +204,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
196 | TestHelpers.InMethod(); | 204 | TestHelpers.InMethod(); |
197 | // log4net.Config.XmlConfigurator.Configure(); | 205 | // log4net.Config.XmlConfigurator.Configure(); |
198 | 206 | ||
207 | SetUpScene(); | ||
208 | |||
199 | UUID userId = TestHelpers.ParseTail(0x1); | 209 | UUID userId = TestHelpers.ParseTail(0x1); |
200 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); | 210 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); |
201 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | 211 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); |
@@ -239,6 +249,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
239 | TestHelpers.InMethod(); | 249 | TestHelpers.InMethod(); |
240 | // log4net.Config.XmlConfigurator.Configure(); | 250 | // log4net.Config.XmlConfigurator.Configure(); |
241 | 251 | ||
252 | SetUpScene(); | ||
253 | |||
242 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 254 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
243 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 255 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
244 | 256 | ||
@@ -303,11 +315,64 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
303 | } | 315 | } |
304 | 316 | ||
305 | [Test] | 317 | [Test] |
318 | public void TestMoveInVarRegion() | ||
319 | { | ||
320 | TestHelpers.InMethod(); | ||
321 | // TestHelpers.EnableLogging(); | ||
322 | |||
323 | SetUpScene(512, 512); | ||
324 | |||
325 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | ||
326 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | ||
327 | |||
328 | Vector3 startPos = new Vector3(128, 246, 30); | ||
329 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); | ||
330 | |||
331 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
332 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | ||
333 | |||
334 | // For now, we'll make the scene presence fly to simplify this test, but this needs to change. | ||
335 | npc.Flying = true; | ||
336 | |||
337 | m_scene.Update(1); | ||
338 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | ||
339 | |||
340 | Vector3 targetPos = startPos + new Vector3(0, 20, 0); | ||
341 | m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false); | ||
342 | |||
343 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | ||
344 | //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); | ||
345 | Assert.That( | ||
346 | npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001)); | ||
347 | |||
348 | m_scene.Update(1); | ||
349 | |||
350 | // We should really check the exact figure. | ||
351 | Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X)); | ||
352 | Assert.That(npc.AbsolutePosition.Y, Is.GreaterThan(startPos.Y)); | ||
353 | Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); | ||
354 | Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X)); | ||
355 | |||
356 | for (int i = 0; i < 20; i++) | ||
357 | { | ||
358 | m_scene.Update(1); | ||
359 | // Console.WriteLine("pos: {0}", npc.AbsolutePosition); | ||
360 | } | ||
361 | |||
362 | double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); | ||
363 | Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); | ||
364 | Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); | ||
365 | Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); | ||
366 | } | ||
367 | |||
368 | [Test] | ||
306 | public void TestSitAndStandWithSitTarget() | 369 | public void TestSitAndStandWithSitTarget() |
307 | { | 370 | { |
308 | TestHelpers.InMethod(); | 371 | TestHelpers.InMethod(); |
309 | // log4net.Config.XmlConfigurator.Configure(); | 372 | // log4net.Config.XmlConfigurator.Configure(); |
310 | 373 | ||
374 | SetUpScene(); | ||
375 | |||
311 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 376 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
312 | 377 | ||
313 | Vector3 startPos = new Vector3(128, 128, 30); | 378 | Vector3 startPos = new Vector3(128, 128, 30); |
@@ -337,6 +402,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
337 | TestHelpers.InMethod(); | 402 | TestHelpers.InMethod(); |
338 | // TestHelpers.EnableLogging(); | 403 | // TestHelpers.EnableLogging(); |
339 | 404 | ||
405 | SetUpScene(); | ||
406 | |||
340 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 407 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
341 | 408 | ||
342 | // FIXME: To get this to work for now, we are going to place the npc right next to the target so that | 409 | // FIXME: To get this to work for now, we are going to place the npc right next to the target so that |
@@ -365,4 +432,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
365 | Assert.That(npc.ParentID, Is.EqualTo(0)); | 432 | Assert.That(npc.ParentID, Is.EqualTo(0)); |
366 | } | 433 | } |
367 | } | 434 | } |
368 | } | 435 | } \ No newline at end of file |