aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs161
1 files changed, 161 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..43ac558
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
@@ -0,0 +1,161 @@
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 Nini.Config;
30using NUnit.Framework;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.CoreModules.Framework.EntityTransfer;
34using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
35using OpenSim.Region.CoreModules.World.Land;
36using OpenSim.Region.OptionalModules;
37using OpenSim.Tests.Common;
38using OpenSim.Tests.Common.Mock;
39
40namespace OpenSim.Region.Framework.Scenes.Tests
41{
42 public class SceneObjectCrossingTests : OpenSimTestCase
43 {
44 [TestFixtureSetUp]
45 public void FixtureInit()
46 {
47 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
48 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
49 }
50
51 [TestFixtureTearDown]
52 public void TearDown()
53 {
54 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
55 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
56 // tests really shouldn't).
57 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
58 }
59
60 /// <summary>
61 /// Test cross with no prim limit module.
62 /// </summary>
63 [Test]
64 public void TestCrossOnSameSimulator()
65 {
66 TestHelpers.InMethod();
67 TestHelpers.EnableLogging();
68
69 UUID userId = TestHelpers.ParseTail(0x1);
70 int sceneObjectIdTail = 0x2;
71
72 EntityTransferModule etmA = new EntityTransferModule();
73 EntityTransferModule etmB = new EntityTransferModule();
74 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
75
76 IConfigSource config = new IniConfigSource();
77 IConfig modulesConfig = config.AddConfig("Modules");
78 modulesConfig.Set("EntityTransferModule", etmA.Name);
79 modulesConfig.Set("SimulationServices", lscm.Name);
80// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
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 /// XXX: This test may be better off in a specific PrimLimitsModuleTest class in optional module tests in the
106 /// future (though it is configured as active by default, so not really optional).
107 /// </remarks>
108 [Test]
109 public void TestCrossOnSameSimulatorPrimLimitsOkay()
110 {
111 TestHelpers.InMethod();
112 TestHelpers.EnableLogging();
113
114 UUID userId = TestHelpers.ParseTail(0x1);
115 int sceneObjectIdTail = 0x2;
116
117 EntityTransferModule etmA = new EntityTransferModule();
118 EntityTransferModule etmB = new EntityTransferModule();
119 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
120 LandManagementModule lmmA = new LandManagementModule();
121 LandManagementModule lmmB = new LandManagementModule();
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
128 // Remove?
129// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
130
131 IConfig permissionsConfig = config.AddConfig("Permissions");
132 permissionsConfig.Set("permissionmodules", "PrimLimitsModule");
133
134 SceneHelpers sh = new SceneHelpers();
135 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
136 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
137
138 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
139 SceneHelpers.SetupSceneModules(
140 sceneA, config, etmA, lmmA, new PrimLimitsModule(), new PrimCountModule());
141 SceneHelpers.SetupSceneModules(
142 sceneB, config, etmB, lmmB, new PrimLimitsModule(), new PrimCountModule());
143
144 // We must set up the parcel for this to work. Normally this is taken care of by OpenSimulator startup
145 // code which is not yet easily invoked by tests.
146 lmmA.EventManagerOnNoLandDataFromStorage();
147 lmmB.EventManagerOnNoLandDataFromStorage();
148
149 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
150 UUID so1Id = so1.UUID;
151 so1.AbsolutePosition = new Vector3(128, 10, 20);
152
153 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
154 // because only this will execute permission checks in the source region.
155 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId);
156
157 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
158 Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
159 }
160 }
161} \ No newline at end of file