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