aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorSean Dague2009-01-28 19:23:20 +0000
committerSean Dague2009-01-28 19:23:20 +0000
commit25e241837bed9d6132dc265fac372ddc47986240 (patch)
treeb5eb6713d3f0163ef12bc5db0f51fad5f9862544 /OpenSim/Region
parentfix: client gets logged out when concierge's broker returns 500 (diff)
downloadopensim-SC_OLD-25e241837bed9d6132dc265fac372ddc47986240.zip
opensim-SC_OLD-25e241837bed9d6132dc265fac372ddc47986240.tar.gz
opensim-SC_OLD-25e241837bed9d6132dc265fac372ddc47986240.tar.bz2
opensim-SC_OLD-25e241837bed9d6132dc265fac372ddc47986240.tar.xz
* Enhanced ScenePresenceTests. Now tests for region and prim crossing.
From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs260
1 files changed, 230 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
index 5649b16..280b5df 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/ScenePresenceTests.cs
@@ -25,34 +25,71 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using Nini.Config;
29using System;
30using System.Collections.Generic;
31using System.Text;
28using NUnit.Framework; 32using NUnit.Framework;
29using NUnit.Framework.SyntaxHelpers; 33using NUnit.Framework.SyntaxHelpers;
30using OpenMetaverse; 34using OpenMetaverse;
31using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
32using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
38using OpenSim.Region.Environment.Interfaces;
39using OpenSim.Region.Environment.Modules.Communications.Local;
40using OpenSim.Region.Environment.Modules.World.Serialiser;
33using OpenSim.Tests.Common.Mock; 41using OpenSim.Tests.Common.Mock;
34using OpenSim.Tests.Common.Setup; 42using OpenSim.Tests.Common.Setup;
35 43
36namespace OpenSim.Region.Environment.Scenes.Tests 44namespace OpenSim.Region.Environment.Scenes.Tests
37{ 45{
38 /// <summary> 46 /// <summary>
39 /// Scene presence tests 47 /// Scene presence tests
40 /// </summary> 48 /// </summary>
41 [TestFixture] 49 [TestFixture]
42 public class ScenePresenceTests 50 public class ScenePresenceTests
43 { 51 {
52 public Scene scene, scene2, scene3;
53 public UUID agent1, agent2, agent3;
54 public static Random random;
55 public ulong region1,region2,region3;
56 public CommunicationsManager cm;
57 public AgentCircuitData acd1;
58 public SceneObjectGroup sog1, sog2, sog3;
59 public TestClient testclient;
60
61 [TestFixtureSetUp]
62 public void Init()
63 {
64 cm = new TestCommunicationsManager();
65 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm);
66 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm);
67 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
68
69 agent1 = UUID.Random();
70 agent2 = UUID.Random();
71 agent3 = UUID.Random();
72 random = new Random();
73 sog1 = NewSOG(UUID.Random(), scene, agent1);
74 sog2 = NewSOG(UUID.Random(), scene, agent1);
75 sog3 = NewSOG(UUID.Random(), scene, agent1);
76
77 //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
78 region1 = scene.RegionInfo.RegionHandle;
79 region2 = scene2.RegionInfo.RegionHandle;
80 region3 = scene3.RegionInfo.RegionHandle;
81 }
82
44 /// <summary> 83 /// <summary>
45 /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene. 84 /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
46 /// </summary> 85 /// </summary>
47 [Test] 86 [Test]
48 public void TestAddRootAgent() 87 public void T010_TestAddRootAgent()
49 { 88 {
50 Scene scene = SceneSetupHelpers.SetupScene();
51 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
52 string firstName = "testfirstname"; 89 string firstName = "testfirstname";
53 90
54 AgentCircuitData agent = new AgentCircuitData(); 91 AgentCircuitData agent = new AgentCircuitData();
55 agent.AgentID = agentId; 92 agent.AgentID = agent1;
56 agent.firstname = firstName; 93 agent.firstname = firstName;
57 agent.lastname = "testlastname"; 94 agent.lastname = "testlastname";
58 agent.SessionID = UUID.Zero; 95 agent.SessionID = UUID.Zero;
@@ -61,33 +98,196 @@ namespace OpenSim.Region.Environment.Scenes.Tests
61 agent.BaseFolder = UUID.Zero; 98 agent.BaseFolder = UUID.Zero;
62 agent.InventoryFolder = UUID.Zero; 99 agent.InventoryFolder = UUID.Zero;
63 agent.startpos = Vector3.Zero; 100 agent.startpos = Vector3.Zero;
64 agent.CapsPath = "http://wibble.com"; 101 agent.CapsPath = GetRandomCapsObjectPath();
65 102
66 scene.NewUserConnection(agent); 103 scene.NewUserConnection(agent);
67 scene.AddNewClient(new TestClient(agent, scene)); 104 testclient = new TestClient(agent, scene);
68 105 scene.AddNewClient(testclient);
69 ScenePresence presence = scene.GetScenePresence(agentId); 106
70 107 ScenePresence presence = scene.GetScenePresence(agent1);
108
71 Assert.That(presence, Is.Not.Null, "presence is null"); 109 Assert.That(presence, Is.Not.Null, "presence is null");
72 Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same"); 110 Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
111 acd1 = agent;
73 } 112 }
74 113
75 /// <summary> 114 /// <summary>
76 /// Test removing an uncrossed root agent from a scene. 115 /// Test removing an uncrossed root agent from a scene.
77 /// </summary> 116 /// </summary>
78 [Test] 117 [Test]
79 public void TestRemoveRootAgent() 118 public void T011_TestRemoveRootAgent()
119 {
120 scene.RemoveClient(agent1);
121
122 ScenePresence presence = scene.GetScenePresence(agent1);
123
124 Assert.That(presence, Is.Null, "presence is not null");
125 }
126
127 [Test]
128 public void T012_TestAddNeighbourRegion()
129 {
130 SceneSetupHelpers.AddRootAgent(scene,agent1);
131
132 ScenePresence presence = scene.GetScenePresence(agent1);
133
134 string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
135
136 presence.AddNeighbourRegion(region2, cap);
137 presence.AddNeighbourRegion(region3, cap);
138
139 List<ulong> neighbours = presence.GetKnownRegionList();
140
141 Assert.That(neighbours.Count, Is.EqualTo(2));
142 }
143
144 [Test]
145 public void T013_TestRemoveNeighbourRegion()
146 {
147 ScenePresence presence = scene.GetScenePresence(agent1);
148 presence.RemoveNeighbourRegion(region3);
149
150 List<ulong> neighbours = presence.GetKnownRegionList();
151 Assert.That(neighbours.Count,Is.EqualTo(1));
152 /*
153 presence.MakeChildAgent;
154 presence.MakeRootAgent;
155 CompleteAvatarMovement
156 */
157 }
158
159 [Test]
160 public void T020_TestMakeRootAgent()
161 {
162 ScenePresence presence = scene.GetScenePresence(agent1);
163 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent");
164
165 presence.MakeChildAgent();
166 Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent");
167
168 // Accepts 0 but rejects Constants.RegionSize
169 Vector3 pos = new Vector3(0,Constants.RegionSize-1,0);
170 presence.MakeRootAgent(pos,true);
171 Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent");
172 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered");
173 }
174
175 [Test]
176 public void T021_TestCrossToNewRegion()
177 {
178 // Adding child agent to region 1001
179 scene2.NewUserConnection(acd1);
180 scene2.AddNewClient(testclient);
181
182 ScenePresence presence = scene.GetScenePresence(agent1);
183 ScenePresence presence2 = scene2.GetScenePresence(agent1);
184
185 // Adding neighbour region caps info to presence2
186 string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
187 presence2.AddNeighbourRegion(region1, cap);
188
189 Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
190 Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
191
192 // Cross to x+1
193 presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
194 scene.RegisterRegionWithGrid();
195 scene2.RegisterRegionWithGrid();
196 presence.Update();
197
198 Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
199 Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
200
201 // Cross Back
202 presence2.AbsolutePosition = new Vector3(-1, 3, 100);
203 presence2.Update();
204
205 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
206 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
207 }
208
209 [Test]
210 public void T030_TestAddAttachments()
211 {
212 ScenePresence presence = scene.GetScenePresence(agent1);
213
214 presence.AddAttachment(sog1);
215 presence.AddAttachment(sog2);
216 presence.AddAttachment(sog3);
217
218 Assert.That(presence.HasAttachments(), Is.True);
219 Assert.That(presence.ValidateAttachments(), Is.True);
220 }
221
222 [Test]
223 public void T031_RemoveAttachments()
224 {
225 ScenePresence presence = scene.GetScenePresence(agent1);
226 presence.RemoveAttachment(sog1);
227 presence.RemoveAttachment(sog2);
228 presence.RemoveAttachment(sog3);
229 Assert.That(presence.HasAttachments(), Is.False);
230 }
231
232 [Test]
233 public void T032_CrossAttachments()
234 {
235 ScenePresence presence = scene.GetScenePresence(agent1);
236 ScenePresence presence2 = scene2.GetScenePresence(agent1);
237 presence2.AddAttachment(sog1);
238 presence2.AddAttachment(sog2);
239
240 IRegionModule serialiser = new SerialiserModule();
241 IRegionModule ircomms = new LocalInterregionComms();
242 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
243 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
244
245 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
246
247 Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
248 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
249 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
250 }
251
252 public static string GetRandomCapsObjectPath()
253 {
254 UUID caps = UUID.Random();
255 string capsPath = caps.ToString();
256 capsPath = capsPath.Remove(capsPath.Length - 4, 4);
257 return capsPath;
258 }
259
260 private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
261 {
262 SceneObjectPart sop = new SceneObjectPart();
263 sop.Name = RandomName();
264 sop.Description = RandomName();
265 sop.Text = RandomName();
266 sop.SitName = RandomName();
267 sop.TouchName = RandomName();
268 sop.UUID = uuid;
269 sop.Shape = PrimitiveBaseShape.Default;
270 sop.Shape.State = 1;
271 sop.OwnerID = agent;
272
273 SceneObjectGroup sog = new SceneObjectGroup();
274 sog.SetScene(scene);
275 sog.SetRootPart(sop);
276
277 return sog;
278 }
279
280 private static string RandomName()
80 { 281 {
81 Scene scene = SceneSetupHelpers.SetupScene(); 282 StringBuilder name = new StringBuilder();
82 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 283 int size = random.Next(5,12);
83 284 char ch ;
84 SceneSetupHelpers.AddRootAgent(scene, agentId); 285 for (int i=0; i<size; i++)
85 286 {
86 scene.RemoveClient(agentId); 287 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
87 288 name.Append(ch);
88 ScenePresence presence = scene.GetScenePresence(agentId); 289 }
89 290 return name.ToString();
90 Assert.That(presence, Is.Null, "presence is not null");
91 } 291 }
92 } 292 }
93} 293}