diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs | 266 |
1 files changed, 266 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs new file mode 100644 index 0000000..4ed67f3 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs | |||
@@ -0,0 +1,266 @@ | |||
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 NUnit.Framework; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | using OpenSim.Tests.Common; | ||
34 | |||
35 | namespace OpenSim.Region.CoreModules.World.Land.Tests | ||
36 | { | ||
37 | public class LandManagementModuleTests : OpenSimTestCase | ||
38 | { | ||
39 | [Test] | ||
40 | public void TestAddLandObject() | ||
41 | { | ||
42 | TestHelpers.InMethod(); | ||
43 | // TestHelpers.EnableLogging(); | ||
44 | |||
45 | UUID userId = TestHelpers.ParseTail(0x1); | ||
46 | |||
47 | LandManagementModule lmm = new LandManagementModule(); | ||
48 | Scene scene = new SceneHelpers().SetupScene(); | ||
49 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
50 | |||
51 | ILandObject lo = new LandObject(userId, false, scene); | ||
52 | lo.LandData.Name = "lo1"; | ||
53 | lo.SetLandBitmap( | ||
54 | lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
55 | lo = lmm.AddLandObject(lo); | ||
56 | |||
57 | // TODO: Should add asserts to check that land object was added properly. | ||
58 | |||
59 | // At the moment, this test just makes sure that we can't add a land object that overlaps the areas that | ||
60 | // the first still holds. | ||
61 | ILandObject lo2 = new LandObject(userId, false, scene); | ||
62 | lo2.SetLandBitmap( | ||
63 | lo2.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
64 | lo2.LandData.Name = "lo2"; | ||
65 | lo2 = lmm.AddLandObject(lo2); | ||
66 | |||
67 | { | ||
68 | ILandObject loAtCoord = lmm.GetLandObject(0, 0); | ||
69 | Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); | ||
70 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); | ||
71 | } | ||
72 | |||
73 | { | ||
74 | ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); | ||
75 | Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); | ||
76 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | /// <summary> | ||
81 | /// Test parcels on region when no land data exists to be loaded. | ||
82 | /// </summary> | ||
83 | [Test] | ||
84 | public void TestLoadWithNoParcels() | ||
85 | { | ||
86 | TestHelpers.InMethod(); | ||
87 | // TestHelpers.EnableLogging(); | ||
88 | |||
89 | SceneHelpers sh = new SceneHelpers(); | ||
90 | LandManagementModule lmm = new LandManagementModule(); | ||
91 | Scene scene = sh.SetupScene(); | ||
92 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
93 | |||
94 | scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID); | ||
95 | |||
96 | ILandObject loAtCoord1 = lmm.GetLandObject(0, 0); | ||
97 | Assert.That(loAtCoord1.LandData.LocalID, Is.Not.EqualTo(0)); | ||
98 | Assert.That(loAtCoord1.LandData.GlobalID, Is.Not.EqualTo(UUID.Zero)); | ||
99 | |||
100 | ILandObject loAtCoord2 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); | ||
101 | Assert.That(loAtCoord2.LandData.LocalID, Is.EqualTo(loAtCoord1.LandData.LocalID)); | ||
102 | Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(loAtCoord1.LandData.GlobalID)); | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Test parcels on region when a single parcel already exists but it does not cover the whole region. | ||
107 | /// </summary> | ||
108 | [Test] | ||
109 | public void TestLoadWithSinglePartialCoveringParcel() | ||
110 | { | ||
111 | TestHelpers.InMethod(); | ||
112 | // TestHelpers.EnableLogging(); | ||
113 | |||
114 | UUID userId = TestHelpers.ParseTail(0x1); | ||
115 | |||
116 | SceneHelpers sh = new SceneHelpers(); | ||
117 | LandManagementModule lmm = new LandManagementModule(); | ||
118 | Scene scene = sh.SetupScene(); | ||
119 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
120 | |||
121 | ILandObject originalLo1 = new LandObject(userId, false, scene); | ||
122 | originalLo1.LandData.Name = "lo1"; | ||
123 | originalLo1.SetLandBitmap( | ||
124 | originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2)); | ||
125 | |||
126 | sh.SimDataService.StoreLandObject(originalLo1); | ||
127 | |||
128 | scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID); | ||
129 | |||
130 | ILandObject loAtCoord1 = lmm.GetLandObject(0, 0); | ||
131 | Assert.That(loAtCoord1.LandData.Name, Is.EqualTo(originalLo1.LandData.Name)); | ||
132 | Assert.That(loAtCoord1.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID)); | ||
133 | |||
134 | ILandObject loAtCoord2 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); | ||
135 | Assert.That(loAtCoord2.LandData.LocalID, Is.EqualTo(loAtCoord1.LandData.LocalID)); | ||
136 | Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(loAtCoord1.LandData.GlobalID)); | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Test parcels on region when a single parcel already exists but it does not cover the whole region. | ||
141 | /// </summary> | ||
142 | [Test] | ||
143 | public void TestLoadWithMultiplePartialCoveringParcels() | ||
144 | { | ||
145 | TestHelpers.InMethod(); | ||
146 | // TestHelpers.EnableLogging(); | ||
147 | |||
148 | UUID userId = TestHelpers.ParseTail(0x1); | ||
149 | |||
150 | SceneHelpers sh = new SceneHelpers(); | ||
151 | LandManagementModule lmm = new LandManagementModule(); | ||
152 | Scene scene = sh.SetupScene(); | ||
153 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
154 | |||
155 | ILandObject originalLo1 = new LandObject(userId, false, scene); | ||
156 | originalLo1.LandData.Name = "lo1"; | ||
157 | originalLo1.SetLandBitmap( | ||
158 | originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2)); | ||
159 | |||
160 | sh.SimDataService.StoreLandObject(originalLo1); | ||
161 | |||
162 | ILandObject originalLo2 = new LandObject(userId, false, scene); | ||
163 | originalLo2.LandData.Name = "lo2"; | ||
164 | originalLo2.SetLandBitmap( | ||
165 | originalLo2.GetSquareLandBitmap( | ||
166 | 0, (int)Constants.RegionSize / 2, (int)Constants.RegionSize, ((int)Constants.RegionSize / 4) * 3)); | ||
167 | |||
168 | sh.SimDataService.StoreLandObject(originalLo2); | ||
169 | |||
170 | scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID); | ||
171 | |||
172 | ILandObject loAtCoord1 = lmm.GetLandObject(0, 0); | ||
173 | Assert.That(loAtCoord1.LandData.Name, Is.EqualTo(originalLo1.LandData.Name)); | ||
174 | Assert.That(loAtCoord1.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID)); | ||
175 | |||
176 | ILandObject loAtCoord2 | ||
177 | = lmm.GetLandObject((int)Constants.RegionSize - 1, (((int)Constants.RegionSize / 4) * 3) - 1); | ||
178 | Assert.That(loAtCoord2.LandData.Name, Is.EqualTo(originalLo2.LandData.Name)); | ||
179 | Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(originalLo2.LandData.GlobalID)); | ||
180 | |||
181 | ILandObject loAtCoord3 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); | ||
182 | Assert.That(loAtCoord3.LandData.LocalID, Is.Not.EqualTo(loAtCoord1.LandData.LocalID)); | ||
183 | Assert.That(loAtCoord3.LandData.LocalID, Is.Not.EqualTo(loAtCoord2.LandData.LocalID)); | ||
184 | Assert.That(loAtCoord3.LandData.GlobalID, Is.Not.EqualTo(loAtCoord1.LandData.GlobalID)); | ||
185 | Assert.That(loAtCoord3.LandData.GlobalID, Is.Not.EqualTo(loAtCoord2.LandData.GlobalID)); | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
189 | /// Test parcels on region when whole region is parcelled (which should normally always be the case). | ||
190 | /// </summary> | ||
191 | [Test] | ||
192 | public void TestLoad() | ||
193 | { | ||
194 | TestHelpers.InMethod(); | ||
195 | // TestHelpers.EnableLogging(); | ||
196 | |||
197 | UUID userId = TestHelpers.ParseTail(0x1); | ||
198 | |||
199 | SceneHelpers sh = new SceneHelpers(); | ||
200 | LandManagementModule lmm = new LandManagementModule(); | ||
201 | Scene scene = sh.SetupScene(); | ||
202 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
203 | |||
204 | ILandObject originalLo1 = new LandObject(userId, false, scene); | ||
205 | originalLo1.LandData.Name = "lo1"; | ||
206 | originalLo1.SetLandBitmap( | ||
207 | originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2)); | ||
208 | |||
209 | sh.SimDataService.StoreLandObject(originalLo1); | ||
210 | |||
211 | ILandObject originalLo2 = new LandObject(userId, false, scene); | ||
212 | originalLo2.LandData.Name = "lo2"; | ||
213 | originalLo2.SetLandBitmap( | ||
214 | originalLo2.GetSquareLandBitmap(0, (int)Constants.RegionSize / 2, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
215 | |||
216 | sh.SimDataService.StoreLandObject(originalLo2); | ||
217 | |||
218 | scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID); | ||
219 | |||
220 | { | ||
221 | ILandObject loAtCoord = lmm.GetLandObject(0, 0); | ||
222 | Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo1.LandData.Name)); | ||
223 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID)); | ||
224 | } | ||
225 | |||
226 | { | ||
227 | ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1)); | ||
228 | Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo2.LandData.Name)); | ||
229 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo2.LandData.GlobalID)); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | [Test] | ||
234 | public void TestSubdivide() | ||
235 | { | ||
236 | TestHelpers.InMethod(); | ||
237 | // TestHelpers.EnableLogging(); | ||
238 | |||
239 | UUID userId = TestHelpers.ParseTail(0x1); | ||
240 | |||
241 | LandManagementModule lmm = new LandManagementModule(); | ||
242 | Scene scene = new SceneHelpers().SetupScene(); | ||
243 | SceneHelpers.SetupSceneModules(scene, lmm); | ||
244 | |||
245 | ILandObject lo = new LandObject(userId, false, scene); | ||
246 | lo.LandData.Name = "lo1"; | ||
247 | lo.SetLandBitmap( | ||
248 | lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
249 | lo = lmm.AddLandObject(lo); | ||
250 | |||
251 | lmm.Subdivide(0, 0, LandManagementModule.LandUnit, LandManagementModule.LandUnit, userId); | ||
252 | |||
253 | { | ||
254 | ILandObject loAtCoord = lmm.GetLandObject(0, 0); | ||
255 | Assert.That(loAtCoord.LandData.LocalID, Is.Not.EqualTo(lo.LandData.LocalID)); | ||
256 | Assert.That(loAtCoord.LandData.GlobalID, Is.Not.EqualTo(lo.LandData.GlobalID)); | ||
257 | } | ||
258 | |||
259 | { | ||
260 | ILandObject loAtCoord = lmm.GetLandObject(LandManagementModule.LandUnit, LandManagementModule.LandUnit); | ||
261 | Assert.That(loAtCoord.LandData.LocalID, Is.EqualTo(lo.LandData.LocalID)); | ||
262 | Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(lo.LandData.GlobalID)); | ||
263 | } | ||
264 | } | ||
265 | } | ||
266 | } \ No newline at end of file | ||