diff options
author | Justin Clark-Casey (justincc) | 2012-07-24 22:33:54 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-24 22:33:54 +0100 |
commit | 2858b1b1f44f67d7ac88b5dcaffbc9710e9e365c (patch) | |
tree | 7ded617af20b48322f5e47e01a1da76a55eeb32b /OpenSim | |
parent | Change attachment handling to remove object from the scene first as per (diff) | |
download | opensim-SC-2858b1b1f44f67d7ac88b5dcaffbc9710e9e365c.zip opensim-SC-2858b1b1f44f67d7ac88b5dcaffbc9710e9e365c.tar.gz opensim-SC-2858b1b1f44f67d7ac88b5dcaffbc9710e9e365c.tar.bz2 opensim-SC-2858b1b1f44f67d7ac88b5dcaffbc9710e9e365c.tar.xz |
extend regression TestDetachScriptedAttachementToInventory() to check correct running status on a re-rezzed attachment
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 28 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | 22 |
2 files changed, 45 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b021a47..8d2128c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -47,6 +47,8 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | |||
47 | using OpenSim.Region.CoreModules.World.Serialiser; | 47 | using OpenSim.Region.CoreModules.World.Serialiser; |
48 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
49 | using OpenSim.Region.Framework.Interfaces; | 49 | using OpenSim.Region.Framework.Interfaces; |
50 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
51 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
50 | using OpenSim.Region.ScriptEngine.XEngine; | 52 | using OpenSim.Region.ScriptEngine.XEngine; |
51 | using OpenSim.Services.Interfaces; | 53 | using OpenSim.Services.Interfaces; |
52 | using OpenSim.Tests.Common; | 54 | using OpenSim.Tests.Common; |
@@ -379,29 +381,49 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
379 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 381 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
380 | 382 | ||
381 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); | 383 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); |
382 | TaskInventoryHelpers.AddScript(scene, so.RootPart); | 384 | TaskInventoryItem scriptTaskItem |
385 | = TaskInventoryHelpers.AddScript( | ||
386 | scene, | ||
387 | so.RootPart, | ||
388 | "scriptItem", | ||
389 | "default { attach(key id) { if (id != NULL_KEY) { llSay(0, \"Hello World\"); } } }"); | ||
390 | |||
383 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); | 391 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); |
384 | 392 | ||
385 | // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. | 393 | // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. |
386 | // In the future, we need to be able to do this programatically more predicably. | 394 | // In the future, we need to be able to do this programatically more predicably. |
387 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 395 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
388 | 396 | ||
389 | SceneObjectGroup soRezzed | 397 | SceneObjectGroup rezzedSo |
390 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 398 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); |
391 | 399 | ||
392 | // Wait for chat to signal rezzed script has been started. | 400 | // Wait for chat to signal rezzed script has been started. |
393 | m_chatEvent.WaitOne(60000); | 401 | m_chatEvent.WaitOne(60000); |
394 | 402 | ||
395 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, soRezzed); | 403 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, rezzedSo); |
396 | 404 | ||
397 | InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem); | 405 | InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem); |
398 | AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString()); | 406 | AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString()); |
399 | 407 | ||
408 | // TODO: It would probably be better here to check script state via the saving and retrieval of state | ||
409 | // information at a higher level, rather than having to inspect the serialization. | ||
400 | XmlDocument soXml = new XmlDocument(); | 410 | XmlDocument soXml = new XmlDocument(); |
401 | soXml.LoadXml(Encoding.UTF8.GetString(asset.Data)); | 411 | soXml.LoadXml(Encoding.UTF8.GetString(asset.Data)); |
402 | 412 | ||
403 | XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState"); | 413 | XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState"); |
404 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | 414 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); |
415 | |||
416 | // Re-rez the attachment to check script running state | ||
417 | SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | ||
418 | |||
419 | // Wait for chat to signal rezzed script has been started. | ||
420 | m_chatEvent.WaitOne(60000); | ||
421 | |||
422 | TaskInventoryItem reRezzedScriptItem = reRezzedSo.RootPart.Inventory.GetInventoryItem(scriptTaskItem.Name); | ||
423 | IScriptModule xengine = scene.RequestModuleInterface<IScriptModule>(); | ||
424 | Assert.That(xengine.GetScriptState(reRezzedScriptItem.ItemID), Is.True); | ||
425 | |||
426 | // Console.WriteLine(soXml.OuterXml); | ||
405 | } | 427 | } |
406 | 428 | ||
407 | /// <summary> | 429 | /// <summary> |
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index fba03ab..0a2b30a 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | |||
@@ -80,8 +80,26 @@ namespace OpenSim.Tests.Common | |||
80 | /// <returns>The item that was added</returns> | 80 | /// <returns>The item that was added</returns> |
81 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) | 81 | public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part) |
82 | { | 82 | { |
83 | return AddScript(scene, part, "scriptItem", "default { state_entry() { llSay(0, \"Hello World\"); } }"); | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Add a simple script to the given part. | ||
88 | /// </summary> | ||
89 | /// <remarks> | ||
90 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | ||
91 | /// functions more than once in a test. | ||
92 | /// </remarks> | ||
93 | /// <param name="scene"></param> | ||
94 | /// <param name="part"></param> | ||
95 | /// <param name="scriptName">Name of the script to add</param> | ||
96 | /// <param name="scriptSource">LSL script source</param> | ||
97 | /// <returns>The item that was added</returns> | ||
98 | public static TaskInventoryItem AddScript( | ||
99 | Scene scene, SceneObjectPart part, string scriptName, string scriptSource) | ||
100 | { | ||
83 | AssetScriptText ast = new AssetScriptText(); | 101 | AssetScriptText ast = new AssetScriptText(); |
84 | ast.Source = "default { state_entry() { llSay(0, \"Hello World\"); } }"; | 102 | ast.Source = scriptSource; |
85 | ast.Encode(); | 103 | ast.Encode(); |
86 | 104 | ||
87 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | 105 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); |
@@ -91,7 +109,7 @@ namespace OpenSim.Tests.Common | |||
91 | scene.AssetService.Store(asset); | 109 | scene.AssetService.Store(asset); |
92 | TaskInventoryItem item | 110 | TaskInventoryItem item |
93 | = new TaskInventoryItem | 111 | = new TaskInventoryItem |
94 | { Name = "scriptItem", AssetID = assetUuid, ItemID = itemUuid, | 112 | { Name = scriptName, AssetID = assetUuid, ItemID = itemUuid, |
95 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; | 113 | Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL }; |
96 | part.Inventory.AddInventoryItem(item, true); | 114 | part.Inventory.AddInventoryItem(item, true); |
97 | 115 | ||