aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs111
1 files changed, 88 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index c1522e7..1c396ac 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -32,13 +32,13 @@ using Nini.Config;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Region.CoreModules.Framework.EntityTransfer;
36using OpenSim.Region.CoreModules.Framework.InventoryAccess; 36using OpenSim.Region.CoreModules.Framework.InventoryAccess;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
37using OpenSim.Region.CoreModules.World.Permissions; 38using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
40using OpenSim.Tests.Common; 41using OpenSim.Tests.Common;
41using OpenSim.Tests.Common.Mock;
42 42
43namespace OpenSim.Region.Framework.Scenes.Tests 43namespace OpenSim.Region.Framework.Scenes.Tests
44{ 44{
@@ -52,6 +52,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52 [TestFixture] 52 [TestFixture]
53 public class SceneObjectDeRezTests : OpenSimTestCase 53 public class SceneObjectDeRezTests : OpenSimTestCase
54 { 54 {
55 [TestFixtureSetUp]
56 public void FixtureInit()
57 {
58 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
59 // This facility was added after the original async delete tests were written, so it may be possible now
60 // to not bother explicitly disabling their async (since everything will be running sync).
61 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
62 }
63
64 [TestFixtureTearDown]
65 public void TearDown()
66 {
67 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
68 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
69 // tests really shouldn't).
70 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
71 }
72
55 /// <summary> 73 /// <summary>
56 /// Test deleting an object from a scene. 74 /// Test deleting an object from a scene.
57 /// </summary> 75 /// </summary>
@@ -59,46 +77,96 @@ namespace OpenSim.Region.Framework.Scenes.Tests
59 public void TestDeRezSceneObject() 77 public void TestDeRezSceneObject()
60 { 78 {
61 TestHelpers.InMethod(); 79 TestHelpers.InMethod();
62// log4net.Config.XmlConfigurator.Configure();
63 80
64 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 81 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
65 82
66 TestScene scene = new SceneHelpers().SetupScene(); 83 TestScene scene = new SceneHelpers().SetupScene();
67 IConfigSource configSource = new IniConfigSource(); 84 SceneHelpers.SetupSceneModules(scene, new PermissionsModule());
68 IConfig config = configSource.AddConfig("Startup"); 85 TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
69 config.Set("serverside_object_permissions", true);
70 SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
71 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
72 86
73 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 87 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
74 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 88 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
75 sogd.Enabled = false; 89 sogd.Enabled = false;
76 90
77 SceneObjectPart part 91 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", userId);
78 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); 92 uint soLocalId = so.LocalId;
79 part.Name = "obj1";
80 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
81 93
82 List<uint> localIds = new List<uint>(); 94 List<uint> localIds = new List<uint>();
83 localIds.Add(part.LocalId); 95 localIds.Add(so.LocalId);
84 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); 96 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
85 97
86 // Check that object isn't deleted until we crank the sogd handle. 98 // Check that object isn't deleted until we crank the sogd handle.
87 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 99 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
88 Assert.That(retrievedPart, Is.Not.Null); 100 Assert.That(retrievedPart, Is.Not.Null);
89 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); 101 Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);
90 102
91 sogd.InventoryDeQueueAndDelete(); 103 sogd.InventoryDeQueueAndDelete();
92 104
93 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 105 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
94 Assert.That(retrievedPart2, Is.Null); 106 Assert.That(retrievedPart2, Is.Null);
107
108 Assert.That(client.ReceivedKills.Count, Is.EqualTo(1));
109 Assert.That(client.ReceivedKills[0], Is.EqualTo(soLocalId));
110 }
111
112 /// <summary>
113 /// Test that child and root agents correctly receive KillObject notifications.
114 /// </summary>
115 [Test]
116 public void TestDeRezSceneObjectToAgents()
117 {
118 TestHelpers.InMethod();
119// TestHelpers.EnableLogging();
120
121 SceneHelpers sh = new SceneHelpers();
122 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
123 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
124
125 // We need this so that the creation of the root client for userB in sceneB can trigger the creation of a child client in sceneA
126 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
127 EntityTransferModule etmB = new EntityTransferModule();
128 IConfigSource config = new IniConfigSource();
129 IConfig modulesConfig = config.AddConfig("Modules");
130 modulesConfig.Set("EntityTransferModule", etmB.Name);
131 modulesConfig.Set("SimulationServices", lscm.Name);
132 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
133 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
134
135 // We need this for derez
136 SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule());
137
138 UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, "");
139 UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, "");
140
141 TestClient clientA = (TestClient)SceneHelpers.AddScenePresence(sceneA, uaA).ControllingClient;
142
143 // This is the more long-winded route we have to take to get a child client created for userB in sceneA
144 // rather than just calling AddScenePresence() as for userA
145 AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB);
146 TestClient clientB = new TestClient(acd, sceneB);
147 List<TestClient> childClientsB = new List<TestClient>();
148 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(clientB, childClientsB);
149
150 SceneHelpers.AddScenePresence(sceneB, clientB, acd);
151
152 SceneObjectGroup so = SceneHelpers.AddSceneObject(sceneA);
153 uint soLocalId = so.LocalId;
154
155 sceneA.DeleteSceneObject(so, false);
156
157 Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1));
158 Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId));
159
160 Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1));
161 Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId));
95 } 162 }
96 163
97 /// <summary> 164 /// <summary>
98 /// Test deleting an object from a scene where the deleter is not the owner 165 /// Test deleting an object from a scene where the deleter is not the owner
99 /// </summary> 166 /// </summary>
100 /// 167 /// <remarks>
101 /// This test assumes that the deleter is not a god. 168 /// This test assumes that the deleter is not a god.
169 /// </remarks>
102 [Test] 170 [Test]
103 public void TestDeRezSceneObjectNotOwner() 171 public void TestDeRezSceneObjectNotOwner()
104 { 172 {
@@ -109,10 +177,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
109 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); 177 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
110 178
111 TestScene scene = new SceneHelpers().SetupScene(); 179 TestScene scene = new SceneHelpers().SetupScene();
112 IConfigSource configSource = new IniConfigSource(); 180 SceneHelpers.SetupSceneModules(scene, new PermissionsModule());
113 IConfig config = configSource.AddConfig("Startup");
114 config.Set("serverside_object_permissions", true);
115 SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
116 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; 181 IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
117 182
118 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 183 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
@@ -164,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
164 229
165 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); 230 UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
166 InventoryFolderBase folder1 231 InventoryFolderBase folder1
167 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1"); 232 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);
168 233
169 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; 234 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
170 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); 235 scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID);