From 14d05dc2a907fcb304e622ab85150049b43f4fd5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 11 Jul 2012 19:54:40 +0100
Subject: Add regression TestRezScriptedAttachmentsFromInventory() though this
currently only checks for the presence of script items, not for started
scripts
---
.../Attachments/Tests/AttachmentsModuleTests.cs | 27 +++++++-
.../Tests/Common/Helpers/TaskInventoryHelpers.cs | 3 +-
.../Tests/Common/Helpers/UserInventoryHelpers.cs | 78 ++++++++++++++++------
3 files changed, 85 insertions(+), 23 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 3e06900..416aa6f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
}
[Test]
- public void TestAddAttachmentFromInventory()
+ public void TestRezAttachmentFromInventory()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@@ -217,6 +217,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
}
+ ///
+ /// Test specific conditions associated with rezzing a scripted attachment from inventory.
+ ///
+ [Test]
+ public void TestRezScriptedAttachmentFromInventory()
+ {
+ TestHelpers.InMethod();
+
+ Scene scene = CreateDefaultTestScene();
+ UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
+ ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
+
+ SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
+ TaskInventoryHelpers.AddScript(scene, so.RootPart);
+ InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
+
+ scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
+
+ // TODO: Need to have a test that checks the script is actually started but this involves a lot more
+ // plumbing of the script engine and either pausing for events or more infrastructure to turn off various
+ // script engine delays/asychronicity that isn't helpful in an automated regression testing context.
+ SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name);
+ Assert.That(attSo.ContainsScripts(), Is.True);
+ }
+
[Test]
public void TestDetachAttachmentToGround()
{
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 9607f1f..c4e29e2 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Tests.Common
}
///
- /// Add a blank script to the given part.
+ /// Add a simple script to the given part.
///
///
/// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
@@ -81,6 +81,7 @@ namespace OpenSim.Tests.Common
public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part)
{
AssetScriptText ast = new AssetScriptText();
+ ast.Source = "default { state_entry() {} }";
ast.Encode();
UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000");
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index fdc60d8..b3a7c9e 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -43,6 +43,57 @@ namespace OpenSim.Tests.Common
public static readonly string PATH_DELIMITER = "/";
///
+ /// Add an existing scene object as an item in the user's inventory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The inventory item created.
+ public static InventoryItemBase AddInventoryItem(
+ Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail)
+ {
+ return AddInventoryItem(
+ scene,
+ so.Name,
+ TestHelpers.ParseTail(inventoryIdTail),
+ InventoryType.Object,
+ AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
+ so.OwnerID);
+ }
+
+ ///
+ /// Creates a notecard in the objects folder and specify an item id.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The serialized asset for this item
+ ///
+ ///
+ private static InventoryItemBase AddInventoryItem(
+ Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
+ {
+ scene.AssetService.Store(asset);
+
+ InventoryItemBase item = new InventoryItemBase();
+ item.Name = itemName;
+ item.AssetID = asset.FullID;
+ item.ID = itemId;
+ item.Owner = userId;
+ item.AssetType = asset.Type;
+ item.InvType = (int)itemType;
+
+ InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);
+
+ item.Folder = folder.ID;
+ scene.AddInventoryItem(item);
+
+ return item;
+ }
+
+ ///
/// Creates a notecard in the objects folder and specify an item id.
///
///
@@ -81,42 +132,27 @@ namespace OpenSim.Tests.Common
/// Type of item to create
///
public static InventoryItemBase CreateInventoryItem(
- Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType type)
+ Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType itemType)
{
AssetBase asset = null;
- if (type == InventoryType.Notecard)
+ if (itemType == InventoryType.Notecard)
{
asset = AssetHelpers.CreateNotecardAsset();
asset.CreatorID = userId.ToString();
}
- else if (type == InventoryType.Object)
+ else if (itemType == InventoryType.Object)
{
asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
}
else
{
- throw new Exception(string.Format("Inventory type {0} not supported", type));
+ throw new Exception(string.Format("Inventory type {0} not supported", itemType));
}
- scene.AssetService.Store(asset);
-
- InventoryItemBase item = new InventoryItemBase();
- item.Name = itemName;
- item.AssetID = asset.FullID;
- item.ID = itemId;
- item.Owner = userId;
- item.AssetType = asset.Type;
- item.InvType = (int)type;
-
- InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
-
- item.Folder = folder.ID;
- scene.AddInventoryItem(item);
-
- return item;
+ return AddInventoryItem(scene, itemName, itemId, itemType, asset, userId);
}
-
+
///
/// Create inventory folders starting from the user's root folder.
///
--
cgit v1.1