aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Framework/Scenes/Tests
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs346
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs259
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs111
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs39
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs135
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs218
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs86
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs247
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs81
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs302
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs69
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs118
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs249
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs91
29 files changed, 2150 insertions, 310 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index 766ce83..da18941 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -34,7 +34,6 @@ using Nini.Config;
34using NUnit.Framework; 34using NUnit.Framework;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
39using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
40 39
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 575a081..ee7c8a9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -32,10 +32,8 @@ using System.Text;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
37using OpenSim.Tests.Common; 36using OpenSim.Tests.Common;
38using OpenSim.Tests.Common.Mock;
39 37
40namespace OpenSim.Region.Framework.Scenes.Tests 38namespace OpenSim.Region.Framework.Scenes.Tests
41{ 39{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
index 2d831fa..3172227 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs
@@ -32,11 +32,9 @@ using System.Threading;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40 38
41namespace OpenSim.Region.Framework.Scenes.Tests 39namespace OpenSim.Region.Framework.Scenes.Tests
42{ 40{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index a07d64c..098f1b4 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -33,11 +33,9 @@ using Nini.Config;
33using NUnit.Framework; 33using NUnit.Framework;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
39using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock;
41 39
42namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
43{ 41{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs
new file mode 100644
index 0000000..0b196c1
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs
@@ -0,0 +1,346 @@
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 Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.CoreModules.Framework.EntityTransfer;
36using OpenSim.Region.CoreModules.Framework.InventoryAccess;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Region.CoreModules.World.Permissions;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces;
41using OpenSim.Tests.Common;
42
43namespace OpenSim.Region.Framework.Scenes.Tests
44{
45 /// <summary>
46 /// Test copying of scene objects.
47 /// </summary>
48 /// <remarks>
49 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly.
50 /// </remarks>
51 [TestFixture]
52 public class SceneObjectCopyTests : OpenSimTestCase
53 {
54 [TestFixtureSetUp]
55 public void FixtureInit()
56 {
57 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
58 // This facility was added after the original async delete tests were written, so it may be possible now
59 // to not bother explicitly disabling their async (since everything will be running sync).
60 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
61 }
62
63 [TestFixtureTearDown]
64 public void TearDown()
65 {
66 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
67 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
68 // tests really shouldn't).
69 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
70 }
71
72 [Test]
73 public void TestTakeCopyWhenCopierIsOwnerWithPerms()
74 {
75 TestHelpers.InMethod();
76// TestHelpers.EnableLogging();
77
78 IConfigSource config = new IniConfigSource();
79 config.AddConfig("Modules");
80 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
81
82 TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);
83 SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
84 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
85 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;
86
87 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
88 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
89 sogd.Enabled = false;
90
91 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID);
92 uint soLocalId = so.LocalId;
93// so.UpdatePermissions(
94// ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1);
95// so.UpdatePermissions(
96// ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
97// so.UpdatePermissions(
98// ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
99// scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
100
101 // Ideally we might change these via client-focussed method calls as commented out above. However, this
102 // becomes very convoluted so we will set only the copy perm directly.
103 so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy;
104// so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy;
105
106 List<uint> localIds = new List<uint>();
107 localIds.Add(so.LocalId);
108
109 // Specifying a UUID.Zero in this case will currently plop it in Lost and Found
110 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);
111
112 // Check that object isn't copied until we crank the sogd handle.
113 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
114 Assert.That(retrievedPart, Is.Not.Null);
115 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
116
117 sogd.InventoryDeQueueAndDelete();
118
119 // Check that object is still there.
120 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
121 Assert.That(retrievedPart2, Is.Not.Null);
122 Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));
123
124 // Check that we have a copy in inventory
125 InventoryItemBase item
126 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1");
127 Assert.That(item, Is.Not.Null);
128 }
129
130 [Test]
131 public void TestTakeCopyWhenCopierIsOwnerWithoutPerms()
132 {
133 TestHelpers.InMethod();
134// TestHelpers.EnableLogging();
135
136 IConfigSource config = new IniConfigSource();
137 config.AddConfig("Modules");
138 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
139
140 TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);
141 SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
142 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
143 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;
144
145 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
146 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
147 sogd.Enabled = false;
148
149 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID);
150 uint soLocalId = so.LocalId;
151
152 so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy);
153 //so.RootPart.OwnerMask = (uint)(OpenMetaverse.PermissionMask.Copy & ~OpenMetaverse.PermissionMask.Copy);
154
155 List<uint> localIds = new List<uint>();
156 localIds.Add(so.LocalId);
157
158 // Specifying a UUID.Zero in this case will currently plop it in Lost and Found
159 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);
160
161 // Check that object isn't copied until we crank the sogd handle.
162 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
163 Assert.That(retrievedPart, Is.Not.Null);
164 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
165
166 sogd.InventoryDeQueueAndDelete();
167
168 // Check that object is still there.
169 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
170 Assert.That(retrievedPart2, Is.Not.Null);
171 Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));
172
173 // Check that we do not have a copy in inventory
174 InventoryItemBase item
175 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1");
176 Assert.That(item, Is.Null);
177 }
178
179 [Test]
180 public void TestTakeCopyWhenCopierIsNotOwnerWithPerms()
181 {
182 TestHelpers.InMethod();
183// TestHelpers.EnableLogging();
184
185 IConfigSource config = new IniConfigSource();
186 config.AddConfig("Modules");
187 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
188
189 TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);
190 SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
191 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
192 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;
193
194 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
195 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
196 sogd.Enabled = false;
197
198 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2));
199 uint soLocalId = so.LocalId;
200
201 // Base must allow transfer and copy
202 so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer);
203 // Must be set so anyone can copy
204 so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy;
205
206 List<uint> localIds = new List<uint>();
207 localIds.Add(so.LocalId);
208
209 // Specifying a UUID.Zero in this case will plop it in the Objects folder
210 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);
211
212 // Check that object isn't copied until we crank the sogd handle.
213 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
214 Assert.That(retrievedPart, Is.Not.Null);
215 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
216
217 sogd.InventoryDeQueueAndDelete();
218
219 // Check that object is still there.
220 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
221 Assert.That(retrievedPart2, Is.Not.Null);
222 Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));
223
224 // Check that we have a copy in inventory
225 InventoryItemBase item
226 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
227 Assert.That(item, Is.Not.Null);
228 }
229
230 [Test]
231 public void TestTakeCopyWhenCopierIsNotOwnerWithoutPerms()
232 {
233 TestHelpers.InMethod();
234// TestHelpers.EnableLogging();
235
236 IConfigSource config = new IniConfigSource();
237 config.AddConfig("Modules");
238 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
239
240 TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);
241 SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
242 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
243 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;
244
245 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
246 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
247 sogd.Enabled = false;
248
249 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2));
250 uint soLocalId = so.LocalId;
251
252 {
253 // Check that object is not copied if copy base perms is missing.
254 // Should not allow copy if base does not have this.
255 so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Transfer;
256 // Must be set so anyone can copy
257 so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy;
258
259 // Check that object is not copied
260 List<uint> localIds = new List<uint>();
261 localIds.Add(so.LocalId);
262
263 // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms
264 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);
265
266 // Check that object isn't copied until we crank the sogd handle.
267 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
268 Assert.That(retrievedPart, Is.Not.Null);
269 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
270
271 sogd.InventoryDeQueueAndDelete();
272 // Check that object is still there.
273 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
274 Assert.That(retrievedPart2, Is.Not.Null);
275 Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));
276
277 // Check that we have a copy in inventory
278 InventoryItemBase item
279 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
280 Assert.That(item, Is.Null);
281 }
282
283 {
284 // Check that object is not copied if copy trans perms is missing.
285 // Should not allow copy if base does not have this.
286 so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy;
287 // Must be set so anyone can copy
288 so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy;
289
290 // Check that object is not copied
291 List<uint> localIds = new List<uint>();
292 localIds.Add(so.LocalId);
293
294 // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms
295 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);
296
297 // Check that object isn't copied until we crank the sogd handle.
298 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
299 Assert.That(retrievedPart, Is.Not.Null);
300 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
301
302 sogd.InventoryDeQueueAndDelete();
303 // Check that object is still there.
304 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
305 Assert.That(retrievedPart2, Is.Not.Null);
306 Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));
307
308 // Check that we have a copy in inventory
309 InventoryItemBase item
310 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
311 Assert.That(item, Is.Null);
312 }
313
314 {
315 // Check that object is not copied if everyone copy perms is missing.
316 // Should not allow copy if base does not have this.
317 so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer);
318 // Make sure everyone perm does not allow copy
319 so.RootPart.EveryoneMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy);
320
321 // Check that object is not copied
322 List<uint> localIds = new List<uint>();
323 localIds.Add(so.LocalId);
324
325 // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms
326 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);
327
328 // Check that object isn't copied until we crank the sogd handle.
329 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
330 Assert.That(retrievedPart, Is.Not.Null);
331 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
332
333 sogd.InventoryDeQueueAndDelete();
334 // Check that object is still there.
335 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
336 Assert.That(retrievedPart2, Is.Not.Null);
337 Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));
338
339 // Check that we have a copy in inventory
340 InventoryItemBase item
341 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
342 Assert.That(item, Is.Null);
343 }
344 }
345 }
346} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
new file mode 100644
index 0000000..5635c20
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
@@ -0,0 +1,259 @@
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 Nini.Config;
31using NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.CoreModules.Framework;
35using OpenSim.Region.CoreModules.Framework.EntityTransfer;
36using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
37using OpenSim.Region.CoreModules.World.Land;
38using OpenSim.Region.OptionalModules;
39using OpenSim.Tests.Common;
40
41namespace OpenSim.Region.Framework.Scenes.Tests
42{
43 public class SceneObjectCrossingTests : OpenSimTestCase
44 {
45 [TestFixtureSetUp]
46 public void FixtureInit()
47 {
48 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
49 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
50 }
51
52 [TestFixtureTearDown]
53 public void TearDown()
54 {
55 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
56 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
57 // tests really shouldn't).
58 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
59 }
60
61 /// <summary>
62 /// Test cross with no prim limit module.
63 /// </summary>
64 [Test]
65 public void TestCrossOnSameSimulator()
66 {
67 TestHelpers.InMethod();
68// TestHelpers.EnableLogging();
69
70 UUID userId = TestHelpers.ParseTail(0x1);
71 int sceneObjectIdTail = 0x2;
72
73 EntityTransferModule etmA = new EntityTransferModule();
74 EntityTransferModule etmB = new EntityTransferModule();
75 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
76
77 IConfigSource config = new IniConfigSource();
78 IConfig modulesConfig = config.AddConfig("Modules");
79 modulesConfig.Set("EntityTransferModule", etmA.Name);
80 modulesConfig.Set("SimulationServices", lscm.Name);
81
82 SceneHelpers sh = new SceneHelpers();
83 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
84 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
85
86 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
87 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
88 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
89
90 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
91 UUID so1Id = so1.UUID;
92 so1.AbsolutePosition = new Vector3(128, 10, 20);
93
94 // Cross with a negative value
95 so1.AbsolutePosition = new Vector3(128, -10, 20);
96
97 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
98 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
99 }
100
101 /// <summary>
102 /// Test cross with no prim limit module.
103 /// </summary>
104 /// <remarks>
105 /// Possibly this should belong in ScenePresenceCrossingTests, though here it is the object that is being moved
106 /// where the avatar is just a passenger.
107 /// </remarks>
108 [Test]
109 public void TestCrossOnSameSimulatorWithSittingAvatar()
110 {
111 TestHelpers.InMethod();
112// TestHelpers.EnableLogging();
113
114 UUID userId = TestHelpers.ParseTail(0x1);
115 int sceneObjectIdTail = 0x2;
116 Vector3 so1StartPos = new Vector3(128, 10, 20);
117
118 EntityTransferModule etmA = new EntityTransferModule();
119 EntityTransferModule etmB = new EntityTransferModule();
120 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
121
122 IConfigSource config = new IniConfigSource();
123 IConfig modulesConfig = config.AddConfig("Modules");
124 modulesConfig.Set("EntityTransferModule", etmA.Name);
125 modulesConfig.Set("SimulationServices", lscm.Name);
126 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
127
128 // In order to run a single threaded regression test we do not want the entity transfer module waiting
129 // for a callback from the destination scene before removing its avatar data.
130 entityTransferConfig.Set("wait_for_callback", false);
131
132 SceneHelpers sh = new SceneHelpers();
133 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
134 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
135
136 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
137 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
138 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
139
140 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
141 UUID so1Id = so1.UUID;
142 so1.AbsolutePosition = so1StartPos;
143
144 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
145 TestClient tc = new TestClient(acd, sceneA);
146 List<TestClient> destinationTestClients = new List<TestClient>();
147 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
148
149 ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
150 sp1SceneA.AbsolutePosition = so1StartPos;
151 sp1SceneA.HandleAgentRequestSit(sp1SceneA.ControllingClient, sp1SceneA.UUID, so1.UUID, Vector3.Zero);
152
153 // Cross
154 sceneA.SceneGraph.UpdatePrimGroupPosition(
155 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId);
156
157 SceneObjectGroup so1PostCross;
158
159 {
160 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
161 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
162
163 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
164 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient);
165 sceneBTc.CompleteMovement();
166
167 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
168 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);
169
170 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
171 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
172 Assert.NotNull(so1PostCross);
173 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
174 }
175
176 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;
177
178// Console.WriteLine("CRISSCROSS");
179
180 // Recross
181 sceneB.SceneGraph.UpdatePrimGroupPosition(
182 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId);
183
184 {
185 ScenePresence sp1SceneBPostReCross = sceneB.GetScenePresence(userId);
186 Assert.IsTrue(sp1SceneBPostReCross.IsChildAgent, "sp1SceneBPostReCross.IsChildAgent unexpectedly false");
187
188 ScenePresence sp1SceneAPostReCross = sceneA.GetScenePresence(userId);
189 TestClient sceneATc = ((TestClient)sp1SceneAPostReCross.ControllingClient);
190 sceneATc.CompleteMovement();
191
192 Assert.IsFalse(sp1SceneAPostReCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
193 Assert.IsTrue(sp1SceneAPostReCross.IsSatOnObject);
194
195 Assert.IsNull(sceneB.GetSceneObjectGroup(so1Id), "uck2");
196 SceneObjectGroup so1PostReCross = sceneA.GetSceneObjectGroup(so1Id);
197 Assert.NotNull(so1PostReCross);
198 Assert.AreEqual(1, so1PostReCross.GetSittingAvatarsCount());
199 }
200 }
201
202 /// <summary>
203 /// Test cross with no prim limit module.
204 /// </summary>
205 /// <remarks>
206 /// XXX: This test may FCbe better off in a specific PrimLimitsModuleTest class in optional module tests in the
207 /// future (though it is configured as active by default, so not really optional).
208 /// </remarks>
209 [Test]
210 public void TestCrossOnSameSimulatorPrimLimitsOkay()
211 {
212 TestHelpers.InMethod();
213// TestHelpers.EnableLogging();
214
215 UUID userId = TestHelpers.ParseTail(0x1);
216 int sceneObjectIdTail = 0x2;
217
218 EntityTransferModule etmA = new EntityTransferModule();
219 EntityTransferModule etmB = new EntityTransferModule();
220 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
221 LandManagementModule lmmA = new LandManagementModule();
222 LandManagementModule lmmB = new LandManagementModule();
223
224 IConfigSource config = new IniConfigSource();
225 IConfig modulesConfig = config.AddConfig("Modules");
226 modulesConfig.Set("EntityTransferModule", etmA.Name);
227 modulesConfig.Set("SimulationServices", lscm.Name);
228
229 IConfig permissionsConfig = config.AddConfig("Permissions");
230 permissionsConfig.Set("permissionmodules", "PrimLimitsModule");
231
232 SceneHelpers sh = new SceneHelpers();
233 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
234 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
235
236 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
237 SceneHelpers.SetupSceneModules(
238 sceneA, config, etmA, lmmA, new PrimLimitsModule(), new PrimCountModule());
239 SceneHelpers.SetupSceneModules(
240 sceneB, config, etmB, lmmB, new PrimLimitsModule(), new PrimCountModule());
241
242 // We must set up the parcel for this to work. Normally this is taken care of by OpenSimulator startup
243 // code which is not yet easily invoked by tests.
244 lmmA.EventManagerOnNoLandDataFromStorage();
245 lmmB.EventManagerOnNoLandDataFromStorage();
246
247 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
248 UUID so1Id = so1.UUID;
249 so1.AbsolutePosition = new Vector3(128, 10, 20);
250
251 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
252 // because only this will execute permission checks in the source region.
253 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId);
254
255 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
256 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
257 }
258 }
259} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index c1522e7..1c396ac 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -32,13 +32,13 @@ using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Region.CoreModules.Framework.EntityTransfer;
36using OpenSim.Region.CoreModules.Framework.InventoryAccess; 36using OpenSim.Region.CoreModules.Framework.InventoryAccess;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
37using OpenSim.Region.CoreModules.World.Permissions; 38using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
40using OpenSim.Tests.Common; 41using OpenSim.Tests.Common;
41using OpenSim.Tests.Common.Mock;
42 42
43namespace OpenSim.Region.Framework.Scenes.Tests 43namespace OpenSim.Region.Framework.Scenes.Tests
44{ 44{
@@ -52,6 +52,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52 [TestFixture] 52 [TestFixture]
53 public class SceneObjectDeRezTests : OpenSimTestCase 53 public class SceneObjectDeRezTests : OpenSimTestCase
54 { 54 {
55 [TestFixtureSetUp]
56 public void FixtureInit()
57 {
58 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
59 // This facility was added after the original async delete tests were written, so it may be possible now
60 // to not bother explicitly disabling their async (since everything will be running sync).
61 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
62 }
63
64 [TestFixtureTearDown]
65 public void TearDown()
66 {
67 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
68 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
69 // tests really shouldn't).
70 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
71 }
72
55 /// <summary> 73 /// <summary>
56 /// Test deleting an object from a scene. 74 /// Test deleting an object from a scene.
57 /// </summary> 75 /// </summary>
@@ -59,46 +77,96 @@ namespace OpenSim.Region.Framework.Scenes.Tests
59 public void TestDeRezSceneObject() 77 public void TestDeRezSceneObject()
60 { 78 {
61 TestHelpers.InMethod(); 79 TestHelpers.InMethod();
62// log4net.Config.XmlConfigurator.Configure();
63 80
64 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 81 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
65 82
66 TestScene scene = new SceneHelpers().SetupScene(); 83 TestScene scene = new SceneHelpers().SetupScene();
67 IConfigSource configSource = new IniConfigSource(); 84 SceneHelpers.SetupSceneModules(scene, new PermissionsModule());
68 IConfig config = configSource.AddConfig("Startup"); 85 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
69 config.Set("serverside_object_permissions", true);
70 SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
71 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
72 86
73 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 87 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
74 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 88 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
75 sogd.Enabled = false; 89 sogd.Enabled = false;
76 90
77 SceneObjectPart part 91 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", userId);
78 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); 92 uint soLocalId = so.LocalId;
79 part.Name = "obj1";
80 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
81 93
82 List<uint> localIds = new List<uint>(); 94 List<uint> localIds = new List<uint>();
83 localIds.Add(part.LocalId); 95 localIds.Add(so.LocalId);
84 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); 96 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
85 97
86 // Check that object isn't deleted until we crank the sogd handle. 98 // Check that object isn't deleted until we crank the sogd handle.
87 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 99 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
88 Assert.That(retrievedPart, Is.Not.Null); 100 Assert.That(retrievedPart, Is.Not.Null);
89 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); 101 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
90 102
91 sogd.InventoryDeQueueAndDelete(); 103 sogd.InventoryDeQueueAndDelete();
92 104
93 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 105 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
94 Assert.That(retrievedPart2, Is.Null); 106 Assert.That(retrievedPart2, Is.Null);
107
108 Assert.That(client.ReceivedKills.Count, Is.EqualTo(1));
109 Assert.That(client.ReceivedKills[0], Is.EqualTo(soLocalId));
110 }
111
112 /// <summary>
113 /// Test that child and root agents correctly receive KillObject notifications.
114 /// </summary>
115 [Test]
116 public void TestDeRezSceneObjectToAgents()
117 {
118 TestHelpers.InMethod();
119// TestHelpers.EnableLogging();
120
121 SceneHelpers sh = new SceneHelpers();
122 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
123 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
124
125 // We need this so that the creation of the root client for userB in sceneB can trigger the creation of a child client in sceneA
126 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
127 EntityTransferModule etmB = new EntityTransferModule();
128 IConfigSource config = new IniConfigSource();
129 IConfig modulesConfig = config.AddConfig("Modules");
130 modulesConfig.Set("EntityTransferModule", etmB.Name);
131 modulesConfig.Set("SimulationServices", lscm.Name);
132 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
133 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
134
135 // We need this for derez
136 SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule());
137
138 UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, "");
139 UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, "");
140
141 TestClient clientA = (TestClient)SceneHelpers.AddScenePresence(sceneA, uaA).ControllingClient;
142
143 // This is the more long-winded route we have to take to get a child client created for userB in sceneA
144 // rather than just calling AddScenePresence() as for userA
145 AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB);
146 TestClient clientB = new TestClient(acd, sceneB);
147 List<TestClient> childClientsB = new List<TestClient>();
148 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(clientB, childClientsB);
149
150 SceneHelpers.AddScenePresence(sceneB, clientB, acd);
151
152 SceneObjectGroup so = SceneHelpers.AddSceneObject(sceneA);
153 uint soLocalId = so.LocalId;
154
155 sceneA.DeleteSceneObject(so, false);
156
157 Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1));
158 Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId));
159
160 Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1));
161 Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId));
95 } 162 }
96 163
97 /// <summary> 164 /// <summary>
98 /// Test deleting an object from a scene where the deleter is not the owner 165 /// Test deleting an object from a scene where the deleter is not the owner
99 /// </summary> 166 /// </summary>
100 /// 167 /// <remarks>
101 /// This test assumes that the deleter is not a god. 168 /// This test assumes that the deleter is not a god.
169 /// </remarks>
102 [Test] 170 [Test]
103 public void TestDeRezSceneObjectNotOwner() 171 public void TestDeRezSceneObjectNotOwner()
104 { 172 {
@@ -109,10 +177,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
109 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); 177 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
110 178
111 TestScene scene = new SceneHelpers().SetupScene(); 179 TestScene scene = new SceneHelpers().SetupScene();
112 IConfigSource configSource = new IniConfigSource(); 180 SceneHelpers.SetupSceneModules(scene, new PermissionsModule());
113 IConfig config = configSource.AddConfig("Startup");
114 config.Set("serverside_object_permissions", true);
115 SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
116 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; 181 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
117 182
118 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 183 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
@@ -164,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
164 229
165 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); 230 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
166 InventoryFolderBase folder1 231 InventoryFolderBase folder1
167 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1"); 232 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);
168 233
169 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; 234 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
170 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); 235 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 9378e20..e6d5a2f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -31,10 +31,8 @@ using System.Reflection;
31using NUnit.Framework; 31using NUnit.Framework;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common; 35using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38using log4net; 36using log4net;
39 37
40namespace OpenSim.Region.Framework.Scenes.Tests 38namespace OpenSim.Region.Framework.Scenes.Tests
@@ -91,7 +89,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
91 grp2.RootPart.ClearUpdateSchedule(); 89 grp2.RootPart.ClearUpdateSchedule();
92 90
93 // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. 91 // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated.
92 Assert.IsFalse(grp1.GroupContainsForeignPrims);
94 grp1.LinkToGroup(grp2); 93 grp1.LinkToGroup(grp2);
94 Assert.IsTrue(grp1.GroupContainsForeignPrims);
95
96 scene.Backup(true);
97 Assert.IsFalse(grp1.GroupContainsForeignPrims);
95 98
96 // FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since 99 // FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since
97 // it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed. 100 // it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed.
@@ -143,7 +146,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
143 146
144 Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink."); 147 Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink.");
145 Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero"); 148 Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero");
146 Assert.That(grp3.HasGroupChangedDueToDelink, Is.True); 149 Assert.NotNull(grp3);
147 } 150 }
148 151
149 [Test] 152 [Test]
@@ -335,30 +338,34 @@ namespace OpenSim.Region.Framework.Scenes.Tests
335 SceneObjectPart rootPart 338 SceneObjectPart rootPart
336 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 339 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
337 { Name = rootPartName, UUID = rootPartUuid }; 340 { Name = rootPartName, UUID = rootPartUuid };
341
338 SceneObjectPart linkPart 342 SceneObjectPart linkPart
339 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 343 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
340 { Name = linkPartName, UUID = linkPartUuid }; 344 { Name = linkPartName, UUID = linkPartUuid };
345 SceneObjectGroup linkGroup = new SceneObjectGroup(linkPart);
346 scene.AddNewSceneObject(linkGroup, true);
341 347
342 SceneObjectGroup sog = new SceneObjectGroup(rootPart); 348 SceneObjectGroup sog = new SceneObjectGroup(rootPart);
343 sog.AddPart(linkPart); 349 scene.AddNewSceneObject(sog, true);
344 scene.AddNewSceneObject(sog, true); 350
345 351 Assert.IsFalse(sog.GroupContainsForeignPrims);
346 // In a test, we have to crank the backup handle manually. Normally this would be done by the timer invoked 352 sog.LinkToGroup(linkGroup);
347 // scene backup thread. 353 Assert.IsTrue(sog.GroupContainsForeignPrims);
354
348 scene.Backup(true); 355 scene.Backup(true);
349 356 Assert.AreEqual(1, scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID).Count);
357
350 // These changes should occur immediately without waiting for a backup pass 358 // These changes should occur immediately without waiting for a backup pass
351 SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false); 359 SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false);
352 360 Assert.IsFalse(groupToDelete.GroupContainsForeignPrims);
353 Assert.That(groupToDelete.HasGroupChangedDueToDelink, Is.True); 361
354 scene.DeleteSceneObject(groupToDelete, false); 362 scene.DeleteSceneObject(groupToDelete, false);
355 Assert.That(groupToDelete.HasGroupChangedDueToDelink, Is.False);
356 363
357 List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID); 364 List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID);
358 365
359 Assert.That(storedObjects.Count, Is.EqualTo(1)); 366 Assert.AreEqual(1, storedObjects.Count);
360 Assert.That(storedObjects[0].Parts.Length, Is.EqualTo(1)); 367 Assert.AreEqual(1, storedObjects[0].Parts.Length);
361 Assert.That(storedObjects[0].ContainsPart(rootPartUuid)); 368 Assert.IsTrue(storedObjects[0].ContainsPart(rootPartUuid));
362 } 369 }
363 } 370 }
364} 371}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index c264433..975c4d9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -30,10 +30,8 @@ using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
35using OpenSim.Tests.Common; 34using OpenSim.Tests.Common;
36using OpenSim.Tests.Common.Mock;
37 35
38namespace OpenSim.Region.Framework.Scenes.Tests 36namespace OpenSim.Region.Framework.Scenes.Tests
39{ 37{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
index a58e735..8a2d2af 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
@@ -31,11 +31,9 @@ using System.Reflection;
31using NUnit.Framework; 31using NUnit.Framework;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
37using OpenSim.Tests.Common; 36using OpenSim.Tests.Common;
38using OpenSim.Tests.Common.Mock;
39 37
40namespace OpenSim.Region.Framework.Scenes.Tests 38namespace OpenSim.Region.Framework.Scenes.Tests
41{ 39{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs
new file mode 100644
index 0000000..e3ceb04
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs
@@ -0,0 +1,135 @@
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.Threading;
32using System.Xml;
33using System.Linq;
34using Nini.Config;
35using NUnit.Framework;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization;
41using OpenSim.Services.Interfaces;
42using OpenSim.Tests.Common;
43
44namespace OpenSim.Region.Framework.Scenes.Tests
45{
46 /// <summary>
47 /// Basic scene object serialization tests.
48 /// </summary>
49 [TestFixture]
50 public class SceneObjectSerializationTests : OpenSimTestCase
51 {
52
53 /// <summary>
54 /// Serialize and deserialize.
55 /// </summary>
56 [Test]
57 public void TestSerialDeserial()
58 {
59 TestHelpers.InMethod();
60
61 Scene scene = new SceneHelpers().SetupScene();
62 int partsToTestCount = 3;
63
64 SceneObjectGroup so
65 = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
66 SceneObjectPart[] parts = so.Parts;
67 so.Name = "obj1";
68 so.Description = "xpto";
69
70 string xml = SceneObjectSerializer.ToXml2Format(so);
71 Assert.That(!string.IsNullOrEmpty(xml), "SOG serialization resulted in empty or null string");
72
73 XmlDocument doc = new XmlDocument();
74 doc.LoadXml(xml);
75 XmlNodeList nodes = doc.GetElementsByTagName("SceneObjectPart");
76 Assert.That(nodes.Count, Is.EqualTo(3), "SOG serialization resulted in wrong number of SOPs");
77
78 SceneObjectGroup so2 = SceneObjectSerializer.FromXml2Format(xml);
79 Assert.IsNotNull(so2, "SOG deserialization resulted in null object");
80 Assert.That(so2.Name == so.Name, "Name of deserialized object does not match original name");
81 Assert.That(so2.Description == so.Description, "Description of deserialized object does not match original name");
82 }
83
84 /// <summary>
85 /// This checks for a bug reported in mantis #7514
86 /// </summary>
87 [Test]
88 public void TestNamespaceAttribute()
89 {
90 TestHelpers.InMethod();
91
92 Scene scene = new SceneHelpers().SetupScene();
93 UserAccount account = new UserAccount(UUID.Zero, UUID.Random(), "Test", "User", string.Empty);
94 scene.UserAccountService.StoreUserAccount(account);
95 int partsToTestCount = 1;
96
97 SceneObjectGroup so
98 = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
99 SceneObjectPart[] parts = so.Parts;
100 so.Name = "obj1";
101 so.Description = "xpto";
102 so.OwnerID = account.PrincipalID;
103 so.RootPart.CreatorID = so.OwnerID;
104
105 string xml = SceneObjectSerializer.ToXml2Format(so);
106 Assert.That(!string.IsNullOrEmpty(xml), "SOG serialization resulted in empty or null string");
107
108 xml = ExternalRepresentationUtils.RewriteSOP(xml, "Test Scene", "http://localhost", scene.UserAccountService, UUID.Zero);
109 //Console.WriteLine(xml);
110
111 XmlDocument doc = new XmlDocument();
112 doc.LoadXml(xml);
113
114 XmlNodeList nodes = doc.GetElementsByTagName("SceneObjectPart");
115 Assert.That(nodes.Count, Is.GreaterThan(0), "SOG serialization resulted in no SOPs");
116 foreach (XmlAttribute a in nodes[0].Attributes)
117 {
118 int count = a.Name.Count(c => c == ':');
119 Assert.That(count, Is.EqualTo(1), "Cannot have multiple ':' in attribute name in SOP");
120 }
121 nodes = doc.GetElementsByTagName("CreatorData");
122 Assert.That(nodes.Count, Is.GreaterThan(0), "SOG serialization resulted in no CreatorData");
123 foreach (XmlAttribute a in nodes[0].Attributes)
124 {
125 int count = a.Name.Count(c => c == ':');
126 Assert.That(count, Is.EqualTo(1), "Cannot have multiple ':' in attribute name in CreatorData");
127 }
128
129 SceneObjectGroup so2 = SceneObjectSerializer.FromXml2Format(xml);
130 Assert.IsNotNull(so2, "SOG deserialization resulted in null object");
131 Assert.AreNotEqual(so.RootPart.CreatorIdentification, so2.RootPart.CreatorIdentification, "RewriteSOP failed to transform CreatorData.");
132 Assert.That(so2.RootPart.CreatorIdentification.Contains("http://"), "RewriteSOP failed to add the homeURL to CreatorData");
133 }
134 }
135} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
index abaa1d1..e00defd 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
@@ -31,10 +31,8 @@ using System.Threading;
31using NUnit.Framework; 31using NUnit.Framework;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common; 35using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38 36
39namespace OpenSim.Region.Framework.Scenes.Tests 37namespace OpenSim.Region.Framework.Scenes.Tests
40{ 38{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 8eb3191..1737e3c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -31,10 +31,8 @@ using System.Reflection;
31using NUnit.Framework; 31using NUnit.Framework;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common; 35using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38 36
39namespace OpenSim.Region.Framework.Scenes.Tests 37namespace OpenSim.Region.Framework.Scenes.Tests
40{ 38{
@@ -58,6 +56,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 } 56 }
59 57
60 [Test] 58 [Test]
59 public void TestSetTemporary()
60 {
61 TestHelpers.InMethod();
62
63 m_scene.AddSceneObject(m_so1);
64 m_so1.ScriptSetTemporaryStatus(true);
65
66 // Is this really the correct flag?
67 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez));
68 Assert.That(m_so1.Backup, Is.False);
69
70 // Test setting back to non-temporary
71 m_so1.ScriptSetTemporaryStatus(false);
72
73 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
74 Assert.That(m_so1.Backup, Is.True);
75 }
76
77 [Test]
61 public void TestSetPhantomSinglePrim() 78 public void TestSetPhantomSinglePrim()
62 { 79 {
63 TestHelpers.InMethod(); 80 TestHelpers.InMethod();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
index 96973de..af3ce8e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
@@ -30,10 +30,8 @@ using System.Reflection;
30using NUnit.Framework; 30using NUnit.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
35using OpenSim.Tests.Common; 34using OpenSim.Tests.Common;
36using OpenSim.Tests.Common.Mock;
37 35
38namespace OpenSim.Region.Framework.Scenes.Tests 36namespace OpenSim.Region.Framework.Scenes.Tests
39{ 37{
@@ -110,8 +108,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
110 108
111 Vector3 firstSize = new Vector3(2, 3, 4); 109 Vector3 firstSize = new Vector3(2, 3, 4);
112 Vector3 secondSize = new Vector3(5, 6, 7); 110 Vector3 secondSize = new Vector3(5, 6, 7);
113 Vector3 thirdSize = new Vector3(8, 9, 10); 111// Vector3 thirdSize = new Vector3(8, 9, 10);
114 Vector3 fourthSize = new Vector3(11, 12, 13); 112// Vector3 fourthSize = new Vector3(11, 12, 13);
115 113
116 Scene scene = new SceneHelpers().SetupScene(); 114 Scene scene = new SceneHelpers().SetupScene();
117 scene.MaxUndoCount = 20; 115 scene.MaxUndoCount = 20;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index 2b79271..aadf7c6 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -32,14 +32,12 @@ using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Region.CoreModules.Avatar.InstantMessage; 35using OpenSim.Region.CoreModules.Avatar.InstantMessage;
37using OpenSim.Region.CoreModules.World.Permissions; 36using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; 39using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
41using OpenSim.Tests.Common; 40using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43 41
44namespace OpenSim.Region.Framework.Scenes.Tests 42namespace OpenSim.Region.Framework.Scenes.Tests
45{ 43{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index 5faf131..96d112d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -36,7 +36,6 @@ using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.ClientStack.Linden; 41using OpenSim.Region.ClientStack.Linden;
@@ -44,7 +43,6 @@ using OpenSim.Region.CoreModules.Framework.EntityTransfer;
44using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
46using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48using GridRegion = OpenSim.Services.Interfaces.GridRegion; 46using GridRegion = OpenSim.Services.Interfaces.GridRegion;
49 47
50namespace OpenSim.Region.Framework.Scenes.Tests 48namespace OpenSim.Region.Framework.Scenes.Tests
@@ -111,6 +109,45 @@ namespace OpenSim.Region.Framework.Scenes.Tests
111 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); 109 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
112 } 110 }
113 111
112 /// <summary>
113 /// Test that duplicate complete movement calls are ignored.
114 /// </summary>
115 /// <remarks>
116 /// If duplicate calls are not ignored then there is a risk of race conditions or other unexpected effects.
117 /// </remarks>
118 [Test]
119 public void TestDupeCompleteMovementCalls()
120 {
121 TestHelpers.InMethod();
122// TestHelpers.EnableLogging();
123
124 UUID spUuid = TestHelpers.ParseTail(0x1);
125
126 TestScene scene = new SceneHelpers().SetupScene();
127
128 int makeRootAgentEvents = 0;
129 scene.EventManager.OnMakeRootAgent += spi => makeRootAgentEvents++;
130
131 ScenePresence sp = SceneHelpers.AddScenePresence(scene, spUuid);
132
133 Assert.That(makeRootAgentEvents, Is.EqualTo(1));
134
135 // Normally these would be invoked by a CompleteMovement message coming in to the UDP stack. But for
136 // convenience, here we will invoke it manually.
137 sp.CompleteMovement(sp.ControllingClient, true);
138
139 Assert.That(makeRootAgentEvents, Is.EqualTo(1));
140
141 // Check rest of exepcted parameters.
142 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null);
143 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
144
145 Assert.That(sp.IsChildAgent, Is.False);
146 Assert.That(sp.UUID, Is.EqualTo(spUuid));
147
148 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
149 }
150
114 [Test] 151 [Test]
115 public void TestCreateDuplicateRootScenePresence() 152 public void TestCreateDuplicateRootScenePresence()
116 { 153 {
@@ -119,7 +156,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
119 156
120 UUID spUuid = TestHelpers.ParseTail(0x1); 157 UUID spUuid = TestHelpers.ParseTail(0x1);
121 158
159 // The etm is only invoked by this test to check whether an agent is still in transit if there is a dupe
160 EntityTransferModule etm = new EntityTransferModule();
161
162 IConfigSource config = new IniConfigSource();
163 IConfig modulesConfig = config.AddConfig("Modules");
164 modulesConfig.Set("EntityTransferModule", etm.Name);
165 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
166
167 // In order to run a single threaded regression test we do not want the entity transfer module waiting
168 // for a callback from the destination scene before removing its avatar data.
169 entityTransferConfig.Set("wait_for_callback", false);
170
122 TestScene scene = new SceneHelpers().SetupScene(); 171 TestScene scene = new SceneHelpers().SetupScene();
172 SceneHelpers.SetupSceneModules(scene, config, etm);
123 SceneHelpers.AddScenePresence(scene, spUuid); 173 SceneHelpers.AddScenePresence(scene, spUuid);
124 SceneHelpers.AddScenePresence(scene, spUuid); 174 SceneHelpers.AddScenePresence(scene, spUuid);
125 175
@@ -133,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
133 } 183 }
134 184
135 [Test] 185 [Test]
136 public void TestCloseAgent() 186 public void TestCloseClient()
137 { 187 {
138 TestHelpers.InMethod(); 188 TestHelpers.InMethod();
139// TestHelpers.EnableLogging(); 189// TestHelpers.EnableLogging();
@@ -141,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 TestScene scene = new SceneHelpers().SetupScene(); 191 TestScene scene = new SceneHelpers().SetupScene();
142 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 192 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
143 193
144 scene.IncomingCloseAgent(sp.UUID, false); 194 scene.CloseAgent(sp.UUID, false);
145 195
146 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 196 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
147 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); 197 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
@@ -176,7 +226,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
176 // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and 226 // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and
177 // establish a child scene presence. We pass in the circuit code that the client has to connect with *** 227 // establish a child scene presence. We pass in the circuit code that the client has to connect with ***
178 // XXX: ViaLogin may not be correct here. 228 // XXX: ViaLogin may not be correct here.
179 scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); 229 scene.SimulationService.CreateAgent(null, region, acd, (uint)TeleportFlags.ViaLogin, out reason);
180 230
181 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); 231 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
182 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); 232 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
@@ -187,7 +237,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
187 // *** This is the second stage, where the client established a child agent/scene presence using the 237 // *** This is the second stage, where the client established a child agent/scene presence using the
188 // circuit code given to the scene in stage 1 *** 238 // circuit code given to the scene in stage 1 ***
189 TestClient client = new TestClient(acd, scene); 239 TestClient client = new TestClient(acd, scene);
190 scene.AddNewClient(client, PresenceType.User); 240 scene.AddNewAgent(client, PresenceType.User);
191 241
192 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); 242 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
193 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); 243 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
@@ -236,161 +286,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
236// Assert.That(childPresence, Is.Not.Null); 286// Assert.That(childPresence, Is.Not.Null);
237// Assert.That(childPresence.IsChildAgent, Is.True); 287// Assert.That(childPresence.IsChildAgent, Is.True);
238 } 288 }
239
240// /// <summary>
241// /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
242// /// </summary>
243// [Test]
244// public void T010_TestAddRootAgent()
245// {
246// TestHelpers.InMethod();
247//
248// string firstName = "testfirstname";
249//
250// AgentCircuitData agent = new AgentCircuitData();
251// agent.AgentID = agent1;
252// agent.firstname = firstName;
253// agent.lastname = "testlastname";
254// agent.SessionID = UUID.Random();
255// agent.SecureSessionID = UUID.Random();
256// agent.circuitcode = 123;
257// agent.BaseFolder = UUID.Zero;
258// agent.InventoryFolder = UUID.Zero;
259// agent.startpos = Vector3.Zero;
260// agent.CapsPath = GetRandomCapsObjectPath();
261// agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
262// agent.child = true;
263//
264// scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
265//
266// string reason;
267// scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
268// testclient = new TestClient(agent, scene);
269// scene.AddNewClient(testclient);
270//
271// ScenePresence presence = scene.GetScenePresence(agent1);
272//
273// Assert.That(presence, Is.Not.Null, "presence is null");
274// Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
275// acd1 = agent;
276// }
277//
278// /// <summary>
279// /// Test removing an uncrossed root agent from a scene.
280// /// </summary>
281// [Test]
282// public void T011_TestRemoveRootAgent()
283// {
284// TestHelpers.InMethod();
285//
286// scene.RemoveClient(agent1);
287//
288// ScenePresence presence = scene.GetScenePresence(agent1);
289//
290// Assert.That(presence, Is.Null, "presence is not null");
291// }
292
293 // I'm commenting this test because it does not represent
294 // crossings. The Thread.Sleep's in here are not meaningful mocks,
295 // and they sometimes fail in panda.
296 // We need to talk in order to develop a test
297 // that really tests region crossings. There are 3 async components,
298 // but things are synchronous among them. So there should be
299 // 3 threads in here.
300 //[Test]
301// public void T021_TestCrossToNewRegion()
302// {
303// TestHelpers.InMethod();
304//
305// scene.RegisterRegionWithGrid();
306// scene2.RegisterRegionWithGrid();
307//
308// // Adding child agent to region 1001
309// string reason;
310// scene2.NewUserConnection(acd1,0, out reason);
311// scene2.AddNewClient(testclient, PresenceType.User);
312//
313// ScenePresence presence = scene.GetScenePresence(agent1);
314// presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
315//
316// ScenePresence presence2 = scene2.GetScenePresence(agent1);
317//
318// // Adding neighbour region caps info to presence2
319//
320// string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
321// presence2.AddNeighbourRegion(region1, cap);
322//
323// Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
324// Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
325//
326// // Cross to x+1
327// presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
328// presence.Update();
329//
330// EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
331//
332// // Mimicking communication between client and server, by waiting OK from client
333// // sent by TestClient.CrossRegion call. Originally, this is network comm.
334// if (!wh.WaitOne(5000,false))
335// {
336// presence.Update();
337// if (!wh.WaitOne(8000,false))
338// throw new ArgumentException("1 - Timeout waiting for signal/variable.");
339// }
340//
341// // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
342// // would normally be fired after receiving the reply packet from comm. done on the last line.
343// testclient.CompleteMovement();
344//
345// // Crossings are asynchronous
346// int timer = 10;
347//
348// // Make sure cross hasn't already finished
349// if (!presence.IsInTransit && !presence.IsChildAgent)
350// {
351// // If not and not in transit yet, give it some more time
352// Thread.Sleep(5000);
353// }
354//
355// // Enough time, should at least be in transit by now.
356// while (presence.IsInTransit && timer > 0)
357// {
358// Thread.Sleep(1000);
359// timer-=1;
360// }
361//
362// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1.");
363// Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
364// Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
365//
366// // Cross Back
367// presence2.AbsolutePosition = new Vector3(-10, 3, 100);
368// presence2.Update();
369//
370// if (!wh.WaitOne(5000,false))
371// {
372// presence2.Update();
373// if (!wh.WaitOne(8000,false))
374// throw new ArgumentException("2 - Timeout waiting for signal/variable.");
375// }
376// testclient.CompleteMovement();
377//
378// if (!presence2.IsInTransit && !presence2.IsChildAgent)
379// {
380// // If not and not in transit yet, give it some more time
381// Thread.Sleep(5000);
382// }
383//
384// // Enough time, should at least be in transit by now.
385// while (presence2.IsInTransit && timer > 0)
386// {
387// Thread.Sleep(1000);
388// timer-=1;
389// }
390//
391// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2.");
392// Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
393// Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
394// }
395 } 289 }
396} \ No newline at end of file 290} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 1cd8ae9..42d91b9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -35,15 +35,13 @@ using Nini.Config;
35using NUnit.Framework; 35using NUnit.Framework;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.CoreModules.Framework.EntityTransfer; 40using OpenSim.Region.CoreModules.Framework.EntityTransfer;
42using OpenSim.Region.CoreModules.World.Serialiser; 41using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 42using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Region.Physics.Manager; 43using OpenSim.Region.PhysicsModules.SharedBase;
45using OpenSim.Tests.Common; 44using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47 45
48namespace OpenSim.Region.Framework.Scenes.Tests 46namespace OpenSim.Region.Framework.Scenes.Tests
49{ 47{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index d80afd3..e5c847e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -33,11 +33,9 @@ using Nini.Config;
33using NUnit.Framework; 33using NUnit.Framework;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
39using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock;
41 39
42namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
43{ 41{
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs
new file mode 100644
index 0000000..2e6dc70
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs
@@ -0,0 +1,86 @@
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 OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Servers;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.ClientStack.Linden;
42using OpenSim.Region.CoreModules.Framework;
43using OpenSim.Region.CoreModules.Framework.EntityTransfer;
44using OpenSim.Region.CoreModules.World.Serialiser;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
46using OpenSim.Region.Framework.Scenes;
47using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Tests.Common;
49using GridRegion = OpenSim.Services.Interfaces.GridRegion;
50
51namespace OpenSim.Region.Framework.Scenes.Tests
52{
53 [TestFixture]
54 public class ScenePresenceCapabilityTests : OpenSimTestCase
55 {
56 [Test]
57 public void TestChildAgentSingleRegionCapabilities()
58 {
59 TestHelpers.InMethod();
60// TestHelpers.EnableLogging();
61
62 UUID spUuid = TestHelpers.ParseTail(0x1);
63
64 // XXX: This is not great since the use of statics will mean that this has to be manually cleaned up for
65 // any subsequent test.
66 // XXX: May replace with a mock IHttpServer later.
67 BaseHttpServer httpServer = new BaseHttpServer(99999);
68 MainServer.AddHttpServer(httpServer);
69 MainServer.Instance = httpServer;
70
71 CapabilitiesModule capsMod = new CapabilitiesModule();
72 TestScene scene = new SceneHelpers().SetupScene();
73 SceneHelpers.SetupSceneModules(scene, capsMod);
74
75 ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid);
76 Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null);
77
78 // TODO: Need to add tests for other ICapabiltiesModule methods.
79
80 scene.CloseAgent(sp.UUID, false);
81 Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null);
82
83 // TODO: Need to add tests for other ICapabiltiesModule methods.
84 }
85 }
86} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
new file mode 100644
index 0000000..7127644
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -0,0 +1,247 @@
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 Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.Framework;
38using OpenSim.Region.CoreModules.Framework.EntityTransfer;
39using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
40using OpenSim.Region.CoreModules.World.Permissions;
41using OpenSim.Tests.Common;
42
43namespace OpenSim.Region.Framework.Scenes.Tests
44{
45 [TestFixture]
46 public class ScenePresenceCrossingTests : OpenSimTestCase
47 {
48 [TestFixtureSetUp]
49 public void FixtureInit()
50 {
51 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
52 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
53 }
54
55 [TestFixtureTearDown]
56 public void TearDown()
57 {
58 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
59 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
60 // tests really shouldn't).
61 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
62 }
63
64 [Test]
65 public void TestCrossOnSameSimulator()
66 {
67 TestHelpers.InMethod();
68// TestHelpers.EnableLogging();
69
70 UUID userId = TestHelpers.ParseTail(0x1);
71
72// TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
73 EntityTransferModule etmA = new EntityTransferModule();
74 EntityTransferModule etmB = new EntityTransferModule();
75 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
76
77 IConfigSource config = new IniConfigSource();
78 IConfig modulesConfig = config.AddConfig("Modules");
79 modulesConfig.Set("EntityTransferModule", etmA.Name);
80 modulesConfig.Set("SimulationServices", lscm.Name);
81// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
82
83 // In order to run a single threaded regression test we do not want the entity transfer module waiting
84 // for a callback from the destination scene before removing its avatar data.
85// entityTransferConfig.Set("wait_for_callback", false);
86
87 SceneHelpers sh = new SceneHelpers();
88 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
89 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
90
91 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
92 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
93// SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
94 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
95
96 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
97 TestClient tc = new TestClient(acd, sceneA);
98 List<TestClient> destinationTestClients = new List<TestClient>();
99 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
100
101 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
102 originalSp.AbsolutePosition = new Vector3(128, 32, 10);
103
104// originalSp.Flying = true;
105
106// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);
107
108// eqmA.ClearEvents();
109
110 AgentUpdateArgs moveArgs = new AgentUpdateArgs();
111 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
112 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
113 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
114 moveArgs.SessionID = acd.SessionID;
115
116 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
117
118 sceneA.Update(1);
119
120// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
121
122 // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
123 // But really we want to do this in a more robust way.
124 for (int i = 0; i < 100; i++)
125 {
126 sceneA.Update(1);
127// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
128 }
129
130 // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
131 // messages
132// Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
133//
134// Assert.That(eqmEvents.Count, Is.EqualTo(1));
135// Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
136//
137// List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
138//
139// Assert.That(spEqmEvents.Count, Is.EqualTo(1));
140// Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));
141
142 // sceneA should now only have a child agent
143 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
144 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);
145
146 ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
147
148 // Agent remains a child until the client triggers complete movement
149 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
150
151 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
152
153 int agentMovementCompleteReceived = 0;
154 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
155
156 sceneBTc.CompleteMovement();
157
158 Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
159 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
160 }
161
162 /// <summary>
163 /// Test a cross attempt where the user can see into the neighbour but does not have permission to become
164 /// root there.
165 /// </summary>
166 [Test]
167 public void TestCrossOnSameSimulatorNoRootDestPerm()
168 {
169 TestHelpers.InMethod();
170// TestHelpers.EnableLogging();
171
172 UUID userId = TestHelpers.ParseTail(0x1);
173
174 EntityTransferModule etmA = new EntityTransferModule();
175 EntityTransferModule etmB = new EntityTransferModule();
176 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
177
178 IConfigSource config = new IniConfigSource();
179 IConfig modulesConfig = config.AddConfig("Modules");
180 modulesConfig.Set("EntityTransferModule", etmA.Name);
181 modulesConfig.Set("SimulationServices", lscm.Name);
182
183 SceneHelpers sh = new SceneHelpers();
184 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
185 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
186
187 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
188 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
189
190 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
191 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
192 // IsAdministrator if no permissions module is present is true.
193 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB);
194
195 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
196 TestClient tc = new TestClient(acd, sceneA);
197 List<TestClient> destinationTestClients = new List<TestClient>();
198 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
199
200 // Make sure sceneB will not accept this avatar.
201 sceneB.RegionInfo.EstateSettings.PublicAccess = false;
202
203 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
204 originalSp.AbsolutePosition = new Vector3(128, 32, 10);
205
206 AgentUpdateArgs moveArgs = new AgentUpdateArgs();
207 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
208 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
209 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
210 moveArgs.SessionID = acd.SessionID;
211
212 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
213
214 sceneA.Update(1);
215
216// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
217
218 // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
219 // But really we want to do this in a more robust way.
220 for (int i = 0; i < 100; i++)
221 {
222 sceneA.Update(1);
223// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
224 }
225
226 // sceneA agent should still be root
227 ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
228 Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False);
229
230 ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
231
232 // sceneB agent should also still be root
233 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
234
235 // sceneB should ignore unauthorized attempt to upgrade agent to root
236 TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
237
238 int agentMovementCompleteReceived = 0;
239 sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
240
241 sceneBTc.CompleteMovement();
242
243 Assert.That(agentMovementCompleteReceived, Is.EqualTo(0));
244 Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
245 }
246 }
247} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
index acaeb90..b232a44 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -32,12 +32,10 @@ using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
39using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock;
41using System.Threading; 39using System.Threading;
42 40
43namespace OpenSim.Region.Framework.Scenes.Tests 41namespace OpenSim.Region.Framework.Scenes.Tests
@@ -73,6 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
73 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); 71 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
74 Assert.That(part.GetSittingAvatars(), Is.Null); 72 Assert.That(part.GetSittingAvatars(), Is.Null);
75 Assert.That(m_sp.ParentID, Is.EqualTo(0)); 73 Assert.That(m_sp.ParentID, Is.EqualTo(0));
74 Assert.AreEqual(startPos, m_sp.AbsolutePosition);
76 } 75 }
77 76
78 [Test] 77 [Test]
@@ -87,15 +86,21 @@ namespace OpenSim.Region.Framework.Scenes.Tests
87 86
88 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; 87 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
89 88
89 // We need to preserve this here because phys actor is removed by the sit.
90 Vector3 spPhysActorSize = m_sp.PhysicsActor.Size;
90 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 91 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
91 92
92 Assert.That(m_sp.PhysicsActor, Is.Null); 93 Assert.That(m_sp.PhysicsActor, Is.Null);
93 94
95 Assert.That(
96 m_sp.AbsolutePosition,
97 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2)));
98
94 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 99 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
95 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); 100 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
96 HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); 101 HashSet<ScenePresence> sittingAvatars = part.GetSittingAvatars();
97 Assert.That(sittingAvatars.Count, Is.EqualTo(1)); 102 Assert.That(sittingAvatars.Count, Is.EqualTo(1));
98 Assert.That(sittingAvatars.Contains(m_sp.UUID)); 103 Assert.That(sittingAvatars.Contains(m_sp));
99 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); 104 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
100 } 105 }
101 106
@@ -111,15 +116,43 @@ namespace OpenSim.Region.Framework.Scenes.Tests
111 116
112 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; 117 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
113 118
119 // We need to preserve this here because phys actor is removed by the sit.
120 Vector3 spPhysActorSize = m_sp.PhysicsActor.Size;
121 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
122
123 Assert.That(
124 m_sp.AbsolutePosition,
125 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2)));
126
127 m_sp.StandUp();
128
129 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
130 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
131 Assert.That(part.GetSittingAvatars(), Is.Null);
132 Assert.That(m_sp.ParentID, Is.EqualTo(0));
133 Assert.That(m_sp.PhysicsActor, Is.Not.Null);
134 }
135
136 [Test]
137 public void TestSitAndStandWithNoSitTargetChildPrim()
138 {
139 TestHelpers.InMethod();
140// log4net.Config.XmlConfigurator.Configure();
141
142 // Make sure we're within range to sit
143 Vector3 startPos = new Vector3(1, 1, 1);
144 m_sp.AbsolutePosition = startPos;
145
146 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene, 2, m_sp.UUID, "part", 0x10).Parts[1];
147 part.OffsetPosition = new Vector3(2, 3, 4);
148
149 // We need to preserve this here because phys actor is removed by the sit.
150 Vector3 spPhysActorSize = m_sp.PhysicsActor.Size;
114 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 151 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
115 152
116 // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
117 // default avatar.
118 // Curiously, Vector3.ToString() will not display the last two places of the float. For example,
119 // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337>
120 Assert.That( 153 Assert.That(
121 m_sp.AbsolutePosition, 154 m_sp.AbsolutePosition,
122 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); 155 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2)));
123 156
124 m_sp.StandUp(); 157 m_sp.StandUp();
125 158
@@ -147,15 +180,39 @@ namespace OpenSim.Region.Framework.Scenes.Tests
147 180
148 Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); 181 Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID));
149 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); 182 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
183
184 // This section is copied from ScenePresence.HandleAgentSit(). Correctness is not guaranteed.
185 double x, y, z, m1, m2;
186
187 Quaternion r = part.SitTargetOrientation;;
188 m1 = r.X * r.X + r.Y * r.Y;
189 m2 = r.Z * r.Z + r.W * r.W;
190
191 // Rotate the vector <0, 0, 1>
192 x = 2 * (r.X * r.Z + r.Y * r.W);
193 y = 2 * (-r.X * r.W + r.Y * r.Z);
194 z = m2 - m1;
195
196 // Set m to be the square of the norm of r.
197 double m = m1 + m2;
198
199 // This constant is emperically determined to be what is used in SL.
200 // See also http://opensimulator.org/mantis/view.php?id=7096
201 double offset = 0.05;
202
203 Vector3 up = new Vector3((float)x, (float)y, (float)z);
204 Vector3 sitOffset = up * (float)offset;
205 // End of copied section.
206
150 Assert.That( 207 Assert.That(
151 m_sp.AbsolutePosition, 208 m_sp.AbsolutePosition,
152 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); 209 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition - sitOffset + ScenePresence.SIT_TARGET_ADJUSTMENT));
153 Assert.That(m_sp.PhysicsActor, Is.Null); 210 Assert.That(m_sp.PhysicsActor, Is.Null);
154 211
155 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); 212 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
156 HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); 213 HashSet<ScenePresence> sittingAvatars = part.GetSittingAvatars();
157 Assert.That(sittingAvatars.Count, Is.EqualTo(1)); 214 Assert.That(sittingAvatars.Count, Is.EqualTo(1));
158 Assert.That(sittingAvatars.Contains(m_sp.UUID)); 215 Assert.That(sittingAvatars.Contains(m_sp));
159 216
160 m_sp.StandUp(); 217 m_sp.StandUp();
161 218
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index 8dd1f3d..443ec51 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -26,12 +26,15 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Text;
33using System.Threading;
30using Nini.Config; 34using Nini.Config;
31using NUnit.Framework; 35using NUnit.Framework;
32using OpenMetaverse; 36using OpenMetaverse;
33using OpenSim.Framework; 37using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
36using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.Framework; 40using OpenSim.Region.CoreModules.Framework;
@@ -39,9 +42,6 @@ using OpenSim.Region.CoreModules.Framework.EntityTransfer;
39using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 42using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
40using OpenSim.Region.CoreModules.World.Permissions; 43using OpenSim.Region.CoreModules.World.Permissions;
41using OpenSim.Tests.Common; 44using OpenSim.Tests.Common;
42using OpenSim.Tests.Common.Mock;
43using System.IO;
44using System.Text;
45 45
46namespace OpenSim.Region.Framework.Scenes.Tests 46namespace OpenSim.Region.Framework.Scenes.Tests
47{ 47{
@@ -68,7 +68,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
68 } 68 }
69 69
70 [Test] 70 [Test]
71 public void TestSameRegionTeleport() 71 public void TestSameRegion()
72 { 72 {
73 TestHelpers.InMethod(); 73 TestHelpers.InMethod();
74// log4net.Config.XmlConfigurator.Configure(); 74// log4net.Config.XmlConfigurator.Configure();
@@ -105,11 +105,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
105// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); 105// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
106 } 106 }
107 107
108/*
108 [Test] 109 [Test]
109 public void TestSameSimulatorSeparatedRegionsTeleport() 110 public void TestSameSimulatorIsolatedRegionsV1()
110 { 111 {
111 TestHelpers.InMethod(); 112 TestHelpers.InMethod();
112// log4net.Config.XmlConfigurator.Configure(); 113// TestHelpers.EnableLogging();
113 114
114 UUID userId = TestHelpers.ParseTail(0x1); 115 UUID userId = TestHelpers.ParseTail(0x1);
115 116
@@ -135,15 +136,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests
135 SceneHelpers.SetupSceneModules(sceneB, config, etmB); 136 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
136 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); 137 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
137 138
139 // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
140 lscm.ServiceVersion = 0.1f;
141
138 Vector3 teleportPosition = new Vector3(10, 11, 12); 142 Vector3 teleportPosition = new Vector3(10, 11, 12);
139 Vector3 teleportLookAt = new Vector3(20, 21, 22); 143 Vector3 teleportLookAt = new Vector3(20, 21, 22);
140 144
141 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 145 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
142 sp.AbsolutePosition = new Vector3(30, 31, 32); 146 sp.AbsolutePosition = new Vector3(30, 31, 32);
143 147
144 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole 148 List<TestClient> destinationTestClients = new List<TestClient>();
145 // UDP stack (?) 149 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
146// ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB; 150 (TestClient)sp.ControllingClient, destinationTestClients);
147 151
148 sceneA.RequestTeleportLocation( 152 sceneA.RequestTeleportLocation(
149 sp.ControllingClient, 153 sp.ControllingClient,
@@ -152,7 +156,72 @@ namespace OpenSim.Region.Framework.Scenes.Tests
152 teleportLookAt, 156 teleportLookAt,
153 (uint)TeleportFlags.ViaLocation); 157 (uint)TeleportFlags.ViaLocation);
154 158
155 ((TestClient)sp.ControllingClient).CompleteTeleportClientSide(); 159 // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
160 // agent. This call will now complete the movement of the user into the destination and upgrade the agent
161 // from child to root.
162 destinationTestClients[0].CompleteMovement();
163
164 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
165
166 ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
167 Assert.That(sceneBSp, Is.Not.Null);
168 Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
169 Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
170
171 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
172 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
173 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
174 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
175
176 // TODO: Add assertions to check correct circuit details in both scenes.
177
178 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
179 // position instead).
180// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
181 }
182*/
183
184 [Test]
185 public void TestSameSimulatorIsolatedRegionsV2()
186 {
187 TestHelpers.InMethod();
188// TestHelpers.EnableLogging();
189
190 UUID userId = TestHelpers.ParseTail(0x1);
191
192 EntityTransferModule etmA = new EntityTransferModule();
193 EntityTransferModule etmB = new EntityTransferModule();
194 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
195
196 IConfigSource config = new IniConfigSource();
197 IConfig modulesConfig = config.AddConfig("Modules");
198 modulesConfig.Set("EntityTransferModule", etmA.Name);
199 modulesConfig.Set("SimulationServices", lscm.Name);
200
201 SceneHelpers sh = new SceneHelpers();
202 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
203 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
204
205 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
206 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
207 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
208
209 Vector3 teleportPosition = new Vector3(10, 11, 12);
210 Vector3 teleportLookAt = new Vector3(20, 21, 22);
211
212 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
213 sp.AbsolutePosition = new Vector3(30, 31, 32);
214
215 List<TestClient> destinationTestClients = new List<TestClient>();
216 EntityTransferHelpers.SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
217 (TestClient)sp.ControllingClient, destinationTestClients);
218
219 sceneA.RequestTeleportLocation(
220 sp.ControllingClient,
221 sceneB.RegionInfo.RegionHandle,
222 teleportPosition,
223 teleportLookAt,
224 (uint)TeleportFlags.ViaLocation);
156 225
157 Assert.That(sceneA.GetScenePresence(userId), Is.Null); 226 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
158 227
@@ -177,7 +246,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
177 /// Test teleport procedures when the target simulator returns false when queried about access. 246 /// Test teleport procedures when the target simulator returns false when queried about access.
178 /// </summary> 247 /// </summary>
179 [Test] 248 [Test]
180 public void TestSameSimulatorSeparatedRegionsQueryAccessFails() 249 public void TestSameSimulatorIsolatedRegions_DeniedOnQueryAccess()
181 { 250 {
182 TestHelpers.InMethod(); 251 TestHelpers.InMethod();
183// TestHelpers.EnableLogging(); 252// TestHelpers.EnableLogging();
@@ -221,7 +290,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
221 Vector3 teleportPosition = new Vector3(10, 11, 12); 290 Vector3 teleportPosition = new Vector3(10, 11, 12);
222 Vector3 teleportLookAt = new Vector3(20, 21, 22); 291 Vector3 teleportLookAt = new Vector3(20, 21, 22);
223 292
224 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 293 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
225 sp.AbsolutePosition = preTeleportPosition; 294 sp.AbsolutePosition = preTeleportPosition;
226 295
227 // Make sceneB return false on query access 296 // Make sceneB return false on query access
@@ -261,7 +330,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
261 /// Test teleport procedures when the target simulator create agent step is refused. 330 /// Test teleport procedures when the target simulator create agent step is refused.
262 /// </summary> 331 /// </summary>
263 [Test] 332 [Test]
264 public void TestSameSimulatorSeparatedRegionsCreateAgentFails() 333 public void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent()
265 { 334 {
266 TestHelpers.InMethod(); 335 TestHelpers.InMethod();
267// TestHelpers.EnableLogging(); 336// TestHelpers.EnableLogging();
@@ -297,7 +366,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
297 Vector3 teleportPosition = new Vector3(10, 11, 12); 366 Vector3 teleportPosition = new Vector3(10, 11, 12);
298 Vector3 teleportLookAt = new Vector3(20, 21, 22); 367 Vector3 teleportLookAt = new Vector3(20, 21, 22);
299 368
300 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 369 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
301 sp.AbsolutePosition = preTeleportPosition; 370 sp.AbsolutePosition = preTeleportPosition;
302 371
303 // Make sceneB refuse CreateAgent 372 // Make sceneB refuse CreateAgent
@@ -333,8 +402,97 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333// TestHelpers.DisableLogging(); 402// TestHelpers.DisableLogging();
334 } 403 }
335 404
405 /// <summary>
406 /// Test teleport when the destination region does not process (or does not receive) the connection attempt
407 /// from the viewer.
408 /// </summary>
409 /// <remarks>
410 /// This could be quite a common case where the source region can connect to a remove destination region
411 /// (for CreateAgent) but the viewer cannot reach the destination region due to network issues.
412 /// </remarks>
336 [Test] 413 [Test]
337 public void TestSameSimulatorNeighbouringRegionsTeleport() 414 public void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection()
415 {
416 TestHelpers.InMethod();
417// TestHelpers.EnableLogging();
418
419 UUID userId = TestHelpers.ParseTail(0x1);
420 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
421
422 EntityTransferModule etmA = new EntityTransferModule();
423 EntityTransferModule etmB = new EntityTransferModule();
424
425 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
426
427 IConfigSource config = new IniConfigSource();
428 config.AddConfig("Modules");
429 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
430 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
431
432 config.AddConfig("EntityTransfer");
433
434 // In order to run a single threaded regression test we do not want the entity transfer module waiting
435 // for a callback from the destination scene before removing its avatar data.
436 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
437
438// config.AddConfig("Startup");
439// config.Configs["Startup"].Set("serverside_object_permissions", true);
440
441 SceneHelpers sh = new SceneHelpers();
442 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
443 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
444
445 SceneHelpers.SetupSceneModules(sceneA, config, etmA );
446
447 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
448 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
449 // IsAdministrator if no permissions module is present is true.
450 SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
451
452 // Shared scene modules
453 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
454
455 Vector3 teleportPosition = new Vector3(10, 11, 12);
456 Vector3 teleportLookAt = new Vector3(20, 21, 22);
457
458 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
459 sp.AbsolutePosition = preTeleportPosition;
460
461 sceneA.RequestTeleportLocation(
462 sp.ControllingClient,
463 sceneB.RegionInfo.RegionHandle,
464 teleportPosition,
465 teleportLookAt,
466 (uint)TeleportFlags.ViaLocation);
467
468 // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate
469 // communication with the destination region. But this is a very non-obvious way of doing it - really we
470 // should be forced to expicitly set this up.
471
472 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
473
474 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
475 Assert.That(sceneASp, Is.Not.Null);
476 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
477 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
478
479 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
480 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
481 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
482 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
483
484 // TODO: Add assertions to check correct circuit details in both scenes.
485
486 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
487 // position instead).
488// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
489
490// TestHelpers.DisableLogging();
491 }
492
493/*
494 [Test]
495 public void TestSameSimulatorNeighbouringRegionsV1()
338 { 496 {
339 TestHelpers.InMethod(); 497 TestHelpers.InMethod();
340// TestHelpers.EnableLogging(); 498// TestHelpers.EnableLogging();
@@ -363,13 +521,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
363 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); 521 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
364 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); 522 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
365 523
524 // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
525 lscm.ServiceVersion = 0.1f;
526
366 Vector3 teleportPosition = new Vector3(10, 11, 12); 527 Vector3 teleportPosition = new Vector3(10, 11, 12);
367 Vector3 teleportLookAt = new Vector3(20, 21, 22); 528 Vector3 teleportLookAt = new Vector3(20, 21, 22);
368 529
369 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager); 530 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
370 originalSp.AbsolutePosition = new Vector3(30, 31, 32); 531 TestClient tc = new TestClient(acd, sceneA);
532 List<TestClient> destinationTestClients = new List<TestClient>();
533 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
534
535 ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
536 beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
371 537
372 ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);
373 Assert.That(beforeSceneASp, Is.Not.Null); 538 Assert.That(beforeSceneASp, Is.Not.Null);
374 Assert.That(beforeSceneASp.IsChildAgent, Is.False); 539 Assert.That(beforeSceneASp.IsChildAgent, Is.False);
375 540
@@ -377,10 +542,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
377 Assert.That(beforeSceneBSp, Is.Not.Null); 542 Assert.That(beforeSceneBSp, Is.Not.Null);
378 Assert.That(beforeSceneBSp.IsChildAgent, Is.True); 543 Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
379 544
380 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole 545 // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
381 // UDP stack (?) 546 // about the neighbour region it is teleporting to.
382// ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;
383
384 sceneA.RequestTeleportLocation( 547 sceneA.RequestTeleportLocation(
385 beforeSceneASp.ControllingClient, 548 beforeSceneASp.ControllingClient,
386 sceneB.RegionInfo.RegionHandle, 549 sceneB.RegionInfo.RegionHandle,
@@ -388,7 +551,92 @@ namespace OpenSim.Region.Framework.Scenes.Tests
388 teleportLookAt, 551 teleportLookAt,
389 (uint)TeleportFlags.ViaLocation); 552 (uint)TeleportFlags.ViaLocation);
390 553
391 ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide(); 554 destinationTestClients[0].CompleteMovement();
555
556 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
557 Assert.That(afterSceneASp, Is.Not.Null);
558 Assert.That(afterSceneASp.IsChildAgent, Is.True);
559
560 ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
561 Assert.That(afterSceneBSp, Is.Not.Null);
562 Assert.That(afterSceneBSp.IsChildAgent, Is.False);
563 Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
564 Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
565
566 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
567 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
568 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
569 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
570
571 // TODO: Add assertions to check correct circuit details in both scenes.
572
573 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
574 // position instead).
575// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
576
577// TestHelpers.DisableLogging();
578 }
579*/
580
581 [Test]
582 public void TestSameSimulatorNeighbouringRegionsV2()
583 {
584 TestHelpers.InMethod();
585// TestHelpers.EnableLogging();
586
587 UUID userId = TestHelpers.ParseTail(0x1);
588
589 EntityTransferModule etmA = new EntityTransferModule();
590 EntityTransferModule etmB = new EntityTransferModule();
591 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
592
593 IConfigSource config = new IniConfigSource();
594 IConfig modulesConfig = config.AddConfig("Modules");
595 modulesConfig.Set("EntityTransferModule", etmA.Name);
596 modulesConfig.Set("SimulationServices", lscm.Name);
597
598 SceneHelpers sh = new SceneHelpers();
599 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
600 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
601
602 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
603 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
604 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
605
606 Vector3 teleportPosition = new Vector3(10, 11, 12);
607 Vector3 teleportLookAt = new Vector3(20, 21, 22);
608
609 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
610 TestClient tc = new TestClient(acd, sceneA);
611 List<TestClient> destinationTestClients = new List<TestClient>();
612 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
613
614 ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
615 beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);
616
617 Assert.That(beforeSceneASp, Is.Not.Null);
618 Assert.That(beforeSceneASp.IsChildAgent, Is.False);
619
620 ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
621 Assert.That(beforeSceneBSp, Is.Not.Null);
622 Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
623
624 // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This
625 // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
626 // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
627 // Both these operations will occur on different threads and will wait for each other.
628 // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
629 // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
630 tc.OnTestClientSendRegionTeleport
631 += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
632 => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);
633
634 sceneA.RequestTeleportLocation(
635 beforeSceneASp.ControllingClient,
636 sceneB.RegionInfo.RegionHandle,
637 teleportPosition,
638 teleportLookAt,
639 (uint)TeleportFlags.ViaLocation);
392 640
393 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId); 641 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
394 Assert.That(afterSceneASp, Is.Not.Null); 642 Assert.That(afterSceneASp, Is.Not.Null);
@@ -414,4 +662,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests
414// TestHelpers.DisableLogging(); 662// TestHelpers.DisableLogging();
415 } 663 }
416 } 664 }
417} \ No newline at end of file 665}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs
new file mode 100644
index 0000000..045fd3c
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs
@@ -0,0 +1,69 @@
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 NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Tests.Common;
36
37namespace OpenSim.Region.Framework.Scenes.Tests
38{
39 [TestFixture]
40 public class SceneStatisticsTests : OpenSimTestCase
41 {
42 private TestScene m_scene;
43
44 [SetUp]
45 public void Init()
46 {
47 m_scene = new SceneHelpers().SetupScene();
48 }
49
50 [Test]
51 public void TestAddRemovePhysicalLinkset()
52 {
53 Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(0));
54
55 UUID ownerId = TestHelpers.ParseTail(0x1);
56 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(3, ownerId, "so1", 0x10);
57 so1.ScriptSetPhysicsStatus(true);
58 m_scene.AddSceneObject(so1);
59
60 Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(3));
61 Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(3));
62
63 m_scene.DeleteSceneObject(so1, false);
64
65 Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(0));
66 Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(0));
67 }
68 }
69} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs
new file mode 100644
index 0000000..584a03c
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs
@@ -0,0 +1,118 @@
1/*
2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions are met:
4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above copyright
7 * notice, this list of conditions and the following disclaimer in the
8 * documentation and/or other materials provided with the distribution.
9 * * Neither the name of the OpenSimulator Project nor the
10 * names of its contributors may be used to endorse or promote products
11 * derived from this software without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25using System;
26using Nini.Config;
27using NUnit.Framework;
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Region.CoreModules.World.Estate;
31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Services.Interfaces;
34using OpenSim.Tests.Common;
35
36namespace OpenSim.Region.Framework.Scenes.Tests
37{
38 /// <summary>
39 /// Scene telehub tests
40 /// </summary>
41 /// <remarks>
42 /// TODO: Tests which run through normal functionality. Currently, the only test is one that checks behaviour
43 /// in the case of an error condition
44 /// </remarks>
45 [TestFixture]
46 public class SceneTelehubTests : OpenSimTestCase
47 {
48 /// <summary>
49 /// Test for desired behaviour when a telehub has no spawn points
50 /// </summary>
51 [Test]
52 public void TestNoTelehubSpawnPoints()
53 {
54 TestHelpers.InMethod();
55// TestHelpers.EnableLogging();
56
57 EstateManagementModule emm = new EstateManagementModule();
58
59 SceneHelpers sh = new SceneHelpers();
60 Scene scene = sh.SetupScene();
61 SceneHelpers.SetupSceneModules(scene, emm);
62
63 UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
64
65 SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
66
67 emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
68 scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
69
70 // Must still be possible to successfully log in
71 UUID loggingInUserId = TestHelpers.ParseTail(0x2);
72
73 UserAccount ua
74 = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
75
76 SceneHelpers.AddScenePresence(scene, ua);
77
78 Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
79 }
80
81 /// <summary>
82 /// Test for desired behaviour when the scene object nominated as a telehub object does not exist.
83 /// </summary>
84 [Test]
85 public void TestNoTelehubSceneObject()
86 {
87 TestHelpers.InMethod();
88// TestHelpers.EnableLogging();
89
90 EstateManagementModule emm = new EstateManagementModule();
91
92 SceneHelpers sh = new SceneHelpers();
93 Scene scene = sh.SetupScene();
94 SceneHelpers.SetupSceneModules(scene, emm);
95
96 UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
97
98 SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
99 SceneObjectGroup spawnPointSo = SceneHelpers.AddSceneObject(scene, "spawnpointObject", telehubSceneObjectOwner);
100
101 emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
102 emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "spawnpoint add", spawnPointSo.LocalId);
103 scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
104
105 scene.DeleteSceneObject(telehubSo, false);
106
107 // Must still be possible to successfully log in
108 UUID loggingInUserId = TestHelpers.ParseTail(0x2);
109
110 UserAccount ua
111 = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
112
113 SceneHelpers.AddScenePresence(scene, ua);
114
115 Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
116 }
117 }
118} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 9d8eb0b..517faf1 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -36,13 +36,11 @@ using Nini.Config;
36using NUnit.Framework; 36using NUnit.Framework;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser; 41using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 42using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
44using OpenSim.Tests.Common; 43using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock;
46 44
47namespace OpenSim.Region.Framework.Scenes.Tests 45namespace OpenSim.Region.Framework.Scenes.Tests
48{ 46{
@@ -52,6 +50,29 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52 [TestFixture] 50 [TestFixture]
53 public class SceneTests : OpenSimTestCase 51 public class SceneTests : OpenSimTestCase
54 { 52 {
53 [Test]
54 public void TestCreateScene()
55 {
56 TestHelpers.InMethod();
57
58 new SceneHelpers().SetupScene();
59 }
60
61 [Test]
62 public void TestCreateVarScene()
63 {
64 TestHelpers.InMethod();
65 UUID regionUuid = TestHelpers.ParseTail(0x1);
66 uint sizeX = 512;
67 uint sizeY = 512;
68
69 Scene scene
70 = new SceneHelpers().SetupScene("scene", regionUuid, 1000, 1000, sizeX, sizeY, new IniConfigSource());
71
72 Assert.AreEqual(sizeX, scene.RegionInfo.RegionSizeX);
73 Assert.AreEqual(sizeY, scene.RegionInfo.RegionSizeY);
74 }
75
55 /// <summary> 76 /// <summary>
56 /// Very basic scene update test. Should become more elaborate with time. 77 /// Very basic scene update test. Should become more elaborate with time.
57 /// </summary> 78 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs
new file mode 100644
index 0000000..eeda84f
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SharedRegionModuleTests.cs
@@ -0,0 +1,249 @@
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.Net;
31using Mono.Addins;
32using Nini.Config;
33using NUnit.Framework;
34using OpenMetaverse;
35using OpenSim;
36using OpenSim.ApplicationPlugins.RegionModulesController;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Tests.Common;
41
42namespace OpenSim.Region.Framework.Scenes.Tests
43{
44 public class SharedRegionModuleTests : OpenSimTestCase
45 {
46// [Test]
47 public void TestLifecycle()
48 {
49 TestHelpers.InMethod();
50 TestHelpers.EnableLogging();
51
52 UUID estateOwnerId = TestHelpers.ParseTail(0x1);
53 UUID regionId = TestHelpers.ParseTail(0x10);
54
55 IConfigSource configSource = new IniConfigSource();
56 configSource.AddConfig("Startup");
57 configSource.AddConfig("Modules");
58
59// // We use this to skip estate questions
60 // Turns out not to be needed is estate owner id is pre-set in region information.
61// IConfig estateConfig = configSource.AddConfig(OpenSimBase.ESTATE_SECTION_NAME);
62// estateConfig.Set("DefaultEstateOwnerName", "Zaphod Beeblebrox");
63// estateConfig.Set("DefaultEstateOwnerUUID", estateOwnerId);
64// estateConfig.Set("DefaultEstateOwnerEMail", "zaphod@galaxy.com");
65// estateConfig.Set("DefaultEstateOwnerPassword", "two heads");
66
67 // For grid servic
68 configSource.AddConfig("GridService");
69 configSource.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
70 configSource.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
71 configSource.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
72 configSource.Configs["GridService"].Set("ConnectionString", "!static");
73
74 LocalGridServicesConnector gridService = new LocalGridServicesConnector();
75//
76 OpenSim sim = new OpenSim(configSource);
77
78 sim.SuppressExit = true;
79 sim.EnableInitialPluginLoad = false;
80 sim.LoadEstateDataService = false;
81 sim.NetServersInfo.HttpListenerPort = 0;
82
83 IRegistryCore reg = sim.ApplicationRegistry;
84
85 RegionInfo ri = new RegionInfo();
86 ri.RegionID = regionId;
87 ri.EstateSettings.EstateOwner = estateOwnerId;
88 ri.InternalEndPoint = new IPEndPoint(0, 0);
89
90 MockRegionModulesControllerPlugin rmcp = new MockRegionModulesControllerPlugin();
91 sim.m_plugins = new List<IApplicationPlugin>() { rmcp };
92 reg.RegisterInterface<IRegionModulesController>(rmcp);
93
94 // XXX: Have to initialize directly for now
95 rmcp.Initialise(sim);
96
97 rmcp.AddNode(gridService);
98
99 TestSharedRegion tsr = new TestSharedRegion();
100 rmcp.AddNode(tsr);
101
102 // FIXME: Want to use the real one eventually but this is currently directly tied into Mono.Addins
103 // which has been written in such a way that makes it impossible to use for regression tests.
104// RegionModulesControllerPlugin rmcp = new RegionModulesControllerPlugin();
105// rmcp.LoadModulesFromAddins = false;
106//// reg.RegisterInterface<IRegionModulesController>(rmcp);
107// rmcp.Initialise(sim);
108// rmcp.PostInitialise();
109// TypeExtensionNode node = new TypeExtensionNode();
110// node.
111// rmcp.AddNode(node, configSource.Configs["Modules"], new Dictionary<RuntimeAddin, IList<int>>());
112
113 sim.Startup();
114 IScene scene;
115 sim.CreateRegion(ri, out scene);
116
117 sim.Shutdown();
118
119 List<string> co = tsr.CallOrder;
120 int expectedEventCount = 6;
121
122 Assert.AreEqual(
123 expectedEventCount,
124 co.Count,
125 "Expected {0} events but only got {1} ({2})",
126 expectedEventCount, co.Count, string.Join(",", co));
127 Assert.AreEqual("Initialise", co[0]);
128 Assert.AreEqual("PostInitialise", co[1]);
129 Assert.AreEqual("AddRegion", co[2]);
130 Assert.AreEqual("RegionLoaded", co[3]);
131 Assert.AreEqual("RemoveRegion", co[4]);
132 Assert.AreEqual("Close", co[5]);
133 }
134 }
135
136 class TestSharedRegion : ISharedRegionModule
137 {
138 // FIXME: Should really use MethodInfo
139 public List<string> CallOrder = new List<string>();
140
141 public string Name { get { return "TestSharedRegion"; } }
142
143 public Type ReplaceableInterface { get { return null; } }
144
145 public void PostInitialise()
146 {
147 CallOrder.Add("PostInitialise");
148 }
149
150 public void Initialise(IConfigSource source)
151 {
152 CallOrder.Add("Initialise");
153 }
154
155 public void Close()
156 {
157 CallOrder.Add("Close");
158 }
159
160 public void AddRegion(Scene scene)
161 {
162 CallOrder.Add("AddRegion");
163 }
164
165 public void RemoveRegion(Scene scene)
166 {
167 CallOrder.Add("RemoveRegion");
168 }
169
170 public void RegionLoaded(Scene scene)
171 {
172 CallOrder.Add("RegionLoaded");
173 }
174 }
175
176 class MockRegionModulesControllerPlugin : IRegionModulesController, IApplicationPlugin
177 {
178 // List of shared module instances, for adding to Scenes
179 private List<ISharedRegionModule> m_sharedInstances = new List<ISharedRegionModule>();
180
181 // Config access
182 private OpenSimBase m_openSim;
183
184 public string Version { get { return "0"; } }
185 public string Name { get { return "MockRegionModulesControllerPlugin"; } }
186
187 public void Initialise() {}
188
189 public void Initialise(OpenSimBase sim)
190 {
191 m_openSim = sim;
192 }
193
194 /// <summary>
195 /// Called when the application loading is completed
196 /// </summary>
197 public void PostInitialise()
198 {
199 foreach (ISharedRegionModule module in m_sharedInstances)
200 module.PostInitialise();
201 }
202
203 public void AddRegionToModules(Scene scene)
204 {
205 List<ISharedRegionModule> sharedlist = new List<ISharedRegionModule>();
206
207 foreach (ISharedRegionModule module in m_sharedInstances)
208 {
209 module.AddRegion(scene);
210 scene.AddRegionModule(module.Name, module);
211
212 sharedlist.Add(module);
213 }
214
215 foreach (ISharedRegionModule module in sharedlist)
216 {
217 module.RegionLoaded(scene);
218 }
219 }
220
221 public void RemoveRegionFromModules(Scene scene)
222 {
223 foreach (IRegionModuleBase module in scene.RegionModules.Values)
224 {
225// m_log.DebugFormat("[REGIONMODULE]: Removing scene {0} from module {1}",
226// scene.RegionInfo.RegionName, module.Name);
227 module.RemoveRegion(scene);
228 }
229
230 scene.RegionModules.Clear();
231 }
232
233 public void AddNode(ISharedRegionModule module)
234 {
235 m_sharedInstances.Add(module);
236 module.Initialise(m_openSim.ConfigSource.Source);
237 }
238
239 public void Dispose()
240 {
241 // We expect that all regions have been removed already
242 while (m_sharedInstances.Count > 0)
243 {
244 m_sharedInstances[0].Close();
245 m_sharedInstances.RemoveAt(0);
246 }
247 }
248 }
249} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index 0b461f5..b01088d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -37,7 +37,6 @@ using NUnit.Framework;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenMetaverse.Assets; 38using OpenMetaverse.Assets;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 42using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
@@ -45,7 +44,6 @@ using OpenSim.Region.CoreModules.World.Serialiser;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
46using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common; 46using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49 47
50namespace OpenSim.Region.Framework.Tests 48namespace OpenSim.Region.Framework.Tests
51{ 49{
@@ -65,7 +63,7 @@ namespace OpenSim.Region.Framework.Tests
65 63
66 // Create an object embedded inside the first 64 // Create an object embedded inside the first
67 UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); 65 UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
68 TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); 66 TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID);
69 67
70 TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId); 68 TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId);
71 Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId)); 69 Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId));
@@ -89,7 +87,7 @@ namespace OpenSim.Region.Framework.Tests
89 // Create an object embedded inside the first 87 // Create an object embedded inside the first
90 UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); 88 UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
91 TaskInventoryItem taskSceneObjectItem 89 TaskInventoryItem taskSceneObjectItem
92 = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); 90 = TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID);
93 91
94 scene.AddSceneObject(sog1); 92 scene.AddSceneObject(sog1);
95 93
@@ -130,13 +128,14 @@ namespace OpenSim.Region.Framework.Tests
130 SceneObjectPart sop1 = sog1.RootPart; 128 SceneObjectPart sop1 = sog1.RootPart;
131 TaskInventoryItem sopItem1 129 TaskInventoryItem sopItem1
132 = TaskInventoryHelpers.AddNotecard( 130 = TaskInventoryHelpers.AddNotecard(
133 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); 131 scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
134 132
135 InventoryFolderBase folder 133 InventoryFolderBase folder
136 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; 134 = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
137 135
138 // Perform test 136 // Perform test
139 scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); 137 string message;
138 scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message);
140 139
141 InventoryItemBase ncUserItem 140 InventoryItemBase ncUserItem
142 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); 141 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem");
@@ -162,10 +161,11 @@ namespace OpenSim.Region.Framework.Tests
162 SceneObjectPart sop1 = sog1.RootPart; 161 SceneObjectPart sop1 = sog1.RootPart;
163 TaskInventoryItem sopItem1 162 TaskInventoryItem sopItem1
164 = TaskInventoryHelpers.AddNotecard( 163 = TaskInventoryHelpers.AddNotecard(
165 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); 164 scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
166 165
167 // Perform test 166 // Perform test
168 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); 167 string message;
168 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message);
169 169
170 InventoryItemBase ncUserItem 170 InventoryItemBase ncUserItem
171 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); 171 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index 9457ebb..8250e6c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -37,7 +37,6 @@ using NUnit.Framework;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenMetaverse.Assets; 38using OpenMetaverse.Assets;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 42using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
@@ -45,7 +44,6 @@ using OpenSim.Region.CoreModules.World.Serialiser;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
46using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common; 46using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49 47
50namespace OpenSim.Region.Framework.Tests 48namespace OpenSim.Region.Framework.Tests
51{ 49{
@@ -64,7 +62,7 @@ namespace OpenSim.Region.Framework.Tests
64 Scene scene = new SceneHelpers().SetupScene(); 62 Scene scene = new SceneHelpers().SetupScene();
65 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 63 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
66 64
67 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName); 65 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
68 66
69 List<InventoryFolderBase> oneFolder 67 List<InventoryFolderBase> oneFolder
70 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName); 68 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
@@ -73,7 +71,7 @@ namespace OpenSim.Region.Framework.Tests
73 InventoryFolderBase firstRetrievedFolder = oneFolder[0]; 71 InventoryFolderBase firstRetrievedFolder = oneFolder[0];
74 Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName)); 72 Assert.That(firstRetrievedFolder.Name, Is.EqualTo(foldersName));
75 73
76 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName); 74 UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, foldersName, false);
77 75
78 List<InventoryFolderBase> twoFolders 76 List<InventoryFolderBase> twoFolders
79 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName); 77 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, foldersName);
@@ -95,7 +93,9 @@ namespace OpenSim.Region.Framework.Tests
95 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 93 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
96 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); 94 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
97 95
98 scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); 96 string message;
97
98 scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message);
99 99
100 InventoryItemBase retrievedItem1 100 InventoryItemBase retrievedItem1
101 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); 101 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1");
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Tests
103 Assert.That(retrievedItem1, Is.Not.Null); 103 Assert.That(retrievedItem1, Is.Not.Null);
104 104
105 // Try giving back the freshly received item 105 // Try giving back the freshly received item
106 scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); 106 scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message);
107 107
108 List<InventoryItemBase> reretrievedItems 108 List<InventoryItemBase> reretrievedItems
109 = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); 109 = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1");
@@ -121,9 +121,9 @@ namespace OpenSim.Region.Framework.Tests
121 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 121 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
122 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 122 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
123 InventoryFolderBase folder1 123 InventoryFolderBase folder1
124 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1"); 124 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false);
125 125
126 scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); 126 scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero);
127 127
128 InventoryFolderBase retrievedFolder1 128 InventoryFolderBase retrievedFolder1
129 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1"); 129 = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1");
@@ -131,7 +131,7 @@ namespace OpenSim.Region.Framework.Tests
131 Assert.That(retrievedFolder1, Is.Not.Null); 131 Assert.That(retrievedFolder1, Is.Not.Null);
132 132
133 // Try giving back the freshly received folder 133 // Try giving back the freshly received folder
134 scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); 134 scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero);
135 135
136 List<InventoryFolderBase> reretrievedFolders 136 List<InventoryFolderBase> reretrievedFolders
137 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1"); 137 = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index dd27294..937c414 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -33,7 +33,6 @@ using OpenSim.Framework;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Tests.Common; 35using OpenSim.Tests.Common;
36using OpenSim.Tests.Common.Mock;
37 36
38namespace OpenSim.Region.Framework.Scenes.Tests 37namespace OpenSim.Region.Framework.Scenes.Tests
39{ 38{
@@ -62,11 +61,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
62 = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero); 61 = AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero);
63 m_assetService.Store(corruptAsset); 62 m_assetService.Store(corruptAsset);
64 63
65 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); 64 m_uuidGatherer.AddForInspection(corruptAssetUuid);
66 m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); 65 m_uuidGatherer.GatherAll();
67 66
68 // We count the uuid as gathered even if the asset itself is corrupt. 67 // We count the uuid as gathered even if the asset itself is corrupt.
69 Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); 68 Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(1));
70 } 69 }
71 70
72 /// <summary> 71 /// <summary>
@@ -78,38 +77,82 @@ namespace OpenSim.Region.Framework.Scenes.Tests
78 TestHelpers.InMethod(); 77 TestHelpers.InMethod();
79 78
80 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 79 UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
81 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
82
83 m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids);
84 80
85 // We count the uuid as gathered even if the asset itself is missing. 81 m_uuidGatherer.AddForInspection(missingAssetUuid);
86 Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); 82 m_uuidGatherer.GatherAll();
83
84 Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(0));
87 } 85 }
88 86
89 [Test] 87 [Test]
90 public void TestNotecardAsset() 88 public void TestNotecardAsset()
91 { 89 {
92 TestHelpers.InMethod(); 90 TestHelpers.InMethod();
93// log4net.Config.XmlConfigurator.Configure(); 91// TestHelpers.EnableLogging();
94 92
95 UUID ownerId = TestHelpers.ParseTail(0x10); 93 UUID ownerId = TestHelpers.ParseTail(0x10);
96 UUID soAssetId = TestHelpers.ParseTail(0x20); 94 UUID embeddedId = TestHelpers.ParseTail(0x20);
95 UUID secondLevelEmbeddedId = TestHelpers.ParseTail(0x21);
96 UUID missingEmbeddedId = TestHelpers.ParseTail(0x22);
97 UUID ncAssetId = TestHelpers.ParseTail(0x30); 97 UUID ncAssetId = TestHelpers.ParseTail(0x30);
98 98
99 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId); 99 AssetBase ncAsset
100 AssetBase soAsset = AssetHelpers.CreateAsset(soAssetId, so); 100 = AssetHelpers.CreateNotecardAsset(
101 m_assetService.Store(soAsset); 101 ncAssetId, string.Format("Hello{0}World{1}", embeddedId, missingEmbeddedId));
102
103 AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString());
104 m_assetService.Store(ncAsset); 102 m_assetService.Store(ncAsset);
105 103
106 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>(); 104 AssetBase embeddedAsset
107 m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids); 105 = AssetHelpers.CreateNotecardAsset(embeddedId, string.Format("{0} We'll meet again.", secondLevelEmbeddedId));
106 m_assetService.Store(embeddedAsset);
108 107
109 // We count the uuid as gathered even if the asset itself is corrupt. 108 AssetBase secondLevelEmbeddedAsset
110 Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); 109 = AssetHelpers.CreateNotecardAsset(secondLevelEmbeddedId, "Don't know where, don't know when.");
111 Assert.That(foundAssetUuids.ContainsKey(ncAssetId)); 110 m_assetService.Store(secondLevelEmbeddedAsset);
112 Assert.That(foundAssetUuids.ContainsKey(soAssetId)); 111
112 m_uuidGatherer.AddForInspection(ncAssetId);
113 m_uuidGatherer.GatherAll();
114
115// foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys)
116// System.Console.WriteLine("key : {0}", key);
117
118 Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(3));
119 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(ncAssetId));
120 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId));
121 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(secondLevelEmbeddedId));
122 }
123
124 [Test]
125 public void TestTaskItems()
126 {
127 TestHelpers.InMethod();
128// TestHelpers.EnableLogging();
129
130 UUID ownerId = TestHelpers.ParseTail(0x10);
131
132 SceneObjectGroup soL0 = SceneHelpers.CreateSceneObject(1, ownerId, "l0", 0x20);
133 SceneObjectGroup soL1 = SceneHelpers.CreateSceneObject(1, ownerId, "l1", 0x21);
134 SceneObjectGroup soL2 = SceneHelpers.CreateSceneObject(1, ownerId, "l2", 0x22);
135
136 TaskInventoryHelpers.AddScript(
137 m_assetService, soL2.RootPart, TestHelpers.ParseTail(0x33), TestHelpers.ParseTail(0x43), "l3-script", "gibberish");
138
139 TaskInventoryHelpers.AddSceneObject(
140 m_assetService, soL1.RootPart, "l2-item", TestHelpers.ParseTail(0x32), soL2, TestHelpers.ParseTail(0x42));
141 TaskInventoryHelpers.AddSceneObject(
142 m_assetService, soL0.RootPart, "l1-item", TestHelpers.ParseTail(0x31), soL1, TestHelpers.ParseTail(0x41));
143
144 m_uuidGatherer.AddForInspection(soL0);
145 m_uuidGatherer.GatherAll();
146
147// foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys)
148// System.Console.WriteLine("key : {0}", key);
149
150 // We expect to see the default prim texture and the assets of the contained task items
151 Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(4));
152 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(new UUID(Constants.DefaultTexture)));
153 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(TestHelpers.ParseTail(0x41)));
154 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(TestHelpers.ParseTail(0x42)));
155 Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(TestHelpers.ParseTail(0x43)));
113 } 156 }
114 } 157 }
115} 158} \ No newline at end of file