diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs | 180 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | 50 |
2 files changed, 180 insertions, 50 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..60e47f6 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs | |||
@@ -0,0 +1,180 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.Framework.Interfaces; | ||
43 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | using OpenSim.Tests.Common.Setup; | ||
48 | |||
49 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// Scene presence 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 | [TearDown] | ||
92 | public void TearDown() | ||
93 | { | ||
94 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
95 | } | ||
96 | |||
97 | [Test] | ||
98 | public void T030_TestAddAttachments() | ||
99 | { | ||
100 | TestHelper.InMethod(); | ||
101 | |||
102 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
103 | |||
104 | presence.AddAttachment(sog1); | ||
105 | presence.AddAttachment(sog2); | ||
106 | presence.AddAttachment(sog3); | ||
107 | |||
108 | Assert.That(presence.HasAttachments(), Is.True); | ||
109 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
110 | } | ||
111 | |||
112 | [Test] | ||
113 | public void T031_RemoveAttachments() | ||
114 | { | ||
115 | TestHelper.InMethod(); | ||
116 | |||
117 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
118 | presence.RemoveAttachment(sog1); | ||
119 | presence.RemoveAttachment(sog2); | ||
120 | presence.RemoveAttachment(sog3); | ||
121 | Assert.That(presence.HasAttachments(), Is.False); | ||
122 | } | ||
123 | |||
124 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
125 | // be non-null | ||
126 | //[Test] | ||
127 | public void T032_CrossAttachments() | ||
128 | { | ||
129 | TestHelper.InMethod(); | ||
130 | |||
131 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
132 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
133 | presence2.AddAttachment(sog1); | ||
134 | presence2.AddAttachment(sog2); | ||
135 | |||
136 | ISharedRegionModule serialiser = new SerialiserModule(); | ||
137 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
138 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
139 | |||
140 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
141 | |||
142 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
143 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
144 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
145 | } | ||
146 | |||
147 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | ||
148 | { | ||
149 | SceneObjectPart sop = new SceneObjectPart(); | ||
150 | sop.Name = RandomName(); | ||
151 | sop.Description = RandomName(); | ||
152 | sop.Text = RandomName(); | ||
153 | sop.SitName = RandomName(); | ||
154 | sop.TouchName = RandomName(); | ||
155 | sop.UUID = uuid; | ||
156 | sop.Shape = PrimitiveBaseShape.Default; | ||
157 | sop.Shape.State = 1; | ||
158 | sop.OwnerID = agent; | ||
159 | |||
160 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
161 | sog.SetScene(scene); | ||
162 | |||
163 | return sog; | ||
164 | } | ||
165 | |||
166 | private static string RandomName() | ||
167 | { | ||
168 | StringBuilder name = new StringBuilder(); | ||
169 | int size = random.Next(5,12); | ||
170 | char ch; | ||
171 | for (int i = 0; i < size; i++) | ||
172 | { | ||
173 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
174 | name.Append(ch); | ||
175 | } | ||
176 | |||
177 | return name.ToString(); | ||
178 | } | ||
179 | } | ||
180 | } \ 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 8286e4f..d82760e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -331,56 +331,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
331 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); | 331 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); |
332 | } | 332 | } |
333 | 333 | ||
334 | [Test] | ||
335 | public void T030_TestAddAttachments() | ||
336 | { | ||
337 | TestHelper.InMethod(); | ||
338 | |||
339 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
340 | |||
341 | presence.AddAttachment(sog1); | ||
342 | presence.AddAttachment(sog2); | ||
343 | presence.AddAttachment(sog3); | ||
344 | |||
345 | Assert.That(presence.HasAttachments(), Is.True); | ||
346 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
347 | } | ||
348 | |||
349 | [Test] | ||
350 | public void T031_RemoveAttachments() | ||
351 | { | ||
352 | TestHelper.InMethod(); | ||
353 | |||
354 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
355 | presence.RemoveAttachment(sog1); | ||
356 | presence.RemoveAttachment(sog2); | ||
357 | presence.RemoveAttachment(sog3); | ||
358 | Assert.That(presence.HasAttachments(), Is.False); | ||
359 | } | ||
360 | |||
361 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
362 | // be non-null | ||
363 | //[Test] | ||
364 | public void T032_CrossAttachments() | ||
365 | { | ||
366 | TestHelper.InMethod(); | ||
367 | |||
368 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
369 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
370 | presence2.AddAttachment(sog1); | ||
371 | presence2.AddAttachment(sog2); | ||
372 | |||
373 | ISharedRegionModule serialiser = new SerialiserModule(); | ||
374 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
375 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
376 | |||
377 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
378 | |||
379 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
380 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
381 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
382 | } | ||
383 | |||
384 | [TearDown] | 334 | [TearDown] |
385 | public void TearDown() | 335 | public void TearDown() |
386 | { | 336 | { |