Exemplo n.º 1
0
        public void TestAddScript()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID userId = TestHelpers.ParseTail(0x1);
//            UUID itemId = TestHelpers.ParseTail(0x2);
            string itemName = "Test Script Item";

            Scene scene = new SceneHelpers().SetupScene();
            SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
            scene.AddNewSceneObject(so, true);

            InventoryItemBase itemTemplate = new InventoryItemBase();
            itemTemplate.Name = itemName;
            itemTemplate.Folder = so.UUID;
            itemTemplate.InvType = (int)InventoryType.LSL;

            SceneObjectPart partWhereScriptAdded = scene.RezNewScript(userId, itemTemplate);

            Assert.That(partWhereScriptAdded, Is.Not.Null);

            IEntityInventory primInventory = partWhereScriptAdded.Inventory;
            Assert.That(primInventory.GetInventoryList().Count, Is.EqualTo(1));
            Assert.That(primInventory.ContainsScripts(), Is.True);

            IList<TaskInventoryItem> primItems = primInventory.GetInventoryItems(itemName);
            Assert.That(primItems.Count, Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void TestDeRezSceneObject()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();
                        
            UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
            
            TestScene scene = new SceneHelpers().SetupScene();
            IConfigSource configSource = new IniConfigSource();
            IConfig config = configSource.AddConfig("Startup");
            config.Set("serverside_object_permissions", true);
            SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
            IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
            
            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
            sogd.Enabled = false;            
            
            SceneObjectPart part
                = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
            part.Name = "obj1";
            scene.AddNewSceneObject(new SceneObjectGroup(part), false);
            List<uint> localIds = new List<uint>();
            localIds.Add(part.LocalId);

            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
            sogd.InventoryDeQueueAndDelete();
            
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
            Assert.That(retrievedPart, Is.Null);
        }
        public void TestDelinkPersistence()
        {
            TestHelpers.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            TestScene scene = new SceneHelpers().SetupScene();

            string rootPartName = "rootpart";
            UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
            string linkPartName = "linkpart";
            UUID linkPartUuid = new UUID("00000000-0000-0000-0001-000000000000");

            SceneObjectPart rootPart
                = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
                    { Name = rootPartName, UUID = rootPartUuid };

            SceneObjectPart linkPart
                = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
                    { Name = linkPartName, UUID = linkPartUuid };
            SceneObjectGroup linkGroup = new SceneObjectGroup(linkPart);
            scene.AddNewSceneObject(linkGroup, true);

            SceneObjectGroup sog = new SceneObjectGroup(rootPart);
            scene.AddNewSceneObject(sog, true);

            Assert.IsFalse(sog.GroupContainsForeignPrims);
            sog.LinkToGroup(linkGroup);
            Assert.IsTrue(sog.GroupContainsForeignPrims);

            scene.Backup(true);
            Assert.AreEqual(1, scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID).Count);

            // These changes should occur immediately without waiting for a backup pass
            SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false);
            Assert.IsFalse(groupToDelete.GroupContainsForeignPrims);

            scene.DeleteSceneObject(groupToDelete, false);

            List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID);

            Assert.AreEqual(1, storedObjects.Count);
            Assert.AreEqual(1, storedObjects[0].Parts.Length);
            Assert.IsTrue(storedObjects[0].ContainsPart(rootPartUuid));
        }
Exemplo n.º 4
0
        public void TestDuplicateObject()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene scene = new SceneHelpers().SetupScene();

            UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
            string part1Name = "part1";
            UUID part1Id = new UUID("00000000-0000-0000-0000-000000000001");
            string part2Name = "part2";
            UUID part2Id = new UUID("00000000-0000-0000-0000-000000000002");

            SceneObjectPart part1
                = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 
                    { Name = part1Name, UUID = part1Id };
            SceneObjectGroup so = new SceneObjectGroup(part1);
            SceneObjectPart part2 
                = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 
                    { Name = part2Name, UUID = part2Id }; 
            so.AddPart(part2);

            scene.AddNewSceneObject(so, false);
            
            SceneObjectGroup dupeSo 
                = scene.SceneGraph.DuplicateObject(
                    part1.LocalId, new Vector3(10, 0, 0), 0, ownerId, UUID.Zero, Quaternion.Identity);
            Assert.That(dupeSo.Parts.Length, Is.EqualTo(2));
            
            SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1);
            SceneObjectPart dupePart2 = dupeSo.GetLinkNumPart(2);
            Assert.That(dupePart1.LocalId, Is.Not.EqualTo(part1.LocalId));
            Assert.That(dupePart2.LocalId, Is.Not.EqualTo(part2.LocalId));
            
            Assert.That(dupePart1.Flags, Is.EqualTo(part1.Flags));
            Assert.That(dupePart2.Flags, Is.EqualTo(part2.Flags));
            
            /*
            Assert.That(part1.PhysActor, Is.Not.Null);
            Assert.That(part2.PhysActor, Is.Not.Null);
            Assert.That(dupePart1.PhysActor, Is.Not.Null);
            Assert.That(dupePart2.PhysActor, Is.Not.Null);
            */

//            TestHelpers.DisableLogging();
        }
Exemplo n.º 5
0
        public void TestDeRezSceneObjectNotOwner()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();
                        
            UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
            UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
            
            TestScene scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(scene, new PermissionsModule());            
            IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient;
            
            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
            sogd.Enabled = false;            
            
            SceneObjectPart part
                = new SceneObjectPart(objectOwnerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
            part.Name = "obj1";
            scene.AddNewSceneObject(new SceneObjectGroup(part), false);
            List<uint> localIds = new List<uint>();
            localIds.Add(part.LocalId);            

            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
            sogd.InventoryDeQueueAndDelete();
            
            // Object should still be in the scene.
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
            Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
        }   
Exemplo n.º 6
0
        private void TestAddObjects(int primsInEachObject, int objectsToAdd)
        {
            UUID ownerId = new UUID("F0000000-0000-0000-0000-000000000000");

            // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage
            // collected when we teardown this test.  If it's done in a member variable, even if that is subsequently
            // nulled out, the garbage collect can be delayed.
            TestScene scene = new SceneHelpers().SetupScene();

//            Process process = Process.GetCurrentProcess();
//            long startProcessMemory = process.PrivateMemorySize64;
            long startGcMemory = GC.GetTotalMemory(true);
            DateTime start = DateTime.Now;

            for (int i = 1; i <= objectsToAdd; i++)
            {
                SceneObjectGroup so = SceneHelpers.CreateSceneObject(primsInEachObject, ownerId, "part_", i);
                Assert.That(scene.AddNewSceneObject(so, false), Is.True, string.Format("Object {0} was not created", i));
            }

            TimeSpan elapsed = DateTime.Now - start;
//            long processMemoryAlloc = process.PrivateMemorySize64 - startProcessMemory;
            long endGcMemory = GC.GetTotalMemory(false);

            for (int i = 1; i <= objectsToAdd; i++)
            {
                Assert.That(
                    scene.GetSceneObjectGroup(TestHelpers.ParseTail(i)),
                    Is.Not.Null,
                    string.Format("Object {0} could not be retrieved", i));
            }

            // When a scene object is added to a scene, it is placed in the update list for sending to viewers
            // (though in this case we have none).  When it is deleted, it is not removed from the update which is
            // fine since it will later be ignored.
            //
            // However, that means that we need to manually run an update here to clear out that list so that deleted
            // objects will be clean up by the garbage collector before the next stress test is run.
            scene.Update(1);

            Console.WriteLine(
                "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)",
                Math.Round(elapsed.TotalMilliseconds),
                (endGcMemory - startGcMemory) / 1024 / 1024,
                endGcMemory / 1024 / 1024,
                startGcMemory / 1024 / 1024,
                objectsToAdd,
                primsInEachObject);

            scene.Close();
//            scene = null;
        }
        public void TestNewSceneObjectLinkPersistence()
        {
            TestHelpers.InMethod();
            //log4net.Config.XmlConfigurator.Configure();
            
            TestScene scene = new SceneHelpers().SetupScene();
            
            string rootPartName = "rootpart";
            UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
            string linkPartName = "linkpart";
            UUID linkPartUuid = new UUID("00000000-0000-0000-0001-000000000000");

            SceneObjectPart rootPart
                = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 
                    { Name = rootPartName, UUID = rootPartUuid };
            SceneObjectPart linkPart
                = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 
                    { Name = linkPartName, UUID = linkPartUuid };

            SceneObjectGroup sog = new SceneObjectGroup(rootPart);
            sog.AddPart(linkPart);
            scene.AddNewSceneObject(sog, true);
            
            // In a test, we have to crank the backup handle manually.  Normally this would be done by the timer invoked
            // scene backup thread.
            scene.Backup(true);
            
            List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID);
            
            Assert.That(storedObjects.Count, Is.EqualTo(1));
            Assert.That(storedObjects[0].Parts.Length, Is.EqualTo(2));
            Assert.That(storedObjects[0].ContainsPart(rootPartUuid));
            Assert.That(storedObjects[0].ContainsPart(linkPartUuid));
        }
        public void TestLoadIarPathWithEscapedChars()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            string itemName = "You & you are a mean/man/";
            string humanEscapedItemName = @"You & you are a mean\/man\/";
            string userPassword = "******";

            InventoryArchiverModule archiverModule = new InventoryArchiverModule();

            Scene scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(scene, archiverModule);

            // Create user
            string userFirstName = "Jock";
            string userLastName = "Stirrup";
            UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
            UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");
            
            // Create asset
            SceneObjectGroup object1;
            SceneObjectPart part1;
            {
                string partName = "part name";
                UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
                PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
                Vector3 groupPosition = new Vector3(10, 20, 30);
                Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
                Vector3 offsetPosition = new Vector3(5, 10, 15);

                part1
                    = new SceneObjectPart(
                        ownerId, shape, groupPosition, rotationOffset, offsetPosition);
                part1.Name = partName;

                object1 = new SceneObjectGroup(part1);
                scene.AddNewSceneObject(object1, false);
            }

            UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
            scene.AssetService.Store(asset1);

            // Create item
            UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = itemName;
            item1.AssetID = asset1.FullID;
            item1.ID = item1Id;
            InventoryFolderBase objsFolder 
                = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, "Objects")[0];
            item1.Folder = objsFolder.ID;
            scene.AddInventoryItem(item1);

            MemoryStream archiveWriteStream = new MemoryStream();
            archiverModule.OnInventoryArchiveSaved += SaveCompleted;

            mre.Reset();
            archiverModule.ArchiveInventory(
                UUID.Random(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
            mre.WaitOne(60000, false);

            // LOAD ITEM
            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            archiverModule.DearchiveInventory(UUID.Random(), userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);

            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(
                    scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);
            
            Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
//            Assert.That(
//                foundItem1.CreatorId, Is.EqualTo(userUuid), 
//                "Loaded item non-uuid creator doesn't match that of the loading user");
            Assert.That(
                foundItem1.Name, Is.EqualTo(itemName), 
                "Loaded item name doesn't match saved name");
        }
Exemplo n.º 9
0
        // llSetPrimitiveParams and llGetPrimitiveParams test.
        public void TestllSetPrimitiveParams()
        {
            TestHelpers.InMethod();

            // Create Prim1.
            Scene scene = new SceneHelpers().SetupScene();
            string obj1Name = "Prim1";
            UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
            SceneObjectPart part1 =
                new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
                Vector3.Zero, Quaternion.Identity,
                Vector3.Zero) { Name = obj1Name, UUID = objUuid };
            Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);

            LSL_Api apiGrp1 = new LSL_Api();
            apiGrp1.Initialize(m_engine, part1, null, null);

            // Note that prim hollow check is passed with the other prim params in order to allow the
            // specification of a different check value from the prim param. A cylinder, prism, sphere,
            // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below
            // specifies a value of 95% and checks to see if 70% was properly returned.

            // Test a sphere.
            CheckllSetPrimitiveParams(
                apiGrp1,
                "test 1",                                   // Prim test identification string
                new LSL_Types.Vector3(6.0d, 9.9d, 9.9d),    // Prim size
                ScriptBaseClass.PRIM_TYPE_SPHERE,           // Prim type
                ScriptBaseClass.PRIM_HOLE_DEFAULT,          // Prim hole type
                new LSL_Types.Vector3(0.0d, 0.075d, 0.0d),  // Prim cut
                0.80f,                                      // Prim hollow
                new LSL_Types.Vector3(0.0d, 0.0d, 0.0d),    // Prim twist
                new LSL_Types.Vector3(0.32d, 0.76d, 0.0d),  // Prim dimple
                0.80f);                                     // Prim hollow check

            // Test a prism.
            CheckllSetPrimitiveParams(
                apiGrp1,
                "test 2",                                   // Prim test identification string
                new LSL_Types.Vector3(3.5d, 3.5d, 3.5d),    // Prim size
                ScriptBaseClass.PRIM_TYPE_PRISM,            // Prim type
                ScriptBaseClass.PRIM_HOLE_CIRCLE,           // Prim hole type
                new LSL_Types.Vector3(0.0d, 1.0d, 0.0d),    // Prim cut
                0.90f,                                      // Prim hollow
                new LSL_Types.Vector3(0.0d, 0.0d, 0.0d),    // Prim twist
                new LSL_Types.Vector3(2.0d, 1.0d, 0.0d),    // Prim taper 
                new LSL_Types.Vector3(0.0d, 0.0d, 0.0d),    // Prim shear
                0.90f);                                     // Prim hollow check

            // Test a box.
            CheckllSetPrimitiveParams(
                apiGrp1,
                "test 3",                                   // Prim test identification string
                new LSL_Types.Vector3(3.5d, 3.5d, 3.5d),    // Prim size
                ScriptBaseClass.PRIM_TYPE_BOX,              // Prim type
                ScriptBaseClass.PRIM_HOLE_TRIANGLE,         // Prim hole type
                new LSL_Types.Vector3(0.0d, 1.0d, 0.0d),    // Prim cut
                0.99f,                                      // Prim hollow
                new LSL_Types.Vector3(1.0d, 0.0d, 0.0d),    // Prim twist
                new LSL_Types.Vector3(1.0d, 1.0d, 0.0d),    // Prim taper 
                new LSL_Types.Vector3(0.0d, 0.0d, 0.0d),    // Prim shear
                0.99f);                                     // Prim hollow check

            // Test a tube.
            CheckllSetPrimitiveParams(
                apiGrp1,
                "test 4",                                   // Prim test identification string
                new LSL_Types.Vector3(4.2d, 4.2d, 4.2d),    // Prim size
                ScriptBaseClass.PRIM_TYPE_TUBE,             // Prim type
                ScriptBaseClass.PRIM_HOLE_SQUARE,           // Prim hole type
                new LSL_Types.Vector3(0.0d, 1.0d, 0.0d),    // Prim cut
                0.00f,                                      // Prim hollow
                new LSL_Types.Vector3(1.0d, -1.0d, 0.0d),   // Prim twist
                new LSL_Types.Vector3(1.0d, 0.05d, 0.0d),   // Prim hole size
                // Expression for y selected to test precision problems during byte
                // cast in SetPrimitiveShapeParams.
                new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d),    // Prim shear
                new LSL_Types.Vector3(0.0d, 1.0d, 0.0d),    // Prim profile cut
                // Expression for y selected to test precision problems during sbyte
                // cast in SetPrimitiveShapeParams.
                new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d),    // Prim taper
                1.11f,                                      // Prim revolutions
                0.88f,                                      // Prim radius
                0.95f,                                      // Prim skew
                0.00f);                                     // Prim hollow check

            // Test a prism.
            CheckllSetPrimitiveParams(
                apiGrp1,
                "test 5",                                   // Prim test identification string
                new LSL_Types.Vector3(3.5d, 3.5d, 3.5d),    // Prim size
                ScriptBaseClass.PRIM_TYPE_PRISM,            // Prim type
                ScriptBaseClass.PRIM_HOLE_SQUARE,           // Prim hole type
                new LSL_Types.Vector3(0.0d, 1.0d, 0.0d),    // Prim cut
                0.99f,                                      // Prim hollow
                // Expression for x selected to test precision problems during sbyte
                // cast in SetPrimitiveShapeBlockParams.
                new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d),     // Prim twist
                // Expression for y selected to test precision problems during sbyte
                // cast in SetPrimitiveShapeParams.
                new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d),   // Prim taper 
                new LSL_Types.Vector3(0.0d, 0.0d, 0.0d),    // Prim shear
                0.70f);                                     // Prim hollow check

            // Test a sculpted prim.
            CheckllSetPrimitiveParams(
                apiGrp1,
                "test 6",                                   // Prim test identification string
                new LSL_Types.Vector3(2.0d, 2.0d, 2.0d),    // Prim size
                ScriptBaseClass.PRIM_TYPE_SCULPT,           // Prim type
                "be293869-d0d9-0a69-5989-ad27f1946fd4",     // Prim map
                ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE);   // Prim sculpt type
        }
Exemplo n.º 10
0
        public void TestAddSceneObject()
        {
            TestHelpers.InMethod();

            Scene scene = new SceneHelpers().SetupScene();
            int partsToTestCount = 3;

            SceneObjectGroup so
                = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
            SceneObjectPart[] parts = so.Parts;

            Assert.That(scene.AddNewSceneObject(so, false), Is.True);
            SceneObjectGroup retrievedSo = scene.GetSceneObjectGroup(so.UUID);
            SceneObjectPart[] retrievedParts = retrievedSo.Parts;
            
            //m_log.Debug("retrievedPart : {0}", retrievedPart);
            // If the parts have the same UUID then we will consider them as one and the same
            Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount));

            for (int i = 0; i < partsToTestCount; i++)
            {
                Assert.That(retrievedParts[i].Name, Is.EqualTo(parts[i].Name));
                Assert.That(retrievedParts[i].UUID, Is.EqualTo(parts[i].UUID));
            }
        }
Exemplo n.º 11
0
        public void TestGetSceneObjectByPartLocalId()
        {
            TestHelpers.InMethod();

            Scene scene = new SceneHelpers().SetupScene();
            int partsToTestCount = 3;

            SceneObjectGroup so
                = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
            SceneObjectPart[] parts = so.Parts;

            scene.AddNewSceneObject(so, false);

            // Test getting via the root part's local id
            Assert.That(scene.GetGroupByPrim(so.LocalId), Is.Not.Null);

            // Test getting via a non root part's local id
            Assert.That(scene.GetGroupByPrim(parts[partsToTestCount - 1].LocalId), Is.Not.Null);

            // Test that we don't get back an object for a local id that doesn't exist
            Assert.That(scene.GetGroupByPrim(999), Is.Null);

            // Now delete the scene object and check again
            scene.DeleteSceneObject(so, false);

            Assert.That(scene.GetGroupByPrim(so.LocalId), Is.Null);
            Assert.That(scene.GetGroupByPrim(parts[partsToTestCount - 1].LocalId), Is.Null);
        }
Exemplo n.º 12
0
        /// <summary>
        /// It shouldn't be possible to add a scene object if one with that uuid already exists in the scene.
        /// </summary>
        public void TestAddExistingSceneObjectUuid()
        {
            TestHelpers.InMethod();

            Scene scene = new SceneHelpers().SetupScene();

            string obj1Name = "Alfred";
            string obj2Name = "Betty";
            UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");

            SceneObjectPart part1
                = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 
                    { Name = obj1Name, UUID = objUuid };

            Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);

            SceneObjectPart part2
                = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 
                    { Name = obj2Name, UUID = objUuid };

            Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part2), false), Is.False);
            
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(objUuid);
            
            //m_log.Debug("retrievedPart : {0}", retrievedPart);
            // If the parts have the same UUID then we will consider them as one and the same
            Assert.That(retrievedPart.Name, Is.EqualTo(obj1Name));
            Assert.That(retrievedPart.UUID, Is.EqualTo(objUuid));
        }
Exemplo n.º 13
0
        public void TestSavePathToIarV0_1()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            InventoryArchiverModule archiverModule = new InventoryArchiverModule();

            Scene scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(scene, archiverModule);

            // Create user
            string userFirstName = "Jock";
            string userLastName = "Stirrup";
            string userPassword = "******";
            UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
            UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
            
            // Create asset
            SceneObjectGroup object1;
            SceneObjectPart part1;
            {
                string partName = "My Little Dog Object";
                UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
                PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
                Vector3 groupPosition = new Vector3(10, 20, 30);
                Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
                Vector3 offsetPosition = new Vector3(5, 10, 15);

                part1 = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition);
                part1.Name = partName;

                object1 = new SceneObjectGroup(part1);
                scene.AddNewSceneObject(object1, false);
            }

            UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1);
            scene.AssetService.Store(asset1);

            // Create item
            UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
            InventoryItemBase item1 = new InventoryItemBase();
            item1.Name = "My Little Dog";
            item1.AssetID = asset1.FullID;
            item1.ID = item1Id;
            InventoryFolderBase objsFolder 
                = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];
            item1.Folder = objsFolder.ID;
            scene.AddInventoryItem(item1);

            MemoryStream archiveWriteStream = new MemoryStream();
            archiverModule.OnInventoryArchiveSaved += SaveCompleted;

            // Test saving a particular path
            mre.Reset();
            archiverModule.ArchiveInventory(
                Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
            mre.WaitOne(60000, false);

            byte[] archive = archiveWriteStream.ToArray();
            MemoryStream archiveReadStream = new MemoryStream(archive);
            TarArchiveReader tar = new TarArchiveReader(archiveReadStream);

            //bool gotControlFile = false;
            bool gotObject1File = false;
            //bool gotObject2File = false;
            string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
            string expectedObject1FilePath = string.Format(
                "{0}{1}{2}",
                ArchiveConstants.INVENTORY_PATH,
                InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
                expectedObject1FileName);

            string filePath;
            TarArchiveReader.TarEntryType tarEntryType;

//            Console.WriteLine("Reading archive");
            
            while (tar.ReadEntry(out filePath, out tarEntryType) != null)
            {
//                Console.WriteLine("Got {0}", filePath);

//                if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
//                {
//                    gotControlFile = true;
//                }
                
                if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
                {
//                    string fileName = filePath.Remove(0, "Objects/".Length);
//
//                    if (fileName.StartsWith(part1.Name))
//                    {
                        Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
                        gotObject1File = true;
//                    }
//                    else if (fileName.StartsWith(part2.Name))
//                    {
//                        Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
//                        gotObject2File = true;
//                    }
                }
            }

//            Assert.That(gotControlFile, Is.True, "No control file in archive");
            Assert.That(gotObject1File, Is.True, "No item1 file in archive");
//            Assert.That(gotObject2File, Is.True, "No object2 file in archive");

            // TODO: Test presence of more files and contents of files.
        }