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