Fixed unit tests for delinking objects

0.8.0.3
Oren Hurvitz 2014-03-24 15:05:39 +02:00
parent 4bccfed80c
commit 7496d0b0f7
1 changed files with 21 additions and 13 deletions

View File

@ -91,7 +91,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
grp2.RootPart.ClearUpdateSchedule(); grp2.RootPart.ClearUpdateSchedule();
// Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated.
Assert.IsFalse(grp1.GroupContainsForeignPrims);
grp1.LinkToGroup(grp2); grp1.LinkToGroup(grp2);
Assert.IsTrue(grp1.GroupContainsForeignPrims);
scene.Backup(true);
Assert.IsFalse(grp1.GroupContainsForeignPrims);
// FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since // FIXME: Can't do this test yet since group 2 still has its root part! We can't yet null this since
// it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed. // it might cause SOG.ProcessBackup() to fail due to the race condition. This really needs to be fixed.
@ -143,7 +148,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink."); Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink.");
Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero"); Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero");
Assert.That(grp3.GroupContainsForeignPrims, Is.True);
} }
[Test] [Test]
@ -335,30 +339,34 @@ namespace OpenSim.Region.Framework.Scenes.Tests
SceneObjectPart rootPart SceneObjectPart rootPart
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = rootPartName, UUID = rootPartUuid }; { Name = rootPartName, UUID = rootPartUuid };
SceneObjectPart linkPart SceneObjectPart linkPart
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = linkPartName, UUID = linkPartUuid }; { Name = linkPartName, UUID = linkPartUuid };
SceneObjectGroup linkGroup = new SceneObjectGroup(linkPart);
scene.AddNewSceneObject(linkGroup, true);
SceneObjectGroup sog = new SceneObjectGroup(rootPart); SceneObjectGroup sog = new SceneObjectGroup(rootPart);
sog.AddPart(linkPart);
scene.AddNewSceneObject(sog, true); scene.AddNewSceneObject(sog, true);
// In a test, we have to crank the backup handle manually. Normally this would be done by the timer invoked Assert.IsFalse(sog.GroupContainsForeignPrims);
// scene backup thread. sog.LinkToGroup(linkGroup);
Assert.IsTrue(sog.GroupContainsForeignPrims);
scene.Backup(true); scene.Backup(true);
Assert.AreEqual(1, scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID).Count);
// These changes should occur immediately without waiting for a backup pass // These changes should occur immediately without waiting for a backup pass
SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false); SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false);
Assert.IsFalse(groupToDelete.GroupContainsForeignPrims);
Assert.That(groupToDelete.GroupContainsForeignPrims, Is.True);
scene.DeleteSceneObject(groupToDelete, false); scene.DeleteSceneObject(groupToDelete, false);
Assert.That(groupToDelete.GroupContainsForeignPrims, Is.False);
List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID); List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID);
Assert.That(storedObjects.Count, Is.EqualTo(1)); Assert.AreEqual(1, storedObjects.Count);
Assert.That(storedObjects[0].Parts.Length, Is.EqualTo(1)); Assert.AreEqual(1, storedObjects[0].Parts.Length);
Assert.That(storedObjects[0].ContainsPart(rootPartUuid)); Assert.IsTrue(storedObjects[0].ContainsPart(rootPartUuid));
} }
} }
} }