From 8d724e90de0fb3b406f82f4e06b6f5b79c5a538c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Jan 2015 22:44:54 +0000 Subject: For scripts in attachments, don't save .state files apart from the initial one as these are ignored since .state is saved in the attachment's asset. This eliminates pointless work and exceptions when an appdomain is unloaded whilst an attachment script state is persisted. Adds test for this case. Relates to http://opensimulator.org/mantis/view.php?id=7407 --- .../Tests/Common/Helpers/TaskInventoryHelpers.cs | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'OpenSim/Tests') diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index bb4b55f..b4bd50b 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs @@ -117,25 +117,43 @@ namespace OpenSim.Tests.Common public static TaskInventoryItem AddScript( Scene scene, SceneObjectPart part, string scriptName, string scriptSource) { + return AddScript(scene, part, UUID.Random(), UUID.Random(), scriptName, scriptSource); + } + + /// + /// Add a simple script to the given part. + /// + /// + /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather + /// than a random component. + /// + /// + /// + /// Item UUID for the script + /// Asset UUID for the script + /// Name of the script to add + /// LSL script source + /// The item that was added + public static TaskInventoryItem AddScript( + Scene scene, SceneObjectPart part, UUID itemId, UUID assetId, string scriptName, string scriptSource) + { AssetScriptText ast = new AssetScriptText(); ast.Source = scriptSource; ast.Encode(); - UUID assetUuid = UUID.Random(); - UUID itemUuid = UUID.Random(); - AssetBase asset - = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); + = AssetHelpers.CreateAsset(assetId, AssetType.LSLText, ast.AssetData, UUID.Zero); scene.AssetService.Store(asset); TaskInventoryItem item = new TaskInventoryItem - { Name = scriptName, AssetID = assetUuid, ItemID = itemUuid, - Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; + { Name = scriptName, AssetID = assetId, ItemID = itemId, + Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; part.Inventory.AddInventoryItem(item, true); - + return item; } + /// /// Add a scene object item to the given part. /// -- cgit v1.1