From fc2456320646df66b95a06d4cd292c3b2385a8ea Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 11 Jul 2012 21:43:35 +0100
Subject: Add regression TestDetachScriptedAttachmentToInventory()
This currently only does a relatively crude check for a ScriptState node in the serialized xml
---
.../Avatar/Attachments/AttachmentsModule.cs | 16 ++-
.../Attachments/Tests/AttachmentsModuleTests.cs | 131 ++++++++++++++++++---
.../Framework/Interfaces/IAttachmentsModule.cs | 2 +-
.../Framework/Scenes/SceneObjectPartInventory.cs | 4 +
.../Api/Implementation/AsyncCommandManager.cs | 15 ++-
.../Shared/Api/Implementation/Plugins/Listener.cs | 8 +-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 +-
.../Tests/Common/Helpers/TaskInventoryHelpers.cs | 2 +-
8 files changed, 150 insertions(+), 32 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index efab6ed..64ee7e4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -339,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
}
- public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
+ public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
{
if (!Enabled)
return null;
@@ -527,6 +527,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
///
///
///
+ ///
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted)
{
// Saving attachments for NPCs messes them up for the real owner!
@@ -720,18 +721,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
- // m_log.DebugFormat(
- // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
- // objatt.Name, remoteClient.Name, AttachmentPt);
-
if (objatt != null)
{
+// m_log.DebugFormat(
+// "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
+// objatt.Name, sp.Name, attachmentPt, m_scene.Name);
+
// HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
objatt.HasGroupChanged = false;
bool tainted = false;
if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
tainted = true;
+ // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
+ // course of events. If not, then it's probably not worth trying to recover the situation
+ // since this is more likely to trigger further exceptions and confuse later debugging. If
+ // exceptions can be thrown in expected error conditions (not NREs) then make this consistent
+ // since other normal error conditions will simply return false instead.
// This will throw if the attachment fails
try
{
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 416aa6f..81e889d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -31,6 +31,7 @@ using System.Reflection;
using System.Text;
using System.Threading;
using System.Timers;
+using System.Xml;
using Timer=System.Timers.Timer;
using Nini.Config;
using NUnit.Framework;
@@ -41,10 +42,12 @@ using OpenSim.Region.CoreModules.Avatar.Attachments;
using OpenSim.Region.CoreModules.Framework;
using OpenSim.Region.CoreModules.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.Framework.InventoryAccess;
-using OpenSim.Region.CoreModules.World.Serialiser;
+using OpenSim.Region.CoreModules.Scripting.WorldComm;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
+using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.ScriptEngine.XEngine;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
@@ -57,6 +60,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
[TestFixture]
public class AttachmentsModuleTests : OpenSimTestCase
{
+ private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
+ private OSChatMessage m_osChatMessageReceived;
+
[TestFixtureSetUp]
public void FixtureInit()
{
@@ -72,16 +78,73 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
}
- private Scene CreateDefaultTestScene()
+ private void OnChatFromWorld(object sender, OSChatMessage oscm)
+ {
+// Console.WriteLine("Got chat [{0}]", oscm.Message);
+
+ m_osChatMessageReceived = oscm;
+ m_chatEvent.Set();
+ }
+
+ private Scene CreateTestScene()
+ {
+ IConfigSource config = new IniConfigSource();
+ List