diff options
author | Justin Clark-Casey (justincc) | 2013-02-28 20:57:03 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-02-28 20:57:03 +0000 |
commit | 14684116f8ef23892b71ef16759224a536ac27bf (patch) | |
tree | 4857f32a20f03c2f7e42e6d00cf0e91b8d615b2f /OpenSim/Tests/Common | |
parent | Robust.HG.ini.example updated to get an [Hypergrid] section too. (diff) | |
download | opensim-SC_OLD-14684116f8ef23892b71ef16759224a536ac27bf.zip opensim-SC_OLD-14684116f8ef23892b71ef16759224a536ac27bf.tar.gz opensim-SC_OLD-14684116f8ef23892b71ef16759224a536ac27bf.tar.bz2 opensim-SC_OLD-14684116f8ef23892b71ef16759224a536ac27bf.tar.xz |
Add regression tests for llGetNotecardLine()
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r-- | OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | 32 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockScriptEngine.cs | 31 | ||||
-rw-r--r-- | OpenSim/Tests/Common/TestHelpers.cs | 21 |
3 files changed, 66 insertions, 18 deletions
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs index 0a2b30a..bb4b55f 100644 --- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs | |||
@@ -46,13 +46,32 @@ namespace OpenSim.Tests.Common | |||
46 | /// <param name="scene"></param> | 46 | /// <param name="scene"></param> |
47 | /// <param name="part"></param> | 47 | /// <param name="part"></param> |
48 | /// <param name="itemName"></param> | 48 | /// <param name="itemName"></param> |
49 | /// <param name="itemIDFrag">UUID or UUID stem</param> | ||
50 | /// <param name="assetIDFrag">UUID or UUID stem</param> | ||
51 | /// <param name="text">The tex to put in the notecard.</param> | ||
52 | /// <returns>The item that was added</returns> | ||
53 | public static TaskInventoryItem AddNotecard( | ||
54 | Scene scene, SceneObjectPart part, string itemName, string itemIDStem, string assetIDStem, string text) | ||
55 | { | ||
56 | return AddNotecard( | ||
57 | scene, part, itemName, TestHelpers.ParseStem(itemIDStem), TestHelpers.ParseStem(assetIDStem), text); | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Add a notecard item to the given part. | ||
62 | /// </summary> | ||
63 | /// <param name="scene"></param> | ||
64 | /// <param name="part"></param> | ||
65 | /// <param name="itemName"></param> | ||
49 | /// <param name="itemID"></param> | 66 | /// <param name="itemID"></param> |
50 | /// <param name="assetID"></param> | 67 | /// <param name="assetID"></param> |
68 | /// <param name="text">The tex to put in the notecard.</param> | ||
51 | /// <returns>The item that was added</returns> | 69 | /// <returns>The item that was added</returns> |
52 | public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID) | 70 | public static TaskInventoryItem AddNotecard( |
71 | Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID, string text) | ||
53 | { | 72 | { |
54 | AssetNotecard nc = new AssetNotecard(); | 73 | AssetNotecard nc = new AssetNotecard(); |
55 | nc.BodyText = "Hello World!"; | 74 | nc.BodyText = text; |
56 | nc.Encode(); | 75 | nc.Encode(); |
57 | 76 | ||
58 | AssetBase ncAsset | 77 | AssetBase ncAsset |
@@ -87,8 +106,8 @@ namespace OpenSim.Tests.Common | |||
87 | /// Add a simple script to the given part. | 106 | /// Add a simple script to the given part. |
88 | /// </summary> | 107 | /// </summary> |
89 | /// <remarks> | 108 | /// <remarks> |
90 | /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these | 109 | /// TODO: Accept input for item and asset IDs so that we have completely replicatable regression tests rather |
91 | /// functions more than once in a test. | 110 | /// than a random component. |
92 | /// </remarks> | 111 | /// </remarks> |
93 | /// <param name="scene"></param> | 112 | /// <param name="scene"></param> |
94 | /// <param name="part"></param> | 113 | /// <param name="part"></param> |
@@ -102,8 +121,9 @@ namespace OpenSim.Tests.Common | |||
102 | ast.Source = scriptSource; | 121 | ast.Source = scriptSource; |
103 | ast.Encode(); | 122 | ast.Encode(); |
104 | 123 | ||
105 | UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | 124 | UUID assetUuid = UUID.Random(); |
106 | UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | 125 | UUID itemUuid = UUID.Random(); |
126 | |||
107 | AssetBase asset | 127 | AssetBase asset |
108 | = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); | 128 | = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero); |
109 | scene.AssetService.Store(asset); | 129 | scene.AssetService.Store(asset); |
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs index 6a53fe7..b444241 100644 --- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs +++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
@@ -110,8 +111,11 @@ namespace OpenSim.Tests.Common | |||
110 | { | 111 | { |
111 | // Console.WriteLine("Posting event {0} for {1}", name, itemID); | 112 | // Console.WriteLine("Posting event {0} for {1}", name, itemID); |
112 | 113 | ||
113 | EventParams evParams = new EventParams(name, args, null); | 114 | return PostScriptEvent(itemID, new EventParams(name, args, null)); |
115 | } | ||
114 | 116 | ||
117 | public bool PostScriptEvent(UUID itemID, EventParams evParams) | ||
118 | { | ||
115 | List<EventParams> eventsForItem; | 119 | List<EventParams> eventsForItem; |
116 | 120 | ||
117 | if (!PostedEvents.ContainsKey(itemID)) | 121 | if (!PostedEvents.ContainsKey(itemID)) |
@@ -132,9 +136,22 @@ namespace OpenSim.Tests.Common | |||
132 | return true; | 136 | return true; |
133 | } | 137 | } |
134 | 138 | ||
139 | public bool PostObjectEvent(uint localID, EventParams evParams) | ||
140 | { | ||
141 | return PostObjectEvent(m_scene.GetSceneObjectPart(localID), evParams); | ||
142 | } | ||
143 | |||
135 | public bool PostObjectEvent(UUID itemID, string name, object[] args) | 144 | public bool PostObjectEvent(UUID itemID, string name, object[] args) |
136 | { | 145 | { |
137 | throw new System.NotImplementedException (); | 146 | return PostObjectEvent(m_scene.GetSceneObjectPart(itemID), new EventParams(name, args, null)); |
147 | } | ||
148 | |||
149 | private bool PostObjectEvent(SceneObjectPart part, EventParams evParams) | ||
150 | { | ||
151 | foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems(InventoryType.LSL)) | ||
152 | PostScriptEvent(item.ItemID, evParams); | ||
153 | |||
154 | return true; | ||
138 | } | 155 | } |
139 | 156 | ||
140 | public void SuspendScript(UUID itemID) | 157 | public void SuspendScript(UUID itemID) |
@@ -187,16 +204,6 @@ namespace OpenSim.Tests.Common | |||
187 | throw new System.NotImplementedException (); | 204 | throw new System.NotImplementedException (); |
188 | } | 205 | } |
189 | 206 | ||
190 | public bool PostScriptEvent(UUID itemID,EventParams parms) | ||
191 | { | ||
192 | throw new System.NotImplementedException (); | ||
193 | } | ||
194 | |||
195 | public bool PostObjectEvent (uint localID, EventParams parms) | ||
196 | { | ||
197 | throw new System.NotImplementedException (); | ||
198 | } | ||
199 | |||
200 | public DetectParams GetDetectParams(UUID item, int number) | 207 | public DetectParams GetDetectParams(UUID item, int number) |
201 | { | 208 | { |
202 | throw new System.NotImplementedException (); | 209 | throw new System.NotImplementedException (); |
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index 57da802..a684d72 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs | |||
@@ -114,6 +114,27 @@ namespace OpenSim.Tests.Common | |||
114 | } | 114 | } |
115 | 115 | ||
116 | /// <summary> | 116 | /// <summary> |
117 | /// Parse a UUID stem into a full UUID. | ||
118 | /// </summary> | ||
119 | /// <remarks> | ||
120 | /// Yes, this is completely inconsistent with ParseTail but this is probably a better way to do it, | ||
121 | /// UUIDs are conceptually not hexadecmial numbers. | ||
122 | /// The fragment will come at the start of the UUID. The rest will be 0s | ||
123 | /// </remarks> | ||
124 | /// <returns></returns> | ||
125 | /// <param name='frag'> | ||
126 | /// A UUID fragment that will be parsed into a full UUID. Therefore, it can only contain | ||
127 | /// cahracters which are valid in a UUID, except for "-" which is currently only allowed if a full UUID is | ||
128 | /// given as the 'fragment'. | ||
129 | /// </param> | ||
130 | public static UUID ParseStem(string stem) | ||
131 | { | ||
132 | string rawUuid = stem.PadRight(32, '0'); | ||
133 | |||
134 | return UUID.Parse(rawUuid); | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
117 | /// Parse tail section into full UUID. | 138 | /// Parse tail section into full UUID. |
118 | /// </summary> | 139 | /// </summary> |
119 | /// <param name="tail"></param> | 140 | /// <param name="tail"></param> |