aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs71
1 files changed, 55 insertions, 16 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index 17769cb..c781305 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -30,6 +30,8 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Text; 31using System.Text;
32using System.Threading; 32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
33using Nini.Config; 35using Nini.Config;
34using NUnit.Framework; 36using NUnit.Framework;
35using NUnit.Framework.SyntaxHelpers; 37using NUnit.Framework.SyntaxHelpers;
@@ -98,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
98 public void T010_TestAddRootAgent() 100 public void T010_TestAddRootAgent()
99 { 101 {
100 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 102 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
101 103
102 string firstName = "testfirstname"; 104 string firstName = "testfirstname";
103 105
104 AgentCircuitData agent = new AgentCircuitData(); 106 AgentCircuitData agent = new AgentCircuitData();
@@ -131,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
131 public void T011_TestRemoveRootAgent() 133 public void T011_TestRemoveRootAgent()
132 { 134 {
133 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 135 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
134 136
135 scene.RemoveClient(agent1); 137 scene.RemoveClient(agent1);
136 138
137 ScenePresence presence = scene.GetScenePresence(agent1); 139 ScenePresence presence = scene.GetScenePresence(agent1);
@@ -143,7 +145,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
143 public void T012_TestAddNeighbourRegion() 145 public void T012_TestAddNeighbourRegion()
144 { 146 {
145 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 147 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
146 148
147 scene.NewUserConnection(acd1); 149 scene.NewUserConnection(acd1);
148 scene.AddNewClient(testclient); 150 scene.AddNewClient(testclient);
149 151
@@ -164,7 +166,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
164 public void T013_TestRemoveNeighbourRegion() 166 public void T013_TestRemoveNeighbourRegion()
165 { 167 {
166 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 168 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
167 169
168 ScenePresence presence = scene.GetScenePresence(agent1); 170 ScenePresence presence = scene.GetScenePresence(agent1);
169 presence.RemoveNeighbourRegion(region3); 171 presence.RemoveNeighbourRegion(region3);
170 172
@@ -181,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
181 public void T020_TestMakeRootAgent() 183 public void T020_TestMakeRootAgent()
182 { 184 {
183 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 185 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
184 186
185 ScenePresence presence = scene.GetScenePresence(agent1); 187 ScenePresence presence = scene.GetScenePresence(agent1);
186 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); 188 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent");
187 189
@@ -195,11 +197,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
195 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); 197 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered");
196 } 198 }
197 199
198 //[Test] 200 [Test]
199 public void T021_TestCrossToNewRegion() 201 public void T021_TestCrossToNewRegion()
200 { 202 {
201 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 203 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
202 204
203 // Adding child agent to region 1001 205 // Adding child agent to region 1001
204 scene2.NewUserConnection(acd1); 206 scene2.NewUserConnection(acd1);
205 scene2.AddNewClient(testclient); 207 scene2.AddNewClient(testclient);
@@ -225,15 +227,35 @@ namespace OpenSim.Region.Framework.Scenes.Tests
225 227
226 // Mimicking communication between client and server, by waiting OK from client 228 // Mimicking communication between client and server, by waiting OK from client
227 // sent by TestClient.CrossRegion call. Originally, this is network comm. 229 // sent by TestClient.CrossRegion call. Originally, this is network comm.
228 wh.WaitOne(); 230 if (!wh.WaitOne(5000,false))
231 {
232 presence.Update();
233 if (!wh.WaitOne(8000,false))
234 throw new ArgumentException("1 - Timeout waiting for signal/variable.");
235 }
229 236
230 // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which 237 // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
231 // would normally be fired after receiving the reply packet from comm. done on the last line. 238 // would normally be fired after receiving the reply packet from comm. done on the last line.
232 testclient.CompleteMovement(); 239 testclient.CompleteMovement();
233 240
234 // Crossings are asynchronous 241 // Crossings are asynchronous
235 while (presence.IsInTransit) { }; 242 int timer = 10;
236 243
244 // Make sure cross hasn't already finished
245 if (!presence.IsInTransit && !presence.IsChildAgent)
246 {
247 // If not and not in transit yet, give it some more time
248 Thread.Sleep(5000);
249 }
250
251 // Enough time, should at least be in transit by now.
252 while (presence.IsInTransit && timer > 0)
253 {
254 Thread.Sleep(1000);
255 timer-=1;
256 }
257
258 Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1.");
237 Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected."); 259 Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
238 Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent."); 260 Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
239 261
@@ -241,11 +263,28 @@ namespace OpenSim.Region.Framework.Scenes.Tests
241 presence2.AbsolutePosition = new Vector3(-10, 3, 100); 263 presence2.AbsolutePosition = new Vector3(-10, 3, 100);
242 presence2.Update(); 264 presence2.Update();
243 265
244 wh.WaitOne(); 266 if (!wh.WaitOne(5000,false))
267 {
268 presence2.Update();
269 if (!wh.WaitOne(8000,false))
270 throw new ArgumentException("2 - Timeout waiting for signal/variable.");
271 }
245 testclient.CompleteMovement(); 272 testclient.CompleteMovement();
246 273
247 while (presence2.IsInTransit) { }; 274 if (!presence2.IsInTransit && !presence2.IsChildAgent)
275 {
276 // If not and not in transit yet, give it some more time
277 Thread.Sleep(5000);
278 }
248 279
280 // Enough time, should at least be in transit by now.
281 while (presence2.IsInTransit && timer > 0)
282 {
283 Thread.Sleep(1000);
284 timer-=1;
285 }
286
287 Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2.");
249 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 288 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
250 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 289 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
251 } 290 }
@@ -254,7 +293,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
254 public void T030_TestAddAttachments() 293 public void T030_TestAddAttachments()
255 { 294 {
256 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 295 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
257 296
258 ScenePresence presence = scene.GetScenePresence(agent1); 297 ScenePresence presence = scene.GetScenePresence(agent1);
259 298
260 presence.AddAttachment(sog1); 299 presence.AddAttachment(sog1);
@@ -269,7 +308,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
269 public void T031_RemoveAttachments() 308 public void T031_RemoveAttachments()
270 { 309 {
271 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 310 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
272 311
273 ScenePresence presence = scene.GetScenePresence(agent1); 312 ScenePresence presence = scene.GetScenePresence(agent1);
274 presence.RemoveAttachment(sog1); 313 presence.RemoveAttachment(sog1);
275 presence.RemoveAttachment(sog2); 314 presence.RemoveAttachment(sog2);
@@ -277,11 +316,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
277 Assert.That(presence.HasAttachments(), Is.False); 316 Assert.That(presence.HasAttachments(), Is.False);
278 } 317 }
279 318
280 //[Test] 319 [Test]
281 public void T032_CrossAttachments() 320 public void T032_CrossAttachments()
282 { 321 {
283 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 322 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
284 323
285 ScenePresence presence = scene.GetScenePresence(agent1); 324 ScenePresence presence = scene.GetScenePresence(agent1);
286 ScenePresence presence2 = scene2.GetScenePresence(agent1); 325 ScenePresence presence2 = scene2.GetScenePresence(agent1);
287 presence2.AddAttachment(sog1); 326 presence2.AddAttachment(sog1);
@@ -301,7 +340,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
301 public static string GetRandomCapsObjectPath() 340 public static string GetRandomCapsObjectPath()
302 { 341 {
303 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 342 Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod());
304 343
305 UUID caps = UUID.Random(); 344 UUID caps = UUID.Random();
306 string capsPath = caps.ToString(); 345 string capsPath = caps.ToString();
307 capsPath = capsPath.Remove(capsPath.Length - 4, 4); 346 capsPath = capsPath.Remove(capsPath.Length - 4, 4);