diff options
author | Justin Clark-Casey (justincc) | 2012-07-19 21:41:13 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-19 21:41:13 +0100 |
commit | c0ab406e2e3ab1e1702285c7cd35e1adc6cc593b (patch) | |
tree | 043291fbbef028d49edac27e0eb6b9f161234e10 /OpenSim | |
parent | Add EventManager.OnRegionLoginsStatusChange fired whenever logins are enabled... (diff) | |
download | opensim-SC_OLD-c0ab406e2e3ab1e1702285c7cd35e1adc6cc593b.zip opensim-SC_OLD-c0ab406e2e3ab1e1702285c7cd35e1adc6cc593b.tar.gz opensim-SC_OLD-c0ab406e2e3ab1e1702285c7cd35e1adc6cc593b.tar.bz2 opensim-SC_OLD-c0ab406e2e3ab1e1702285c7cd35e1adc6cc593b.tar.xz |
Add basic TestCreateRootScenePresence() regression test
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | 279 |
1 files changed, 144 insertions, 135 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 02c45ef..44c1396 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -53,48 +53,60 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
53 | /// Scene presence tests | 53 | /// Scene presence tests |
54 | /// </summary> | 54 | /// </summary> |
55 | [TestFixture] | 55 | [TestFixture] |
56 | public class ScenePresenceAgentTests | 56 | public class ScenePresenceAgentTests : OpenSimTestCase |
57 | { | 57 | { |
58 | public Scene scene, scene2, scene3; | 58 | // public Scene scene, scene2, scene3; |
59 | public UUID agent1, agent2, agent3; | 59 | // public UUID agent1, agent2, agent3; |
60 | public static Random random; | 60 | // public static Random random; |
61 | public ulong region1,region2,region3; | 61 | // public ulong region1, region2, region3; |
62 | public AgentCircuitData acd1; | 62 | // public AgentCircuitData acd1; |
63 | public SceneObjectGroup sog1, sog2, sog3; | 63 | // public TestClient testclient; |
64 | public TestClient testclient; | 64 | |
65 | 65 | // [TestFixtureSetUp] | |
66 | [TestFixtureSetUp] | 66 | // public void Init() |
67 | public void Init() | 67 | // { |
68 | //// TestHelpers.InMethod(); | ||
69 | //// | ||
70 | //// SceneHelpers sh = new SceneHelpers(); | ||
71 | //// | ||
72 | //// scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | ||
73 | //// scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | ||
74 | //// scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | ||
75 | //// | ||
76 | //// ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | ||
77 | //// interregionComms.Initialise(new IniConfigSource()); | ||
78 | //// interregionComms.PostInitialise(); | ||
79 | //// SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | ||
80 | //// SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); | ||
81 | //// SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); | ||
82 | // | ||
83 | //// agent1 = UUID.Random(); | ||
84 | //// agent2 = UUID.Random(); | ||
85 | //// agent3 = UUID.Random(); | ||
86 | // | ||
87 | //// region1 = scene.RegionInfo.RegionHandle; | ||
88 | //// region2 = scene2.RegionInfo.RegionHandle; | ||
89 | //// region3 = scene3.RegionInfo.RegionHandle; | ||
90 | // } | ||
91 | |||
92 | [Test] | ||
93 | public void TestCreateRootScenePresence() | ||
68 | { | 94 | { |
69 | TestHelpers.InMethod(); | 95 | TestHelpers.InMethod(); |
96 | // TestHelpers.EnableLogging(); | ||
97 | |||
98 | UUID spUuid = TestHelpers.ParseTail(0x1); | ||
99 | |||
100 | TestScene scene = new SceneHelpers().SetupScene(); | ||
101 | SceneHelpers.AddScenePresence(scene, spUuid); | ||
102 | |||
103 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null); | ||
104 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); | ||
70 | 105 | ||
71 | SceneHelpers sh = new SceneHelpers(); | 106 | ScenePresence sp = scene.GetScenePresence(spUuid); |
72 | 107 | Assert.That(sp, Is.Not.Null); | |
73 | scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | 108 | Assert.That(sp.IsChildAgent, Is.False); |
74 | scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | 109 | Assert.That(sp.UUID, Is.EqualTo(spUuid)); |
75 | scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | ||
76 | |||
77 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | ||
78 | interregionComms.Initialise(new IniConfigSource()); | ||
79 | interregionComms.PostInitialise(); | ||
80 | SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | ||
81 | SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); | ||
82 | SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); | ||
83 | |||
84 | agent1 = UUID.Random(); | ||
85 | agent2 = UUID.Random(); | ||
86 | agent3 = UUID.Random(); | ||
87 | random = new Random(); | ||
88 | sog1 = SceneHelpers.CreateSceneObject(1, agent1); | ||
89 | scene.AddSceneObject(sog1); | ||
90 | sog2 = SceneHelpers.CreateSceneObject(1, agent1); | ||
91 | scene.AddSceneObject(sog2); | ||
92 | sog3 = SceneHelpers.CreateSceneObject(1, agent1); | ||
93 | scene.AddSceneObject(sog3); | ||
94 | |||
95 | region1 = scene.RegionInfo.RegionHandle; | ||
96 | region2 = scene2.RegionInfo.RegionHandle; | ||
97 | region3 = scene3.RegionInfo.RegionHandle; | ||
98 | } | 110 | } |
99 | 111 | ||
100 | [Test] | 112 | [Test] |
@@ -106,9 +118,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
106 | TestScene scene = new SceneHelpers().SetupScene(); | 118 | TestScene scene = new SceneHelpers().SetupScene(); |
107 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 119 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
108 | 120 | ||
109 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); | ||
110 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); | ||
111 | |||
112 | scene.IncomingCloseAgent(sp.UUID); | 121 | scene.IncomingCloseAgent(sp.UUID); |
113 | 122 | ||
114 | Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); | 123 | Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); |
@@ -266,99 +275,99 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
266 | // but things are synchronous among them. So there should be | 275 | // but things are synchronous among them. So there should be |
267 | // 3 threads in here. | 276 | // 3 threads in here. |
268 | //[Test] | 277 | //[Test] |
269 | public void T021_TestCrossToNewRegion() | 278 | // public void T021_TestCrossToNewRegion() |
270 | { | 279 | // { |
271 | TestHelpers.InMethod(); | 280 | // TestHelpers.InMethod(); |
272 | 281 | // | |
273 | scene.RegisterRegionWithGrid(); | 282 | // scene.RegisterRegionWithGrid(); |
274 | scene2.RegisterRegionWithGrid(); | 283 | // scene2.RegisterRegionWithGrid(); |
275 | 284 | // | |
276 | // Adding child agent to region 1001 | 285 | // // Adding child agent to region 1001 |
277 | string reason; | 286 | // string reason; |
278 | scene2.NewUserConnection(acd1,0, out reason); | 287 | // scene2.NewUserConnection(acd1,0, out reason); |
279 | scene2.AddNewClient(testclient, PresenceType.User); | 288 | // scene2.AddNewClient(testclient, PresenceType.User); |
280 | 289 | // | |
281 | ScenePresence presence = scene.GetScenePresence(agent1); | 290 | // ScenePresence presence = scene.GetScenePresence(agent1); |
282 | presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); | 291 | // presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); |
283 | 292 | // | |
284 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | 293 | // ScenePresence presence2 = scene2.GetScenePresence(agent1); |
285 | 294 | // | |
286 | // Adding neighbour region caps info to presence2 | 295 | // // Adding neighbour region caps info to presence2 |
287 | 296 | // | |
288 | string cap = presence.ControllingClient.RequestClientInfo().CapsPath; | 297 | // string cap = presence.ControllingClient.RequestClientInfo().CapsPath; |
289 | presence2.AddNeighbourRegion(region1, cap); | 298 | // presence2.AddNeighbourRegion(region1, cap); |
290 | 299 | // | |
291 | Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region."); | 300 | // Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region."); |
292 | Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region."); | 301 | // Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region."); |
293 | 302 | // | |
294 | // Cross to x+1 | 303 | // // Cross to x+1 |
295 | presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100); | 304 | // presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100); |
296 | presence.Update(); | 305 | // presence.Update(); |
297 | 306 | // | |
298 | EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); | 307 | // EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); |
299 | 308 | // | |
300 | // Mimicking communication between client and server, by waiting OK from client | 309 | // // Mimicking communication between client and server, by waiting OK from client |
301 | // sent by TestClient.CrossRegion call. Originally, this is network comm. | 310 | // // sent by TestClient.CrossRegion call. Originally, this is network comm. |
302 | if (!wh.WaitOne(5000,false)) | 311 | // if (!wh.WaitOne(5000,false)) |
303 | { | 312 | // { |
304 | presence.Update(); | 313 | // presence.Update(); |
305 | if (!wh.WaitOne(8000,false)) | 314 | // if (!wh.WaitOne(8000,false)) |
306 | throw new ArgumentException("1 - Timeout waiting for signal/variable."); | 315 | // throw new ArgumentException("1 - Timeout waiting for signal/variable."); |
307 | } | 316 | // } |
308 | 317 | // | |
309 | // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which | 318 | // // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which |
310 | // would normally be fired after receiving the reply packet from comm. done on the last line. | 319 | // // would normally be fired after receiving the reply packet from comm. done on the last line. |
311 | testclient.CompleteMovement(); | 320 | // testclient.CompleteMovement(); |
312 | 321 | // | |
313 | // Crossings are asynchronous | 322 | // // Crossings are asynchronous |
314 | int timer = 10; | 323 | // int timer = 10; |
315 | 324 | // | |
316 | // Make sure cross hasn't already finished | 325 | // // Make sure cross hasn't already finished |
317 | if (!presence.IsInTransit && !presence.IsChildAgent) | 326 | // if (!presence.IsInTransit && !presence.IsChildAgent) |
318 | { | 327 | // { |
319 | // If not and not in transit yet, give it some more time | 328 | // // If not and not in transit yet, give it some more time |
320 | Thread.Sleep(5000); | 329 | // Thread.Sleep(5000); |
321 | } | 330 | // } |
322 | 331 | // | |
323 | // Enough time, should at least be in transit by now. | 332 | // // Enough time, should at least be in transit by now. |
324 | while (presence.IsInTransit && timer > 0) | 333 | // while (presence.IsInTransit && timer > 0) |
325 | { | 334 | // { |
326 | Thread.Sleep(1000); | 335 | // Thread.Sleep(1000); |
327 | timer-=1; | 336 | // timer-=1; |
328 | } | 337 | // } |
329 | 338 | // | |
330 | Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1."); | 339 | // Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1."); |
331 | Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); | 340 | // Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); |
332 | Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); | 341 | // Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); |
333 | 342 | // | |
334 | // Cross Back | 343 | // // Cross Back |
335 | presence2.AbsolutePosition = new Vector3(-10, 3, 100); | 344 | // presence2.AbsolutePosition = new Vector3(-10, 3, 100); |
336 | presence2.Update(); | 345 | // presence2.Update(); |
337 | 346 | // | |
338 | if (!wh.WaitOne(5000,false)) | 347 | // if (!wh.WaitOne(5000,false)) |
339 | { | 348 | // { |
340 | presence2.Update(); | 349 | // presence2.Update(); |
341 | if (!wh.WaitOne(8000,false)) | 350 | // if (!wh.WaitOne(8000,false)) |
342 | throw new ArgumentException("2 - Timeout waiting for signal/variable."); | 351 | // throw new ArgumentException("2 - Timeout waiting for signal/variable."); |
343 | } | 352 | // } |
344 | testclient.CompleteMovement(); | 353 | // testclient.CompleteMovement(); |
345 | 354 | // | |
346 | if (!presence2.IsInTransit && !presence2.IsChildAgent) | 355 | // if (!presence2.IsInTransit && !presence2.IsChildAgent) |
347 | { | 356 | // { |
348 | // If not and not in transit yet, give it some more time | 357 | // // If not and not in transit yet, give it some more time |
349 | Thread.Sleep(5000); | 358 | // Thread.Sleep(5000); |
350 | } | 359 | // } |
351 | 360 | // | |
352 | // Enough time, should at least be in transit by now. | 361 | // // Enough time, should at least be in transit by now. |
353 | while (presence2.IsInTransit && timer > 0) | 362 | // while (presence2.IsInTransit && timer > 0) |
354 | { | 363 | // { |
355 | Thread.Sleep(1000); | 364 | // Thread.Sleep(1000); |
356 | timer-=1; | 365 | // timer-=1; |
357 | } | 366 | // } |
358 | 367 | // | |
359 | Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2."); | 368 | // Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2."); |
360 | Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); | 369 | // Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); |
361 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); | 370 | // Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); |
362 | } | 371 | // } |
363 | } | 372 | } |
364 | } \ No newline at end of file | 373 | } \ No newline at end of file |