aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common/Helpers/SceneHelpers.cs')
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs139
1 files changed, 89 insertions, 50 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index ea3e348..df8b14c 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -30,12 +30,13 @@ using System.Net;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Data.Null;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Framework.Communications; 35
35using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
37using OpenSim.Framework.Servers.HttpServer; 38using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.PhysicsModules.SharedBase;
39using OpenSim.Region.Framework; 40using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
@@ -47,8 +48,8 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory;
47using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; 48using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
48using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; 49using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
49using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; 50using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence;
51using OpenSim.Region.PhysicsModule.BasicPhysics;
50using OpenSim.Services.Interfaces; 52using OpenSim.Services.Interfaces;
51using OpenSim.Tests.Common.Mock;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53 54
54namespace OpenSim.Tests.Common 55namespace OpenSim.Tests.Common
@@ -63,9 +64,9 @@ namespace OpenSim.Tests.Common
63 /// </summary> 64 /// </summary>
64 public SceneManager SceneManager { get; private set; } 65 public SceneManager SceneManager { get; private set; }
65 66
67 public ISimulationDataService SimDataService { get; private set; }
68
66 private AgentCircuitManager m_acm = new AgentCircuitManager(); 69 private AgentCircuitManager m_acm = new AgentCircuitManager();
67 private ISimulationDataService m_simDataService
68 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
69 private IEstateDataService m_estateDataService = null; 70 private IEstateDataService m_estateDataService = null;
70 71
71 private LocalAssetServicesConnector m_assetService; 72 private LocalAssetServicesConnector m_assetService;
@@ -77,6 +78,8 @@ namespace OpenSim.Tests.Common
77 78
78 private CoreAssetCache m_cache; 79 private CoreAssetCache m_cache;
79 80
81 private PhysicsScene m_physicsScene;
82
80 public SceneHelpers() : this(null) {} 83 public SceneHelpers() : this(null) {}
81 84
82 public SceneHelpers(CoreAssetCache cache) 85 public SceneHelpers(CoreAssetCache cache)
@@ -96,6 +99,11 @@ namespace OpenSim.Tests.Common
96 m_presenceService.PostInitialise(); 99 m_presenceService.PostInitialise();
97 100
98 m_cache = cache; 101 m_cache = cache;
102
103 m_physicsScene = StartPhysicsScene();
104
105 SimDataService
106 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
99 } 107 }
100 108
101 /// <summary> 109 /// <summary>
@@ -115,6 +123,11 @@ namespace OpenSim.Tests.Common
115 return SetupScene(name, id, x, y, new IniConfigSource()); 123 return SetupScene(name, id, x, y, new IniConfigSource());
116 } 124 }
117 125
126 public TestScene SetupScene(string name, UUID id, uint x, uint y, IConfigSource configSource)
127 {
128 return SetupScene(name, id, x, y, Constants.RegionSize, Constants.RegionSize, configSource);
129 }
130
118 /// <summary> 131 /// <summary>
119 /// Set up a scene. 132 /// Set up a scene.
120 /// </summary> 133 /// </summary>
@@ -122,10 +135,12 @@ namespace OpenSim.Tests.Common
122 /// <param name="id">ID of the region</param> 135 /// <param name="id">ID of the region</param>
123 /// <param name="x">X co-ordinate of the region</param> 136 /// <param name="x">X co-ordinate of the region</param>
124 /// <param name="y">Y co-ordinate of the region</param> 137 /// <param name="y">Y co-ordinate of the region</param>
138 /// <param name="sizeX">X size of scene</param>
139 /// <param name="sizeY">Y size of scene</param>
125 /// <param name="configSource"></param> 140 /// <param name="configSource"></param>
126 /// <returns></returns> 141 /// <returns></returns>
127 public TestScene SetupScene( 142 public TestScene SetupScene(
128 string name, UUID id, uint x, uint y, IConfigSource configSource) 143 string name, UUID id, uint x, uint y, uint sizeX, uint sizeY, IConfigSource configSource)
129 { 144 {
130 Console.WriteLine("Setting up test scene {0}", name); 145 Console.WriteLine("Setting up test scene {0}", name);
131 146
@@ -135,16 +150,20 @@ namespace OpenSim.Tests.Common
135 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); 150 RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
136 regInfo.RegionName = name; 151 regInfo.RegionName = name;
137 regInfo.RegionID = id; 152 regInfo.RegionID = id;
138 153 regInfo.RegionSizeX = sizeX;
139 SceneCommunicationService scs = new SceneCommunicationService(); 154 regInfo.RegionSizeY = sizeY;
140 155
141 TestScene testScene = new TestScene( 156 TestScene testScene = new TestScene(
142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, false, configSource, null); 157 regInfo, m_acm, SimDataService, m_estateDataService, configSource, null);
143 158
144 INonSharedRegionModule godsModule = new GodsModule(); 159 INonSharedRegionModule godsModule = new GodsModule();
145 godsModule.Initialise(new IniConfigSource()); 160 godsModule.Initialise(new IniConfigSource());
146 godsModule.AddRegion(testScene); 161 godsModule.AddRegion(testScene);
147 162
163 // Add scene to physics
164 ((INonSharedRegionModule)m_physicsScene).AddRegion(testScene);
165 ((INonSharedRegionModule)m_physicsScene).RegionLoaded(testScene);
166
148 // Add scene to services 167 // Add scene to services
149 m_assetService.AddRegion(testScene); 168 m_assetService.AddRegion(testScene);
150 169
@@ -182,12 +201,7 @@ namespace OpenSim.Tests.Common
182 testScene.SetModuleInterfaces(); 201 testScene.SetModuleInterfaces();
183 202
184 testScene.LandChannel = new TestLandChannel(testScene); 203 testScene.LandChannel = new TestLandChannel(testScene);
185 testScene.LoadWorldMap(); 204 testScene.LoadWorldMap();
186
187 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
188 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
189 testScene.PhysicsScene
190 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
191 205
192 testScene.RegionInfo.EstateSettings = new EstateSettings(); 206 testScene.RegionInfo.EstateSettings = new EstateSettings();
193 testScene.LoginsEnabled = true; 207 testScene.LoginsEnabled = true;
@@ -297,6 +311,11 @@ namespace OpenSim.Tests.Common
297 /// <param name="testScene"></param> 311 /// <param name="testScene"></param>
298 private static LocalPresenceServicesConnector StartPresenceService() 312 private static LocalPresenceServicesConnector StartPresenceService()
299 { 313 {
314 // Unfortunately, some services share data via statics, so we need to null every time to stop interference
315 // between tests.
316 // This is a massive non-obvious pita.
317 NullPresenceData.Instance = null;
318
300 IConfigSource config = new IniConfigSource(); 319 IConfigSource config = new IniConfigSource();
301 config.AddConfig("Modules"); 320 config.AddConfig("Modules");
302 config.AddConfig("PresenceService"); 321 config.AddConfig("PresenceService");
@@ -311,6 +330,19 @@ namespace OpenSim.Tests.Common
311 return presenceService; 330 return presenceService;
312 } 331 }
313 332
333 private static PhysicsScene StartPhysicsScene()
334 {
335 IConfigSource config = new IniConfigSource();
336 config.AddConfig("Startup");
337 config.Configs["Startup"].Set("physics", "basicphysics");
338
339 PhysicsScene pScene = new BasicScene();
340 INonSharedRegionModule mod = pScene as INonSharedRegionModule;
341 mod.Initialise(config);
342
343 return pScene;
344 }
345
314 /// <summary> 346 /// <summary>
315 /// Setup modules for a scene using their default settings. 347 /// Setup modules for a scene using their default settings.
316 /// </summary> 348 /// </summary>
@@ -447,9 +479,6 @@ namespace OpenSim.Tests.Common
447 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 479 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
448 /// </summary> 480 /// </summary>
449 /// <remarks> 481 /// <remarks>
450 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
451 /// and teleport doesn't take place.
452 ///
453 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will 482 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
454 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. 483 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
455 /// </remarks> 484 /// </remarks>
@@ -462,22 +491,6 @@ namespace OpenSim.Tests.Common
462 } 491 }
463 492
464 /// <summary> 493 /// <summary>
465 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
466 /// </summary>
467 /// <remarks>
468 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
469 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
470 /// </remarks>
471 /// <param name="scene"></param>
472 /// <param name="agentId"></param>
473 /// <param name="sceneManager"></param>
474 /// <returns></returns>
475 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
476 {
477 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
478 }
479
480 /// <summary>
481 /// Add a root agent. 494 /// Add a root agent.
482 /// </summary> 495 /// </summary>
483 /// <param name="scene"></param> 496 /// <param name="scene"></param>
@@ -508,7 +521,7 @@ namespace OpenSim.Tests.Common
508 /// <returns></returns> 521 /// <returns></returns>
509 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 522 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
510 { 523 {
511 return AddScenePresence(scene, agentData, null); 524 return AddScenePresence(scene, new TestClient(agentData, scene), agentData);
512 } 525 }
513 526
514 /// <summary> 527 /// <summary>
@@ -528,9 +541,9 @@ namespace OpenSim.Tests.Common
528 /// </remarks> 541 /// </remarks>
529 /// <param name="scene"></param> 542 /// <param name="scene"></param>
530 /// <param name="agentData"></param> 543 /// <param name="agentData"></param>
531 /// <param name="sceneManager"></param>
532 /// <returns></returns> 544 /// <returns></returns>
533 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager) 545 public static ScenePresence AddScenePresence(
546 Scene scene, IClientAPI client, AgentCircuitData agentData)
534 { 547 {
535 // We emulate the proper login sequence here by doing things in four stages 548 // We emulate the proper login sequence here by doing things in four stages
536 549
@@ -541,7 +554,7 @@ namespace OpenSim.Tests.Common
541 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 554 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
542 555
543 // Stages 1 & 2 556 // Stages 1 & 2
544 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin); 557 ScenePresence sp = IntroduceClientToScene(scene, client, agentData, TeleportFlags.ViaLogin);
545 558
546 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 559 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
547 sp.CompleteMovement(sp.ControllingClient, true); 560 sp.CompleteMovement(sp.ControllingClient, true);
@@ -553,37 +566,37 @@ namespace OpenSim.Tests.Common
553 /// Introduce an agent into the scene by adding a new client. 566 /// Introduce an agent into the scene by adding a new client.
554 /// </summary> 567 /// </summary>
555 /// <returns>The scene presence added</returns> 568 /// <returns>The scene presence added</returns>
556 /// <param name='sceneManager'>
557 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
558 /// neighbours and where no teleporting takes place.
559 /// </param>
560 /// <param name='scene'></param> 569 /// <param name='scene'></param>
561 /// <param name='sceneManager></param> 570 /// <param name='testClient'></param>
562 /// <param name='agentData'></param> 571 /// <param name='agentData'></param>
563 /// <param name='tf'></param> 572 /// <param name='tf'></param>
564 private static ScenePresence IntroduceClientToScene( 573 private static ScenePresence IntroduceClientToScene(
565 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf) 574 Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf)
566 { 575 {
567 string reason; 576 string reason;
568 577
569 // Stage 1: tell the scene to expect a new user connection 578 // Stage 1: tell the scene to expect a new user connection
570 if (!scene.NewUserConnection(agentData, (uint)tf, out reason)) 579 if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason))
571 Console.WriteLine("NewUserConnection failed: " + reason); 580 Console.WriteLine("NewUserConnection failed: " + reason);
572 581
573 // Stage 2: add the new client as a child agent to the scene 582 // Stage 2: add the new client as a child agent to the scene
574 TestClient client = new TestClient(agentData, scene, sceneManager); 583 scene.AddNewAgent(client, PresenceType.User);
575 scene.AddNewClient(client, PresenceType.User);
576 584
577 return scene.GetScenePresence(agentData.AgentID); 585 return scene.GetScenePresence(client.AgentId);
578 } 586 }
579 587
580 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId) 588 public static ScenePresence AddChildScenePresence(Scene scene, UUID agentId)
581 { 589 {
582 AgentCircuitData acd = GenerateAgentData(agentId); 590 return AddChildScenePresence(scene, GenerateAgentData(agentId));
591 }
592
593 public static ScenePresence AddChildScenePresence(Scene scene, AgentCircuitData acd)
594 {
583 acd.child = true; 595 acd.child = true;
584 596
585 // XXX: ViaLogin may not be correct for child agents 597 // XXX: ViaLogin may not be correct for child agents
586 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin); 598 TestClient client = new TestClient(acd, scene);
599 return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin);
587 } 600 }
588 601
589 /// <summary> 602 /// <summary>
@@ -610,6 +623,32 @@ namespace OpenSim.Tests.Common
610 //part.UpdatePrimFlags(false, false, true); 623 //part.UpdatePrimFlags(false, false, true);
611 //part.ObjectFlags |= (uint)PrimFlags.Phantom; 624 //part.ObjectFlags |= (uint)PrimFlags.Phantom;
612 625
626 scene.AddNewSceneObject(so, true);
627
628 return so;
629 }
630
631 /// <summary>
632 /// Add a test object
633 /// </summary>
634 /// <param name="scene"></param>
635 /// <param name="parts">
636 /// The number of parts that should be in the scene object
637 /// </param>
638 /// <param name="ownerId"></param>
639 /// <param name="partNamePrefix">
640 /// The prefix to be given to part names. This will be suffixed with "Part<part no>"
641 /// (e.g. mynamePart1 for the root part)
642 /// </param>
643 /// <param name="uuidTail">
644 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
645 /// will be given to the root part, and incremented for each part thereafter.
646 /// </param>
647 /// <returns></returns>
648 public static SceneObjectGroup AddSceneObject(Scene scene, int parts, UUID ownerId, string partNamePrefix, int uuidTail)
649 {
650 SceneObjectGroup so = CreateSceneObject(parts, ownerId, partNamePrefix, uuidTail);
651
613 scene.AddNewSceneObject(so, false); 652 scene.AddNewSceneObject(so, false);
614 653
615 return so; 654 return so;