aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Helpers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common/Helpers')
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs72
1 files changed, 68 insertions, 4 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 8e54707..dc24418 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -58,6 +58,11 @@ namespace OpenSim.Tests.Common
58 /// </summary> 58 /// </summary>
59 public class SceneHelpers 59 public class SceneHelpers
60 { 60 {
61 /// <summary>
62 /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests.
63 /// </summary>
64 public SceneManager SceneManager { get; private set; }
65
61 private AgentCircuitManager m_acm = new AgentCircuitManager(); 66 private AgentCircuitManager m_acm = new AgentCircuitManager();
62 private ISimulationDataService m_simDataService 67 private ISimulationDataService m_simDataService
63 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); 68 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
@@ -76,6 +81,8 @@ namespace OpenSim.Tests.Common
76 81
77 public SceneHelpers(CoreAssetCache cache) 82 public SceneHelpers(CoreAssetCache cache)
78 { 83 {
84 SceneManager = new SceneManager();
85
79 m_assetService = StartAssetService(cache); 86 m_assetService = StartAssetService(cache);
80 m_authenticationService = StartAuthenticationService(); 87 m_authenticationService = StartAuthenticationService();
81 m_inventoryService = StartInventoryService(); 88 m_inventoryService = StartInventoryService();
@@ -186,6 +193,8 @@ namespace OpenSim.Tests.Common
186 testScene.LoginsDisabled = false; 193 testScene.LoginsDisabled = false;
187 testScene.RegisterRegionWithGrid(); 194 testScene.RegisterRegionWithGrid();
188 195
196 SceneManager.Add(testScene);
197
189 return testScene; 198 return testScene;
190 } 199 }
191 200
@@ -350,6 +359,7 @@ namespace OpenSim.Tests.Common
350 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); 359 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
351 foreach (object module in modules) 360 foreach (object module in modules)
352 { 361 {
362// Console.WriteLine("MODULE RAW {0}", module);
353 if (module is IRegionModule) 363 if (module is IRegionModule)
354 { 364 {
355 IRegionModule m = (IRegionModule)module; 365 IRegionModule m = (IRegionModule)module;
@@ -367,6 +377,7 @@ namespace OpenSim.Tests.Common
367 // for the new system, everything has to be initialised first, 377 // for the new system, everything has to be initialised first,
368 // shared modules have to be post-initialised, then all get an AddRegion with the scene 378 // shared modules have to be post-initialised, then all get an AddRegion with the scene
369 IRegionModuleBase m = (IRegionModuleBase)module; 379 IRegionModuleBase m = (IRegionModuleBase)module;
380// Console.WriteLine("MODULE {0}", m.Name);
370 m.Initialise(config); 381 m.Initialise(config);
371 newModules.Add(m); 382 newModules.Add(m);
372 } 383 }
@@ -426,6 +437,10 @@ namespace OpenSim.Tests.Common
426 /// <summary> 437 /// <summary>
427 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 438 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
428 /// </summary> 439 /// </summary>
440 /// <remarks>
441 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
442 /// and teleport doesn't take place.
443 /// </remarks>
429 /// <param name="scene"></param> 444 /// <param name="scene"></param>
430 /// <param name="agentId"></param> 445 /// <param name="agentId"></param>
431 /// <returns></returns> 446 /// <returns></returns>
@@ -435,6 +450,18 @@ namespace OpenSim.Tests.Common
435 } 450 }
436 451
437 /// <summary> 452 /// <summary>
453 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
454 /// </summary>
455 /// <param name="scene"></param>
456 /// <param name="agentId"></param>
457 /// <param name="sceneManager"></param>
458 /// <returns></returns>
459 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
460 {
461 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
462 }
463
464 /// <summary>
438 /// Add a root agent. 465 /// Add a root agent.
439 /// </summary> 466 /// </summary>
440 /// <remarks> 467 /// <remarks>
@@ -454,6 +481,30 @@ namespace OpenSim.Tests.Common
454 /// <returns></returns> 481 /// <returns></returns>
455 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 482 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
456 { 483 {
484 return AddScenePresence(scene, agentData, null);
485 }
486
487 /// <summary>
488 /// Add a root agent.
489 /// </summary>
490 /// <remarks>
491 /// This function
492 ///
493 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
494 /// userserver if grid) would give initial login data back to the client and separately tell the scene that the
495 /// agent was coming.
496 ///
497 /// 2) Connects the agent with the scene
498 ///
499 /// This function performs actions equivalent with notifying the scene that an agent is
500 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first
501 /// </remarks>
502 /// <param name="scene"></param>
503 /// <param name="agentData"></param>
504 /// <param name="sceneManager"></param>
505 /// <returns></returns>
506 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager)
507 {
457 // We emulate the proper login sequence here by doing things in four stages 508 // We emulate the proper login sequence here by doing things in four stages
458 509
459 // Stage 0: login 510 // Stage 0: login
@@ -463,7 +514,7 @@ namespace OpenSim.Tests.Common
463 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 514 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
464 515
465 // Stages 1 & 2 516 // Stages 1 & 2
466 ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); 517 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin);
467 518
468 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 519 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
469 sp.CompleteMovement(sp.ControllingClient, true); 520 sp.CompleteMovement(sp.ControllingClient, true);
@@ -471,7 +522,20 @@ namespace OpenSim.Tests.Common
471 return sp; 522 return sp;
472 } 523 }
473 524
474 private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) 525 /// <summary>
526 /// Introduce an agent into the scene by adding a new client.
527 /// </summary>
528 /// <returns>The scene presence added</returns>
529 /// <param name='sceneManager'>
530 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
531 /// neighbours and where no teleporting takes place.
532 /// </param>
533 /// <param name='scene'></param>
534 /// <param name='sceneManager></param>
535 /// <param name='agentData'></param>
536 /// <param name='tf'></param>
537 private static ScenePresence IntroduceClientToScene(
538 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf)
475 { 539 {
476 string reason; 540 string reason;
477 541
@@ -480,7 +544,7 @@ namespace OpenSim.Tests.Common
480 Console.WriteLine("NewUserConnection failed: " + reason); 544 Console.WriteLine("NewUserConnection failed: " + reason);
481 545
482 // Stage 2: add the new client as a child agent to the scene 546 // Stage 2: add the new client as a child agent to the scene
483 TestClient client = new TestClient(agentData, scene); 547 TestClient client = new TestClient(agentData, scene, sceneManager);
484 scene.AddNewClient(client, PresenceType.User); 548 scene.AddNewClient(client, PresenceType.User);
485 549
486 return scene.GetScenePresence(agentData.AgentID); 550 return scene.GetScenePresence(agentData.AgentID);
@@ -492,7 +556,7 @@ namespace OpenSim.Tests.Common
492 acd.child = true; 556 acd.child = true;
493 557
494 // XXX: ViaLogin may not be correct for child agents 558 // XXX: ViaLogin may not be correct for child agents
495 return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); 559 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin);
496 } 560 }
497 561
498 /// <summary> 562 /// <summary>