aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs28
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;
47using OpenSim.Region.CoreModules.World.Serialiser; 47using OpenSim.Region.CoreModules.World.Serialiser;
48using OpenSim.Region.Framework.Scenes; 48using OpenSim.Region.Framework.Scenes;
49using OpenSim.Region.Framework.Interfaces; 49using OpenSim.Region.Framework.Interfaces;
50using OpenSim.Region.ScriptEngine.Interfaces;
51using OpenSim.Region.ScriptEngine.Shared.Instance;
50using OpenSim.Region.ScriptEngine.XEngine; 52using OpenSim.Region.ScriptEngine.XEngine;
51using OpenSim.Services.Interfaces; 53using OpenSim.Services.Interfaces;
52using OpenSim.Tests.Common; 54using 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>