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 System.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | using log4net.Config; |
||
32 | using NUnit.Framework; |
||
33 | using OpenMetaverse; |
||
34 | using OpenMetaverse.Assets; |
||
35 | using OpenSim.Framework; |
||
36 | using OpenSim.Region.Framework.Interfaces; |
||
37 | using OpenSim.Region.Framework.Scenes; |
||
38 | using OpenSim.Tests.Common; |
||
39 | using OpenSim.Tests.Common.Mock; |
||
40 | |||
41 | namespace OpenSim.Region.CoreModules.World.Land.Tests |
||
42 | { |
||
43 | [TestFixture] |
||
44 | public class PrimCountModuleTests : OpenSimTestCase |
||
45 | { |
||
46 | protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000"); |
||
47 | protected UUID m_groupId = new UUID("00000000-0000-0000-8888-000000000000"); |
||
48 | protected UUID m_otherUserId = new UUID("99999999-9999-9999-9999-999999999999"); |
||
49 | protected TestScene m_scene; |
||
50 | protected PrimCountModule m_pcm; |
||
51 | |||
52 | /// <summary> |
||
53 | /// A parcel that covers the entire sim except for a 1 unit wide strip on the eastern side. |
||
54 | /// </summary> |
||
55 | protected ILandObject m_lo; |
||
56 | |||
57 | /// <summary> |
||
58 | /// A parcel that covers just the eastern strip of the sim. |
||
59 | /// </summary> |
||
60 | protected ILandObject m_lo2; |
||
61 | |||
62 | [SetUp] |
||
63 | public override void SetUp() |
||
64 | { |
||
65 | base.SetUp(); |
||
66 | |||
67 | m_pcm = new PrimCountModule(); |
||
68 | LandManagementModule lmm = new LandManagementModule(); |
||
69 | m_scene = new SceneHelpers().SetupScene(); |
||
70 | SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); |
||
71 | |||
72 | int xParcelDivider = (int)Constants.RegionSize - 1; |
||
73 | |||
74 | ILandObject lo = new LandObject(m_userId, false, m_scene); |
||
75 | lo.LandData.Name = "m_lo"; |
||
76 | lo.SetLandBitmap( |
||
77 | lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize)); |
||
78 | m_lo = lmm.AddLandObject(lo); |
||
79 | |||
80 | ILandObject lo2 = new LandObject(m_userId, false, m_scene); |
||
81 | lo2.SetLandBitmap( |
||
82 | lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
||
83 | lo2.LandData.Name = "m_lo2"; |
||
84 | m_lo2 = lmm.AddLandObject(lo2); |
||
85 | } |
||
86 | |||
87 | /// <summary> |
||
88 | /// Test that counts before we do anything are correct. |
||
89 | /// </summary> |
||
90 | [Test] |
||
91 | public void TestInitialCounts() |
||
92 | { |
||
93 | IPrimCounts pc = m_lo.PrimCounts; |
||
94 | |||
95 | Assert.That(pc.Owner, Is.EqualTo(0)); |
||
96 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
97 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
98 | Assert.That(pc.Total, Is.EqualTo(0)); |
||
99 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
100 | Assert.That(pc.Users[m_userId], Is.EqualTo(0)); |
||
101 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
102 | Assert.That(pc.Simulator, Is.EqualTo(0)); |
||
103 | } |
||
104 | |||
105 | /// <summary> |
||
106 | /// Test count after a parcel owner owned object is added. |
||
107 | /// </summary> |
||
108 | [Test] |
||
109 | public void TestAddOwnerObject() |
||
110 | { |
||
111 | TestHelpers.InMethod(); |
||
112 | // log4net.Config.XmlConfigurator.Configure(); |
||
113 | |||
114 | IPrimCounts pc = m_lo.PrimCounts; |
||
115 | |||
116 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
||
117 | m_scene.AddNewSceneObject(sog, false); |
||
118 | |||
119 | Assert.That(pc.Owner, Is.EqualTo(3)); |
||
120 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
121 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
122 | Assert.That(pc.Total, Is.EqualTo(3)); |
||
123 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
124 | Assert.That(pc.Users[m_userId], Is.EqualTo(3)); |
||
125 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
126 | Assert.That(pc.Simulator, Is.EqualTo(3)); |
||
127 | |||
128 | // Add a second object and retest |
||
129 | SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10); |
||
130 | m_scene.AddNewSceneObject(sog2, false); |
||
131 | |||
132 | Assert.That(pc.Owner, Is.EqualTo(5)); |
||
133 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
134 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
135 | Assert.That(pc.Total, Is.EqualTo(5)); |
||
136 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
137 | Assert.That(pc.Users[m_userId], Is.EqualTo(5)); |
||
138 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
139 | Assert.That(pc.Simulator, Is.EqualTo(5)); |
||
140 | } |
||
141 | |||
142 | /// <summary> |
||
143 | /// Test count after a parcel owner owned copied object is added. |
||
144 | /// </summary> |
||
145 | [Test] |
||
146 | public void TestCopyOwnerObject() |
||
147 | { |
||
148 | TestHelpers.InMethod(); |
||
149 | // log4net.Config.XmlConfigurator.Configure(); |
||
150 | |||
151 | IPrimCounts pc = m_lo.PrimCounts; |
||
152 | |||
153 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
||
154 | m_scene.AddNewSceneObject(sog, false); |
||
155 | m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); |
||
156 | |||
157 | Assert.That(pc.Owner, Is.EqualTo(6)); |
||
158 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
159 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
160 | Assert.That(pc.Total, Is.EqualTo(6)); |
||
161 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
162 | Assert.That(pc.Users[m_userId], Is.EqualTo(6)); |
||
163 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
164 | Assert.That(pc.Simulator, Is.EqualTo(6)); |
||
165 | } |
||
166 | |||
167 | /// <summary> |
||
168 | /// Test that parcel counts update correctly when an object is moved between parcels, where that movement |
||
169 | /// is not done directly by the user/ |
||
170 | /// </summary> |
||
171 | [Test] |
||
172 | public void TestMoveOwnerObject() |
||
173 | { |
||
174 | TestHelpers.InMethod(); |
||
175 | // log4net.Config.XmlConfigurator.Configure(); |
||
176 | |||
177 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
||
178 | m_scene.AddNewSceneObject(sog, false); |
||
179 | SceneObjectGroup sog2 = SceneHelpers.CreateSceneObject(2, m_userId, "b", 0x10); |
||
180 | m_scene.AddNewSceneObject(sog2, false); |
||
181 | |||
182 | // Move the first scene object to the eastern strip parcel |
||
183 | sog.AbsolutePosition = new Vector3(254, 2, 2); |
||
184 | |||
185 | IPrimCounts pclo1 = m_lo.PrimCounts; |
||
186 | |||
187 | Assert.That(pclo1.Owner, Is.EqualTo(2)); |
||
188 | Assert.That(pclo1.Group, Is.EqualTo(0)); |
||
189 | Assert.That(pclo1.Others, Is.EqualTo(0)); |
||
190 | Assert.That(pclo1.Total, Is.EqualTo(2)); |
||
191 | Assert.That(pclo1.Selected, Is.EqualTo(0)); |
||
192 | Assert.That(pclo1.Users[m_userId], Is.EqualTo(2)); |
||
193 | Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0)); |
||
194 | Assert.That(pclo1.Simulator, Is.EqualTo(5)); |
||
195 | |||
196 | IPrimCounts pclo2 = m_lo2.PrimCounts; |
||
197 | |||
198 | Assert.That(pclo2.Owner, Is.EqualTo(3)); |
||
199 | Assert.That(pclo2.Group, Is.EqualTo(0)); |
||
200 | Assert.That(pclo2.Others, Is.EqualTo(0)); |
||
201 | Assert.That(pclo2.Total, Is.EqualTo(3)); |
||
202 | Assert.That(pclo2.Selected, Is.EqualTo(0)); |
||
203 | Assert.That(pclo2.Users[m_userId], Is.EqualTo(3)); |
||
204 | Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0)); |
||
205 | Assert.That(pclo2.Simulator, Is.EqualTo(5)); |
||
206 | |||
207 | // Now move it back again |
||
208 | sog.AbsolutePosition = new Vector3(2, 2, 2); |
||
209 | |||
210 | Assert.That(pclo1.Owner, Is.EqualTo(5)); |
||
211 | Assert.That(pclo1.Group, Is.EqualTo(0)); |
||
212 | Assert.That(pclo1.Others, Is.EqualTo(0)); |
||
213 | Assert.That(pclo1.Total, Is.EqualTo(5)); |
||
214 | Assert.That(pclo1.Selected, Is.EqualTo(0)); |
||
215 | Assert.That(pclo1.Users[m_userId], Is.EqualTo(5)); |
||
216 | Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0)); |
||
217 | Assert.That(pclo1.Simulator, Is.EqualTo(5)); |
||
218 | |||
219 | Assert.That(pclo2.Owner, Is.EqualTo(0)); |
||
220 | Assert.That(pclo2.Group, Is.EqualTo(0)); |
||
221 | Assert.That(pclo2.Others, Is.EqualTo(0)); |
||
222 | Assert.That(pclo2.Total, Is.EqualTo(0)); |
||
223 | Assert.That(pclo2.Selected, Is.EqualTo(0)); |
||
224 | Assert.That(pclo2.Users[m_userId], Is.EqualTo(0)); |
||
225 | Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0)); |
||
226 | Assert.That(pclo2.Simulator, Is.EqualTo(5)); |
||
227 | } |
||
228 | |||
229 | /// <summary> |
||
230 | /// Test count after a parcel owner owned object is removed. |
||
231 | /// </summary> |
||
232 | [Test] |
||
233 | public void TestRemoveOwnerObject() |
||
234 | { |
||
235 | TestHelpers.InMethod(); |
||
236 | // log4net.Config.XmlConfigurator.Configure(); |
||
237 | |||
238 | IPrimCounts pc = m_lo.PrimCounts; |
||
239 | |||
240 | m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false); |
||
241 | SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10); |
||
242 | m_scene.AddNewSceneObject(sogToDelete, false); |
||
243 | m_scene.DeleteSceneObject(sogToDelete, false); |
||
244 | |||
245 | Assert.That(pc.Owner, Is.EqualTo(1)); |
||
246 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
247 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
248 | Assert.That(pc.Total, Is.EqualTo(1)); |
||
249 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
250 | Assert.That(pc.Users[m_userId], Is.EqualTo(1)); |
||
251 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
252 | Assert.That(pc.Simulator, Is.EqualTo(1)); |
||
253 | } |
||
254 | |||
255 | [Test] |
||
256 | public void TestAddGroupObject() |
||
257 | { |
||
258 | TestHelpers.InMethod(); |
||
259 | // log4net.Config.XmlConfigurator.Configure(); |
||
260 | |||
261 | m_lo.DeedToGroup(m_groupId); |
||
262 | |||
263 | IPrimCounts pc = m_lo.PrimCounts; |
||
264 | |||
265 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); |
||
266 | sog.GroupID = m_groupId; |
||
267 | m_scene.AddNewSceneObject(sog, false); |
||
268 | |||
269 | Assert.That(pc.Owner, Is.EqualTo(0)); |
||
270 | Assert.That(pc.Group, Is.EqualTo(3)); |
||
271 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
272 | Assert.That(pc.Total, Is.EqualTo(3)); |
||
273 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
274 | |||
275 | // Is this desired behaviour? Not totally sure. |
||
276 | Assert.That(pc.Users[m_userId], Is.EqualTo(0)); |
||
277 | Assert.That(pc.Users[m_groupId], Is.EqualTo(0)); |
||
278 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3)); |
||
279 | |||
280 | Assert.That(pc.Simulator, Is.EqualTo(3)); |
||
281 | } |
||
282 | |||
283 | /// <summary> |
||
284 | /// Test count after a parcel owner owned object is removed. |
||
285 | /// </summary> |
||
286 | [Test] |
||
287 | public void TestRemoveGroupObject() |
||
288 | { |
||
289 | TestHelpers.InMethod(); |
||
290 | // log4net.Config.XmlConfigurator.Configure(); |
||
291 | |||
292 | m_lo.DeedToGroup(m_groupId); |
||
293 | |||
294 | IPrimCounts pc = m_lo.PrimCounts; |
||
295 | |||
296 | SceneObjectGroup sogToKeep = SceneHelpers.CreateSceneObject(1, m_userId, "a", 0x1); |
||
297 | sogToKeep.GroupID = m_groupId; |
||
298 | m_scene.AddNewSceneObject(sogToKeep, false); |
||
299 | |||
300 | SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_userId, "b", 0x10); |
||
301 | m_scene.AddNewSceneObject(sogToDelete, false); |
||
302 | m_scene.DeleteSceneObject(sogToDelete, false); |
||
303 | |||
304 | Assert.That(pc.Owner, Is.EqualTo(0)); |
||
305 | Assert.That(pc.Group, Is.EqualTo(1)); |
||
306 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
307 | Assert.That(pc.Total, Is.EqualTo(1)); |
||
308 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
309 | Assert.That(pc.Users[m_userId], Is.EqualTo(1)); |
||
310 | Assert.That(pc.Users[m_groupId], Is.EqualTo(0)); |
||
311 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
312 | Assert.That(pc.Simulator, Is.EqualTo(1)); |
||
313 | } |
||
314 | |||
315 | [Test] |
||
316 | public void TestAddOthersObject() |
||
317 | { |
||
318 | TestHelpers.InMethod(); |
||
319 | // log4net.Config.XmlConfigurator.Configure(); |
||
320 | |||
321 | IPrimCounts pc = m_lo.PrimCounts; |
||
322 | |||
323 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01); |
||
324 | m_scene.AddNewSceneObject(sog, false); |
||
325 | |||
326 | Assert.That(pc.Owner, Is.EqualTo(0)); |
||
327 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
328 | Assert.That(pc.Others, Is.EqualTo(3)); |
||
329 | Assert.That(pc.Total, Is.EqualTo(3)); |
||
330 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
331 | Assert.That(pc.Users[m_userId], Is.EqualTo(0)); |
||
332 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(3)); |
||
333 | Assert.That(pc.Simulator, Is.EqualTo(3)); |
||
334 | } |
||
335 | |||
336 | [Test] |
||
337 | public void TestRemoveOthersObject() |
||
338 | { |
||
339 | TestHelpers.InMethod(); |
||
340 | // log4net.Config.XmlConfigurator.Configure(); |
||
341 | |||
342 | IPrimCounts pc = m_lo.PrimCounts; |
||
343 | |||
344 | m_scene.AddNewSceneObject(SceneHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false); |
||
345 | SceneObjectGroup sogToDelete = SceneHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10); |
||
346 | m_scene.AddNewSceneObject(sogToDelete, false); |
||
347 | m_scene.DeleteSceneObject(sogToDelete, false); |
||
348 | |||
349 | Assert.That(pc.Owner, Is.EqualTo(0)); |
||
350 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
351 | Assert.That(pc.Others, Is.EqualTo(1)); |
||
352 | Assert.That(pc.Total, Is.EqualTo(1)); |
||
353 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
354 | Assert.That(pc.Users[m_userId], Is.EqualTo(0)); |
||
355 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(1)); |
||
356 | Assert.That(pc.Simulator, Is.EqualTo(1)); |
||
357 | } |
||
358 | |||
359 | /// <summary> |
||
360 | /// Test the count is correct after is has been tainted. |
||
361 | /// </summary> |
||
362 | [Test] |
||
363 | public void TestTaint() |
||
364 | { |
||
365 | TestHelpers.InMethod(); |
||
366 | IPrimCounts pc = m_lo.PrimCounts; |
||
367 | |||
368 | SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); |
||
369 | m_scene.AddNewSceneObject(sog, false); |
||
370 | |||
371 | m_pcm.TaintPrimCount(); |
||
372 | |||
373 | Assert.That(pc.Owner, Is.EqualTo(3)); |
||
374 | Assert.That(pc.Group, Is.EqualTo(0)); |
||
375 | Assert.That(pc.Others, Is.EqualTo(0)); |
||
376 | Assert.That(pc.Total, Is.EqualTo(3)); |
||
377 | Assert.That(pc.Selected, Is.EqualTo(0)); |
||
378 | Assert.That(pc.Users[m_userId], Is.EqualTo(3)); |
||
379 | Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); |
||
380 | Assert.That(pc.Simulator, Is.EqualTo(3)); |
||
381 | } |
||
382 | } |
||
383 | } |