aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/BasicRegionTest.cs
diff options
context:
space:
mode:
authorSean Dague2008-10-30 12:56:04 +0000
committerSean Dague2008-10-30 12:56:04 +0000
commit409e7262df255649de687eec828d9ef476edc03b (patch)
treeff631ba12d6eb899abff42ade2c56244485c1a5a /OpenSim/Data/Tests/BasicRegionTest.cs
parent- Inserted code coverage monocov. To run do nant test-cov. (diff)
downloadopensim-SC-409e7262df255649de687eec828d9ef476edc03b.zip
opensim-SC-409e7262df255649de687eec828d9ef476edc03b.tar.gz
opensim-SC-409e7262df255649de687eec828d9ef476edc03b.tar.bz2
opensim-SC-409e7262df255649de687eec828d9ef476edc03b.tar.xz
Mid-work, trying to fix region part insertion and retrieval
SQLite reports System NUll Reference, but works, inside LoadItems, on SQLiteRegionData.cs From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
Diffstat (limited to 'OpenSim/Data/Tests/BasicRegionTest.cs')
-rw-r--r--OpenSim/Data/Tests/BasicRegionTest.cs324
1 files changed, 315 insertions, 9 deletions
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
index 9a73cc2..d09b458 100644
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing;
31using System.Text;
30using NUnit.Framework; 32using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers; 33using NUnit.Framework.SyntaxHelpers;
32using OpenSim.Framework; 34using OpenSim.Framework;
@@ -44,15 +46,24 @@ namespace OpenSim.Data.Tests
44 public UUID zero = UUID.Zero; 46 public UUID zero = UUID.Zero;
45 public UUID region1; 47 public UUID region1;
46 public UUID region2; 48 public UUID region2;
49 public UUID region3;
50 public UUID region4;
47 public UUID prim1; 51 public UUID prim1;
48 public UUID prim2; 52 public UUID prim2;
49 public UUID prim3; 53 public UUID prim3;
54 public UUID prim4;
55 public UUID prim5;
56 public UUID prim6;
50 public UUID item1; 57 public UUID item1;
51 public UUID item2; 58 public UUID item2;
52 public UUID item3; 59 public UUID item3;
53 60
61 public static Random random;
62
54 public string itemname1 = "item1"; 63 public string itemname1 = "item1";
55 64
65 public uint localID;
66
56 public double height1; 67 public double height1;
57 public double height2; 68 public double height2;
58 69
@@ -68,12 +79,19 @@ namespace OpenSim.Data.Tests
68 } 79 }
69 80
70 region1 = UUID.Random(); 81 region1 = UUID.Random();
82 region3 = UUID.Random();
83 region4 = UUID.Random();
71 prim1 = UUID.Random(); 84 prim1 = UUID.Random();
72 prim2 = UUID.Random(); 85 prim2 = UUID.Random();
73 prim3 = UUID.Random(); 86 prim3 = UUID.Random();
87 prim4 = UUID.Random();
88 prim5 = UUID.Random();
89 prim6 = UUID.Random();
74 item1 = UUID.Random(); 90 item1 = UUID.Random();
75 item2 = UUID.Random(); 91 item2 = UUID.Random();
76 item3 = UUID.Random(); 92 item3 = UUID.Random();
93 random = new Random();
94 localID = 1;
77 height1 = 20; 95 height1 = 20;
78 height2 = 100; 96 height2 = 100;
79 } 97 }
@@ -82,18 +100,22 @@ namespace OpenSim.Data.Tests
82 // Prims 100 // Prims
83 // - empty test - 001 101 // - empty test - 001
84 // - store / retrieve basic prims (most minimal we can make) - 010, 011 102 // - store / retrieve basic prims (most minimal we can make) - 010, 011
85 // - update existing prims, make sure it sticks - 012 103 // - store / retrieve parts in a scenegroup 012
86 // - add inventory items to prims make - 013 104 // - store a prim with complete information for consistency check 013
87 // - remove inventory items make sure it sticks - 014 105 // - update existing prims, make sure it sticks - 014
106 // - add inventory items to prims make - 015
107 // - remove inventory items make sure it sticks - 016
88 // - remove prim, make sure it sticks - 020 108 // - remove prim, make sure it sticks - 020
89 109
90 [Test] 110 [Test]
91 public void T001_LoadEmpty() 111 public void T001_LoadEmpty()
92 { 112 {
93 List<SceneObjectGroup> objs = db.LoadObjects(region1); 113 List<SceneObjectGroup> objs = db.LoadObjects(region1);
114 List<SceneObjectGroup> objs3 = db.LoadObjects(region3);
94 List<LandData> land = db.LoadLandObjects(region1); 115 List<LandData> land = db.LoadLandObjects(region1);
95 116
96 Assert.That(objs.Count, Is.EqualTo(0)); 117 Assert.That(objs.Count, Is.EqualTo(0));
118 Assert.That(objs3.Count, Is.EqualTo(0));
97 Assert.That(land.Count, Is.EqualTo(0)); 119 Assert.That(land.Count, Is.EqualTo(0));
98 } 120 }
99 121
@@ -145,9 +167,262 @@ namespace OpenSim.Data.Tests
145 Assert.That(p.Name, Is.EqualTo(p.Description)); 167 Assert.That(p.Name, Is.EqualTo(p.Description));
146 } 168 }
147 } 169 }
148 170
171 [Test]
172 public void T012_SceneParts()
173 {
174 UUID tmp0 = UUID.Random();
175 UUID tmp1 = UUID.Random();
176 UUID tmp2 = UUID.Random();
177 UUID tmp3 = UUID.Random();
178 UUID newregion = UUID.Random();
179 SceneObjectPart p1 = NewSOP("SoP 1",tmp1);
180 SceneObjectPart p2 = NewSOP("SoP 2",tmp2);
181 SceneObjectPart p3 = NewSOP("SoP 3",tmp3);
182 SceneObjectGroup sog = NewSOG("Sop 0",tmp0);
183 sog.AddPart(p1);
184 sog.AddPart(p2);
185 sog.AddPart(p3);
186
187 Console.WriteLine("Test 10 has prims {0} and {1} in region {2}",prim1,prim2,region1);
188 Console.WriteLine("The prims are {0}, {1}, {2} and {3} and region is {4}",tmp0,tmp1,tmp2,tmp3,newregion);
189 SceneObjectPart[] parts = sog.GetParts();
190 Console.WriteLine("Before Insertion:");
191 Assert.That(parts.Length,Is.EqualTo(4));
192 Console.WriteLine("PASSED BEFORE");
193
194 db.StoreObject(sog, newregion);
195 List<SceneObjectGroup> sogs = db.LoadObjects(newregion);
196 Assert.That(sogs.Count,Is.EqualTo(1));
197 SceneObjectGroup newsog = sogs[0];
198
199 SceneObjectPart[] newparts = newsog.GetParts();
200 Console.WriteLine("After Insertion:");
201 Assert.That(newparts.Length,Is.EqualTo(4));
202 Console.WriteLine("PASSED AFTER!");
203
204 Assert.That(newsog.HasChildPrim(tmp0));
205 Assert.That(newsog.HasChildPrim(tmp1));
206 Assert.That(newsog.HasChildPrim(tmp2));
207 Assert.That(newsog.HasChildPrim(tmp3));
208 }
209
210 [Test]
211 [Ignore("Make sure 12 works first")]
212 public void T013_ObjectConsistency()
213 {
214 UUID creator,uuid = new UUID();
215 creator = UUID.Random();
216 uint iserial = (uint) random.Next();
217 TaskInventoryDictionary dic = new TaskInventoryDictionary();
218 uint objf = (uint) random.Next();
219 uuid = prim4;
220 uint localid = localID+1;
221 localID = localID + 1;
222 string name = "Adam West";
223 byte material = (byte) random.Next(255);
224 ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next();
225 int pin = random.Next();
226 Byte[] partsys = new byte[8];
227 Byte[] textani = new byte[8];
228 random.NextBytes(textani);
229 random.NextBytes(partsys);
230 DateTime expires = new DateTime(2008, 12, 20);
231 DateTime rezzed = new DateTime(2009, 07, 15);
232 Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next());
233 Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next());
234 Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next());
235 Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next());
236 Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next());
237 Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next());
238 string description = name;
239 //Color color = Color.Brown;
240 Color color = Color.FromArgb(255, 165, 42, 42);
241 string text = "All Your Base Are Belong to Us";
242 string sitname = "SitName";
243 string touchname = "TouchName";
244 int linknum = random.Next();
245 byte clickaction = (byte) random.Next(255);
246 PrimitiveBaseShape pbshap = new PrimitiveBaseShape();
247 pbshap = PrimitiveBaseShape.Default;
248 Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
249 byte updatef = (byte) random.Next(255);
250
251 SceneObjectPart sop = new SceneObjectPart();
252 sop.RegionHandle = regionh;
253 sop.UUID = uuid;
254 sop.LocalId = localid;
255 sop.Shape = pbshap;
256 sop.GroupPosition = groupos;
257 sop.RotationOffset = rotoff;
258 sop.CreatorID = creator;
259 sop.InventorySerial = iserial;
260 sop.TaskInventory = dic;
261 sop.ObjectFlags = objf;
262 sop.Name = name;
263 sop.Material = material;
264 sop.ScriptAccessPin = pin;
265 sop.TextureAnimation = textani;
266 sop.ParticleSystem = partsys;
267 sop.Expires = expires;
268 sop.Rezzed = rezzed;
269 sop.OffsetPosition = offset;
270 sop.Velocity = velocity;
271 sop.AngularVelocity = angvelo;
272 sop.Acceleration = accel;
273 sop.Description = description;
274 sop.Color = color;
275 sop.Text = text;
276 sop.SitName = sitname;
277 sop.TouchName = touchname;
278 sop.LinkNum = linknum;
279 sop.ClickAction = clickaction;
280 sop.Scale = scale;
281 sop.UpdateFlag = updatef;
282
283 //Tests if local part accepted the parameters:
284 Console.WriteLine("Test -0");
285 Assert.That(regionh,Is.EqualTo(sop.RegionHandle));
286 Console.WriteLine("Test -1 localid é: {0} e LocalId é {1}",localid,sop.LocalId);
287 Assert.That(localid,Is.EqualTo(sop.LocalId));
288 Console.WriteLine("Test -2");
289 //**Assert.That(pbshap,Is.EqualTo(sop.Shape));
290 Assert.That(groupos,Is.EqualTo(sop.GroupPosition));
291 Console.WriteLine("Test -3");
292 Assert.That(name,Is.EqualTo(sop.Name));
293 Console.WriteLine("Test -4");
294 Assert.That(rotoff,Is.EqualTo(sop.RotationOffset));
295 Console.WriteLine("Test 0 - uuid is {0}",uuid);
296 Assert.That(uuid,Is.EqualTo(sop.UUID));
297 Console.WriteLine("Test 1");
298 Assert.That(creator,Is.EqualTo(sop.CreatorID));
299 Console.WriteLine("Test 2 - iserial is {0}",iserial);
300 Assert.That(iserial,Is.EqualTo(sop.InventorySerial));
301 Console.WriteLine("Test 3");
302 Assert.That(dic,Is.EqualTo(sop.TaskInventory));
303 Console.WriteLine("Test 4");
304 Assert.That(objf,Is.EqualTo(sop.ObjectFlags));
305 Console.WriteLine("Test 5");
306 Assert.That(name,Is.EqualTo(sop.Name));
307 Console.WriteLine("Test 6");
308 Assert.That(material,Is.EqualTo(sop.Material));
309 Console.WriteLine("Test 7");
310 Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin));
311 Console.WriteLine("Test 8");
312 Assert.That(textani,Is.EqualTo(sop.TextureAnimation));
313 Console.WriteLine("Test 9");
314 Assert.That(partsys,Is.EqualTo(sop.ParticleSystem));
315 Console.WriteLine("Test 9.1");
316 Assert.That(expires,Is.EqualTo(sop.Expires));
317 Console.WriteLine("Test 9.2");
318 Assert.That(rezzed,Is.EqualTo(sop.Rezzed));
319 Console.WriteLine("Test 10");
320 Assert.That(offset,Is.EqualTo(sop.OffsetPosition));
321 Assert.That(velocity,Is.EqualTo(sop.Velocity));
322 Console.WriteLine("Test 12");
323 Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity));
324 Console.WriteLine("Test 13");
325 Assert.That(accel,Is.EqualTo(sop.Acceleration));
326 Console.WriteLine("Test 14");
327 Assert.That(description,Is.EqualTo(sop.Description));
328 Assert.That(color,Is.EqualTo(sop.Color));
329 Assert.That(text,Is.EqualTo(sop.Text));
330 Assert.That(sitname,Is.EqualTo(sop.SitName));
331 Console.WriteLine("Test 15");
332 Assert.That(touchname,Is.EqualTo(sop.TouchName));
333 Console.WriteLine("Test 16");
334 Assert.That(linknum,Is.EqualTo(sop.LinkNum));
335 Console.WriteLine("Test 17");
336 Assert.That(clickaction,Is.EqualTo(sop.ClickAction));
337 Console.WriteLine("Test 18");
338 Assert.That(scale,Is.EqualTo(sop.Scale));
339 Console.WriteLine("Test 19");
340 Assert.That(updatef,Is.EqualTo(sop.UpdateFlag));
341 Console.WriteLine("Test 20");
342
343 // This is necessary or object will not be inserted in DB
344 sop.ObjectFlags = 0;
345
346 SceneObjectGroup sog = new SceneObjectGroup();
347 sog.AddPart(sop);
348 sog.RootPart = sop;
349
350 // Inserts group in DB
351 db.StoreObject(sog,region3);
352 List<SceneObjectGroup> sogs = db.LoadObjects(region3);
353 Assert.That(sogs.Count, Is.EqualTo(1));
354 // Makes sure there are no double insertions:
355 /*
356 db.StoreObject(sog,region3);
357 sogs = db.LoadObjects(region3);
358 Assert.That(sogs.Count, Is.EqualTo(1));
359 */
360
361 // Tests if the parameters were inserted correctly
362 SceneObjectPart p = sogs[0].RootPart;
363 Console.WriteLine("Test -0");
364 Assert.That(regionh,Is.EqualTo(p.RegionHandle));
365 Console.WriteLine("Test -1 localid é: {0} e LocalId é {1}",localid,p.LocalId);
366 //Assert.That(localid,Is.EqualTo(p.LocalId));
367 Console.WriteLine("Test -2");
368 //Assert.That(pbshap,Is.EqualTo(p.Shape));
369 Assert.That(groupos,Is.EqualTo(p.GroupPosition));
370 Console.WriteLine("Test -3");
371 Assert.That(name,Is.EqualTo(p.Name));
372 Console.WriteLine("Test -4");
373 Assert.That(rotoff,Is.EqualTo(p.RotationOffset));
374 Console.WriteLine("Test 0 - uuid is {0}",uuid);
375 Assert.That(uuid,Is.EqualTo(p.UUID));
376 Console.WriteLine("Test 1");
377 Assert.That(creator,Is.EqualTo(p.CreatorID));
378 Console.WriteLine("Test 2 - iserial is {0}",iserial);
379 //Assert.That(iserial,Is.EqualTo(p.InventorySerial));
380 Console.WriteLine("Test 3");
381 Assert.That(dic,Is.EqualTo(p.TaskInventory));
382 Console.WriteLine("Test 4");
383 //Assert.That(objf,Is.EqualTo(p.ObjectFlags));
384 Console.WriteLine("Test 5");
385 Assert.That(name,Is.EqualTo(p.Name));
386 Console.WriteLine("Test 6");
387 Assert.That(material,Is.EqualTo(p.Material));
388 Console.WriteLine("Test 7");
389 Assert.That(pin,Is.EqualTo(p.ScriptAccessPin));
390 Console.WriteLine("Test 8");
391 Assert.That(textani,Is.EqualTo(p.TextureAnimation));
392 Console.WriteLine("Test 9");
393 Assert.That(partsys,Is.EqualTo(p.ParticleSystem));
394 Console.WriteLine("Test 9.1 - Expires in {0}",expires);
395 //Assert.That(expires,Is.EqualTo(p.Expires));
396 Console.WriteLine("Test 9.2 - Rezzed in {0}",rezzed);
397 //Assert.That(rezzed,Is.EqualTo(p.Rezzed));
398 Console.WriteLine("Test 10");
399 Assert.That(offset,Is.EqualTo(p.OffsetPosition));
400 Assert.That(velocity,Is.EqualTo(p.Velocity));
401 Console.WriteLine("Test 12");
402 Assert.That(angvelo,Is.EqualTo(p.AngularVelocity));
403 Console.WriteLine("Test 13");
404 Assert.That(accel,Is.EqualTo(p.Acceleration));
405 Console.WriteLine("Test 14");
406 Assert.That(description,Is.EqualTo(p.Description));
407 Assert.That(color,Is.EqualTo(p.Color));
408 Assert.That(text,Is.EqualTo(p.Text));
409 Assert.That(sitname,Is.EqualTo(p.SitName));
410 Console.WriteLine("Test 15");
411 Assert.That(touchname,Is.EqualTo(p.TouchName));
412 Console.WriteLine("Test 16");
413 //Assert.That(linknum,Is.EqualTo(p.LinkNum));
414 Console.WriteLine("Test 17");
415 Assert.That(clickaction,Is.EqualTo(p.ClickAction));
416 Console.WriteLine("Test 18");
417 Assert.That(scale,Is.EqualTo(p.Scale));
418 Console.WriteLine("Test 19");
419 //Assert.That(updatef,Is.EqualTo(p.UpdateFlag));
420 Console.WriteLine("Test 20");
421
422 }
423
149 [Test] 424 [Test]
150 public void T012_UpdateObject() 425 public void T014_UpdateObject()
151 { 426 {
152 string text = "object1 text"; 427 string text = "object1 text";
153 SceneObjectGroup sog = FindSOG("object1", region1); 428 SceneObjectGroup sog = FindSOG("object1", region1);
@@ -364,14 +639,17 @@ namespace OpenSim.Data.Tests
364 private SceneObjectGroup NewSOG(string name, UUID uuid) 639 private SceneObjectGroup NewSOG(string name, UUID uuid)
365 { 640 {
366 SceneObjectPart sop = new SceneObjectPart(); 641 SceneObjectPart sop = new SceneObjectPart();
367 sop.LocalId = 1; 642 //sop.LocalId = 1;
643 sop.LocalId = localID;
644 localID = localID + 1;
368 sop.Name = name; 645 sop.Name = name;
369 sop.Description = name; 646 sop.Description = name;
370 sop.Text = ""; 647 sop.Text = RandomName();
371 sop.SitName = ""; 648 sop.SitName = RandomName();
372 sop.TouchName = ""; 649 sop.TouchName = RandomName();
373 sop.UUID = uuid; 650 sop.UUID = uuid;
374 sop.Shape = PrimitiveBaseShape.Default; 651 sop.Shape = PrimitiveBaseShape.Default;
652
375 653
376 SceneObjectGroup sog = new SceneObjectGroup(); 654 SceneObjectGroup sog = new SceneObjectGroup();
377 sog.AddPart(sop); 655 sog.AddPart(sop);
@@ -379,6 +657,22 @@ namespace OpenSim.Data.Tests
379 657
380 return sog; 658 return sog;
381 } 659 }
660
661 private SceneObjectPart NewSOP(string name, UUID uuid)
662 {
663 SceneObjectPart sop = new SceneObjectPart();
664 //sop.LocalId = 1;
665 sop.LocalId = localID;
666 localID = localID + 1;
667 sop.Name = name;
668 sop.Description = name;
669 sop.Text = RandomName();
670 sop.SitName = RandomName();
671 sop.TouchName = RandomName();
672 sop.UUID = uuid;
673 sop.Shape = PrimitiveBaseShape.Default;
674 return sop;
675 }
382 676
383 // These are copied from the Inventory Item tests 677 // These are copied from the Inventory Item tests
384 678
@@ -395,6 +689,18 @@ namespace OpenSim.Data.Tests
395 return i; 689 return i;
396 } 690 }
397 691
692 private static string RandomName()
693 {
694 StringBuilder name = new StringBuilder();
695 int size = random.Next(5,12);
696 char ch ;
697 for (int i=0; i<size; i++)
698 {
699 ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
700 name.Append(ch);
701 }
702 return name.ToString();
703 }
398// private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name) 704// private InventoryFolderBase NewFolder(UUID id, UUID parent, UUID owner, string name)
399// { 705// {
400// InventoryFolderBase f = new InventoryFolderBase(); 706// InventoryFolderBase f = new InventoryFolderBase();