From b8a7c8b26f3005eed5b161c37509b06b1d604967 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 26 Feb 2013 23:36:36 +0000
Subject: Add regression test for llRequestUrl()
---
OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 57 ++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Tests/Common/Mock')
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
index 78bab5b..6a53fe7 100644
--- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
+++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
@@ -40,10 +40,33 @@ namespace OpenSim.Tests.Common
{
public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
{
+ public IConfigSource ConfigSource { get; private set; }
+
+ public IConfig Config { get; private set; }
+
private Scene m_scene;
+ ///
+ /// Expose posted events to tests.
+ ///
+ public Dictionary> PostedEvents { get; private set; }
+
+ ///
+ /// A very primitive way of hooking text cose to a posed event.
+ ///
+ ///
+ /// May be replaced with something that uses more original code in the future.
+ ///
+ public event Action PostEventHook;
+
public void Initialise(IConfigSource source)
{
+ ConfigSource = source;
+
+ // Can set later on if required
+ Config = new IniConfig("MockScriptEngine", ConfigSource);
+
+ PostedEvents = new Dictionary>();
}
public void Close()
@@ -85,7 +108,28 @@ namespace OpenSim.Tests.Common
public bool PostScriptEvent(UUID itemID, string name, object[] args)
{
- return false;
+// Console.WriteLine("Posting event {0} for {1}", name, itemID);
+
+ EventParams evParams = new EventParams(name, args, null);
+
+ List eventsForItem;
+
+ if (!PostedEvents.ContainsKey(itemID))
+ {
+ eventsForItem = new List();
+ PostedEvents.Add(itemID, eventsForItem);
+ }
+ else
+ {
+ eventsForItem = PostedEvents[itemID];
+ }
+
+ eventsForItem.Add(evParams);
+
+ if (PostEventHook != null)
+ PostEventHook(itemID, evParams);
+
+ return true;
}
public bool PostObjectEvent(UUID itemID, string name, object[] args)
@@ -195,11 +239,7 @@ namespace OpenSim.Tests.Common
public Scene World { get { return m_scene; } }
- public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } }
-
- public IConfig Config { get { throw new System.NotImplementedException (); } }
-
- public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } }
+ public IScriptModule ScriptModule { get { return this; } }
public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
@@ -210,5 +250,10 @@ namespace OpenSim.Tests.Common
public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
+
+ public void ClearPostedEvents()
+ {
+ PostedEvents.Clear();
+ }
}
}
\ No newline at end of file
--
cgit v1.1