clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 using OpenSim.Tests.Common.Mock;
41  
42 namespace OpenSim.Region.Framework.Scenes.Tests
43 {
44 public class SceneObjectCrossingTests : OpenSimTestCase
45 {
46 [TestFixtureSetUp]
47 public void FixtureInit()
48 {
49 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
50 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
51 }
52  
53 [TestFixtureTearDown]
54 public void TearDown()
55 {
56 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
57 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
58 // tests really shouldn't).
59 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
60 }
61  
62 /// <summary>
63 /// Test cross with no prim limit module.
64 /// </summary>
65 [Test]
66 public void TestCrossOnSameSimulator()
67 {
68 TestHelpers.InMethod();
69 // TestHelpers.EnableLogging();
70  
71 UUID userId = TestHelpers.ParseTail(0x1);
72 int sceneObjectIdTail = 0x2;
73  
74 EntityTransferModule etmA = new EntityTransferModule();
75 EntityTransferModule etmB = new EntityTransferModule();
76 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
77  
78 IConfigSource config = new IniConfigSource();
79 IConfig modulesConfig = config.AddConfig("Modules");
80 modulesConfig.Set("EntityTransferModule", etmA.Name);
81 modulesConfig.Set("SimulationServices", lscm.Name);
82  
83 SceneHelpers sh = new SceneHelpers();
84 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
85 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
86  
87 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
88 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
89 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
90  
91 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
92 UUID so1Id = so1.UUID;
93 so1.AbsolutePosition = new Vector3(128, 10, 20);
94  
95 // Cross with a negative value
96 so1.AbsolutePosition = new Vector3(128, -10, 20);
97  
98 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
99 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
100 }
101  
102 /// <summary>
103 /// Test cross with no prim limit module.
104 /// </summary>
105 /// <remarks>
106 /// Possibly this should belong in ScenePresenceCrossingTests, though here it is the object that is being moved
107 /// where the avatar is just a passenger.
108 /// </remarks>
109 [Test]
110 public void TestCrossOnSameSimulatorWithSittingAvatar()
111 {
112 TestHelpers.InMethod();
113 // TestHelpers.EnableLogging();
114  
115 UUID userId = TestHelpers.ParseTail(0x1);
116 int sceneObjectIdTail = 0x2;
117 Vector3 so1StartPos = new Vector3(128, 10, 20);
118  
119 EntityTransferModule etmA = new EntityTransferModule();
120 EntityTransferModule etmB = new EntityTransferModule();
121 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
122  
123 IConfigSource config = new IniConfigSource();
124 IConfig modulesConfig = config.AddConfig("Modules");
125 modulesConfig.Set("EntityTransferModule", etmA.Name);
126 modulesConfig.Set("SimulationServices", lscm.Name);
127 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
128  
129 // In order to run a single threaded regression test we do not want the entity transfer module waiting
130 // for a callback from the destination scene before removing its avatar data.
131 entityTransferConfig.Set("wait_for_callback", false);
132  
133 SceneHelpers sh = new SceneHelpers();
134 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
135 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
136  
137 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
138 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
139 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
140  
141 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
142 UUID so1Id = so1.UUID;
143 so1.AbsolutePosition = so1StartPos;
144  
145 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
146 TestClient tc = new TestClient(acd, sceneA);
147 List<TestClient> destinationTestClients = new List<TestClient>();
148 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
149  
150 ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
151 sp1SceneA.AbsolutePosition = so1StartPos;
152 sp1SceneA.HandleAgentRequestSit(sp1SceneA.ControllingClient, sp1SceneA.UUID, so1.UUID, Vector3.Zero);
153  
154 // Cross
155 sceneA.SceneGraph.UpdatePrimGroupPosition(
156 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId);
157  
158 SceneObjectGroup so1PostCross;
159  
160 {
161 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
162 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
163  
164 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
165 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient);
166 sceneBTc.CompleteMovement();
167  
168 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
169 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);
170  
171 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
172 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
173 Assert.NotNull(so1PostCross);
174 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
175 }
176  
177 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;
178  
179 // Console.WriteLine("CRISSCROSS");
180  
181 // Recross
182 sceneB.SceneGraph.UpdatePrimGroupPosition(
183 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId);
184  
185 {
186 ScenePresence sp1SceneBPostReCross = sceneB.GetScenePresence(userId);
187 Assert.IsTrue(sp1SceneBPostReCross.IsChildAgent, "sp1SceneBPostReCross.IsChildAgent unexpectedly false");
188  
189 ScenePresence sp1SceneAPostReCross = sceneA.GetScenePresence(userId);
190 TestClient sceneATc = ((TestClient)sp1SceneAPostReCross.ControllingClient);
191 sceneATc.CompleteMovement();
192  
193 Assert.IsFalse(sp1SceneAPostReCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
194 Assert.IsTrue(sp1SceneAPostReCross.IsSatOnObject);
195  
196 Assert.IsNull(sceneB.GetSceneObjectGroup(so1Id), "uck2");
197 SceneObjectGroup so1PostReCross = sceneA.GetSceneObjectGroup(so1Id);
198 Assert.NotNull(so1PostReCross);
199 Assert.AreEqual(1, so1PostReCross.GetSittingAvatarsCount());
200 }
201 }
202  
203 /// <summary>
204 /// Test cross with no prim limit module.
205 /// </summary>
206 /// <remarks>
207 /// XXX: This test may FCbe better off in a specific PrimLimitsModuleTest class in optional module tests in the
208 /// future (though it is configured as active by default, so not really optional).
209 /// </remarks>
210 [Test]
211 public void TestCrossOnSameSimulatorPrimLimitsOkay()
212 {
213 TestHelpers.InMethod();
214 // TestHelpers.EnableLogging();
215  
216 UUID userId = TestHelpers.ParseTail(0x1);
217 int sceneObjectIdTail = 0x2;
218  
219 EntityTransferModule etmA = new EntityTransferModule();
220 EntityTransferModule etmB = new EntityTransferModule();
221 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
222 LandManagementModule lmmA = new LandManagementModule();
223 LandManagementModule lmmB = new LandManagementModule();
224  
225 IConfigSource config = new IniConfigSource();
226 IConfig modulesConfig = config.AddConfig("Modules");
227 modulesConfig.Set("EntityTransferModule", etmA.Name);
228 modulesConfig.Set("SimulationServices", lscm.Name);
229  
230 IConfig permissionsConfig = config.AddConfig("Permissions");
231 permissionsConfig.Set("permissionmodules", "PrimLimitsModule");
232  
233 SceneHelpers sh = new SceneHelpers();
234 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
235 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
236  
237 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
238 SceneHelpers.SetupSceneModules(
239 sceneA, config, etmA, lmmA, new PrimLimitsModule(), new PrimCountModule());
240 SceneHelpers.SetupSceneModules(
241 sceneB, config, etmB, lmmB, new PrimLimitsModule(), new PrimCountModule());
242  
243 // We must set up the parcel for this to work. Normally this is taken care of by OpenSimulator startup
244 // code which is not yet easily invoked by tests.
245 lmmA.EventManagerOnNoLandDataFromStorage();
246 lmmB.EventManagerOnNoLandDataFromStorage();
247  
248 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
249 UUID so1Id = so1.UUID;
250 so1.AbsolutePosition = new Vector3(128, 10, 20);
251  
252 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
253 // because only this will execute permission checks in the source region.
254 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId);
255  
256 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
257 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
258 }
259 }
260 }