public void TestPostAssetRewrite() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); XEngine xengine = new OpenSim.Region.ScriptEngine.XEngine.XEngine(); xengine.DebugLevel = 1; IniConfigSource configSource = new IniConfigSource(); IConfig startupConfig = configSource.AddConfig("Startup"); startupConfig.Set("DefaultScriptEngine", "XEngine"); IConfig xEngineConfig = configSource.AddConfig("XEngine"); xEngineConfig.Set("Enabled", "true"); xEngineConfig.Set("StartDelay", "0"); xEngineConfig.Set("AppDomainLoading", "false"); string homeUrl = "http://hg.HomeTestPostAssetRewriteGrid.com"; string foreignUrl = "http://hg.ForeignTestPostAssetRewriteGrid.com"; int soIdTail = 0x1; UUID assetId = TestHelpers.ParseTail(0x10); UUID userId = TestHelpers.ParseTail(0x100); UUID sceneId = TestHelpers.ParseTail(0x1000); string userFirstName = "TestPostAsset"; string userLastName = "Rewrite"; int soPartsCount = 3; Scene scene = new SceneHelpers().SetupScene("TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource); SceneHelpers.SetupSceneModules(scene, configSource, xengine); scene.StartScripts(); HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl); UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password"); SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail); RezScript( scene, so.UUID, "default { state_entry() { llSay(0, \"Hello World\"); } }", "item1", ua.PrincipalID); AssetBase asset = AssetHelpers.CreateAsset(assetId, so); asset.CreatorID = foreignUrl; hgam.PostAsset(foreignUrl, asset); // Check transformed asset. AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString()); Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID); string xmlData = Utils.BytesToString(ncAssetGet.Data); XmlDocument ncAssetGetXmlDoc = new XmlDocument(); ncAssetGetXmlDoc.LoadXml(xmlData); // Console.WriteLine(ncAssetGetXmlDoc.OuterXml); XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData"); Assert.AreEqual(soPartsCount, creatorDataNodes.Count); //Console.WriteLine("creatorDataNodes {0}", creatorDataNodes.Count); foreach (XmlNode creatorDataNode in creatorDataNodes) { Assert.AreEqual( string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText); } // Check that saved script nodes have attributes XmlNodeList savedScriptStateNodes = ncAssetGetXmlDoc.GetElementsByTagName("SavedScriptState"); Assert.AreEqual(1, savedScriptStateNodes.Count); Assert.AreEqual(1, savedScriptStateNodes[0].Attributes.Count); XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID"); Assert.NotNull(uuidAttribute); // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task // item created earlier. }
public void TestMove() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); Vector3 startPos = sp.AbsolutePosition; // Vector3 startPos = new Vector3(128, 128, 30); // For now, we'll make the scene presence fly to simplify this test, but this needs to change. sp.Flying = true; m_scene.Update(); Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); Vector3 targetPos = startPos + new Vector3(0, 10, 0); sp.MoveToTarget(targetPos, false, false); Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); Assert.That( sp.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001)); m_scene.Update(); // We should really check the exact figure. Assert.That(sp.AbsolutePosition.X, Is.EqualTo(startPos.X)); Assert.That(sp.AbsolutePosition.Y, Is.GreaterThan(startPos.Y)); Assert.That(sp.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); Assert.That(sp.AbsolutePosition.Z, Is.LessThan(targetPos.X)); for (int i = 0; i < 10; i++) { m_scene.Update(); } double distanceToTarget = Util.GetDistanceTo(sp.AbsolutePosition, targetPos); Assert.That(distanceToTarget, Is.LessThan(1), "Avatar not within 1 unit of target position on first move"); Assert.That(sp.AbsolutePosition, Is.EqualTo(targetPos)); Assert.That(sp.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); // Try a second movement startPos = sp.AbsolutePosition; targetPos = startPos + new Vector3(10, 0, 0); sp.MoveToTarget(targetPos, false, false); Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); Assert.That( sp.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0, 1), 0.000001)); m_scene.Update(); // We should really check the exact figure. Assert.That(sp.AbsolutePosition.X, Is.GreaterThan(startPos.X)); Assert.That(sp.AbsolutePosition.X, Is.LessThan(targetPos.X)); Assert.That(sp.AbsolutePosition.Y, Is.EqualTo(startPos.Y)); Assert.That(sp.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); for (int i = 0; i < 10; i++) { m_scene.Update(); } distanceToTarget = Util.GetDistanceTo(sp.AbsolutePosition, targetPos); Assert.That(distanceToTarget, Is.LessThan(1), "Avatar not within 1 unit of target position on second move"); Assert.That(sp.AbsolutePosition, Is.EqualTo(targetPos)); }
public void TestDeleteSceneObjectAsyncToUserInventory() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); string myObjectName = "Fred"; TestScene scene = new SceneHelpers().SetupScene(); IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Modules"); config.Set("InventoryAccessModule", "BasicInventoryAccessModule"); SceneHelpers.SetupSceneModules( scene, configSource, new object[] { new BasicInventoryAccessModule() }); SceneHelpers.SetupSceneModules(scene, new object[] { }); // 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; SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId); UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); InventoryFolderBase folder1 = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false); IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; scene.DeRezObjects(client, new List <uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); // Assert.That(retrievedPart, Is.Not.Null); // Assert.That(so.IsDeleted, Is.False); sogd.InventoryDeQueueAndDelete(); Assert.That(so.IsDeleted, Is.True); SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); Assert.That(retrievedPart2, Is.Null); // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); InventoryItemBase retrievedItem = UserInventoryHelpers.GetInventoryItem( scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName); // Check that we now have the taken part in our inventory Assert.That(retrievedItem, Is.Not.Null); // Check that the taken part has actually disappeared // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); // Assert.That(retrievedPart, Is.Null); }
public void TestCrossOnSameSimulator() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); // TestEventQueueGetModule eqmA = new TestEventQueueGetModule(); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); // IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); // In order to run a single threaded regression test we do not want the entity transfer module waiting // for a callback from the destination scene before removing its avatar data. // entityTransferConfig.Set("wait_for_callback", false); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); // SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA); SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); TestClient tc = new TestClient(acd, sceneA); List <TestClient> destinationTestClients = new List <TestClient>(); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); originalSp.AbsolutePosition = new Vector3(128, 32, 10); // originalSp.Flying = true; // Console.WriteLine("First pos {0}", originalSp.AbsolutePosition); // eqmA.ClearEvents(); AgentUpdateArgs moveArgs = new AgentUpdateArgs(); //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; moveArgs.SessionID = acd.SessionID; originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); sceneA.Update(1); // Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition); // FIXME: This is a sufficient number of updates to for the presence to reach the northern border. // But really we want to do this in a more robust way. for (int i = 0; i < 100; i++) { sceneA.Update(1); // Console.WriteLine("Pos {0}", originalSp.AbsolutePosition); } // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm // messages // Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events; // // Assert.That(eqmEvents.Count, Is.EqualTo(1)); // Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True); // // List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID]; // // Assert.That(spEqmEvents.Count, Is.EqualTo(1)); // Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion")); // sceneA should now only have a child agent ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID); Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True); ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID); // Agent remains a child until the client triggers complete movement Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient); int agentMovementCompleteReceived = 0; sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++; sceneBTc.CompleteMovement(); Assert.That(agentMovementCompleteReceived, Is.EqualTo(1)); Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False); }
public void TestllGetLinkPrimitiveParams() { TestHelpers.InMethod(); TestHelpers.EnableLogging(); UUID ownerId = TestHelpers.ParseTail(0x1); SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); grp1.AbsolutePosition = new Vector3(10, 11, 12); m_scene.AddSceneObject(grp1); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, grp1.RootPart, null, null); // Check simple 1 prim case { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(1)); } // Check 2 prim case { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( 1, new LSL_List( new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(2), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(2)); } // Check invalid parameters are ignored { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(0)); } // Check all parameters are ignored if an initial bad link is given { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( 3, new LSL_List( new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(1), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(0)); } // Check only subsequent parameters are ignored when we hit the first bad link number { LSL_List resList = apiGrp1.llGetLinkPrimitiveParams( 1, new LSL_List( new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), new LSL_Integer(3), new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); Assert.That(resList.Length, Is.EqualTo(1)); } }
public void TestSaveNonRootFolderToIar() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); string userFirstName = "Jock"; string userLastName = "Stirrup"; string userPassword = "******"; UUID userId = TestHelpers.ParseTail(0x20); UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); // Create base folder InventoryFolderBase f1 = UserInventoryHelpers.CreateInventoryFolder(m_scene.InventoryService, userId, "f1", true); // Create item1 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, userId, "My Little Dog Object", 0x5); InventoryItemBase i1 = UserInventoryHelpers.AddInventoryItem(m_scene, so1, 0x50, 0x60, "f1"); // Create embedded folder InventoryFolderBase f1_1 = UserInventoryHelpers.CreateInventoryFolder(m_scene.InventoryService, userId, "f1/f1.1", true); // Create embedded item SceneObjectGroup so1_1 = SceneHelpers.CreateSceneObject(1, userId, "My Little Cat Object", 0x6); InventoryItemBase i2 = UserInventoryHelpers.AddInventoryItem(m_scene, so1_1, 0x500, 0x600, "f1/f1.1"); MemoryStream archiveWriteStream = new MemoryStream(); m_archiverModule.OnInventoryArchiveSaved += SaveCompleted; mre.Reset(); m_archiverModule.ArchiveInventory( Guid.NewGuid(), userFirstName, userLastName, "f1", userPassword, archiveWriteStream); mre.WaitOne(60000, false); // Test created iar byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); TarArchiveReader tar = new TarArchiveReader(archiveReadStream); // InventoryArchiveUtils. bool gotf1 = false, gotf1_1 = false, gotso1 = false, gotso2 = false; string f1FileName = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, InventoryArchiveWriteRequest.CreateArchiveFolderName(f1)); string f1_1FileName = string.Format("{0}{1}", f1FileName, InventoryArchiveWriteRequest.CreateArchiveFolderName(f1_1)); string so1FileName = string.Format("{0}{1}", f1FileName, InventoryArchiveWriteRequest.CreateArchiveItemName(i1)); string so2FileName = string.Format("{0}{1}", f1_1FileName, InventoryArchiveWriteRequest.CreateArchiveItemName(i2)); string filePath; TarArchiveReader.TarEntryType tarEntryType; while (tar.ReadEntry(out filePath, out tarEntryType) != null) { // Console.WriteLine("Got {0}", filePath); if (filePath == f1FileName) { gotf1 = true; } else if (filePath == f1_1FileName) { gotf1_1 = true; } else if (filePath == so1FileName) { gotso1 = true; } else if (filePath == so2FileName) { gotso2 = true; } } // Assert.That(gotControlFile, Is.True, "No control file in archive"); Assert.That(gotf1, Is.True); Assert.That(gotf1_1, Is.True); Assert.That(gotso1, Is.True); Assert.That(gotso2, Is.True); // TODO: Test presence of more files and contents of files. }
protected void ConstructDefaultIarBytesForTestLoad() { // log4net.Config.XmlConfigurator.Configure(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(); Scene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, archiverModule); UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); MemoryStream archiveWriteStream = new MemoryStream(); // Create scene object asset UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); scene.AssetService.Store(asset1); // Create scene object item InventoryItemBase item1 = new InventoryItemBase(); item1.Name = m_item1Name; item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); item1.AssetID = asset1.FullID; item1.GroupID = UUID.Random(); item1.CreatorIdAsUuid = m_uaLL1.PrincipalID; item1.Owner = m_uaLL1.PrincipalID; item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; scene.AddInventoryItem(item1); // Create coalesced objects asset SceneObjectGroup cobj1 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120); cobj1.AbsolutePosition = new Vector3(15, 30, 45); SceneObjectGroup cobj2 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140); cobj2.AbsolutePosition = new Vector3(25, 50, 75); CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2); AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa); scene.AssetService.Store(coaAsset); // Create coalesced objects inventory item InventoryItemBase coaItem = new InventoryItemBase(); coaItem.Name = m_coaItemName; coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); coaItem.AssetID = coaAsset.FullID; coaItem.GroupID = UUID.Random(); coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID; coaItem.Owner = m_uaLL1.PrincipalID; coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; scene.AddInventoryItem(coaItem); archiverModule.ArchiveInventory( Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream); m_iarStreamBytes = archiveWriteStream.ToArray(); }
public void TestWearAttachmentFromGround() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); Scene scene = CreateTestScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); SceneObjectGroup so2 = SceneHelpers.AddSceneObject(scene, "att2", sp.UUID); { SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); m_numberOfAttachEventsFired = 0; scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(so.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); // Check item status // Assert.That( // sp.Appearance.GetAttachpoint(attSo.FromItemID), // Is.EqualTo((int)AttachmentPoint.LeftHand)); InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); Assert.That(attachmentItem, Is.Not.Null); Assert.That(attachmentItem.Name, Is.EqualTo(so.Name)); InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object); Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(2)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); } // Test wearing a different attachment from the ground. { scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(so2.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); // Check item status // Assert.That( // sp.Appearance.GetAttachpoint(attSo.FromItemID), // Is.EqualTo((int)AttachmentPoint.LeftHand)); InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); Assert.That(attachmentItem, Is.Not.Null); Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name)); InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object); Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); } // Test rewearing an already worn attachment from ground. Nothing should happen. { scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(so2.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); // Check item status // Assert.That( // sp.Appearance.GetAttachpoint(attSo.FromItemID), // Is.EqualTo((int)AttachmentPoint.LeftHand)); InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); Assert.That(attachmentItem, Is.Not.Null); Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name)); InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, FolderType.Object); Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); } }
public void TestRezAttachmentFromInventory() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); Scene scene = CreateTestScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); { scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); // Check scene presence status Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); Assert.IsFalse(attSo.Backup); // Check appearance status // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); // Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); } // Test attaching an already attached attachment { scene.AttachmentsModule.RezSingleAttachmentFromInventory( sp, attItem.ID, (uint)AttachmentPoint.Chest); // Check scene presence status Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); // Check appearance status // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); // Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); } }
public void Init() { m_scene = new SceneHelpers().SetupScene(); m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); }
public void TestLlRequestAgentDataOnline() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, userId); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, part); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part, scriptItem, null); // Initially long timeout to test cache apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20000; // Offline test { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(0, int.Parse(data)); m_engine.PostedEvents.Clear(); } // Online test. Should get the 'wrong' result because of caching. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(0, int.Parse(data)); m_engine.PostedEvents.Clear(); } apiGrp1.LlRequestAgentDataCacheTimeoutMs = 1; // Make absolutely sure that we should trigger cache timeout. Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 1); { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(1, int.Parse(data)); m_engine.PostedEvents.Clear(); } m_scene.CloseAgent(userId, false); Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 1 + 1); { apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE); Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID)); List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID]; Assert.That(events.Count, Is.EqualTo(1)); EventParams eventParams = events[0]; Assert.That(eventParams.EventName, Is.EqualTo("dataserver")); string data = eventParams.Params[1].ToString(); Assert.AreEqual(0, int.Parse(data)); m_engine.PostedEvents.Clear(); } }
public void TestSitAndStandWithSitTarget() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // If a prim has a sit target then we can sit from any distance away Vector3 startPos = new Vector3(128, 128, 30); m_sp.AbsolutePosition = startPos; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; part.SitTargetPosition = new Vector3(0, 0, 1); m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); // This section is copied from ScenePresence.HandleAgentSit(). Correctness is not guaranteed. double x, y, z, m1, m2; Quaternion r = part.SitTargetOrientation;; m1 = r.X * r.X + r.Y * r.Y; m2 = r.Z * r.Z + r.W * r.W; // Rotate the vector <0, 0, 1> x = 2 * (r.X * r.Z + r.Y * r.W); y = 2 * (-r.X * r.W + r.Y * r.Z); z = m2 - m1; // Set m to be the square of the norm of r. double m = m1 + m2; // This constant is emperically determined to be what is used in SL. // See also http://opensimulator.org/mantis/view.php?id=7096 double offset = 0.05; Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 sitOffset = up * (float)offset; // End of copied section. Assert.That( m_sp.AbsolutePosition, Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition - sitOffset + ScenePresence.SIT_TARGET_ADJUSTMENT)); Assert.That(m_sp.PhysicsActor, Is.Null); Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); HashSet <ScenePresence> sittingAvatars = part.GetSittingAvatars(); Assert.That(sittingAvatars.Count, Is.EqualTo(1)); Assert.That(sittingAvatars.Contains(m_sp)); m_sp.StandUp(); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(m_sp.ParentID, Is.EqualTo(0)); Assert.That(m_sp.PhysicsActor, Is.Not.Null); Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); Assert.That(part.GetSittingAvatars(), Is.Null); }
public void TestRezCoalescedObject() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Create asset SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, m_userId, "Object1", 0x20); object1.AbsolutePosition = new Vector3(15, 30, 45); SceneObjectGroup object2 = SceneHelpers.CreateSceneObject(1, m_userId, "Object2", 0x40); object2.AbsolutePosition = new Vector3(25, 50, 75); CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa); m_scene.AssetService.Store(asset1); // Create item UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); string item1Name = "My Little Dog"; InventoryItemBase item1 = new InventoryItemBase(); item1.Name = item1Name; item1.AssetID = asset1.FullID; item1.ID = item1Id; InventoryFolderBase objsFolder = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, m_userId, "Objects")[0]; item1.Folder = objsFolder.ID; item1.Flags |= (uint)InventoryItemFlags.ObjectHasMultipleItems; m_scene.AddInventoryItem(item1); SceneObjectGroup so = m_iam.RezObject( m_tc, item1Id, new Vector3(100, 100, 100), Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); Assert.That(so, Is.Not.Null); Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2)); SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name); Assert.That(retrievedObj1Part, Is.Null); retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name); Assert.That(retrievedObj1Part, Is.Not.Null); Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name)); // Bottom of coalescence is placed on ground, hence we end up with 100.5 rather than 85 since the bottom // object is unit square. Assert.That(retrievedObj1Part.AbsolutePosition, Is.EqualTo(new Vector3(95, 90, 100.5f))); SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name); Assert.That(retrievedObj2Part, Is.Not.Null); Assert.That(retrievedObj2Part.Name, Is.EqualTo(object2.Name)); Assert.That(retrievedObj2Part.AbsolutePosition, Is.EqualTo(new Vector3(105, 110, 130.5f))); }
public void TestSameSimulatorNeighbouringRegionsTeleportV1() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); BaseHttpServer httpServer = new BaseHttpServer(99999); MainServer.AddHttpServer(httpServer); MainServer.Instance = httpServer; AttachmentsModule attModA = new AttachmentsModule(); AttachmentsModule attModB = new AttachmentsModule(); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); // In order to run a single threaded regression test we do not want the entity transfer module waiting // for a callback from the destination scene before removing its avatar data. entityTransferConfig.Set("wait_for_callback", false); modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules( sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule()); SceneHelpers.SetupSceneModules( sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour lscm.ServiceVersion = "SIMULATION/0.1"; UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); TestClient tc = new TestClient(acd, sceneA); List <TestClient> destinationTestClients = new List <TestClient>(); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); Vector3 teleportPosition = new Vector3(10, 11, 12); Vector3 teleportLookAt = new Vector3(20, 21, 22); m_numberOfAttachEventsFired = 0; sceneA.RequestTeleportLocation( beforeTeleportSp.ControllingClient, sceneB.RegionInfo.RegionHandle, teleportPosition, teleportLookAt, (uint)TeleportFlags.ViaLocation); destinationTestClients[0].CompleteMovement(); // Check attachments have made it into sceneB ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); // This is appearance data, as opposed to actually rezzed attachments List <AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); Assert.That(sceneBAttachments.Count, Is.EqualTo(1)); Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID)); Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment List <SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments(); Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1)); SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0]; Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name)); Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); Assert.IsFalse(actualSceneBAtt.Backup); Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check attachments have been removed from sceneA ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID); // Since this is appearance data, it is still present on the child avatar! List <AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); Assert.That(sceneAAttachments.Count, Is.EqualTo(1)); Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment, which should no longer exist List <SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); }
public void TestSaveMultiRegionOar() { TestHelpers.InMethod(); // Create test regions int WIDTH = 2; int HEIGHT = 2; List <Scene> scenes = new List <Scene>(); // Maps (Directory in OAR file -> scene) Dictionary <string, Scene> regionPaths = new Dictionary <string, Scene>(); // Maps (Scene -> expected object paths) Dictionary <UUID, List <string> > expectedPaths = new Dictionary <UUID, List <string> >(); // List of expected assets List <UUID> expectedAssets = new List <UUID>(); for (uint y = 0; y < HEIGHT; y++) { for (uint x = 0; x < WIDTH; x++) { Scene scene; if (x == 0 && y == 0) { scene = m_scene; // this scene was already created in SetUp() } else { scene = m_sceneHelpers.SetupScene(string.Format("Unit test region {0}", (y * WIDTH) + x + 1), UUID.Random(), 1000 + x, 1000 + y); SceneHelpers.SetupSceneModules(scene, new ArchiverModule(), m_serialiserModule, new TerrainModule()); } scenes.Add(scene); string dir = String.Format("{0}_{1}_{2}", x + 1, y + 1, scene.RegionInfo.RegionName.Replace(" ", "_")); regionPaths[dir] = scene; SceneObjectGroup sog1; SceneObjectGroup sog2; UUID ncAssetUuid; CreateTestObjects(scene, out sog1, out sog2, out ncAssetUuid); expectedPaths[scene.RegionInfo.RegionID] = new List <string>(); expectedPaths[scene.RegionInfo.RegionID].Add(ArchiveHelpers.CreateObjectPath(sog1)); expectedPaths[scene.RegionInfo.RegionID].Add(ArchiveHelpers.CreateObjectPath(sog2)); expectedAssets.Add(ncAssetUuid); } } // Save OAR MemoryStream archiveWriteStream = new MemoryStream(); Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); Dictionary <string, Object> options = new Dictionary <string, Object>(); options.Add("all", true); m_scene.EventManager.OnOarFileSaved += SaveCompleted; m_oarEvent.Reset(); m_archiverModule.ArchiveRegion(archiveWriteStream, requestId, options); m_oarEvent.WaitOne(60000); // Check that the OAR contains the expected data Assert.That(m_lastRequestId, Is.EqualTo(requestId)); byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); TarArchiveReader tar = new TarArchiveReader(archiveReadStream); Dictionary <UUID, List <string> > foundPaths = new Dictionary <UUID, List <string> >(); List <UUID> foundAssets = new List <UUID>(); foreach (Scene scene in scenes) { foundPaths[scene.RegionInfo.RegionID] = new List <string>(); } string filePath; TarArchiveReader.TarEntryType tarEntryType; byte[] data = tar.ReadEntry(out filePath, out tarEntryType); Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); Dictionary <string, object> archiveOptions = new Dictionary <string, object>(); ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions); arr.LoadControlFile(filePath, data, new DearchiveScenesInfo()); Assert.That(arr.ControlFileLoaded, Is.True); while (tar.ReadEntry(out filePath, out tarEntryType) != null) { if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { // Assets are shared, so this file doesn't belong to any specific region. string fileName = filePath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); if (fileName.EndsWith("_notecard.txt")) { foundAssets.Add(UUID.Parse(fileName.Substring(0, fileName.Length - "_notecard.txt".Length))); } } else { // This file belongs to one of the regions. Find out which one. Assert.IsTrue(filePath.StartsWith(ArchiveConstants.REGIONS_PATH)); string[] parts = filePath.Split(new Char[] { '/' }, 3); Assert.AreEqual(3, parts.Length); string regionDirectory = parts[1]; string relativePath = parts[2]; Scene scene = regionPaths[regionDirectory]; if (relativePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) { foundPaths[scene.RegionInfo.RegionID].Add(relativePath); } } } Assert.AreEqual(scenes.Count, foundPaths.Count); foreach (Scene scene in scenes) { Assert.That(foundPaths[scene.RegionInfo.RegionID], Is.EquivalentTo(expectedPaths[scene.RegionInfo.RegionID])); } Assert.That(foundAssets, Is.EquivalentTo(expectedAssets)); }
public void TestWearAttachmentFromInventory() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); Scene scene = CreateTestScene(); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); InventoryItemBase attItem1 = CreateAttachmentItem(scene, ua1.PrincipalID, "att1", 0x10, 0x20); InventoryItemBase attItem2 = CreateAttachmentItem(scene, ua1.PrincipalID, "att2", 0x11, 0x21); { m_numberOfAttachEventsFired = 0; scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem1.ID, (uint)AttachmentPoint.Default); // default attachment point is currently the left hand. Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attItem1.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); Assert.That(attSo.IsAttachment); // Check appearance status // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); // Assert.That(sp.Appearance.GetAttachpoint(attItem1.ID), Is.EqualTo((int)AttachmentPoint.LeftHand)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); } // Test wearing a second attachment at the same position // Until multiple attachments at one point is implemented, this will remove the first attachment // This test relies on both attachments having the same default attachment point (in this case LeftHand // since none other has been set). { scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default); // default attachment point is currently the left hand. Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attItem2.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); Assert.That(attSo.IsAttachment); // Check appearance status // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); // Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); } // Test wearing an already attached attachment { scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default); // default attachment point is currently the left hand. Assert.That(sp.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = sp.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attItem2.Name)); Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); Assert.That(attSo.IsAttachment); // Check appearance status // Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); // Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand)); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); } }
public void TestLoadMultiRegionOar() { TestHelpers.InMethod(); // Create an ArchiveScenesGroup with the regions in the OAR. This is needed to generate the control file. int WIDTH = 2; int HEIGHT = 2; for (uint y = 0; y < HEIGHT; y++) { for (uint x = 0; x < WIDTH; x++) { Scene scene; if (x == 0 && y == 0) { scene = m_scene; // this scene was already created in SetUp() } else { scene = m_sceneHelpers.SetupScene(string.Format("Unit test region {0}", (y * WIDTH) + x + 1), UUID.Random(), 1000 + x, 1000 + y); SceneHelpers.SetupSceneModules(scene, new ArchiverModule(), m_serialiserModule, new TerrainModule()); } } } ArchiveScenesGroup scenesGroup = new ArchiveScenesGroup(); m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene) { scenesGroup.AddScene(scene); }); scenesGroup.CalcSceneLocations(); // Generate the OAR file MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); ArchiveWriteRequest writeRequest = new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty); writeRequest.MultiRegionFormat = true; tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, writeRequest.CreateControlFile(scenesGroup)); SceneObjectPart part1 = CreateSceneObjectPart1(); part1.SitTargetOrientation = new Quaternion(0.2f, 0.3f, 0.4f, 0.5f); part1.SitTargetPosition = new Vector3(1, 2, 3); SceneObjectGroup object1 = new SceneObjectGroup(part1); // Let's put some inventory items into our object string soundItemName = "sound-item1"; UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); Type type = GetType(); Assembly assembly = type.Assembly; string soundDataResourceName = null; string[] names = assembly.GetManifestResourceNames(); foreach (string name in names) { if (name.EndsWith(".Resources.test-sound.wav")) { soundDataResourceName = name; } } Assert.That(soundDataResourceName, Is.Not.Null); byte[] soundData; UUID soundUuid; CreateSoundAsset(tar, assembly, soundDataResourceName, out soundData, out soundUuid); TaskInventoryItem item1 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; part1.Inventory.AddInventoryItem(item1, true); m_scene.AddNewSceneObject(object1, false); string object1FileName = string.Format( "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", part1.Name, Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z), part1.UUID); string path = "regions/1_1_Unit_test_region/" + ArchiveConstants.OBJECTS_PATH + object1FileName; tar.WriteFile(path, SceneObjectSerializer.ToXml2Format(object1)); tar.Close(); // Delete the current objects, to test that they're loaded from the OAR and didn't // just remain in the scene. m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene) { scene.DeleteAllSceneObjects(); }); // Create a "hole", to test that that the corresponding region isn't loaded from the OAR m_sceneHelpers.SceneManager.CloseScene(SceneManager.Instance.Scenes[1]); // Check thay the OAR file contains the expected data MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_oarEvent.Reset(); m_archiverModule.DearchiveRegion(archiveReadStream); m_oarEvent.WaitOne(60000); Assert.That(m_lastErrorMessage, Is.Null); Assert.AreEqual(3, m_sceneHelpers.SceneManager.Scenes.Count); TestLoadedRegion(part1, soundItemName, soundData); }
public void TestSameSimulatorNeighbouringRegionsTeleportV2() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); BaseHttpServer httpServer = new BaseHttpServer(99999); MainServer.AddHttpServer(httpServer); MainServer.Instance = httpServer; AttachmentsModule attModA = new AttachmentsModule(); AttachmentsModule attModB = new AttachmentsModule(); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules( sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule()); SceneHelpers.SetupSceneModules( sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); TestClient tc = new TestClient(acd, sceneA); List <TestClient> destinationTestClients = new List <TestClient>(); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); Assert.That(destinationTestClients.Count, Is.EqualTo(1)); Assert.That(destinationTestClients[0], Is.Not.Null); InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); Vector3 teleportPosition = new Vector3(10, 11, 12); Vector3 teleportLookAt = new Vector3(20, 21, 22); // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt // Both these operations will occur on different threads and will wait for each other. // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1 // test protocol, where we are trying to avoid unpredictable async operations in regression tests. tc.OnTestClientSendRegionTeleport += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null); m_numberOfAttachEventsFired = 0; sceneA.RequestTeleportLocation( beforeTeleportSp.ControllingClient, sceneB.RegionInfo.RegionHandle, teleportPosition, teleportLookAt, (uint)TeleportFlags.ViaLocation); // Check attachments have made it into sceneB ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); // This is appearance data, as opposed to actually rezzed attachments List <AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); Assert.That(sceneBAttachments.Count, Is.EqualTo(1)); Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID)); Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment List <SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments(); Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1)); SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0]; Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name)); Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); Assert.IsFalse(actualSceneBAtt.Backup); Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check attachments have been removed from sceneA ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID); // Since this is appearance data, it is still present on the child avatar! List <AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); Assert.That(sceneAAttachments.Count, Is.EqualTo(1)); Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment, which should no longer exist List <SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); }
public void TestSaveItemToIarNoAssets() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Create user string userFirstName = "Jock"; string userLastName = "Stirrup"; string userPassword = "******"; UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); // Create asset UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50); UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); m_scene.AssetService.Store(asset1); // Create item UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); string item1Name = "My Little Dog"; InventoryItemBase item1 = new InventoryItemBase(); item1.Name = item1Name; item1.AssetID = asset1.FullID; item1.ID = item1Id; InventoryFolderBase objsFolder = InventoryArchiveUtils.FindFoldersByPath(m_scene.InventoryService, userId, "Objects")[0]; item1.Folder = objsFolder.ID; m_scene.AddInventoryItem(item1); MemoryStream archiveWriteStream = new MemoryStream(); Dictionary <string, Object> options = new Dictionary <string, Object>(); options.Add("noassets", true); // When we're not saving assets, archiving is being done synchronously. m_archiverModule.ArchiveInventory( Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream, options); 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}", ArchiveConstants.INVENTORY_PATH, 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; // } } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { Assert.Fail("Found asset path in TestSaveItemToIarNoAssets()"); } } // 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. }
public void TestLinkDelink2groups4SceneObjects() { TestHelpers.InMethod(); bool debugtest = false; Scene scene = SceneHelpers.SetupScene(); SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); SceneObjectGroup grp1 = part1.ParentGroup; SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); SceneObjectGroup grp2 = part2.ParentGroup; SceneObjectPart part3 = SceneHelpers.AddSceneObject(scene); SceneObjectGroup grp3 = part3.ParentGroup; SceneObjectPart part4 = SceneHelpers.AddSceneObject(scene); SceneObjectGroup grp4 = part4.ParentGroup; grp1.AbsolutePosition = new Vector3(10, 10, 10); grp2.AbsolutePosition = Vector3.Zero; grp3.AbsolutePosition = new Vector3(20, 20, 20); grp4.AbsolutePosition = new Vector3(40, 40, 40); // <90,0,0> // grp1.UpdateGroupRotationR(Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); // <180,0,0> grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); // <270,0,0> // grp3.UpdateGroupRotationR(Quaternion.CreateFromEulers(270 * Utils.DEG_TO_RAD, 0, 0)); // <0,90,0> grp4.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 90 * Utils.DEG_TO_RAD, 0)); // Required for linking grp1.RootPart.ClearUpdateSchedule(); grp2.RootPart.ClearUpdateSchedule(); grp3.RootPart.ClearUpdateSchedule(); grp4.RootPart.ClearUpdateSchedule(); // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. grp1.LinkToGroup(grp2); // Link grp4 to grp3. grp3.LinkToGroup(grp4); // At this point we should have 4 parts total in two groups. Assert.That(grp1.Parts.Length == 2, "Group1 children count should be 2"); Assert.That(grp2.IsDeleted, "Group 2 was not registered as deleted after link."); Assert.That(grp2.Parts.Length, Is.EqualTo(0), "Group 2 still contained parts after delink."); Assert.That(grp3.Parts.Length == 2, "Group3 children count should be 2"); Assert.That(grp4.IsDeleted, "Group 4 was not registered as deleted after link."); Assert.That(grp4.Parts.Length, Is.EqualTo(0), "Group 4 still contained parts after delink."); if (debugtest) { m_log.Debug("--------After Link-------"); m_log.Debug("Group1: parts:" + grp1.Parts.Length); m_log.Debug("Group1: Pos:" + grp1.AbsolutePosition + ", Rot:" + grp1.GroupRotation); m_log.Debug("Group1: Prim1: OffsetPosition:" + part1.OffsetPosition + ", OffsetRotation:" + part1.RotationOffset); m_log.Debug("Group1: Prim2: OffsetPosition:" + part2.OffsetPosition + ", OffsetRotation:" + part2.RotationOffset); m_log.Debug("Group3: parts:" + grp3.Parts.Length); m_log.Debug("Group3: Pos:" + grp3.AbsolutePosition + ", Rot:" + grp3.GroupRotation); m_log.Debug("Group3: Prim1: OffsetPosition:" + part3.OffsetPosition + ", OffsetRotation:" + part3.RotationOffset); m_log.Debug("Group3: Prim2: OffsetPosition:" + part4.OffsetPosition + ", OffsetRotation:" + part4.RotationOffset); } // Required for linking grp1.RootPart.ClearUpdateSchedule(); grp3.RootPart.ClearUpdateSchedule(); // root part should have no offset position or rotation Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity, "root part should have no offset position or rotation (again)"); // offset position should be root part position - part2.absolute position. Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10), "offset position should be root part position - part2.absolute position (again)"); float roll = 0; float pitch = 0; float yaw = 0; // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180. part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); if (debugtest) { m_log.Debug(rotEuler1); } part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); if (debugtest) { m_log.Debug(rotEuler2); } Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f), "Not sure what this assertion is all about..."); // Now we're linking the first group to the third group. This will make the first group child parts of the third one. grp3.LinkToGroup(grp1); // Delink parts 2 and 3 grp3.DelinkFromGroup(part2.LocalId); grp3.DelinkFromGroup(part3.LocalId); if (debugtest) { m_log.Debug("--------After De-Link-------"); m_log.Debug("Group1: parts:" + grp1.Parts.Length); m_log.Debug("Group1: Pos:" + grp1.AbsolutePosition + ", Rot:" + grp1.GroupRotation); m_log.Debug("Group1: Prim1: OffsetPosition:" + part1.OffsetPosition + ", OffsetRotation:" + part1.RotationOffset); m_log.Debug("Group1: Prim2: OffsetPosition:" + part2.OffsetPosition + ", OffsetRotation:" + part2.RotationOffset); m_log.Debug("Group3: parts:" + grp3.Parts.Length); m_log.Debug("Group3: Pos:" + grp3.AbsolutePosition + ", Rot:" + grp3.GroupRotation); m_log.Debug("Group3: Prim1: OffsetPosition:" + part3.OffsetPosition + ", OffsetRotation:" + part3.RotationOffset); m_log.Debug("Group3: Prim2: OffsetPosition:" + part4.OffsetPosition + ", OffsetRotation:" + part4.RotationOffset); } Assert.That(part2.AbsolutePosition == Vector3.Zero, "Badness 1"); Assert.That(part4.OffsetPosition == new Vector3(20, 20, 20), "Badness 2"); Quaternion compareQuaternion = new Quaternion(0, 0.7071068f, 0, 0.7071068f); Assert.That((part4.RotationOffset.X - compareQuaternion.X < 0.00003) && (part4.RotationOffset.Y - compareQuaternion.Y < 0.00003) && (part4.RotationOffset.Z - compareQuaternion.Z < 0.00003) && (part4.RotationOffset.W - compareQuaternion.W < 0.00003), "Badness 3"); }
public void TestCrossOnSameSimulatorNoRootDestPerm() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); // We need to set up the permisions module on scene B so that our later use of agent limit to deny // QueryAccess won't succeed anyway because administrators are always allowed in and the default // IsAdministrator if no permissions module is present is true. SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new DefaultPermissionsModule(), etmB); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); TestClient tc = new TestClient(acd, sceneA); List <TestClient> destinationTestClients = new List <TestClient>(); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); // Make sure sceneB will not accept this avatar. sceneB.RegionInfo.EstateSettings.PublicAccess = false; ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); originalSp.AbsolutePosition = new Vector3(128, 32, 10); AgentUpdateArgs moveArgs = new AgentUpdateArgs(); //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; moveArgs.SessionID = acd.SessionID; originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); sceneA.Update(1); // Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition); // FIXME: This is a sufficient number of updates to for the presence to reach the northern border. // But really we want to do this in a more robust way. for (int i = 0; i < 100; i++) { sceneA.Update(1); // Console.WriteLine("Pos {0}", originalSp.AbsolutePosition); } // sceneA agent should still be root ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID); Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False); ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID); // sceneB agent should still be child Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); // sceneB should ignore unauthorized attempt to upgrade agent to root TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient); int agentMovementCompleteReceived = 0; sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++; sceneBTc.CompleteMovement(); Assert.That(agentMovementCompleteReceived, Is.EqualTo(0)); Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); }
public void TestLinkDelink2SceneObjects() { TestHelpers.InMethod(); bool debugtest = false; Scene scene = SceneHelpers.SetupScene(); SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); SceneObjectGroup grp1 = part1.ParentGroup; SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); SceneObjectGroup grp2 = part2.ParentGroup; grp1.AbsolutePosition = new Vector3(10, 10, 10); grp2.AbsolutePosition = Vector3.Zero; // <90,0,0> // grp1.UpdateGroupRotationR(Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); // <180,0,0> grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); // Required for linking grp1.RootPart.ClearUpdateSchedule(); grp2.RootPart.ClearUpdateSchedule(); // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. grp1.LinkToGroup(grp2); // 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. Assert.That(grp2.IsDeleted, "SOG 2 was not registered as deleted after link."); Assert.That(grp2.Parts.Length, Is.EqualTo(0), "Group 2 still contained children after delink."); Assert.That(grp1.Parts.Length == 2); if (debugtest) { m_log.Debug("parts: " + grp1.Parts.Length); m_log.Debug("Group1: Pos:" + grp1.AbsolutePosition + ", Rot:" + grp1.GroupRotation); m_log.Debug("Group1: Prim1: OffsetPosition:" + part1.OffsetPosition + ", OffsetRotation:" + part1.RotationOffset); m_log.Debug("Group1: Prim2: OffsetPosition:" + part2.OffsetPosition + ", OffsetRotation:" + part2.RotationOffset); } // root part should have no offset position or rotation Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity, "root part should have no offset position or rotation"); // offset position should be root part position - part2.absolute position. Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10), "offset position should be root part position - part2.absolute position."); float roll = 0; float pitch = 0; float yaw = 0; // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180. part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); if (debugtest) { m_log.Debug(rotEuler1); } part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); if (debugtest) { m_log.Debug(rotEuler2); } Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f), "Not exactly sure what this is asserting..."); // Delink part 2 SceneObjectGroup grp3 = grp1.DelinkFromGroup(part2.LocalId); if (debugtest) { m_log.Debug("Group2: Prim2: OffsetPosition:" + part2.AbsolutePosition + ", OffsetRotation:" + part2.RotationOffset); } 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(grp3.HasGroupChangedDueToDelink, Is.True); }
// 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.95f, // 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.95f); // 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.95f, // 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 }
public void TestLoadPublishedOar() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SceneObjectPart part1 = CreateSceneObjectPart1(); SceneObjectGroup sog1 = new SceneObjectGroup(part1); m_scene.AddNewSceneObject(sog1, false); SceneObjectPart part2 = CreateSceneObjectPart2(); AssetNotecard nc = new AssetNotecard(); nc.BodyText = "Hello World!"; nc.Encode(); UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); AssetBase ncAsset = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); m_scene.AssetService.Store(ncAsset); SceneObjectGroup sog2 = new SceneObjectGroup(part2); TaskInventoryItem ncItem = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid }; part2.Inventory.AddInventoryItem(ncItem, true); m_scene.AddNewSceneObject(sog2, false); MemoryStream archiveWriteStream = new MemoryStream(); m_scene.EventManager.OnOarFileSaved += SaveCompleted; Guid requestId = new Guid("00000000-0000-0000-0000-808080808080"); m_oarEvent.Reset(); m_archiverModule.ArchiveRegion( archiveWriteStream, requestId, new Dictionary <string, Object>() { { "wipe-owners", Boolean.TrueString } }); m_oarEvent.WaitOne(60000); Assert.That(m_lastRequestId, Is.EqualTo(requestId)); byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); { UUID estateOwner = TestHelpers.ParseTail(0x4747); UUID objectOwner = TestHelpers.ParseTail(0x15); // Reload to new scene ArchiverModule archiverModule = new ArchiverModule(); SerialiserModule serialiserModule = new SerialiserModule(); TerrainModule terrainModule = new TerrainModule(); SceneHelpers m_sceneHelpers2 = new SceneHelpers(); TestScene scene2 = m_sceneHelpers2.SetupScene(); SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is // behaving correctly UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner); scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner; scene2.EventManager.OnOarFileLoaded += LoadCompleted; m_oarEvent.Reset(); archiverModule.DearchiveRegion(archiveReadStream); m_oarEvent.WaitOne(60000); Assert.That(m_lastErrorMessage, Is.Null); SceneObjectGroup loadedSog = scene2.GetSceneObjectGroup(part1.Name); Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner)); Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner)); } }
public void Init() { m_scene = SceneHelpers.SetupScene(); }
public void TestLoadOarDeededLand() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID landID = TestHelpers.ParseTail(0x10); MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector(); IConfigSource configSource = new IniConfigSource(); IConfig config = configSource.AddConfig("Groups"); config.Set("Enabled", true); config.Set("Module", "GroupsModule"); config.Set("DebugEnabled", true); SceneHelpers.SetupSceneModules( m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() }); // Create group in scene for loading // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests. UUID groupID = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero); // Construct OAR MemoryStream oarStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(oarStream); tar.WriteDir(ArchiveConstants.LANDDATA_PATH); tar.WriteFile( ArchiveConstants.CONTROL_FILE_PATH, new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); LandObject lo = new LandObject(groupID, true, m_scene); lo.SetLandBitmap(lo.BasicFullRegionLandBitmap()); LandData ld = lo.LandData; ld.GlobalID = landID; string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); Dictionary <string, object> options = new Dictionary <string, object>(); tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options)); tar.Close(); oarStream = new MemoryStream(oarStream.ToArray()); // Load OAR m_scene.EventManager.OnOarFileLoaded += LoadCompleted; m_oarEvent.Reset(); m_archiverModule.DearchiveRegion(oarStream); m_oarEvent.WaitOne(60000); ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); LandData rLd = rLo.LandData; Assert.That(rLd.GlobalID, Is.EqualTo(landID)); Assert.That(rLd.OwnerID, Is.EqualTo(groupID)); Assert.That(rLd.GroupID, Is.EqualTo(groupID)); Assert.That(rLd.IsGroupOwned, Is.EqualTo(true)); }
public void Init() { m_serialiserModule = new SerialiserModule(); m_scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); }
/// <summary> /// Test merging an OpenSim Region Archive into an existing scene /// </summary> //[Test] public void TestMergeOar() { TestHelpers.InMethod(); //XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); // string part2Name = "objectMerge"; // PrimitiveBaseShape part2Shape = PrimitiveBaseShape.CreateCylinder(); // Vector3 part2GroupPosition = new Vector3(90, 80, 70); // Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); // Vector3 part2OffsetPosition = new Vector3(20, 25, 30); SceneObjectPart part2 = CreateSceneObjectPart2(); // Create an oar file that we can use for the merge { ArchiverModule archiverModule = new ArchiverModule(); SerialiserModule serialiserModule = new SerialiserModule(); TerrainModule terrainModule = new TerrainModule(); Scene scene = m_sceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); // Write out this scene scene.EventManager.OnOarFileSaved += SaveCompleted; m_oarEvent.Reset(); m_archiverModule.ArchiveRegion(archiveWriteStream); m_oarEvent.WaitOne(60000); } { SceneObjectPart part1 = CreateSceneObjectPart1(); m_scene.AddNewSceneObject(new SceneObjectGroup(part1), false); // Merge in the archive we created earlier byte[] archive = archiveWriteStream.ToArray(); MemoryStream archiveReadStream = new MemoryStream(archive); m_scene.EventManager.OnOarFileLoaded += LoadCompleted; Dictionary <string, object> archiveOptions = new Dictionary <string, object>(); archiveOptions.Add("merge", null); m_oarEvent.Reset(); m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions); m_oarEvent.WaitOne(60000); SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); Assert.That(object1Existing.Name, Is.EqualTo(part1.Name), "object1 names not identical after merge"); Assert.That(object1Existing.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal after merge"); SceneObjectPart object2PartMerged = m_scene.GetSceneObjectPart(part2.Name); Assert.That(object2PartMerged, Is.Not.Null, "object2 was not present after merge"); Assert.That(object2PartMerged.Name, Is.EqualTo(part2.Name), "object2 names not identical after merge"); Assert.That(object2PartMerged.GroupPosition, Is.EqualTo(part2.GroupPosition), "object2 group position not equal after merge"); } }
public void TestCrossOnSameSimulatorWithSittingAvatar() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); UUID userId = TestHelpers.ParseTail(0x1); int sceneObjectIdTail = 0x2; Vector3 so1StartPos = new Vector3(128, 10, 20); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); // In order to run a single threaded regression test we do not want the entity transfer module waiting // for a callback from the destination scene before removing its avatar data. entityTransferConfig.Set("wait_for_callback", false); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA); SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB); SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail); UUID so1Id = so1.UUID; so1.AbsolutePosition = so1StartPos; AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); TestClient tc = new TestClient(acd, sceneA); List <TestClient> destinationTestClients = new List <TestClient>(); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd); sp1SceneA.AbsolutePosition = so1StartPos; sp1SceneA.HandleAgentRequestSit(sp1SceneA.ControllingClient, sp1SceneA.UUID, so1.UUID, Vector3.Zero); sceneA.Update(4); sceneB.Update(4); // Cross sceneA.SceneGraph.UpdatePrimGroupPosition( so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), sp1SceneA.ControllingClient); // crossing is async sceneA.Update(4); sceneB.Update(4); Thread.Sleep(500); SceneObjectGroup so1PostCross; ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId); Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false"); ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId); TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient); sceneBTc.CompleteMovement(); sceneA.Update(4); sceneB.Update(4); Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true"); Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject); Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck"); so1PostCross = sceneB.GetSceneObjectGroup(so1Id); Assert.NotNull(so1PostCross); Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount()); Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition; // Console.WriteLine("CRISSCROSS"); // Recross sceneB.SceneGraph.UpdatePrimGroupPosition( so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), sp1SceneBPostCross.ControllingClient); sceneA.Update(4); sceneB.Update(4); // crossing is async Thread.Sleep(500); { ScenePresence sp1SceneBPostReCross = sceneB.GetScenePresence(userId); Assert.IsTrue(sp1SceneBPostReCross.IsChildAgent, "sp1SceneBPostReCross.IsChildAgent unexpectedly false"); ScenePresence sp1SceneAPostReCross = sceneA.GetScenePresence(userId); TestClient sceneATc = ((TestClient)sp1SceneAPostReCross.ControllingClient); sceneATc.CompleteMovement(); Assert.IsFalse(sp1SceneAPostReCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true"); Assert.IsTrue(sp1SceneAPostReCross.IsSatOnObject); Assert.IsNull(sceneB.GetSceneObjectGroup(so1Id), "uck2"); SceneObjectGroup so1PostReCross = sceneA.GetSceneObjectGroup(so1Id); Assert.NotNull(so1PostReCross); Assert.AreEqual(1, so1PostReCross.GetSittingAvatarsCount()); } }
public void TestTakeCopyWhenCopierIsOwnerWithPerms() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); IConfigSource config = new IniConfigSource(); config.AddConfig("Modules"); config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).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; SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); uint soLocalId = so.LocalId; // so.UpdatePermissions( // ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1); // so.UpdatePermissions( // ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); // so.UpdatePermissions( // ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); // scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); // Ideally we might change these via client-focussed method calls as commented out above. However, this // becomes very convoluted so we will set only the copy perm directly. so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; // so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy; List <uint> localIds = new List <uint>(); localIds.Add(so.LocalId); // Specifying a UUID.Zero in this case will currently plop it in Lost and Found scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); // Check that object isn't copied until we crank the sogd handle. SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); Assert.That(retrievedPart, Is.Not.Null); Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); sogd.InventoryDeQueueAndDelete(); // Check that object is still there. SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); Assert.That(retrievedPart2, Is.Not.Null); Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); // Check that we have a copy in inventory InventoryItemBase item = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); Assert.That(item, Is.Not.Null); }