Add new FireAndForgetMethod.None.
This executes the callback on the same thread that made the request. Designed for use only by regression tests that rely on a predicable event ordering.bulletsim
parent
d3c10e609e
commit
57e54d84d6
|
@ -412,12 +412,20 @@ namespace OpenSim.Framework
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an attachment, if the attachpoint has the
|
||||
/// Add an attachment
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the attachpoint has the
|
||||
/// 0x80 bit set then we assume this is an append
|
||||
/// operation otherwise we replace whatever is
|
||||
/// currently attached at the attachpoint
|
||||
/// </remarks>
|
||||
/// <param name="attachpoint"></param>
|
||||
/// <param name="item">If UUID.Zero, then an any attachment at the attachpoint is removed.</param>
|
||||
/// <param name="asset"></param>
|
||||
/// <returns>
|
||||
/// return true if something actually changed
|
||||
/// </summary>
|
||||
/// </returns>
|
||||
public bool SetAttachment(int attachpoint, UUID item, UUID asset)
|
||||
{
|
||||
if (attachpoint == 0)
|
||||
|
|
|
@ -56,8 +56,13 @@ namespace OpenSim.Framework
|
|||
/// <summary>
|
||||
/// The method used by Util.FireAndForget for asynchronously firing events
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// None is used to execute the method in the same thread that made the call. It should only be used by regression
|
||||
/// test code that relies on predictable event ordering.
|
||||
/// </remarks>
|
||||
public enum FireAndForgetMethod
|
||||
{
|
||||
None,
|
||||
UnsafeQueueUserWorkItem,
|
||||
QueueUserWorkItem,
|
||||
BeginInvoke,
|
||||
|
@ -89,7 +94,8 @@ namespace OpenSim.Framework
|
|||
public static readonly Regex UUIDPattern
|
||||
= new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
||||
|
||||
public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
|
||||
public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
|
||||
public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the directory where the current running executable
|
||||
|
@ -1506,6 +1512,9 @@ namespace OpenSim.Framework
|
|||
|
||||
switch (FireAndForgetMethod)
|
||||
{
|
||||
case FireAndForgetMethod.None:
|
||||
realCallback.Invoke(obj);
|
||||
break;
|
||||
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
|
||||
ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj);
|
||||
break;
|
||||
|
|
|
@ -37,10 +37,11 @@ using NUnit.Framework;
|
|||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.CoreModules.Avatar.Attachments;
|
||||
using OpenSim.Region.CoreModules.World.Serialiser;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
|
||||
|
@ -61,18 +62,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
|||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
|
||||
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
|
||||
Util.FireAndForgetMethod = FireAndForgetMethod.None;
|
||||
|
||||
ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
|
||||
interregionComms.Initialise(new IniConfigSource());
|
||||
interregionComms.PostInitialise();
|
||||
SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
|
||||
scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
|
||||
SceneHelpers.SetupSceneModules(scene, new AttachmentsModule());
|
||||
|
||||
agent1 = UUID.Random();
|
||||
random = new Random();
|
||||
sog1 = NewSOG(UUID.Random(), scene, agent1);
|
||||
sog2 = NewSOG(UUID.Random(), scene, agent1);
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
// We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
|
||||
// threads. Possibly, later tests should be rewritten not to worry about such things.
|
||||
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddAttachments()
|
||||
|
@ -100,11 +108,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
|||
Assert.That(presence.HasAttachments(), Is.False);
|
||||
}
|
||||
|
||||
// [Test]
|
||||
// public void TestRezAttachmentsOnAvatarEntrance()
|
||||
// {
|
||||
// ScenePresence presence = scene.GetScenePresence(agent1);
|
||||
// }
|
||||
[Test]
|
||||
public void TestRezAttachmentsOnAvatarEntrance()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
UUID spId = TestHelpers.ParseTail(0x1);
|
||||
UUID attItemId = TestHelpers.ParseTail(0x2);
|
||||
UUID attAssetId = TestHelpers.ParseTail(0x3);
|
||||
|
||||
AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId);
|
||||
acd.Appearance = new AvatarAppearance();
|
||||
acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId);
|
||||
ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
|
||||
|
||||
// Assert.That(presence.HasAttachments(), Is.True);
|
||||
}
|
||||
|
||||
// I'm commenting this test because scene setup NEEDS InventoryService to
|
||||
// be non-null
|
||||
|
|
Loading…
Reference in New Issue