diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests')
28 files changed, 1389 insertions, 78 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 575a081..b6b3344 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | |||
@@ -35,7 +35,6 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
38 | using OpenSim.Tests.Common.Mock; | ||
39 | 38 | ||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | 39 | namespace OpenSim.Region.Framework.Scenes.Tests |
41 | { | 40 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs index 2d831fa..6118004 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs | |||
@@ -36,7 +36,6 @@ using OpenSim.Framework.Communications; | |||
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | ||
40 | 39 | ||
41 | namespace OpenSim.Region.Framework.Scenes.Tests | 40 | namespace OpenSim.Region.Framework.Scenes.Tests |
42 | { | 41 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index a07d64c..bdf0700 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -37,7 +37,6 @@ using OpenSim.Framework.Communications; | |||
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
40 | using OpenSim.Tests.Common.Mock; | ||
41 | 40 | ||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | 41 | namespace OpenSim.Region.Framework.Scenes.Tests |
43 | { | 42 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs new file mode 100644 index 0000000..1d41d33 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs | |||
@@ -0,0 +1,347 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using Nini.Config; | ||
32 | using NUnit.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
37 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
39 | using OpenSim.Region.CoreModules.World.Permissions; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Tests.Common; | ||
43 | |||
44 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
45 | { | ||
46 | /// <summary> | ||
47 | /// Test copying of scene objects. | ||
48 | /// </summary> | ||
49 | /// <remarks> | ||
50 | /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. | ||
51 | /// </remarks> | ||
52 | [TestFixture] | ||
53 | public class SceneObjectCopyTests : OpenSimTestCase | ||
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 | |||
73 | [Test] | ||
74 | public void TestTakeCopyWhenCopierIsOwnerWithPerms() | ||
75 | { | ||
76 | TestHelpers.InMethod(); | ||
77 | // TestHelpers.EnableLogging(); | ||
78 | |||
79 | IConfigSource config = new IniConfigSource(); | ||
80 | config.AddConfig("Modules"); | ||
81 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
82 | |||
83 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
84 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
85 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
86 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
87 | |||
88 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
89 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
90 | sogd.Enabled = false; | ||
91 | |||
92 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); | ||
93 | uint soLocalId = so.LocalId; | ||
94 | // so.UpdatePermissions( | ||
95 | // ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1); | ||
96 | // so.UpdatePermissions( | ||
97 | // ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); | ||
98 | // so.UpdatePermissions( | ||
99 | // ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); | ||
100 | // scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); | ||
101 | |||
102 | // Ideally we might change these via client-focussed method calls as commented out above. However, this | ||
103 | // becomes very convoluted so we will set only the copy perm directly. | ||
104 | so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
105 | // so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
106 | |||
107 | List<uint> localIds = new List<uint>(); | ||
108 | localIds.Add(so.LocalId); | ||
109 | |||
110 | // Specifying a UUID.Zero in this case will currently plop it in Lost and Found | ||
111 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
112 | |||
113 | // Check that object isn't copied until we crank the sogd handle. | ||
114 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
115 | Assert.That(retrievedPart, Is.Not.Null); | ||
116 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
117 | |||
118 | sogd.InventoryDeQueueAndDelete(); | ||
119 | |||
120 | // Check that object is still there. | ||
121 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
122 | Assert.That(retrievedPart2, Is.Not.Null); | ||
123 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
124 | |||
125 | // Check that we have a copy in inventory | ||
126 | InventoryItemBase item | ||
127 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); | ||
128 | Assert.That(item, Is.Not.Null); | ||
129 | } | ||
130 | |||
131 | [Test] | ||
132 | public void TestTakeCopyWhenCopierIsOwnerWithoutPerms() | ||
133 | { | ||
134 | TestHelpers.InMethod(); | ||
135 | // TestHelpers.EnableLogging(); | ||
136 | |||
137 | IConfigSource config = new IniConfigSource(); | ||
138 | config.AddConfig("Modules"); | ||
139 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
140 | |||
141 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
142 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
143 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
144 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
145 | |||
146 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
147 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
148 | sogd.Enabled = false; | ||
149 | |||
150 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); | ||
151 | uint soLocalId = so.LocalId; | ||
152 | |||
153 | so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy); | ||
154 | //so.RootPart.OwnerMask = (uint)(OpenMetaverse.PermissionMask.Copy & ~OpenMetaverse.PermissionMask.Copy); | ||
155 | |||
156 | List<uint> localIds = new List<uint>(); | ||
157 | localIds.Add(so.LocalId); | ||
158 | |||
159 | // Specifying a UUID.Zero in this case will currently plop it in Lost and Found | ||
160 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
161 | |||
162 | // Check that object isn't copied until we crank the sogd handle. | ||
163 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
164 | Assert.That(retrievedPart, Is.Not.Null); | ||
165 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
166 | |||
167 | sogd.InventoryDeQueueAndDelete(); | ||
168 | |||
169 | // Check that object is still there. | ||
170 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
171 | Assert.That(retrievedPart2, Is.Not.Null); | ||
172 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
173 | |||
174 | // Check that we do not have a copy in inventory | ||
175 | InventoryItemBase item | ||
176 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); | ||
177 | Assert.That(item, Is.Null); | ||
178 | } | ||
179 | |||
180 | [Test] | ||
181 | public void TestTakeCopyWhenCopierIsNotOwnerWithPerms() | ||
182 | { | ||
183 | TestHelpers.InMethod(); | ||
184 | // TestHelpers.EnableLogging(); | ||
185 | |||
186 | IConfigSource config = new IniConfigSource(); | ||
187 | config.AddConfig("Modules"); | ||
188 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
189 | |||
190 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
191 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
192 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
193 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
194 | |||
195 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
196 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
197 | sogd.Enabled = false; | ||
198 | |||
199 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2)); | ||
200 | uint soLocalId = so.LocalId; | ||
201 | |||
202 | // Base must allow transfer and copy | ||
203 | so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer); | ||
204 | // Must be set so anyone can copy | ||
205 | so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
206 | |||
207 | List<uint> localIds = new List<uint>(); | ||
208 | localIds.Add(so.LocalId); | ||
209 | |||
210 | // Specifying a UUID.Zero in this case will plop it in the Objects folder | ||
211 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
212 | |||
213 | // Check that object isn't copied until we crank the sogd handle. | ||
214 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
215 | Assert.That(retrievedPart, Is.Not.Null); | ||
216 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
217 | |||
218 | sogd.InventoryDeQueueAndDelete(); | ||
219 | |||
220 | // Check that object is still there. | ||
221 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
222 | Assert.That(retrievedPart2, Is.Not.Null); | ||
223 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
224 | |||
225 | // Check that we have a copy in inventory | ||
226 | InventoryItemBase item | ||
227 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
228 | Assert.That(item, Is.Not.Null); | ||
229 | } | ||
230 | |||
231 | [Test] | ||
232 | public void TestTakeCopyWhenCopierIsNotOwnerWithoutPerms() | ||
233 | { | ||
234 | TestHelpers.InMethod(); | ||
235 | // TestHelpers.EnableLogging(); | ||
236 | |||
237 | IConfigSource config = new IniConfigSource(); | ||
238 | config.AddConfig("Modules"); | ||
239 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
240 | |||
241 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
242 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
243 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
244 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
245 | |||
246 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
247 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
248 | sogd.Enabled = false; | ||
249 | |||
250 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2)); | ||
251 | uint soLocalId = so.LocalId; | ||
252 | |||
253 | { | ||
254 | // Check that object is not copied if copy base perms is missing. | ||
255 | // Should not allow copy if base does not have this. | ||
256 | so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Transfer; | ||
257 | // Must be set so anyone can copy | ||
258 | so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
259 | |||
260 | // Check that object is not copied | ||
261 | List<uint> localIds = new List<uint>(); | ||
262 | localIds.Add(so.LocalId); | ||
263 | |||
264 | // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms | ||
265 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
266 | |||
267 | // Check that object isn't copied until we crank the sogd handle. | ||
268 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
269 | Assert.That(retrievedPart, Is.Not.Null); | ||
270 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
271 | |||
272 | sogd.InventoryDeQueueAndDelete(); | ||
273 | // Check that object is still there. | ||
274 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
275 | Assert.That(retrievedPart2, Is.Not.Null); | ||
276 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
277 | |||
278 | // Check that we have a copy in inventory | ||
279 | InventoryItemBase item | ||
280 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
281 | Assert.That(item, Is.Null); | ||
282 | } | ||
283 | |||
284 | { | ||
285 | // Check that object is not copied if copy trans perms is missing. | ||
286 | // Should not allow copy if base does not have this. | ||
287 | so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
288 | // Must be set so anyone can copy | ||
289 | so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
290 | |||
291 | // Check that object is not copied | ||
292 | List<uint> localIds = new List<uint>(); | ||
293 | localIds.Add(so.LocalId); | ||
294 | |||
295 | // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms | ||
296 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
297 | |||
298 | // Check that object isn't copied until we crank the sogd handle. | ||
299 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
300 | Assert.That(retrievedPart, Is.Not.Null); | ||
301 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
302 | |||
303 | sogd.InventoryDeQueueAndDelete(); | ||
304 | // Check that object is still there. | ||
305 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
306 | Assert.That(retrievedPart2, Is.Not.Null); | ||
307 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
308 | |||
309 | // Check that we have a copy in inventory | ||
310 | InventoryItemBase item | ||
311 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
312 | Assert.That(item, Is.Null); | ||
313 | } | ||
314 | |||
315 | { | ||
316 | // Check that object is not copied if everyone copy perms is missing. | ||
317 | // Should not allow copy if base does not have this. | ||
318 | so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer); | ||
319 | // Make sure everyone perm does not allow copy | ||
320 | so.RootPart.EveryoneMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy); | ||
321 | |||
322 | // Check that object is not copied | ||
323 | List<uint> localIds = new List<uint>(); | ||
324 | localIds.Add(so.LocalId); | ||
325 | |||
326 | // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms | ||
327 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
328 | |||
329 | // Check that object isn't copied until we crank the sogd handle. | ||
330 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
331 | Assert.That(retrievedPart, Is.Not.Null); | ||
332 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
333 | |||
334 | sogd.InventoryDeQueueAndDelete(); | ||
335 | // Check that object is still there. | ||
336 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
337 | Assert.That(retrievedPart2, Is.Not.Null); | ||
338 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
339 | |||
340 | // Check that we have a copy in inventory | ||
341 | InventoryItemBase item | ||
342 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
343 | Assert.That(item, Is.Null); | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | } \ 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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.CoreModules.Framework; | ||
35 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
36 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
37 | using OpenSim.Region.CoreModules.World.Land; | ||
38 | using OpenSim.Region.OptionalModules; | ||
39 | using OpenSim.Tests.Common; | ||
40 | |||
41 | namespace 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 95b30d5..b7e9499 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -40,7 +40,6 @@ using OpenSim.Region.CoreModules.World.Permissions; | |||
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
42 | using OpenSim.Tests.Common; | 42 | using OpenSim.Tests.Common; |
43 | using OpenSim.Tests.Common.Mock; | ||
44 | 43 | ||
45 | namespace OpenSim.Region.Framework.Scenes.Tests | 44 | namespace OpenSim.Region.Framework.Scenes.Tests |
46 | { | 45 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index 9378e20..c2e0ae3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -34,7 +34,6 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
37 | using OpenSim.Tests.Common.Mock; | ||
38 | using log4net; | 37 | using log4net; |
39 | 38 | ||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | 39 | namespace OpenSim.Region.Framework.Scenes.Tests |
@@ -91,7 +90,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
91 | grp2.RootPart.ClearUpdateSchedule(); | 90 | grp2.RootPart.ClearUpdateSchedule(); |
92 | 91 | ||
93 | // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. | 92 | // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. |
93 | Assert.IsFalse(grp1.GroupContainsForeignPrims); | ||
94 | grp1.LinkToGroup(grp2); | 94 | grp1.LinkToGroup(grp2); |
95 | Assert.IsTrue(grp1.GroupContainsForeignPrims); | ||
96 | |||
97 | scene.Backup(true); | ||
98 | Assert.IsFalse(grp1.GroupContainsForeignPrims); | ||
95 | 99 | ||
96 | // FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since | 100 | // 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. | 101 | // it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed. |
@@ -143,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
143 | 147 | ||
144 | Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink."); | 148 | 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"); | 149 | Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero"); |
146 | Assert.That(grp3.HasGroupChangedDueToDelink, Is.True); | 150 | Assert.NotNull(grp3); |
147 | } | 151 | } |
148 | 152 | ||
149 | [Test] | 153 | [Test] |
@@ -335,30 +339,34 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
335 | SceneObjectPart rootPart | 339 | SceneObjectPart rootPart |
336 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | 340 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) |
337 | { Name = rootPartName, UUID = rootPartUuid }; | 341 | { Name = rootPartName, UUID = rootPartUuid }; |
342 | |||
338 | SceneObjectPart linkPart | 343 | SceneObjectPart linkPart |
339 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | 344 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) |
340 | { Name = linkPartName, UUID = linkPartUuid }; | 345 | { Name = linkPartName, UUID = linkPartUuid }; |
346 | SceneObjectGroup linkGroup = new SceneObjectGroup(linkPart); | ||
347 | scene.AddNewSceneObject(linkGroup, true); | ||
341 | 348 | ||
342 | SceneObjectGroup sog = new SceneObjectGroup(rootPart); | 349 | SceneObjectGroup sog = new SceneObjectGroup(rootPart); |
343 | sog.AddPart(linkPart); | 350 | scene.AddNewSceneObject(sog, true); |
344 | scene.AddNewSceneObject(sog, true); | 351 | |
345 | 352 | 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 | 353 | sog.LinkToGroup(linkGroup); |
347 | // scene backup thread. | 354 | Assert.IsTrue(sog.GroupContainsForeignPrims); |
355 | |||
348 | scene.Backup(true); | 356 | scene.Backup(true); |
349 | 357 | Assert.AreEqual(1, scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID).Count); | |
358 | |||
350 | // These changes should occur immediately without waiting for a backup pass | 359 | // These changes should occur immediately without waiting for a backup pass |
351 | SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false); | 360 | SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false); |
352 | 361 | Assert.IsFalse(groupToDelete.GroupContainsForeignPrims); | |
353 | Assert.That(groupToDelete.HasGroupChangedDueToDelink, Is.True); | 362 | |
354 | scene.DeleteSceneObject(groupToDelete, false); | 363 | scene.DeleteSceneObject(groupToDelete, false); |
355 | Assert.That(groupToDelete.HasGroupChangedDueToDelink, Is.False); | ||
356 | 364 | ||
357 | List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID); | 365 | List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID); |
358 | 366 | ||
359 | Assert.That(storedObjects.Count, Is.EqualTo(1)); | 367 | Assert.AreEqual(1, storedObjects.Count); |
360 | Assert.That(storedObjects[0].Parts.Length, Is.EqualTo(1)); | 368 | Assert.AreEqual(1, storedObjects[0].Parts.Length); |
361 | Assert.That(storedObjects[0].ContainsPart(rootPartUuid)); | 369 | Assert.IsTrue(storedObjects[0].ContainsPart(rootPartUuid)); |
362 | } | 370 | } |
363 | } | 371 | } |
364 | } | 372 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 1182c96..ce7fc0e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -33,7 +33,6 @@ using OpenSim.Framework; | |||
33 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Framework.Communications; |
34 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Tests.Common; | 35 | using OpenSim.Tests.Common; |
36 | using OpenSim.Tests.Common.Mock; | ||
37 | 36 | ||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | 37 | namespace OpenSim.Region.Framework.Scenes.Tests |
39 | { | 38 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs index a58e735..fdbe7ae 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs | |||
@@ -35,7 +35,6 @@ using OpenSim.Framework.Communications; | |||
35 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
38 | using OpenSim.Tests.Common.Mock; | ||
39 | 38 | ||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | 39 | namespace OpenSim.Region.Framework.Scenes.Tests |
41 | { | 40 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs new file mode 100644 index 0000000..927d8e8 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs | |||
@@ -0,0 +1,136 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Xml; | ||
33 | using System.Linq; | ||
34 | using Nini.Config; | ||
35 | using NUnit.Framework; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Serialization.External; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
42 | using OpenSim.Services.Interfaces; | ||
43 | using OpenSim.Tests.Common; | ||
44 | |||
45 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Basic scene object serialization tests. | ||
49 | /// </summary> | ||
50 | [TestFixture] | ||
51 | public class SceneObjectSerializationTests : OpenSimTestCase | ||
52 | { | ||
53 | |||
54 | /// <summary> | ||
55 | /// Serialize and deserialize. | ||
56 | /// </summary> | ||
57 | [Test] | ||
58 | public void TestSerialDeserial() | ||
59 | { | ||
60 | TestHelpers.InMethod(); | ||
61 | |||
62 | Scene scene = new SceneHelpers().SetupScene(); | ||
63 | int partsToTestCount = 3; | ||
64 | |||
65 | SceneObjectGroup so | ||
66 | = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10); | ||
67 | SceneObjectPart[] parts = so.Parts; | ||
68 | so.Name = "obj1"; | ||
69 | so.Description = "xpto"; | ||
70 | |||
71 | string xml = SceneObjectSerializer.ToXml2Format(so); | ||
72 | Assert.That(!string.IsNullOrEmpty(xml), "SOG serialization resulted in empty or null string"); | ||
73 | |||
74 | XmlDocument doc = new XmlDocument(); | ||
75 | doc.LoadXml(xml); | ||
76 | XmlNodeList nodes = doc.GetElementsByTagName("SceneObjectPart"); | ||
77 | Assert.That(nodes.Count, Is.EqualTo(3), "SOG serialization resulted in wrong number of SOPs"); | ||
78 | |||
79 | SceneObjectGroup so2 = SceneObjectSerializer.FromXml2Format(xml); | ||
80 | Assert.IsNotNull(so2, "SOG deserialization resulted in null object"); | ||
81 | Assert.That(so2.Name == so.Name, "Name of deserialized object does not match original name"); | ||
82 | Assert.That(so2.Description == so.Description, "Description of deserialized object does not match original name"); | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// This checks for a bug reported in mantis #7514 | ||
87 | /// </summary> | ||
88 | [Test] | ||
89 | public void TestNamespaceAttribute() | ||
90 | { | ||
91 | TestHelpers.InMethod(); | ||
92 | |||
93 | Scene scene = new SceneHelpers().SetupScene(); | ||
94 | UserAccount account = new UserAccount(UUID.Zero, UUID.Random(), "Test", "User", string.Empty); | ||
95 | scene.UserAccountService.StoreUserAccount(account); | ||
96 | int partsToTestCount = 1; | ||
97 | |||
98 | SceneObjectGroup so | ||
99 | = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10); | ||
100 | SceneObjectPart[] parts = so.Parts; | ||
101 | so.Name = "obj1"; | ||
102 | so.Description = "xpto"; | ||
103 | so.OwnerID = account.PrincipalID; | ||
104 | so.RootPart.CreatorID = so.OwnerID; | ||
105 | |||
106 | string xml = SceneObjectSerializer.ToXml2Format(so); | ||
107 | Assert.That(!string.IsNullOrEmpty(xml), "SOG serialization resulted in empty or null string"); | ||
108 | |||
109 | xml = ExternalRepresentationUtils.RewriteSOP(xml, "Test Scene", "http://localhost", scene.UserAccountService, UUID.Zero); | ||
110 | //Console.WriteLine(xml); | ||
111 | |||
112 | XmlDocument doc = new XmlDocument(); | ||
113 | doc.LoadXml(xml); | ||
114 | |||
115 | XmlNodeList nodes = doc.GetElementsByTagName("SceneObjectPart"); | ||
116 | Assert.That(nodes.Count, Is.GreaterThan(0), "SOG serialization resulted in no SOPs"); | ||
117 | foreach (XmlAttribute a in nodes[0].Attributes) | ||
118 | { | ||
119 | int count = a.Name.Count(c => c == ':'); | ||
120 | Assert.That(count, Is.EqualTo(1), "Cannot have multiple ':' in attribute name in SOP"); | ||
121 | } | ||
122 | nodes = doc.GetElementsByTagName("CreatorData"); | ||
123 | Assert.That(nodes.Count, Is.GreaterThan(0), "SOG serialization resulted in no CreatorData"); | ||
124 | foreach (XmlAttribute a in nodes[0].Attributes) | ||
125 | { | ||
126 | int count = a.Name.Count(c => c == ':'); | ||
127 | Assert.That(count, Is.EqualTo(1), "Cannot have multiple ':' in attribute name in CreatorData"); | ||
128 | } | ||
129 | |||
130 | SceneObjectGroup so2 = SceneObjectSerializer.FromXml2Format(xml); | ||
131 | Assert.IsNotNull(so2, "SOG deserialization resulted in null object"); | ||
132 | Assert.AreNotEqual(so.RootPart.CreatorIdentification, so2.RootPart.CreatorIdentification, "RewriteSOP failed to transform CreatorData."); | ||
133 | Assert.That(so2.RootPart.CreatorIdentification.Contains("http://"), "RewriteSOP failed to add the homeURL to CreatorData"); | ||
134 | } | ||
135 | } | ||
136 | } \ 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..974529a 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -34,7 +34,6 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
37 | using OpenSim.Tests.Common.Mock; | ||
38 | 37 | ||
39 | namespace OpenSim.Region.Framework.Scenes.Tests | 38 | namespace OpenSim.Region.Framework.Scenes.Tests |
40 | { | 39 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 8eb3191..5ba754c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | |||
@@ -34,7 +34,6 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
37 | using OpenSim.Tests.Common.Mock; | ||
38 | 37 | ||
39 | namespace OpenSim.Region.Framework.Scenes.Tests | 38 | namespace OpenSim.Region.Framework.Scenes.Tests |
40 | { | 39 | { |
@@ -58,6 +57,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
58 | } | 57 | } |
59 | 58 | ||
60 | [Test] | 59 | [Test] |
60 | public void TestSetTemporary() | ||
61 | { | ||
62 | TestHelpers.InMethod(); | ||
63 | |||
64 | m_scene.AddSceneObject(m_so1); | ||
65 | m_so1.ScriptSetTemporaryStatus(true); | ||
66 | |||
67 | // Is this really the correct flag? | ||
68 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez)); | ||
69 | Assert.That(m_so1.Backup, Is.False); | ||
70 | |||
71 | // Test setting back to non-temporary | ||
72 | m_so1.ScriptSetTemporaryStatus(false); | ||
73 | |||
74 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
75 | Assert.That(m_so1.Backup, Is.True); | ||
76 | } | ||
77 | |||
78 | [Test] | ||
61 | public void TestSetPhantomSinglePrim() | 79 | public void TestSetPhantomSinglePrim() |
62 | { | 80 | { |
63 | TestHelpers.InMethod(); | 81 | TestHelpers.InMethod(); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs new file mode 100644 index 0000000..cdebe25 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs | |||
@@ -0,0 +1,183 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Tests.Common; | ||
36 | |||
37 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Tests for undo/redo | ||
41 | /// </summary> | ||
42 | public class SceneObjectUndoRedoTests : OpenSimTestCase | ||
43 | { | ||
44 | [Test] | ||
45 | public void TestUndoRedoResizeSceneObject() | ||
46 | { | ||
47 | TestHelpers.InMethod(); | ||
48 | // TestHelpers.EnableLogging(); | ||
49 | |||
50 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
51 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
52 | |||
53 | Scene scene = new SceneHelpers().SetupScene(); | ||
54 | scene.MaxUndoCount = 20; | ||
55 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
56 | |||
57 | // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG, | ||
58 | // which is the way that AddSceneObject() sets up the object (i.e. it creates the SOP first). However, | ||
59 | // this is somewhat by chance. Really, we shouldn't be storing undo states at all if the object is not | ||
60 | // in a scene. | ||
61 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
62 | |||
63 | g1.GroupResize(firstSize); | ||
64 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
65 | |||
66 | g1.GroupResize(secondSize); | ||
67 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
68 | |||
69 | g1.RootPart.Undo(); | ||
70 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
71 | Assert.That(g1.GroupScale, Is.EqualTo(firstSize)); | ||
72 | |||
73 | g1.RootPart.Redo(); | ||
74 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
75 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
76 | } | ||
77 | |||
78 | [Test] | ||
79 | public void TestUndoLimit() | ||
80 | { | ||
81 | TestHelpers.InMethod(); | ||
82 | |||
83 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
84 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
85 | Vector3 thirdSize = new Vector3(8, 9, 10); | ||
86 | Vector3 fourthSize = new Vector3(11, 12, 13); | ||
87 | |||
88 | Scene scene = new SceneHelpers().SetupScene(); | ||
89 | scene.MaxUndoCount = 2; | ||
90 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
91 | |||
92 | g1.GroupResize(firstSize); | ||
93 | g1.GroupResize(secondSize); | ||
94 | g1.GroupResize(thirdSize); | ||
95 | g1.GroupResize(fourthSize); | ||
96 | |||
97 | g1.RootPart.Undo(); | ||
98 | g1.RootPart.Undo(); | ||
99 | g1.RootPart.Undo(); | ||
100 | |||
101 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
102 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
103 | } | ||
104 | |||
105 | [Test] | ||
106 | public void TestNoUndoOnObjectsNotInScene() | ||
107 | { | ||
108 | TestHelpers.InMethod(); | ||
109 | |||
110 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
111 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
112 | // Vector3 thirdSize = new Vector3(8, 9, 10); | ||
113 | // Vector3 fourthSize = new Vector3(11, 12, 13); | ||
114 | |||
115 | Scene scene = new SceneHelpers().SetupScene(); | ||
116 | scene.MaxUndoCount = 20; | ||
117 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); | ||
118 | |||
119 | g1.GroupResize(firstSize); | ||
120 | g1.GroupResize(secondSize); | ||
121 | |||
122 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
123 | |||
124 | g1.RootPart.Undo(); | ||
125 | |||
126 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
127 | } | ||
128 | |||
129 | [Test] | ||
130 | public void TestUndoBeyondAvailable() | ||
131 | { | ||
132 | TestHelpers.InMethod(); | ||
133 | |||
134 | Vector3 newSize = new Vector3(2, 3, 4); | ||
135 | |||
136 | Scene scene = new SceneHelpers().SetupScene(); | ||
137 | scene.MaxUndoCount = 20; | ||
138 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
139 | Vector3 originalSize = g1.GroupScale; | ||
140 | |||
141 | g1.RootPart.Undo(); | ||
142 | |||
143 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
144 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
145 | |||
146 | g1.GroupResize(newSize); | ||
147 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
148 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
149 | |||
150 | g1.RootPart.Undo(); | ||
151 | g1.RootPart.Undo(); | ||
152 | |||
153 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
154 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
155 | } | ||
156 | |||
157 | [Test] | ||
158 | public void TestRedoBeyondAvailable() | ||
159 | { | ||
160 | TestHelpers.InMethod(); | ||
161 | |||
162 | Vector3 newSize = new Vector3(2, 3, 4); | ||
163 | |||
164 | Scene scene = new SceneHelpers().SetupScene(); | ||
165 | scene.MaxUndoCount = 20; | ||
166 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
167 | Vector3 originalSize = g1.GroupScale; | ||
168 | |||
169 | g1.RootPart.Redo(); | ||
170 | |||
171 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
172 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
173 | |||
174 | g1.GroupResize(newSize); | ||
175 | g1.RootPart.Undo(); | ||
176 | g1.RootPart.Redo(); | ||
177 | g1.RootPart.Redo(); | ||
178 | |||
179 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
180 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
181 | } | ||
182 | } | ||
183 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index e7a1fe0..32d6649 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -39,7 +39,6 @@ using OpenSim.Region.Framework.Interfaces; | |||
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; | 40 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; |
41 | using OpenSim.Tests.Common; | 41 | using OpenSim.Tests.Common; |
42 | using OpenSim.Tests.Common.Mock; | ||
43 | 42 | ||
44 | namespace OpenSim.Region.Framework.Scenes.Tests | 43 | namespace OpenSim.Region.Framework.Scenes.Tests |
45 | { | 44 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index 1ff1329..06e6423 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -44,7 +44,6 @@ using OpenSim.Region.CoreModules.Framework.EntityTransfer; | |||
44 | using OpenSim.Region.CoreModules.World.Serialiser; | 44 | using OpenSim.Region.CoreModules.World.Serialiser; |
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
46 | using OpenSim.Tests.Common; | 46 | using OpenSim.Tests.Common; |
47 | using OpenSim.Tests.Common.Mock; | ||
48 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 47 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
49 | 48 | ||
50 | namespace OpenSim.Region.Framework.Scenes.Tests | 49 | namespace OpenSim.Region.Framework.Scenes.Tests |
@@ -228,7 +227,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
228 | // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and | 227 | // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and |
229 | // establish a child scene presence. We pass in the circuit code that the client has to connect with *** | 228 | // establish a child scene presence. We pass in the circuit code that the client has to connect with *** |
230 | // XXX: ViaLogin may not be correct here. | 229 | // XXX: ViaLogin may not be correct here. |
231 | scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason); | 230 | scene.SimulationService.CreateAgent(null, region, acd, (uint)TeleportFlags.ViaLogin, out reason); |
232 | 231 | ||
233 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); | 232 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null); |
234 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); | 233 | Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs index 1cd8ae9..42cfa1b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs | |||
@@ -43,7 +43,6 @@ using OpenSim.Region.CoreModules.World.Serialiser; | |||
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
44 | using OpenSim.Region.Physics.Manager; | 44 | using OpenSim.Region.Physics.Manager; |
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | ||
47 | 46 | ||
48 | namespace OpenSim.Region.Framework.Scenes.Tests | 47 | namespace OpenSim.Region.Framework.Scenes.Tests |
49 | { | 48 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs index d80afd3..c6e3b8b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs | |||
@@ -37,7 +37,6 @@ using OpenSim.Framework.Communications; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
40 | using OpenSim.Tests.Common.Mock; | ||
41 | 40 | ||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | 41 | namespace OpenSim.Region.Framework.Scenes.Tests |
43 | { | 42 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs index 9fa0a71..45bfbff 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs | |||
@@ -47,7 +47,6 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | |||
47 | using OpenSim.Region.Framework.Scenes; | 47 | using OpenSim.Region.Framework.Scenes; |
48 | using OpenSim.Region.Framework.Interfaces; | 48 | using OpenSim.Region.Framework.Interfaces; |
49 | using OpenSim.Tests.Common; | 49 | using OpenSim.Tests.Common; |
50 | using OpenSim.Tests.Common.Mock; | ||
51 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 50 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
52 | 51 | ||
53 | namespace OpenSim.Region.Framework.Scenes.Tests | 52 | namespace OpenSim.Region.Framework.Scenes.Tests |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs index b806a97..c193a97 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | |||
@@ -40,7 +40,6 @@ using OpenSim.Region.CoreModules.Framework.EntityTransfer; | |||
40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 40 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
41 | using OpenSim.Region.CoreModules.World.Permissions; | 41 | using OpenSim.Region.CoreModules.World.Permissions; |
42 | using OpenSim.Tests.Common; | 42 | using OpenSim.Tests.Common; |
43 | using OpenSim.Tests.Common.Mock; | ||
44 | 43 | ||
45 | namespace OpenSim.Region.Framework.Scenes.Tests | 44 | namespace OpenSim.Region.Framework.Scenes.Tests |
46 | { | 45 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index 0911f00..b775178 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -37,7 +37,6 @@ using OpenSim.Framework.Servers; | |||
37 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
39 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
40 | using OpenSim.Tests.Common.Mock; | ||
41 | using System.Threading; | 40 | using System.Threading; |
42 | 41 | ||
43 | namespace OpenSim.Region.Framework.Scenes.Tests | 42 | namespace OpenSim.Region.Framework.Scenes.Tests |
@@ -73,6 +72,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
73 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); | 72 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); |
74 | Assert.That(part.GetSittingAvatars(), Is.Null); | 73 | Assert.That(part.GetSittingAvatars(), Is.Null); |
75 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); | 74 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); |
75 | Assert.AreEqual(startPos, m_sp.AbsolutePosition); | ||
76 | } | 76 | } |
77 | 77 | ||
78 | [Test] | 78 | [Test] |
@@ -87,15 +87,21 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
87 | 87 | ||
88 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; | 88 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
89 | 89 | ||
90 | // We need to preserve this here because phys actor is removed by the sit. | ||
91 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; | ||
90 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 92 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
91 | 93 | ||
92 | Assert.That(m_sp.PhysicsActor, Is.Null); | 94 | Assert.That(m_sp.PhysicsActor, Is.Null); |
93 | 95 | ||
96 | Assert.That( | ||
97 | m_sp.AbsolutePosition, | ||
98 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); | ||
99 | |||
94 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | 100 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
95 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); | 101 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
96 | HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); | 102 | HashSet<ScenePresence> sittingAvatars = part.GetSittingAvatars(); |
97 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); | 103 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); |
98 | Assert.That(sittingAvatars.Contains(m_sp.UUID)); | 104 | Assert.That(sittingAvatars.Contains(m_sp)); |
99 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); | 105 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
100 | } | 106 | } |
101 | 107 | ||
@@ -129,6 +135,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
129 | } | 135 | } |
130 | 136 | ||
131 | [Test] | 137 | [Test] |
138 | public void TestSitAndStandWithNoSitTargetChildPrim() | ||
139 | { | ||
140 | TestHelpers.InMethod(); | ||
141 | // log4net.Config.XmlConfigurator.Configure(); | ||
142 | |||
143 | // Make sure we're within range to sit | ||
144 | Vector3 startPos = new Vector3(1, 1, 1); | ||
145 | m_sp.AbsolutePosition = startPos; | ||
146 | |||
147 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene, 2, m_sp.UUID, "part", 0x10).Parts[1]; | ||
148 | part.OffsetPosition = new Vector3(2, 3, 4); | ||
149 | |||
150 | // We need to preserve this here because phys actor is removed by the sit. | ||
151 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; | ||
152 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | ||
153 | |||
154 | Assert.That( | ||
155 | m_sp.AbsolutePosition, | ||
156 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); | ||
157 | |||
158 | m_sp.StandUp(); | ||
159 | |||
160 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | ||
161 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); | ||
162 | Assert.That(part.GetSittingAvatars(), Is.Null); | ||
163 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); | ||
164 | Assert.That(m_sp.PhysicsActor, Is.Not.Null); | ||
165 | } | ||
166 | |||
167 | [Test] | ||
132 | public void TestSitAndStandWithSitTarget() | 168 | public void TestSitAndStandWithSitTarget() |
133 | { | 169 | { |
134 | TestHelpers.InMethod(); | 170 | TestHelpers.InMethod(); |
@@ -145,15 +181,39 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
145 | 181 | ||
146 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); | 182 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); |
147 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); | 183 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
148 | // Assert.That( | 184 | |
149 | // m_sp.AbsolutePosition, | 185 | // This section is copied from ScenePresence.HandleAgentSit(). Correctness is not guaranteed. |
150 | // Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); | 186 | double x, y, z, m1, m2; |
187 | |||
188 | Quaternion r = part.SitTargetOrientation;; | ||
189 | m1 = r.X * r.X + r.Y * r.Y; | ||
190 | m2 = r.Z * r.Z + r.W * r.W; | ||
191 | |||
192 | // Rotate the vector <0, 0, 1> | ||
193 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
194 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
195 | z = m2 - m1; | ||
196 | |||
197 | // Set m to be the square of the norm of r. | ||
198 | double m = m1 + m2; | ||
199 | |||
200 | // This constant is emperically determined to be what is used in SL. | ||
201 | // See also http://opensimulator.org/mantis/view.php?id=7096 | ||
202 | double offset = 0.05; | ||
203 | |||
204 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
205 | Vector3 sitOffset = up * (float)offset; | ||
206 | // End of copied section. | ||
207 | |||
208 | Assert.That( | ||
209 | m_sp.AbsolutePosition, | ||
210 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition - sitOffset + ScenePresence.SIT_TARGET_ADJUSTMENT)); | ||
151 | Assert.That(m_sp.PhysicsActor, Is.Null); | 211 | Assert.That(m_sp.PhysicsActor, Is.Null); |
152 | 212 | ||
153 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); | 213 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
154 | HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); | 214 | HashSet<ScenePresence> sittingAvatars = part.GetSittingAvatars(); |
155 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); | 215 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); |
156 | Assert.That(sittingAvatars.Contains(m_sp.UUID)); | 216 | Assert.That(sittingAvatars.Contains(m_sp)); |
157 | 217 | ||
158 | m_sp.StandUp(); | 218 | m_sp.StandUp(); |
159 | 219 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index fff542b..42276dd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -43,7 +43,6 @@ using OpenSim.Region.CoreModules.Framework.EntityTransfer; | |||
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
44 | using OpenSim.Region.CoreModules.World.Permissions; | 44 | using OpenSim.Region.CoreModules.World.Permissions; |
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | ||
47 | 46 | ||
48 | namespace OpenSim.Region.Framework.Scenes.Tests | 47 | namespace OpenSim.Region.Framework.Scenes.Tests |
49 | { | 48 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs index 1667002..2d36214 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs | |||
@@ -34,7 +34,6 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Tests.Common; | 36 | using OpenSim.Tests.Common; |
37 | using OpenSim.Tests.Common.Mock; | ||
38 | 37 | ||
39 | namespace OpenSim.Region.Framework.Scenes.Tests | 38 | namespace OpenSim.Region.Framework.Scenes.Tests |
40 | { | 39 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs index 9a97acc..584a03c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs | |||
@@ -32,7 +32,6 @@ using OpenSim.Region.Framework.Scenes; | |||
32 | using OpenSim.Region.Framework.Interfaces; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Services.Interfaces; | 33 | using OpenSim.Services.Interfaces; |
34 | using OpenSim.Tests.Common; | 34 | using OpenSim.Tests.Common; |
35 | using OpenSim.Tests.Common.Mock; | ||
36 | 35 | ||
37 | namespace OpenSim.Region.Framework.Scenes.Tests | 36 | namespace OpenSim.Region.Framework.Scenes.Tests |
38 | { | 37 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 9d8eb0b..33ef83b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -42,7 +42,6 @@ using OpenSim.Region.Framework.Interfaces; | |||
42 | using OpenSim.Region.CoreModules.World.Serialiser; | 42 | using OpenSim.Region.CoreModules.World.Serialiser; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
44 | using OpenSim.Tests.Common; | 44 | using OpenSim.Tests.Common; |
45 | using OpenSim.Tests.Common.Mock; | ||
46 | 45 | ||
47 | namespace OpenSim.Region.Framework.Scenes.Tests | 46 | namespace OpenSim.Region.Framework.Scenes.Tests |
48 | { | 47 | { |
@@ -52,6 +51,29 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
52 | [TestFixture] | 51 | [TestFixture] |
53 | public class SceneTests : OpenSimTestCase | 52 | public class SceneTests : OpenSimTestCase |
54 | { | 53 | { |
54 | [Test] | ||
55 | public void TestCreateScene() | ||
56 | { | ||
57 | TestHelpers.InMethod(); | ||
58 | |||
59 | new SceneHelpers().SetupScene(); | ||
60 | } | ||
61 | |||
62 | [Test] | ||
63 | public void TestCreateVarScene() | ||
64 | { | ||
65 | TestHelpers.InMethod(); | ||
66 | UUID regionUuid = TestHelpers.ParseTail(0x1); | ||
67 | uint sizeX = 512; | ||
68 | uint sizeY = 512; | ||
69 | |||
70 | Scene scene | ||
71 | = new SceneHelpers().SetupScene("scene", regionUuid, 1000, 1000, sizeX, sizeY, new IniConfigSource()); | ||
72 | |||
73 | Assert.AreEqual(sizeX, scene.RegionInfo.RegionSizeX); | ||
74 | Assert.AreEqual(sizeY, scene.RegionInfo.RegionSizeY); | ||
75 | } | ||
76 | |||
55 | /// <summary> | 77 | /// <summary> |
56 | /// Very basic scene update test. Should become more elaborate with time. | 78 | /// Very basic scene update test. Should become more elaborate with time. |
57 | /// </summary> | 79 | /// </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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using Mono.Addins; | ||
32 | using Nini.Config; | ||
33 | using NUnit.Framework; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim; | ||
36 | using OpenSim.ApplicationPlugins.RegionModulesController; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Tests.Common; | ||
41 | |||
42 | namespace 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 020bb6c..3caea8b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -45,7 +45,6 @@ using OpenSim.Region.CoreModules.World.Serialiser; | |||
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
46 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
47 | using OpenSim.Tests.Common; | 47 | using OpenSim.Tests.Common; |
48 | using OpenSim.Tests.Common.Mock; | ||
49 | 48 | ||
50 | namespace OpenSim.Region.Framework.Tests | 49 | namespace OpenSim.Region.Framework.Tests |
51 | { | 50 | { |
@@ -65,7 +64,7 @@ namespace OpenSim.Region.Framework.Tests | |||
65 | 64 | ||
66 | // Create an object embedded inside the first | 65 | // Create an object embedded inside the first |
67 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | 66 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); |
68 | TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); | 67 | TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); |
69 | 68 | ||
70 | TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId); | 69 | TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId); |
71 | Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId)); | 70 | Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId)); |
@@ -89,7 +88,7 @@ namespace OpenSim.Region.Framework.Tests | |||
89 | // Create an object embedded inside the first | 88 | // Create an object embedded inside the first |
90 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | 89 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); |
91 | TaskInventoryItem taskSceneObjectItem | 90 | TaskInventoryItem taskSceneObjectItem |
92 | = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); | 91 | = TaskInventoryHelpers.AddSceneObject(scene.AssetService, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID); |
93 | 92 | ||
94 | scene.AddSceneObject(sog1); | 93 | scene.AddSceneObject(sog1); |
95 | 94 | ||
@@ -130,13 +129,14 @@ namespace OpenSim.Region.Framework.Tests | |||
130 | SceneObjectPart sop1 = sog1.RootPart; | 129 | SceneObjectPart sop1 = sog1.RootPart; |
131 | TaskInventoryItem sopItem1 | 130 | TaskInventoryItem sopItem1 |
132 | = TaskInventoryHelpers.AddNotecard( | 131 | = TaskInventoryHelpers.AddNotecard( |
133 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); | 132 | scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
134 | 133 | ||
135 | InventoryFolderBase folder | 134 | InventoryFolderBase folder |
136 | = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; | 135 | = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; |
137 | 136 | ||
138 | // Perform test | 137 | // Perform test |
139 | scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID); | 138 | string message; |
139 | scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID, out message); | ||
140 | 140 | ||
141 | InventoryItemBase ncUserItem | 141 | InventoryItemBase ncUserItem |
142 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); | 142 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem"); |
@@ -162,10 +162,11 @@ namespace OpenSim.Region.Framework.Tests | |||
162 | SceneObjectPart sop1 = sog1.RootPart; | 162 | SceneObjectPart sop1 = sog1.RootPart; |
163 | TaskInventoryItem sopItem1 | 163 | TaskInventoryItem sopItem1 |
164 | = TaskInventoryHelpers.AddNotecard( | 164 | = TaskInventoryHelpers.AddNotecard( |
165 | scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); | 165 | scene.AssetService, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
166 | 166 | ||
167 | // Perform test | 167 | // Perform test |
168 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); | 168 | string message; |
169 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID, out message); | ||
169 | 170 | ||
170 | InventoryItemBase ncUserItem | 171 | InventoryItemBase ncUserItem |
171 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem"); | 172 | = 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 e50b4da..edc0a52 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs | |||
@@ -45,7 +45,6 @@ using OpenSim.Region.CoreModules.World.Serialiser; | |||
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
46 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
47 | using OpenSim.Tests.Common; | 47 | using OpenSim.Tests.Common; |
48 | using OpenSim.Tests.Common.Mock; | ||
49 | 48 | ||
50 | namespace OpenSim.Region.Framework.Tests | 49 | namespace OpenSim.Region.Framework.Tests |
51 | { | 50 | { |
@@ -95,7 +94,9 @@ namespace OpenSim.Region.Framework.Tests | |||
95 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); | 94 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); |
96 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); | 95 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); |
97 | 96 | ||
98 | scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); | 97 | string message; |
98 | |||
99 | scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message); | ||
99 | 100 | ||
100 | InventoryItemBase retrievedItem1 | 101 | InventoryItemBase retrievedItem1 |
101 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); | 102 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); |
@@ -103,7 +104,7 @@ namespace OpenSim.Region.Framework.Tests | |||
103 | Assert.That(retrievedItem1, Is.Not.Null); | 104 | Assert.That(retrievedItem1, Is.Not.Null); |
104 | 105 | ||
105 | // Try giving back the freshly received item | 106 | // Try giving back the freshly received item |
106 | scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); | 107 | scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID, out message); |
107 | 108 | ||
108 | List<InventoryItemBase> reretrievedItems | 109 | List<InventoryItemBase> reretrievedItems |
109 | = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); | 110 | = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); |
@@ -123,7 +124,7 @@ namespace OpenSim.Region.Framework.Tests | |||
123 | InventoryFolderBase folder1 | 124 | InventoryFolderBase folder1 |
124 | = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false); | 125 | = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1", false); |
125 | 126 | ||
126 | scene.GiveInventoryFolder(user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); | 127 | scene.GiveInventoryFolder(null, user2.PrincipalID, user1.PrincipalID, folder1.ID, UUID.Zero); |
127 | 128 | ||
128 | InventoryFolderBase retrievedFolder1 | 129 | InventoryFolderBase retrievedFolder1 |
129 | = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1"); | 130 | = UserInventoryHelpers.GetInventoryFolder(scene.InventoryService, user2.PrincipalID, "folder1"); |
@@ -131,7 +132,7 @@ namespace OpenSim.Region.Framework.Tests | |||
131 | Assert.That(retrievedFolder1, Is.Not.Null); | 132 | Assert.That(retrievedFolder1, Is.Not.Null); |
132 | 133 | ||
133 | // Try giving back the freshly received folder | 134 | // Try giving back the freshly received folder |
134 | scene.GiveInventoryFolder(user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); | 135 | scene.GiveInventoryFolder(null, user1.PrincipalID, user2.PrincipalID, retrievedFolder1.ID, UUID.Zero); |
135 | 136 | ||
136 | List<InventoryFolderBase> reretrievedFolders | 137 | List<InventoryFolderBase> reretrievedFolders |
137 | = UserInventoryHelpers.GetInventoryFolders(scene.InventoryService, user1.PrincipalID, "folder1"); | 138 | = 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 1e59e3f..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; | |||
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using OpenSim.Tests.Common; | 35 | using OpenSim.Tests.Common; |
36 | using OpenSim.Tests.Common.Mock; | ||
37 | 36 | ||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | 37 | namespace 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, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); | 64 | m_uuidGatherer.AddForInspection(corruptAssetUuid); |
66 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, (sbyte)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, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); | ||
82 | |||
83 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, (sbyte)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, sbyte> foundAssetUuids = new Dictionary<UUID, sbyte>(); | 104 | AssetBase embeddedAsset |
107 | m_uuidGatherer.GatherAssetUuids(ncAssetId, (sbyte)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 |