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
---
.../Tests/Common/Helpers/TaskInventoryHelpers.cs | 3 +-
.../Tests/Common/Helpers/UserInventoryHelpers.cs | 78 ++++++++++++++++------
2 files changed, 59 insertions(+), 22 deletions(-)
(limited to 'OpenSim/Tests/Common')
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