Add new regression TestRezAttachmentsOnAvatarEntrance() to do simple attachments check

bulletsim
Justin Clark-Casey (justincc) 2011-08-17 00:37:33 +01:00
parent d73c424078
commit 696bd44833
6 changed files with 69 additions and 20 deletions

View File

@ -261,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
false, false, remoteClient.AgentId, true); false, false, remoteClient.AgentId, true);
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
// objatt.Name, remoteClient.Name, AttachmentPt); // objatt.Name, remoteClient.Name, AttachmentPt);
if (objatt != null) if (objatt != null)

View File

@ -38,6 +38,7 @@ using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Region.CoreModules.Avatar.Attachments; using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -65,8 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
Util.FireAndForgetMethod = FireAndForgetMethod.None; Util.FireAndForgetMethod = FireAndForgetMethod.None;
scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); IConfigSource config = new IniConfigSource();
SceneHelpers.SetupSceneModules(scene, new AttachmentsModule()); config.AddConfig("Modules");
config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
scene = SceneHelpers.SetupScene();
SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule());
agent1 = UUID.Random(); agent1 = UUID.Random();
random = new Random(); random = new Random();
@ -114,16 +119,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
UUID spId = TestHelpers.ParseTail(0x1); UUID userId = TestHelpers.ParseTail(0x1);
UUID attItemId = TestHelpers.ParseTail(0x2); UUID attItemId = TestHelpers.ParseTail(0x2);
UUID attAssetId = TestHelpers.ParseTail(0x3); UUID attAssetId = TestHelpers.ParseTail(0x3);
AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId); UserAccountHelpers.CreateUserWithInventory(scene, userId);
InventoryItemBase attItem
= UserInventoryHelpers.CreateInventoryItem(
scene, "att", attItemId, attAssetId, userId, InventoryType.Object);
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
acd.Appearance = new AvatarAppearance(); acd.Appearance = new AvatarAppearance();
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId); acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
// Assert.That(presence.HasAttachments(), Is.True); Assert.That(presence.HasAttachments(), Is.True);
} }
// I'm commenting this test because scene setup NEEDS InventoryService to // I'm commenting this test because scene setup NEEDS InventoryService to

View File

@ -964,8 +964,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
} }
} }
} }
else
{
m_log.WarnFormat(
"[InventoryAccessModule]: Could not find asset {0} for item {1} {2} for {3} in RezObject()", item.AssetID, item.Name, item.ID, remoteClient.Name);
}
return group; return group;
} }
else
{
m_log.WarnFormat(
"[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()",
itemID, remoteClient.Name);
}
return null; return null;
} }

View File

@ -59,8 +59,8 @@ namespace OpenSim.Region.Framework.Tests
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneHelpers.SetupScene(); Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, 1001); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, 1002); UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID);
@ -86,8 +86,8 @@ namespace OpenSim.Region.Framework.Tests
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneHelpers.SetupScene(); Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, 1001); UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, 1002); UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
InventoryFolderBase folder1 InventoryFolderBase folder1
= UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1"); = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1");

View File

@ -118,13 +118,12 @@ namespace OpenSim.Tests.Common
public static UserAccount CreateUserWithInventory(Scene scene) public static UserAccount CreateUserWithInventory(Scene scene)
{ {
return CreateUserWithInventory(scene, 99); return CreateUserWithInventory(scene, TestHelpers.ParseTail(99));
} }
public static UserAccount CreateUserWithInventory(Scene scene, int uuidTail) public static UserAccount CreateUserWithInventory(Scene scene, UUID userId)
{ {
return CreateUserWithInventory( return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll");
scene, "Bill", "Bailey", new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail)), "troll");
} }
public static UserAccount CreateUserWithInventory( public static UserAccount CreateUserWithInventory(
@ -139,7 +138,6 @@ namespace OpenSim.Tests.Common
{ {
// FIXME: This should really be set up by UserAccount itself // FIXME: This should really be set up by UserAccount itself
ua.ServiceURLs = new Dictionary<string, object>(); ua.ServiceURLs = new Dictionary<string, object>();
scene.UserAccountService.StoreUserAccount(ua); scene.UserAccountService.StoreUserAccount(ua);
scene.InventoryService.CreateUserInventory(ua.PrincipalID); scene.InventoryService.CreateUserInventory(ua.PrincipalID);
scene.AuthenticationService.SetPassword(ua.PrincipalID, pw); scene.AuthenticationService.SetPassword(ua.PrincipalID, pw);

View File

@ -52,7 +52,22 @@ namespace OpenSim.Tests.Common
/// <returns></returns> /// <returns></returns>
public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID userId) public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID userId)
{ {
return CreateInventoryItem(scene, itemName, UUID.Random(), userId); return CreateInventoryItem(scene, itemName, UUID.Random(), UUID.Random(), userId, InventoryType.Notecard);
}
/// <summary>
/// Creates an item of the given type with an accompanying asset.
/// </summary>
/// <param name="scene"></param>
/// <param name="itemName"></param>
/// <param name="itemId"></param>
/// <param name="userId"></param>
/// <param name="type">Type of item to create</param>
/// <returns></returns>
public static InventoryItemBase CreateInventoryItem(
Scene scene, string itemName, UUID userId, InventoryType type)
{
return CreateInventoryItem(scene, itemName, UUID.Random(), UUID.Random(), userId, type);
} }
/// <summary> /// <summary>
@ -61,18 +76,32 @@ namespace OpenSim.Tests.Common
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="itemName"></param> /// <param name="itemName"></param>
/// <param name="itemId"></param> /// <param name="itemId"></param>
/// <param name="assetId"></param>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <param name="type">Type of item to create</param>
/// <returns></returns> /// <returns></returns>
public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID itemId, UUID userId) public static InventoryItemBase CreateInventoryItem(
Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType type)
{ {
AssetBase asset = AssetHelpers.CreateAsset(scene, userId); AssetBase asset = null;
if (type == InventoryType.Notecard)
asset = AssetHelpers.CreateAsset(scene, userId);
else if (type == InventoryType.Object)
asset
= AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
else
throw new Exception(string.Format("Inventory type {0} not supported", type));
scene.AssetService.Store(asset);
InventoryItemBase item = new InventoryItemBase(); InventoryItemBase item = new InventoryItemBase();
item.Name = itemName; item.Name = itemName;
item.AssetID = asset.FullID; item.AssetID = asset.FullID;
item.ID = itemId; item.ID = itemId;
item.Owner = userId; item.Owner = userId;
item.AssetType = asset.Type; item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Notecard; item.InvType = (int)type;
InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard); InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);