public void TestGiveInventoryItem() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); Scene scene = new SceneHelpers().SetupScene(); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); InventoryItemBase retrievedItem1 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); Assert.That(retrievedItem1, Is.Not.Null); // Try giving back the freshly received item scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); List <InventoryItemBase> reretrievedItems = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); Assert.That(reretrievedItems.Count, Is.EqualTo(2)); }
public void TestRemoveAttachmentsOnAvatarExit() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserAccountHelpers.CreateUserWithInventory(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, userId, InventoryType.Object); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); acd.Appearance = new AvatarAppearance(); acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; scene.IncomingCloseAgent(presence.UUID); // Check that we can't retrieve this attachment from the scene. Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); }
public void TestDetachAttachmentToInventory() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); AddPresence(); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( m_presence, attItemId, (uint)AttachmentPoint.Chest); m_attMod.DetachSingleAttachmentToInv(m_presence, attItemId); // Check status on scene presence Assert.That(m_presence.HasAttachments(), Is.False); List <SceneObjectGroup> attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); }
public void TestDetachAttachmentToGround() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); AddPresence(); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory( m_presence, attItemId, (uint)AttachmentPoint.Chest); m_attMod.DetachSingleAttachmentToGround(m_presence, so.LocalId); // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.False); List <SceneObjectGroup> attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(0)); // Check appearance status Assert.That(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(0)); // Check item status Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); // Check object in scene Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); }
public void TestAddAttachmentFromInventory() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); AddPresence(); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( m_presence, attItemId, (uint)AttachmentPoint.Chest); // Check scene presence status Assert.That(m_presence.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = m_presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); 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(m_presence.Appearance.GetAttachments().Count, Is.EqualTo(1)); Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); }
/// <summary> /// Creates an attachment item in the given user's inventory. Does not attach. /// </summary> /// <remarks> /// A user with the given ID and an inventory must already exist. /// </remarks> /// <returns> /// The attachment item. /// </returns> /// <param name='scene'></param> /// <param name='userId'></param> /// <param name='attName'></param> /// <param name='rawItemId'></param> /// <param name='rawAssetId'></param> private InventoryItemBase CreateAttachmentItem( Scene scene, UUID userId, string attName, int rawItemId, int rawAssetId) { return(UserInventoryHelpers.CreateInventoryItem( scene, attName, TestHelpers.ParseTail(rawItemId), TestHelpers.ParseTail(rawAssetId), userId, InventoryType.Object)); }
public void TestGiveInventoryItemFullPerms() { TestHelpers.InMethod(); List <Object> modules = new List <object>(); IConfigSource config = DefaultConfig(modules); Scene scene = new SceneHelpers().SetupScene("Inventory Permissions", UUID.Random(), 1000, 1000, config); SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); ScenePresence sp1 = SceneHelpers.AddScenePresence(scene, user1.PrincipalID); ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, user2.PrincipalID); InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "SomeObject", user1.PrincipalID, InventoryType.Object); // Set All perms in inventory item1.NextPermissions = (uint)OpenMetaverse.PermissionMask.All; scene.UpdateInventoryItemAsset(sp1.ControllingClient, UUID.Zero, item1.ID, item1); //Assert.That((item1.NextPermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All); string message; InventoryItemBase retrievedItem1 = scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID, out message); Assert.That(retrievedItem1, Is.Not.Null); //Assert.That((retrievedItem1.CurrentPermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All); retrievedItem1 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/SomeObject"); Assert.That(retrievedItem1, Is.Not.Null); //Assert.That((retrievedItem1.BasePermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All); //Assert.That((retrievedItem1.CurrentPermissions & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All); // Rez the object scene.RezObject(sp2.ControllingClient, retrievedItem1.ID, UUID.Zero, Vector3.Zero, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero); SceneObjectGroup sog = scene.GetSceneObjectGroup("SomeObject"); Assert.That(sog, Is.Not.Null); // This is failing for all sorts of reasons. We'll fix it after perms are fixed. //Console.WriteLine("Item Perms " + retrievedItem1.CurrentPermissions + " Obj Owner Perms " + sog.RootPart.OwnerMask + " Base Perms " + sog.RootPart.BaseMask + "\n"); //Assert.True((sog.RootPart.OwnerMask & (uint)OpenMetaverse.PermissionMask.All) == (uint)OpenMetaverse.PermissionMask.All); }
public void TestLoadAppearance() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); SetUpScene(); UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); // Now add the attachment to the original avatar and use that to load a new appearance // TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserInventoryHelpers.CreateInventoryItem(m_scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); m_npcMod.SetNPCAppearance(npcId, sp.Appearance, m_scene); ScenePresence npc = m_scene.GetScenePresence(npcId); // Check scene presence status Assert.That(npc.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = npc.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. // Assert.That(attSo.Name, Is.EqualTo(attName)); 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.That(attSo.OwnerID, Is.EqualTo(npc.UUID)); }
public void TestCreateWithMultiAttachments() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); SetUpScene(); // m_attMod.DebugLevel = 1; UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); InventoryItemBase att1Item = UserInventoryHelpers.CreateInventoryItem( m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object); InventoryItemBase att2Item = UserInventoryHelpers.CreateInventoryItem( m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory(sp, att1Item.ID, (uint)AttachmentPoint.Chest); m_attMod.RezSingleAttachmentFromInventory(sp, att2Item.ID, (uint)AttachmentPoint.Chest | 0x80); UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); ScenePresence npc = m_scene.GetScenePresence(npcId); // Check scene presence status Assert.That(npc.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = npc.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(2)); // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. // Assert.That(attSo.Name, Is.EqualTo(attName)); TestAttachedObject(attachments[0], AttachmentPoint.Chest, npc.UUID); TestAttachedObject(attachments[1], AttachmentPoint.Chest, npc.UUID); // Attached objects on the same point must have different FromItemIDs to be shown to other avatars, at least // on Singularity 1.8.5. Otherwise, only one (the first ObjectUpdate sent) appears. Assert.AreNotEqual(attachments[0].FromItemID, attachments[1].FromItemID); }
public void TestRezAttachmentsOnAvatarEntrance() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserAccountHelpers.CreateUserWithInventory(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( scene, attName, attItemId, attAssetId, userId, InventoryType.Object); AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); acd.Appearance = new AvatarAppearance(); acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); Assert.That(presence.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = presence.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); 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 List <AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments(); Assert.That(retreivedAttachments.Count, Is.EqualTo(1)); Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItemId)); Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attAssetId)); Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); }
public void TestAttachments() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); UserAccountHelpers.CreateUserWithInventory(scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object); am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); INPCModule npcModule = scene.RequestModuleInterface <INPCModule>(); UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); // Check scene presence status Assert.That(npc.HasAttachments(), Is.True); List <SceneObjectGroup> attachments = npc.GetAttachments(); Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. // Assert.That(attSo.Name, Is.EqualTo(attName)); 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.That(attSo.OwnerID, Is.EqualTo(npc.UUID)); }
public void TestAcceptGivenItem() { // TestHelpers.EnableLogging(); UUID initialSessionId = TestHelpers.ParseTail(0x10); UUID itemId = TestHelpers.ParseTail(0x100); UUID assetId = TestHelpers.ParseTail(0x200); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw"); UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw"); ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1); TestClient giverClient = (TestClient)giverSp.ControllingClient; ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2); TestClient receiverClient = (TestClient)receiverSp.ControllingClient; // Create the object to test give InventoryItemBase originalItem = UserInventoryHelpers.CreateInventoryItem( m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object); byte[] giveImBinaryBucket = new byte[17]; byte[] itemIdBytes = itemId.GetBytes(); Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length); GridInstantMessage giveIm = new GridInstantMessage( m_scene, giverSp.UUID, giverSp.Name, receiverSp.UUID, (byte)InstantMessageDialog.InventoryOffered, false, "inventory offered msg", initialSessionId, false, Vector3.Zero, giveImBinaryBucket, true); giverClient.HandleImprovedInstantMessage(giveIm); // These details might not all be correct. GridInstantMessage acceptIm = new GridInstantMessage( m_scene, receiverSp.UUID, receiverSp.Name, giverSp.UUID, (byte)InstantMessageDialog.InventoryAccepted, false, "inventory accepted msg", initialSessionId, false, Vector3.Zero, null, true); receiverClient.HandleImprovedInstantMessage(acceptIm); // Test for item remaining in the giver's inventory (here we assume a copy item) // TODO: Test no-copy items. InventoryItemBase originalItemAfterGive = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj"); Assert.That(originalItemAfterGive, Is.Not.Null); Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID)); // Test for item successfully making it into the receiver's inventory InventoryItemBase receivedItem = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Objects/givenObj"); Assert.That(receivedItem, Is.Not.Null); Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID)); // Test that on a delete, item still exists and is accessible for the giver. m_scene.InventoryService.DeleteItems(receiverSp.UUID, new List <UUID>() { receivedItem.ID }); InventoryItemBase originalItemAfterDelete = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj"); Assert.That(originalItemAfterDelete, Is.Not.Null); // TODO: Test scenario where giver deletes their item first. }