aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs174
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs136
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs71
3 files changed, 290 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
new file mode 100644
index 0000000..af44640
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs
@@ -0,0 +1,174 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.Framework.Scenes.Tests
50{
51 /// <summary>
52 /// Attachment tests
53 /// </summary>
54 [TestFixture]
55 public class AttachmentTests
56 {
57 public Scene scene, scene2;
58 public UUID agent1;
59 public static Random random;
60 public ulong region1, region2;
61 public AgentCircuitData acd1;
62 public SceneObjectGroup sog1, sog2, sog3;
63
64 [TestFixtureSetUp]
65 public void Init()
66 {
67 TestHelper.InMethod();
68
69 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
70 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
71
72 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
73 interregionComms.Initialise(new IniConfigSource());
74 interregionComms.PostInitialise();
75 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
76 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
77
78 agent1 = UUID.Random();
79 random = new Random();
80 sog1 = NewSOG(UUID.Random(), scene, agent1);
81 sog2 = NewSOG(UUID.Random(), scene, agent1);
82 sog3 = NewSOG(UUID.Random(), scene, agent1);
83
84 //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
85 region1 = scene.RegionInfo.RegionHandle;
86 region2 = scene2.RegionInfo.RegionHandle;
87
88 SceneSetupHelpers.AddRootAgent(scene, agent1);
89 }
90
91 [Test]
92 public void T030_TestAddAttachments()
93 {
94 TestHelper.InMethod();
95
96 ScenePresence presence = scene.GetScenePresence(agent1);
97
98 presence.AddAttachment(sog1);
99 presence.AddAttachment(sog2);
100 presence.AddAttachment(sog3);
101
102 Assert.That(presence.HasAttachments(), Is.True);
103 Assert.That(presence.ValidateAttachments(), Is.True);
104 }
105
106 [Test]
107 public void T031_RemoveAttachments()
108 {
109 TestHelper.InMethod();
110
111 ScenePresence presence = scene.GetScenePresence(agent1);
112 presence.RemoveAttachment(sog1);
113 presence.RemoveAttachment(sog2);
114 presence.RemoveAttachment(sog3);
115 Assert.That(presence.HasAttachments(), Is.False);
116 }
117
118 // I'm commenting this test because scene setup NEEDS InventoryService to
119 // be non-null
120 //[Test]
121 public void T032_CrossAttachments()
122 {
123 TestHelper.InMethod();
124
125 ScenePresence presence = scene.GetScenePresence(agent1);
126 ScenePresence presence2 = scene2.GetScenePresence(agent1);
127 presence2.AddAttachment(sog1);
128 presence2.AddAttachment(sog2);
129
130 ISharedRegionModule serialiser = new SerialiserModule();
131 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
132 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
133
134 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
135
136 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
137 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
138 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
139 }
140
141 private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent)
142 {
143 SceneObjectPart sop = new SceneObjectPart();
144 sop.Name = RandomName();
145 sop.Description = RandomName();
146 sop.Text = RandomName();
147 sop.SitName = RandomName();
148 sop.TouchName = RandomName();
149 sop.UUID = uuid;
150 sop.Shape = PrimitiveBaseShape.Default;
151 sop.Shape.State = 1;
152 sop.OwnerID = agent;
153
154 SceneObjectGroup sog = new SceneObjectGroup(sop);
155 sog.SetScene(scene);
156
157 return sog;
158 }
159
160 private static string RandomName()
161 {
162 StringBuilder name = new StringBuilder();
163 int size = random.Next(5,12);
164 char ch;
165 for (int i = 0; i < size; i++)
166 {
167 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
168 name.Append(ch);
169 }
170
171 return name.ToString();
172 }
173 }
174} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index ef52363..fd2d6fa 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
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;
@@ -116,9 +117,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
116 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); 117 agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
117 agent.child = true; 118 agent.child = true;
118 119
119 if (scene.PresenceService == null)
120 Console.WriteLine("Presence Service is null");
121
122 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); 120 scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
123 121
124 string reason; 122 string reason;
@@ -175,25 +173,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
175 173
176 Assert.That(neighbours.Count, Is.EqualTo(2)); 174 Assert.That(neighbours.Count, Is.EqualTo(2));
177 } 175 }
178
179 public void fixNullPresence()
180 {
181 string firstName = "testfirstname";
182
183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = agent1;
185 agent.firstname = firstName;
186 agent.lastname = "testlastname";
187 agent.SessionID = UUID.Zero;
188 agent.SecureSessionID = UUID.Zero;
189 agent.circuitcode = 123;
190 agent.BaseFolder = UUID.Zero;
191 agent.InventoryFolder = UUID.Zero;
192 agent.startpos = Vector3.Zero;
193 agent.CapsPath = GetRandomCapsObjectPath();
194
195 acd1 = agent;
196 }
197 176
198 [Test] 177 [Test]
199 public void T013_TestRemoveNeighbourRegion() 178 public void T013_TestRemoveNeighbourRegion()
@@ -211,24 +190,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests
211 CompleteAvatarMovement 190 CompleteAvatarMovement
212 */ 191 */
213 } 192 }
214 193
215 // I'm commenting this test, because this is not supposed to happen here 194 /// <summary>
216 //[Test] 195 /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region
217 public void T020_TestMakeRootAgent() 196 /// </summary>
197 /// <remarks>
198 /// Please note that unlike the other tests here, this doesn't rely on structures
199 /// </remarks>
200 [Test]
201 public void TestChildAgentEstablished()
218 { 202 {
219 TestHelper.InMethod(); 203 TestHelper.InMethod();
220 204// log4net.Config.XmlConfigurator.Configure();
221 ScenePresence presence = scene.GetScenePresence(agent1); 205
222 Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); 206 UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
223 207
224 presence.MakeChildAgent(); 208 TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
225 Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); 209 TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
226 210
227 // Accepts 0 but rejects Constants.RegionSize 211 IConfigSource configSource = new IniConfigSource();
228 Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); 212 configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule");
229 presence.MakeRootAgent(pos,true); 213 EntityTransferModule etm = new EntityTransferModule();
230 Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); 214
231 Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); 215 SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm);
216
217 SceneSetupHelpers.AddRootAgent(myScene1, agent1Id);
218 ScenePresence childPresence = myScene2.GetScenePresence(agent1);
219
220 // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents
221// Assert.That(childPresence, Is.Not.Null);
222// Assert.That(childPresence.IsChildAgent, Is.True);
232 } 223 }
233 224
234 // I'm commenting this test because it does not represent 225 // I'm commenting this test because it does not represent
@@ -333,63 +324,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); 324 Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
334 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); 325 Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
335 } 326 }
336 327
337 [Test] 328 public void fixNullPresence()
338 public void T030_TestAddAttachments()
339 {
340 TestHelper.InMethod();
341
342 ScenePresence presence = scene.GetScenePresence(agent1);
343
344 presence.AddAttachment(sog1);
345 presence.AddAttachment(sog2);
346 presence.AddAttachment(sog3);
347
348 Assert.That(presence.HasAttachments(), Is.True);
349 Assert.That(presence.ValidateAttachments(), Is.True);
350 }
351
352 [Test]
353 public void T031_RemoveAttachments()
354 {
355 TestHelper.InMethod();
356
357 ScenePresence presence = scene.GetScenePresence(agent1);
358 presence.RemoveAttachment(sog1);
359 presence.RemoveAttachment(sog2);
360 presence.RemoveAttachment(sog3);
361 Assert.That(presence.HasAttachments(), Is.False);
362 }
363
364 // I'm commenting this test because scene setup NEEDS InventoryService to
365 // be non-null
366 //[Test]
367 public void T032_CrossAttachments()
368 { 329 {
369 TestHelper.InMethod(); 330 string firstName = "testfirstname";
370
371 ScenePresence presence = scene.GetScenePresence(agent1);
372 ScenePresence presence2 = scene2.GetScenePresence(agent1);
373 presence2.AddAttachment(sog1);
374 presence2.AddAttachment(sog2);
375
376 ISharedRegionModule serialiser = new SerialiserModule();
377 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
378 SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);
379
380 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
381 331
382 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 332 AgentCircuitData agent = new AgentCircuitData();
383 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 333 agent.AgentID = agent1;
384 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 334 agent.firstname = firstName;
385 } 335 agent.lastname = "testlastname";
336 agent.SessionID = UUID.Zero;
337 agent.SecureSessionID = UUID.Zero;
338 agent.circuitcode = 123;
339 agent.BaseFolder = UUID.Zero;
340 agent.InventoryFolder = UUID.Zero;
341 agent.startpos = Vector3.Zero;
342 agent.CapsPath = GetRandomCapsObjectPath();
386 343
387 [TearDown] 344 acd1 = agent;
388 public void TearDown()
389 {
390 if (MainServer.Instance != null) MainServer.Instance.Stop();
391 } 345 }
392 346
393 public static string GetRandomCapsObjectPath() 347 public static string GetRandomCapsObjectPath()
394 { 348 {
395 UUID caps = UUID.Random(); 349 UUID caps = UUID.Random();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
new file mode 100644
index 0000000..9aba8a8
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse;
39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup;
48
49namespace OpenSim.Region.Framework.Scenes.Tests
50{
51 /// <summary>
52 /// Scene presence tests
53 /// </summary>
54 [TestFixture]
55 public class SceneTests
56 {
57 /// <summary>
58 /// Very basic scene update test. Should become more elaborate with time.
59 /// </summary>
60 [Test]
61 public void TestUpdateScene()
62 {
63 TestHelper.InMethod();
64
65 Scene scene = SceneSetupHelpers.SetupScene();
66 scene.Update();
67
68 Assert.That(scene.Frame, Is.EqualTo(1));
69 }
70 }
71} \ No newline at end of file