aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs27
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs3
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs78
3 files changed, 85 insertions, 23 deletions
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
185 } 185 }
186 186
187 [Test] 187 [Test]
188 public void TestAddAttachmentFromInventory() 188 public void TestRezAttachmentFromInventory()
189 { 189 {
190 TestHelpers.InMethod(); 190 TestHelpers.InMethod();
191// log4net.Config.XmlConfigurator.Configure(); 191// log4net.Config.XmlConfigurator.Configure();
@@ -217,6 +217,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
217 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 217 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
218 } 218 }
219 219
220 /// <summary>
221 /// Test specific conditions associated with rezzing a scripted attachment from inventory.
222 /// </summary>
223 [Test]
224 public void TestRezScriptedAttachmentFromInventory()
225 {
226 TestHelpers.InMethod();
227
228 Scene scene = CreateDefaultTestScene();
229 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
230 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);
231
232 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10);
233 TaskInventoryHelpers.AddScript(scene, so.RootPart);
234 InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000);
235
236 scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest);
237
238 // TODO: Need to have a test that checks the script is actually started but this involves a lot more
239 // plumbing of the script engine and either pausing for events or more infrastructure to turn off various
240 // script engine delays/asychronicity that isn't helpful in an automated regression testing context.
241 SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name);
242 Assert.That(attSo.ContainsScripts(), Is.True);
243 }
244
220 [Test] 245 [Test]
221 public void TestDetachAttachmentToGround() 246 public void TestDetachAttachmentToGround()
222 { 247 {
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
69 } 69 }
70 70
71 /// <summary> 71 /// <summary>
72 /// Add a blank script to the given part. 72 /// Add a simple script to the given part.
73 /// </summary> 73 /// </summary>
74 /// <remarks> 74 /// <remarks>
75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these 75 /// 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
81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) 81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part)
82 { 82 {
83 AssetScriptText ast = new AssetScriptText(); 83 AssetScriptText ast = new AssetScriptText();
84 ast.Source = "default { state_entry() {} }";
84 ast.Encode(); 85 ast.Encode();
85 86
86 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); 87 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
43 public static readonly string PATH_DELIMITER = "/"; 43 public static readonly string PATH_DELIMITER = "/";
44 44
45 /// <summary> 45 /// <summary>
46 /// Add an existing scene object as an item in the user's inventory.
47 /// </summary>
48 /// <param name='scene'></param>
49 /// <param name='so'></param>
50 /// <param name='inventoryIdTail'></param>
51 /// <param name='assetIdTail'></param>
52 /// <returns>The inventory item created.</returns>
53 public static InventoryItemBase AddInventoryItem(
54 Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail)
55 {
56 return AddInventoryItem(
57 scene,
58 so.Name,
59 TestHelpers.ParseTail(inventoryIdTail),
60 InventoryType.Object,
61 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
62 so.OwnerID);
63 }
64
65 /// <summary>
66 /// Creates a notecard in the objects folder and specify an item id.
67 /// </summary>
68 /// <param name="scene"></param>
69 /// <param name="itemName"></param>
70 /// <param name="itemId"></param>
71 /// <param name="itemType"></param>
72 /// <param name="asset">The serialized asset for this item</param>
73 /// <param name="userId"></param>
74 /// <returns></returns>
75 private static InventoryItemBase AddInventoryItem(
76 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
77 {
78 scene.AssetService.Store(asset);
79
80 InventoryItemBase item = new InventoryItemBase();
81 item.Name = itemName;
82 item.AssetID = asset.FullID;
83 item.ID = itemId;
84 item.Owner = userId;
85 item.AssetType = asset.Type;
86 item.InvType = (int)itemType;
87
88 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);
89
90 item.Folder = folder.ID;
91 scene.AddInventoryItem(item);
92
93 return item;
94 }
95
96 /// <summary>
46 /// Creates a notecard in the objects folder and specify an item id. 97 /// Creates a notecard in the objects folder and specify an item id.
47 /// </summary> 98 /// </summary>
48 /// <param name="scene"></param> 99 /// <param name="scene"></param>
@@ -81,42 +132,27 @@ namespace OpenSim.Tests.Common
81 /// <param name="type">Type of item to create</param> 132 /// <param name="type">Type of item to create</param>
82 /// <returns></returns> 133 /// <returns></returns>
83 public static InventoryItemBase CreateInventoryItem( 134 public static InventoryItemBase CreateInventoryItem(
84 Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType type) 135 Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType itemType)
85 { 136 {
86 AssetBase asset = null; 137 AssetBase asset = null;
87 138
88 if (type == InventoryType.Notecard) 139 if (itemType == InventoryType.Notecard)
89 { 140 {
90 asset = AssetHelpers.CreateNotecardAsset(); 141 asset = AssetHelpers.CreateNotecardAsset();
91 asset.CreatorID = userId.ToString(); 142 asset.CreatorID = userId.ToString();
92 } 143 }
93 else if (type == InventoryType.Object) 144 else if (itemType == InventoryType.Object)
94 { 145 {
95 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId)); 146 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
96 } 147 }
97 else 148 else
98 { 149 {
99 throw new Exception(string.Format("Inventory type {0} not supported", type)); 150 throw new Exception(string.Format("Inventory type {0} not supported", itemType));
100 } 151 }
101 152
102 scene.AssetService.Store(asset); 153 return AddInventoryItem(scene, itemName, itemId, itemType, asset, userId);
103
104 InventoryItemBase item = new InventoryItemBase();
105 item.Name = itemName;
106 item.AssetID = asset.FullID;
107 item.ID = itemId;
108 item.Owner = userId;
109 item.AssetType = asset.Type;
110 item.InvType = (int)type;
111
112 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
113
114 item.Folder = folder.ID;
115 scene.AddInventoryItem(item);
116
117 return item;
118 } 154 }
119 155
120 /// <summary> 156 /// <summary>
121 /// Create inventory folders starting from the user's root folder. 157 /// Create inventory folders starting from the user's root folder.
122 /// </summary> 158 /// </summary>