aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 11:43:07 +0100
committerUbitUmarov2015-09-01 11:43:07 +0100
commitfb78b182520fc9bb0f971afd0322029c70278ea6 (patch)
treeb4e30d383938fdeef8c92d1d1c2f44bb61d329bd /OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
parentlixo (diff)
parentMantis #7713: fixed bug introduced by 1st MOSES patch. (diff)
downloadopensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.zip
opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.gz
opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.bz2
opensim-SC_OLD-fb78b182520fc9bb0f971afd0322029c70278ea6.tar.xz
Merge remote-tracking branch 'os/master'
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs264
1 files changed, 264 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
new file mode 100644
index 0000000..558ba2c
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -0,0 +1,264 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Region.CoreModules.Framework.EntityTransfer;
37using OpenSim.Region.CoreModules.Framework.InventoryAccess;
38using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
39using OpenSim.Region.CoreModules.World.Permissions;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Services.Interfaces;
42using OpenSim.Tests.Common;
43
44namespace OpenSim.Region.Framework.Scenes.Tests
45{
46 /// <summary>
47 /// Tests derez of scene objects.
48 /// </summary>
49 /// <remarks>
50 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly.
51 /// TODO: These tests are incomplete - need to test more kinds of derez (e.g. return object).
52 /// </remarks>
53 [TestFixture]
54 public class SceneObjectDeRezTests : OpenSimTestCase
55 {
56 [TestFixtureSetUp]
57 public void FixtureInit()
58 {
59 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
60 // This facility was added after the original async delete tests were written, so it may be possible now
61 // to not bother explicitly disabling their async (since everything will be running sync).
62 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
63 }
64
65 [TestFixtureTearDown]
66 public void TearDown()
67 {
68 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
69 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
70 // tests really shouldn't).
71 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
72 }
73
74 /// <summary>
75 /// Test deleting an object from a scene.
76 /// </summary>
77 [Test]
78 public void TestDeRezSceneObject()
79 {
80 TestHelpers.InMethod();
81
82 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
83
84 TestScene scene = new SceneHelpers().SetupScene();
85 SceneHelpers.SetupSceneModules(scene, new PermissionsModule());
86 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, userId).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", userId);
93 uint soLocalId = so.LocalId;
94
95 List<uint> localIds = new List<uint>();
96 localIds.Add(so.LocalId);
97 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
98
99 // Check that object isn't deleted until we crank the sogd handle.
100 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
101 Assert.That(retrievedPart, Is.Not.Null);
102 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
103
104 sogd.InventoryDeQueueAndDelete();
105
106 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
107 Assert.That(retrievedPart2, Is.Null);
108
109 Assert.That(client.ReceivedKills.Count, Is.EqualTo(1));
110 Assert.That(client.ReceivedKills[0], Is.EqualTo(soLocalId));
111 }
112
113 /// <summary>
114 /// Test that child and root agents correctly receive KillObject notifications.
115 /// </summary>
116 [Test]
117 public void TestDeRezSceneObjectToAgents()
118 {
119 TestHelpers.InMethod();
120// TestHelpers.EnableLogging();
121
122 SceneHelpers sh = new SceneHelpers();
123 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
124 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
125
126 // We need this so that the creation of the root client for userB in sceneB can trigger the creation of a child client in sceneA
127 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
128 EntityTransferModule etmB = new EntityTransferModule();
129 IConfigSource config = new IniConfigSource();
130 IConfig modulesConfig = config.AddConfig("Modules");
131 modulesConfig.Set("EntityTransferModule", etmB.Name);
132 modulesConfig.Set("SimulationServices", lscm.Name);
133 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
134 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
135
136 // We need this for derez
137 SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule());
138
139 UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, "");
140 UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, "");
141
142 TestClient clientA = (TestClient)SceneHelpers.AddScenePresence(sceneA, uaA).ControllingClient;
143
144 // This is the more long-winded route we have to take to get a child client created for userB in sceneA
145 // rather than just calling AddScenePresence() as for userA
146 AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB);
147 TestClient clientB = new TestClient(acd, sceneB);
148 List<TestClient> childClientsB = new List<TestClient>();
149 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(clientB, childClientsB);
150
151 SceneHelpers.AddScenePresence(sceneB, clientB, acd);
152
153 SceneObjectGroup so = SceneHelpers.AddSceneObject(sceneA);
154 uint soLocalId = so.LocalId;
155
156 sceneA.DeleteSceneObject(so, false);
157
158 Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1));
159 Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId));
160
161 Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1));
162 Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId));
163 }
164
165 /// <summary>
166 /// Test deleting an object from a scene where the deleter is not the owner
167 /// </summary>
168 /// <remarks>
169 /// This test assumes that the deleter is not a god.
170 /// </remarks>
171 [Test]
172 public void TestDeRezSceneObjectNotOwner()
173 {
174 TestHelpers.InMethod();
175// log4net.Config.XmlConfigurator.Configure();
176
177 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
178 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
179
180 TestScene scene = new SceneHelpers().SetupScene();
181 SceneHelpers.SetupSceneModules(scene, new PermissionsModule());
182 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
183
184 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
185 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
186 sogd.Enabled = false;
187
188 SceneObjectPart part
189 = new SceneObjectPart(objectOwnerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
190 part.Name = "obj1";
191 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
192 List<uint> localIds = new List<uint>();
193 localIds.Add(part.LocalId);
194
195 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
196 sogd.InventoryDeQueueAndDelete();
197
198 // Object should still be in the scene.
199 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
200 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
201 }
202
203 /// <summary>
204 /// Test deleting an object asynchronously to user inventory.
205 /// </summary>
206 [Test]
207 public void TestDeleteSceneObjectAsyncToUserInventory()
208 {
209 TestHelpers.InMethod();
210// TestHelpers.EnableLogging();
211
212 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
213 string myObjectName = "Fred";
214
215 TestScene scene = new SceneHelpers().SetupScene();
216
217 IConfigSource configSource = new IniConfigSource();
218 IConfig config = configSource.AddConfig("Modules");
219 config.Set("InventoryAccessModule", "BasicInventoryAccessModule");
220 SceneHelpers.SetupSceneModules(
221 scene, configSource, new object[] { new BasicInventoryAccessModule() });
222
223 SceneHelpers.SetupSceneModules(scene, new object[] { });
224
225 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
226 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
227 sogd.Enabled = false;
228
229 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);
230
231 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
232 InventoryFolderBase folder1
233 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);
234
235 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
236 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);
237
238 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
239
240 Assert.That(retrievedPart, Is.Not.Null);
241 Assert.That(so.IsDeleted, Is.False);
242
243 sogd.InventoryDeQueueAndDelete();
244
245 Assert.That(so.IsDeleted, Is.True);
246
247 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
248 Assert.That(retrievedPart2, Is.Null);
249
250// SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);
251
252 InventoryItemBase retrievedItem
253 = UserInventoryHelpers.GetInventoryItem(
254 scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);
255
256 // Check that we now have the taken part in our inventory
257 Assert.That(retrievedItem, Is.Not.Null);
258
259 // Check that the taken part has actually disappeared
260// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
261// Assert.That(retrievedPart, Is.Null);
262 }
263 }
264} \ No newline at end of file