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/Region/CoreModules/Avatar/Attachments | |
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/Region/CoreModules/Avatar/Attachments')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 28 |
1 files changed, 25 insertions, 3 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> |