aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs259
1 files changed, 259 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
new file mode 100644
index 0000000..5635c20
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
@@ -0,0 +1,259 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.CoreModules.Framework;
35using OpenSim.Region.CoreModules.Framework.EntityTransfer;
36using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
37using OpenSim.Region.CoreModules.World.Land;
38using OpenSim.Region.OptionalModules;
39using OpenSim.Tests.Common;
40
41namespace OpenSim.Region.Framework.Scenes.Tests
42{
43 public class SceneObjectCrossingTests : OpenSimTestCase
44 {
45 [TestFixtureSetUp]
46 public void FixtureInit()
47 {
48 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
49 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
50 }
51
52 [TestFixtureTearDown]
53 public void TearDown()
54 {
55 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
56 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
57 // tests really shouldn't).
58 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
59 }
60
61 /// <summary>
62 /// Test cross with no prim limit module.
63 /// </summary>
64 [Test]
65 public void TestCrossOnSameSimulator()
66 {
67 TestHelpers.InMethod();
68// TestHelpers.EnableLogging();
69
70 UUID userId = TestHelpers.ParseTail(0x1);
71 int sceneObjectIdTail = 0x2;
72
73 EntityTransferModule etmA = new EntityTransferModule();
74 EntityTransferModule etmB = new EntityTransferModule();
75 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
76
77 IConfigSource config = new IniConfigSource();
78 IConfig modulesConfig = config.AddConfig("Modules");
79 modulesConfig.Set("EntityTransferModule", etmA.Name);
80 modulesConfig.Set("SimulationServices", lscm.Name);
81
82 SceneHelpers sh = new SceneHelpers();
83 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
84 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
85
86 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
87 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
88 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
89
90 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
91 UUID so1Id = so1.UUID;
92 so1.AbsolutePosition = new Vector3(128, 10, 20);
93
94 // Cross with a negative value
95 so1.AbsolutePosition = new Vector3(128, -10, 20);
96
97 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
98 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
99 }
100
101 /// <summary>
102 /// Test cross with no prim limit module.
103 /// </summary>
104 /// <remarks>
105 /// Possibly this should belong in ScenePresenceCrossingTests, though here it is the object that is being moved
106 /// where the avatar is just a passenger.
107 /// </remarks>
108 [Test]
109 public void TestCrossOnSameSimulatorWithSittingAvatar()
110 {
111 TestHelpers.InMethod();
112// TestHelpers.EnableLogging();
113
114 UUID userId = TestHelpers.ParseTail(0x1);
115 int sceneObjectIdTail = 0x2;
116 Vector3 so1StartPos = new Vector3(128, 10, 20);
117
118 EntityTransferModule etmA = new EntityTransferModule();
119 EntityTransferModule etmB = new EntityTransferModule();
120 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
121
122 IConfigSource config = new IniConfigSource();
123 IConfig modulesConfig = config.AddConfig("Modules");
124 modulesConfig.Set("EntityTransferModule", etmA.Name);
125 modulesConfig.Set("SimulationServices", lscm.Name);
126 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
127
128 // In order to run a single threaded regression test we do not want the entity transfer module waiting
129 // for a callback from the destination scene before removing its avatar data.
130 entityTransferConfig.Set("wait_for_callback", false);
131
132 SceneHelpers sh = new SceneHelpers();
133 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
134 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
135
136 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
137 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
138 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
139
140 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
141 UUID so1Id = so1.UUID;
142 so1.AbsolutePosition = so1StartPos;
143
144 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
145 TestClient tc = new TestClient(acd, sceneA);
146 List<TestClient> destinationTestClients = new List<TestClient>();
147 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
148
149 ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
150 sp1SceneA.AbsolutePosition = so1StartPos;
151 sp1SceneA.HandleAgentRequestSit(sp1SceneA.ControllingClient, sp1SceneA.UUID, so1.UUID, Vector3.Zero);
152
153 // Cross
154 sceneA.SceneGraph.UpdatePrimGroupPosition(
155 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId);
156
157 SceneObjectGroup so1PostCross;
158
159 {
160 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
161 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
162
163 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
164 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient);
165 sceneBTc.CompleteMovement();
166
167 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
168 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);
169
170 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
171 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
172 Assert.NotNull(so1PostCross);
173 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
174 }
175
176 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;
177
178// Console.WriteLine("CRISSCROSS");
179
180 // Recross
181 sceneB.SceneGraph.UpdatePrimGroupPosition(
182 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId);
183
184 {
185 ScenePresence sp1SceneBPostReCross = sceneB.GetScenePresence(userId);
186 Assert.IsTrue(sp1SceneBPostReCross.IsChildAgent, "sp1SceneBPostReCross.IsChildAgent unexpectedly false");
187
188 ScenePresence sp1SceneAPostReCross = sceneA.GetScenePresence(userId);
189 TestClient sceneATc = ((TestClient)sp1SceneAPostReCross.ControllingClient);
190 sceneATc.CompleteMovement();
191
192 Assert.IsFalse(sp1SceneAPostReCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
193 Assert.IsTrue(sp1SceneAPostReCross.IsSatOnObject);
194
195 Assert.IsNull(sceneB.GetSceneObjectGroup(so1Id), "uck2");
196 SceneObjectGroup so1PostReCross = sceneA.GetSceneObjectGroup(so1Id);
197 Assert.NotNull(so1PostReCross);
198 Assert.AreEqual(1, so1PostReCross.GetSittingAvatarsCount());
199 }
200 }
201
202 /// <summary>
203 /// Test cross with no prim limit module.
204 /// </summary>
205 /// <remarks>
206 /// XXX: This test may FCbe better off in a specific PrimLimitsModuleTest class in optional module tests in the
207 /// future (though it is configured as active by default, so not really optional).
208 /// </remarks>
209 [Test]
210 public void TestCrossOnSameSimulatorPrimLimitsOkay()
211 {
212 TestHelpers.InMethod();
213// TestHelpers.EnableLogging();
214
215 UUID userId = TestHelpers.ParseTail(0x1);
216 int sceneObjectIdTail = 0x2;
217
218 EntityTransferModule etmA = new EntityTransferModule();
219 EntityTransferModule etmB = new EntityTransferModule();
220 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
221 LandManagementModule lmmA = new LandManagementModule();
222 LandManagementModule lmmB = new LandManagementModule();
223
224 IConfigSource config = new IniConfigSource();
225 IConfig modulesConfig = config.AddConfig("Modules");
226 modulesConfig.Set("EntityTransferModule", etmA.Name);
227 modulesConfig.Set("SimulationServices", lscm.Name);
228
229 IConfig permissionsConfig = config.AddConfig("Permissions");
230 permissionsConfig.Set("permissionmodules", "PrimLimitsModule");
231
232 SceneHelpers sh = new SceneHelpers();
233 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
234 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
235
236 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
237 SceneHelpers.SetupSceneModules(
238 sceneA, config, etmA, lmmA, new PrimLimitsModule(), new PrimCountModule());
239 SceneHelpers.SetupSceneModules(
240 sceneB, config, etmB, lmmB, new PrimLimitsModule(), new PrimCountModule());
241
242 // We must set up the parcel for this to work. Normally this is taken care of by OpenSimulator startup
243 // code which is not yet easily invoked by tests.
244 lmmA.EventManagerOnNoLandDataFromStorage();
245 lmmB.EventManagerOnNoLandDataFromStorage();
246
247 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
248 UUID so1Id = so1.UUID;
249 so1.AbsolutePosition = new Vector3(128, 10, 20);
250
251 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
252 // because only this will execute permission checks in the source region.
253 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId);
254
255 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
256 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
257 }
258 }
259} \ No newline at end of file