diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs (renamed from OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs) | 223 |
1 files changed, 105 insertions, 118 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index a37b338..35b41fb 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
51 | /// Scene presence tests | 51 | /// Scene presence tests |
52 | /// </summary> | 52 | /// </summary> |
53 | [TestFixture] | 53 | [TestFixture] |
54 | public class ScenePresenceTests | 54 | public class ScenePresenceAgentTests |
55 | { | 55 | { |
56 | public Scene scene, scene2, scene3; | 56 | public Scene scene, scene2, scene3; |
57 | public UUID agent1, agent2, agent3; | 57 | public UUID agent1, agent2, agent3; |
@@ -64,90 +64,140 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
64 | [TestFixtureSetUp] | 64 | [TestFixtureSetUp] |
65 | public void Init() | 65 | public void Init() |
66 | { | 66 | { |
67 | TestHelper.InMethod(); | 67 | TestHelpers.InMethod(); |
68 | 68 | ||
69 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | 69 | scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); |
70 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | 70 | scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); |
71 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | 71 | scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); |
72 | 72 | ||
73 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | 73 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
74 | interregionComms.Initialise(new IniConfigSource()); | 74 | interregionComms.Initialise(new IniConfigSource()); |
75 | interregionComms.PostInitialise(); | 75 | interregionComms.PostInitialise(); |
76 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | 76 | SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); |
77 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); | 77 | SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); |
78 | SceneSetupHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); | 78 | SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); |
79 | 79 | ||
80 | agent1 = UUID.Random(); | 80 | agent1 = UUID.Random(); |
81 | agent2 = UUID.Random(); | 81 | agent2 = UUID.Random(); |
82 | agent3 = UUID.Random(); | 82 | agent3 = UUID.Random(); |
83 | random = new Random(); | 83 | random = new Random(); |
84 | sog1 = NewSOG(UUID.Random(), scene, agent1); | 84 | sog1 = SceneHelpers.CreateSceneObject(1, agent1); |
85 | sog2 = NewSOG(UUID.Random(), scene, agent1); | 85 | scene.AddSceneObject(sog1); |
86 | sog3 = NewSOG(UUID.Random(), scene, agent1); | 86 | sog2 = SceneHelpers.CreateSceneObject(1, agent1); |
87 | scene.AddSceneObject(sog2); | ||
88 | sog3 = SceneHelpers.CreateSceneObject(1, agent1); | ||
89 | scene.AddSceneObject(sog3); | ||
87 | 90 | ||
88 | //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
89 | region1 = scene.RegionInfo.RegionHandle; | 91 | region1 = scene.RegionInfo.RegionHandle; |
90 | region2 = scene2.RegionInfo.RegionHandle; | 92 | region2 = scene2.RegionInfo.RegionHandle; |
91 | region3 = scene3.RegionInfo.RegionHandle; | 93 | region3 = scene3.RegionInfo.RegionHandle; |
92 | } | 94 | } |
93 | 95 | ||
94 | /// <summary> | ||
95 | /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene. | ||
96 | /// </summary> | ||
97 | [Test] | 96 | [Test] |
98 | public void T010_TestAddRootAgent() | 97 | public void TestCloseAgent() |
99 | { | 98 | { |
100 | TestHelper.InMethod(); | 99 | TestHelpers.InMethod(); |
101 | 100 | // log4net.Config.XmlConfigurator.Configure(); | |
102 | string firstName = "testfirstname"; | ||
103 | |||
104 | AgentCircuitData agent = new AgentCircuitData(); | ||
105 | agent.AgentID = agent1; | ||
106 | agent.firstname = firstName; | ||
107 | agent.lastname = "testlastname"; | ||
108 | agent.SessionID = UUID.Random(); | ||
109 | agent.SecureSessionID = UUID.Random(); | ||
110 | agent.circuitcode = 123; | ||
111 | agent.BaseFolder = UUID.Zero; | ||
112 | agent.InventoryFolder = UUID.Zero; | ||
113 | agent.startpos = Vector3.Zero; | ||
114 | agent.CapsPath = GetRandomCapsObjectPath(); | ||
115 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); | ||
116 | agent.child = true; | ||
117 | 101 | ||
118 | scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); | 102 | TestScene scene = SceneHelpers.SetupScene(); |
103 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | ||
119 | 104 | ||
120 | string reason; | 105 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); |
121 | scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); | ||
122 | testclient = new TestClient(agent, scene); | ||
123 | scene.AddNewClient(testclient); | ||
124 | 106 | ||
125 | ScenePresence presence = scene.GetScenePresence(agent1); | 107 | scene.IncomingCloseAgent(sp.UUID); |
126 | 108 | ||
127 | Assert.That(presence, Is.Not.Null, "presence is null"); | 109 | Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); |
128 | Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same"); | 110 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); |
129 | acd1 = agent; | ||
130 | } | 111 | } |
131 | 112 | ||
132 | /// <summary> | 113 | /// <summary> |
133 | /// Test removing an uncrossed root agent from a scene. | 114 | /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region |
134 | /// </summary> | 115 | /// </summary> |
116 | /// <remarks> | ||
117 | /// Please note that unlike the other tests here, this doesn't rely on structures | ||
118 | /// </remarks> | ||
135 | [Test] | 119 | [Test] |
136 | public void T011_TestRemoveRootAgent() | 120 | public void TestChildAgentEstablished() |
137 | { | 121 | { |
138 | TestHelper.InMethod(); | 122 | TestHelpers.InMethod(); |
139 | 123 | // log4net.Config.XmlConfigurator.Configure(); | |
140 | scene.RemoveClient(agent1); | 124 | |
141 | 125 | UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); | |
142 | ScenePresence presence = scene.GetScenePresence(agent1); | 126 | |
127 | TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); | ||
128 | // TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); | ||
129 | |||
130 | IConfigSource configSource = new IniConfigSource(); | ||
131 | configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); | ||
132 | EntityTransferModule etm = new EntityTransferModule(); | ||
133 | |||
134 | SceneHelpers.SetupSceneModules(myScene1, configSource, etm); | ||
135 | |||
136 | SceneHelpers.AddScenePresence(myScene1, agent1Id); | ||
137 | // ScenePresence childPresence = myScene2.GetScenePresence(agent1); | ||
143 | 138 | ||
144 | Assert.That(presence, Is.Null, "presence is not null"); | 139 | // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents |
140 | // Assert.That(childPresence, Is.Not.Null); | ||
141 | // Assert.That(childPresence.IsChildAgent, Is.True); | ||
145 | } | 142 | } |
146 | 143 | ||
144 | // /// <summary> | ||
145 | // /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene. | ||
146 | // /// </summary> | ||
147 | // [Test] | ||
148 | // public void T010_TestAddRootAgent() | ||
149 | // { | ||
150 | // TestHelpers.InMethod(); | ||
151 | // | ||
152 | // string firstName = "testfirstname"; | ||
153 | // | ||
154 | // AgentCircuitData agent = new AgentCircuitData(); | ||
155 | // agent.AgentID = agent1; | ||
156 | // agent.firstname = firstName; | ||
157 | // agent.lastname = "testlastname"; | ||
158 | // agent.SessionID = UUID.Random(); | ||
159 | // agent.SecureSessionID = UUID.Random(); | ||
160 | // agent.circuitcode = 123; | ||
161 | // agent.BaseFolder = UUID.Zero; | ||
162 | // agent.InventoryFolder = UUID.Zero; | ||
163 | // agent.startpos = Vector3.Zero; | ||
164 | // agent.CapsPath = GetRandomCapsObjectPath(); | ||
165 | // agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); | ||
166 | // agent.child = true; | ||
167 | // | ||
168 | // scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); | ||
169 | // | ||
170 | // string reason; | ||
171 | // scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason); | ||
172 | // testclient = new TestClient(agent, scene); | ||
173 | // scene.AddNewClient(testclient); | ||
174 | // | ||
175 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
176 | // | ||
177 | // Assert.That(presence, Is.Not.Null, "presence is null"); | ||
178 | // Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same"); | ||
179 | // acd1 = agent; | ||
180 | // } | ||
181 | // | ||
182 | // /// <summary> | ||
183 | // /// Test removing an uncrossed root agent from a scene. | ||
184 | // /// </summary> | ||
185 | // [Test] | ||
186 | // public void T011_TestRemoveRootAgent() | ||
187 | // { | ||
188 | // TestHelpers.InMethod(); | ||
189 | // | ||
190 | // scene.RemoveClient(agent1); | ||
191 | // | ||
192 | // ScenePresence presence = scene.GetScenePresence(agent1); | ||
193 | // | ||
194 | // Assert.That(presence, Is.Null, "presence is not null"); | ||
195 | // } | ||
196 | |||
147 | [Test] | 197 | [Test] |
148 | public void T012_TestAddNeighbourRegion() | 198 | public void T012_TestAddNeighbourRegion() |
149 | { | 199 | { |
150 | TestHelper.InMethod(); | 200 | TestHelpers.InMethod(); |
151 | 201 | ||
152 | string reason; | 202 | string reason; |
153 | 203 | ||
@@ -157,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
157 | scene.NewUserConnection(acd1, 0, out reason); | 207 | scene.NewUserConnection(acd1, 0, out reason); |
158 | if (testclient == null) | 208 | if (testclient == null) |
159 | testclient = new TestClient(acd1, scene); | 209 | testclient = new TestClient(acd1, scene); |
160 | scene.AddNewClient(testclient); | 210 | scene.AddNewClient(testclient, PresenceType.User); |
161 | 211 | ||
162 | ScenePresence presence = scene.GetScenePresence(agent1); | 212 | ScenePresence presence = scene.GetScenePresence(agent1); |
163 | presence.MakeRootAgent(new Vector3(90,90,90),false); | 213 | presence.MakeRootAgent(new Vector3(90,90,90),false); |
@@ -175,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
175 | [Test] | 225 | [Test] |
176 | public void T013_TestRemoveNeighbourRegion() | 226 | public void T013_TestRemoveNeighbourRegion() |
177 | { | 227 | { |
178 | TestHelper.InMethod(); | 228 | TestHelpers.InMethod(); |
179 | 229 | ||
180 | ScenePresence presence = scene.GetScenePresence(agent1); | 230 | ScenePresence presence = scene.GetScenePresence(agent1); |
181 | presence.RemoveNeighbourRegion(region3); | 231 | presence.RemoveNeighbourRegion(region3); |
@@ -188,37 +238,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
188 | CompleteAvatarMovement | 238 | CompleteAvatarMovement |
189 | */ | 239 | */ |
190 | } | 240 | } |
191 | |||
192 | /// <summary> | ||
193 | /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region | ||
194 | /// </summary> | ||
195 | /// <remarks> | ||
196 | /// Please note that unlike the other tests here, this doesn't rely on structures | ||
197 | /// </remarks> | ||
198 | [Test] | ||
199 | public void TestChildAgentEstablished() | ||
200 | { | ||
201 | TestHelper.InMethod(); | ||
202 | // log4net.Config.XmlConfigurator.Configure(); | ||
203 | |||
204 | UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
205 | |||
206 | TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); | ||
207 | TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); | ||
208 | |||
209 | IConfigSource configSource = new IniConfigSource(); | ||
210 | configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); | ||
211 | EntityTransferModule etm = new EntityTransferModule(); | ||
212 | |||
213 | SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm); | ||
214 | |||
215 | SceneSetupHelpers.AddClient(myScene1, agent1Id); | ||
216 | ScenePresence childPresence = myScene2.GetScenePresence(agent1); | ||
217 | |||
218 | // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents | ||
219 | // Assert.That(childPresence, Is.Not.Null); | ||
220 | // Assert.That(childPresence.IsChildAgent, Is.True); | ||
221 | } | ||
222 | 241 | ||
223 | // I'm commenting this test because it does not represent | 242 | // I'm commenting this test because it does not represent |
224 | // crossings. The Thread.Sleep's in here are not meaningful mocks, | 243 | // crossings. The Thread.Sleep's in here are not meaningful mocks, |
@@ -230,7 +249,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
230 | //[Test] | 249 | //[Test] |
231 | public void T021_TestCrossToNewRegion() | 250 | public void T021_TestCrossToNewRegion() |
232 | { | 251 | { |
233 | TestHelper.InMethod(); | 252 | TestHelpers.InMethod(); |
234 | 253 | ||
235 | scene.RegisterRegionWithGrid(); | 254 | scene.RegisterRegionWithGrid(); |
236 | scene2.RegisterRegionWithGrid(); | 255 | scene2.RegisterRegionWithGrid(); |
@@ -238,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
238 | // Adding child agent to region 1001 | 257 | // Adding child agent to region 1001 |
239 | string reason; | 258 | string reason; |
240 | scene2.NewUserConnection(acd1,0, out reason); | 259 | scene2.NewUserConnection(acd1,0, out reason); |
241 | scene2.AddNewClient(testclient); | 260 | scene2.AddNewClient(testclient, PresenceType.User); |
242 | 261 | ||
243 | ScenePresence presence = scene.GetScenePresence(agent1); | 262 | ScenePresence presence = scene.GetScenePresence(agent1); |
244 | presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); | 263 | presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); |
@@ -349,37 +368,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
349 | capsPath = capsPath.Remove(capsPath.Length - 4, 4); | 368 | capsPath = capsPath.Remove(capsPath.Length - 4, 4); |
350 | return capsPath; | 369 | return capsPath; |
351 | } | 370 | } |
352 | |||
353 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | ||
354 | { | ||
355 | SceneObjectPart sop = new SceneObjectPart(); | ||
356 | sop.Name = RandomName(); | ||
357 | sop.Description = RandomName(); | ||
358 | sop.Text = RandomName(); | ||
359 | sop.SitName = RandomName(); | ||
360 | sop.TouchName = RandomName(); | ||
361 | sop.UUID = uuid; | ||
362 | sop.Shape = PrimitiveBaseShape.Default; | ||
363 | sop.Shape.State = 1; | ||
364 | sop.OwnerID = agent; | ||
365 | |||
366 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
367 | sog.SetScene(scene); | ||
368 | |||
369 | return sog; | ||
370 | } | ||
371 | |||
372 | private static string RandomName() | ||
373 | { | ||
374 | StringBuilder name = new StringBuilder(); | ||
375 | int size = random.Next(5,12); | ||
376 | char ch ; | ||
377 | for (int i=0; i<size; i++) | ||
378 | { | ||
379 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
380 | name.Append(ch); | ||
381 | } | ||
382 | return name.ToString(); | ||
383 | } | ||
384 | } | 371 | } |
385 | } \ No newline at end of file | 372 | } \ No newline at end of file |