aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs151
1 files changed, 70 insertions, 81 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index f0bbf0b..d4c299f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -31,7 +31,7 @@ using System.Reflection;
31using System.Text; 31using System.Text;
32using System.Threading; 32using System.Threading;
33using System.Timers; 33using System.Timers;
34using Timer=System.Timers.Timer; 34using Timer = System.Timers.Timer;
35using Nini.Config; 35using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using OpenMetaverse; 37using OpenMetaverse;
@@ -39,11 +39,13 @@ using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.ClientStack.Linden;
42using OpenSim.Region.CoreModules.Framework.EntityTransfer; 43using OpenSim.Region.CoreModules.Framework.EntityTransfer;
43using OpenSim.Region.CoreModules.World.Serialiser; 44using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 46using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 47using OpenSim.Tests.Common.Mock;
48using GridRegion = OpenSim.Services.Interfaces.GridRegion;
47 49
48namespace OpenSim.Region.Framework.Scenes.Tests 50namespace OpenSim.Region.Framework.Scenes.Tests
49{ 51{
@@ -103,21 +105,71 @@ namespace OpenSim.Region.Framework.Scenes.Tests
103 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 105 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
104 106
105 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); 107 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null);
108 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
106 109
107 scene.IncomingCloseAgent(sp.UUID); 110 scene.IncomingCloseAgent(sp.UUID);
108 111
109 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 112 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
110 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); 113 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
114 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0));
115 }
116
117 [Test]
118 public void TestCreateChildScenePresence()
119 {
120 TestHelpers.InMethod();
121// log4net.Config.XmlConfigurator.Configure();
122
123 LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule();
124
125 IConfigSource configSource = new IniConfigSource();
126 IConfig config = configSource.AddConfig("Modules");
127 config.Set("SimulationServices", "LocalSimulationConnectorModule");
128
129 TestScene scene = SceneHelpers.SetupScene();
130 SceneHelpers.SetupSceneModules(scene, configSource, lsc);
131
132 UUID agentId = TestHelpers.ParseTail(0x01);
133 AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId);
134 acd.child = true;
135
136 GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName);
137 string reason;
138
139 // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and
140 // establish a child scene presence. We pass in the circuit code that the client has to connect with ***
141 // XXX: ViaLogin may not be correct here.
142 scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason);
143
144 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
145 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
146
147 // There's no scene presence yet since only an agent circuit has been established.
148 Assert.That(scene.GetScenePresence(agentId), Is.Null);
149
150 // *** This is the second stage, where the client established a child agent/scene presence using the
151 // circuit code given to the scene in stage 1 ***
152 TestClient client = new TestClient(acd, scene);
153 scene.AddNewClient(client, PresenceType.User);
154
155 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
156 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
157
158 ScenePresence sp = scene.GetScenePresence(agentId);
159 Assert.That(sp, Is.Not.Null);
160 Assert.That(sp.UUID, Is.EqualTo(agentId));
161 Assert.That(sp.IsChildAgent, Is.True);
111 } 162 }
112 163
113 /// <summary> 164 /// <summary>
114 /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region 165 /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
115 /// </summary> 166 /// </summary>
116 /// <remarks> 167 /// <remarks>
117 /// Please note that unlike the other tests here, this doesn't rely on structures 168 /// Please note that unlike the other tests here, this doesn't rely on anything set up in the instance fields.
169 /// INCOMPLETE
118 /// </remarks> 170 /// </remarks>
119 [Test] 171 [Test]
120 public void TestChildAgentEstablished() 172 public void TestChildAgentEstablishedInNeighbour()
121 { 173 {
122 TestHelpers.InMethod(); 174 TestHelpers.InMethod();
123// log4net.Config.XmlConfigurator.Configure(); 175// log4net.Config.XmlConfigurator.Configure();
@@ -125,18 +177,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests
125 UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); 177 UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
126 178
127 TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); 179 TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
128// TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); 180 TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
129 181
130 IConfigSource configSource = new IniConfigSource(); 182 IConfigSource configSource = new IniConfigSource();
131 configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); 183 IConfig config = configSource.AddConfig("Startup");
184 config.Set("serverside_object_permissions", true);
185 config.Set("EventQueue", true);
186
132 EntityTransferModule etm = new EntityTransferModule(); 187 EntityTransferModule etm = new EntityTransferModule();
188
189 EventQueueGetModule eqgm1 = new EventQueueGetModule();
190 SceneHelpers.SetupSceneModules(myScene1, configSource, etm, eqgm1);
191
192 EventQueueGetModule eqgm2 = new EventQueueGetModule();
193 SceneHelpers.SetupSceneModules(myScene2, configSource, etm, eqgm2);
133 194
134 SceneHelpers.SetupSceneModules(myScene1, configSource, etm); 195// SceneHelpers.AddScenePresence(myScene1, agent1Id);
135
136 SceneHelpers.AddScenePresence(myScene1, agent1Id);
137// ScenePresence childPresence = myScene2.GetScenePresence(agent1); 196// ScenePresence childPresence = myScene2.GetScenePresence(agent1);
138 197//
139 // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents 198// // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
140// Assert.That(childPresence, Is.Not.Null); 199// Assert.That(childPresence, Is.Not.Null);
141// Assert.That(childPresence.IsChildAgent, Is.True); 200// Assert.That(childPresence.IsChildAgent, Is.True);
142 } 201 }
@@ -194,48 +253,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
194// Assert.That(presence, Is.Null, "presence is not null"); 253// Assert.That(presence, Is.Null, "presence is not null");
195// } 254// }
196 255
197 [Test]
198 public void T012_TestAddNeighbourRegion()
199 {
200 TestHelpers.InMethod();
201
202 string reason;
203
204 if (acd1 == null)
205 fixNullPresence();
206
207 scene.NewUserConnection(acd1, 0, out reason);
208 if (testclient == null)
209 testclient = new TestClient(acd1, scene);
210 scene.AddNewClient(testclient, PresenceType.User);
211
212 ScenePresence presence = scene.GetScenePresence(agent1);
213 presence.MakeRootAgent(new Vector3(90,90,90),false);
214
215 string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
216
217 presence.AddNeighbourRegion(region2, cap);
218 presence.AddNeighbourRegion(region3, cap);
219
220 Assert.That(presence.KnownRegionCount, Is.EqualTo(2));
221 }
222
223 [Test]
224 public void T013_TestRemoveNeighbourRegion()
225 {
226 TestHelpers.InMethod();
227
228 ScenePresence presence = scene.GetScenePresence(agent1);
229 presence.RemoveNeighbourRegion(region3);
230
231 Assert.That(presence.KnownRegionCount,Is.EqualTo(1));
232 /*
233 presence.MakeChildAgent;
234 presence.MakeRootAgent;
235 CompleteAvatarMovement
236 */
237 }
238
239 // I'm commenting this test because it does not represent 256 // I'm commenting this test because it does not represent
240 // crossings. The Thread.Sleep's in here are not meaningful mocks, 257 // crossings. The Thread.Sleep's in here are not meaningful mocks,
241 // and they sometimes fail in panda. 258 // and they sometimes fail in panda.
@@ -338,33 +355,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
338 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 355 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
339 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 356 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
340 } 357 }
341
342 public void fixNullPresence()
343 {
344 string firstName = "testfirstname";
345
346 AgentCircuitData agent = new AgentCircuitData();
347 agent.AgentID = agent1;
348 agent.firstname = firstName;
349 agent.lastname = "testlastname";
350 agent.SessionID = UUID.Zero;
351 agent.SecureSessionID = UUID.Zero;
352 agent.circuitcode = 123;
353 agent.BaseFolder = UUID.Zero;
354 agent.InventoryFolder = UUID.Zero;
355 agent.startpos = Vector3.Zero;
356 agent.CapsPath = GetRandomCapsObjectPath();
357 agent.Appearance = new AvatarAppearance();
358
359 acd1 = agent;
360 }
361
362 public static string GetRandomCapsObjectPath()
363 {
364 UUID caps = UUID.Random();
365 string capsPath = caps.ToString();
366 capsPath = capsPath.Remove(capsPath.Length - 4, 4);
367 return capsPath;
368 }
369 } 358 }
370} \ No newline at end of file 359} \ No newline at end of file