aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs158
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs248
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs126
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs50
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs269
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs398
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs240
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs157
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs7
12 files changed, 1417 insertions, 261 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs
new file mode 100644
index 0000000..af1da7c
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs
@@ -0,0 +1,158 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance;
45using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
46using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common;
48using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
49using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
50
51namespace OpenSim.Region.ScriptEngine.Shared.Tests
52{
53 /// <summary>
54 /// Tests relating directly to avatars
55 /// </summary>
56 [TestFixture]
57 public class LSL_ApiAvatarTests : OpenSimTestCase
58 {
59 protected Scene m_scene;
60 protected XEngine.XEngine m_engine;
61
62 [SetUp]
63 public override void SetUp()
64 {
65 base.SetUp();
66
67 IConfigSource initConfigSource = new IniConfigSource();
68 IConfig config = initConfigSource.AddConfig("XEngine");
69 config.Set("Enabled", "true");
70
71 m_scene = new SceneHelpers().SetupScene();
72 SceneHelpers.SetupSceneModules(m_scene, initConfigSource);
73
74 m_engine = new XEngine.XEngine();
75 m_engine.Initialise(initConfigSource);
76 m_engine.AddRegion(m_scene);
77 }
78
79 /// <summary>
80 /// Test llSetLinkPrimtiveParams for agents.
81 /// </summary>
82 /// <remarks>
83 /// Also testing entity updates here as well. Possibly that's putting 2 different concerns into one test and
84 /// this should be separated.
85 /// </remarks>
86 [Test]
87 public void TestllSetLinkPrimitiveParamsForAgent()
88 {
89 TestHelpers.InMethod();
90// TestHelpers.EnableLogging();
91
92 UUID userId = TestHelpers.ParseTail(0x1);
93
94 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
95 part.RotationOffset = new Quaternion(0.7071068f, 0, 0, 0.7071068f);
96
97 LSL_Api apiGrp1 = new LSL_Api();
98 apiGrp1.Initialize(m_engine, part, null);
99
100 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
101
102 // sp has to be less than 10 meters away from 0, 0, 0 (default part position)
103 Vector3 startPos = new Vector3(3, 2, 1);
104 sp.AbsolutePosition = startPos;
105
106 sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero);
107
108 int entityUpdates = 0;
109 ((TestClient)sp.ControllingClient).OnReceivedEntityUpdate += (entity, flags) => { if (entity is ScenePresence) { entityUpdates++; }};
110
111 // Test position
112 {
113 Vector3 newPos = new Vector3(1, 2, 3);
114 apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos));
115
116 Assert.That(sp.OffsetPosition, Is.EqualTo(newPos));
117
118 m_scene.Update(1);
119 Assert.That(entityUpdates, Is.EqualTo(1));
120 }
121
122 // Test small reposition
123 {
124 Vector3 newPos = new Vector3(1.001f, 2, 3);
125 apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos));
126
127 Assert.That(sp.OffsetPosition, Is.EqualTo(newPos));
128
129 m_scene.Update(1);
130 Assert.That(entityUpdates, Is.EqualTo(2));
131 }
132
133 // Test world rotation
134 {
135 Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
136 apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot));
137
138 Assert.That(
139 sp.Rotation, new QuaternionToleranceConstraint(part.GetWorldRotation() * newRot, 0.000001));
140
141 m_scene.Update(1);
142 Assert.That(entityUpdates, Is.EqualTo(3));
143 }
144
145 // Test local rotation
146 {
147 Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
148 apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROT_LOCAL, newRot));
149
150 Assert.That(
151 sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001));
152
153 m_scene.Update(1);
154 Assert.That(entityUpdates, Is.EqualTo(4));
155 }
156 }
157 }
158}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs
new file mode 100644
index 0000000..9a5ebce
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs
@@ -0,0 +1,248 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using log4net;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Servers;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Region.CoreModules.Scripting.LSLHttp;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.ScriptEngine.Shared;
44using OpenSim.Region.ScriptEngine.Shared.Api;
45using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
46using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common;
48
49namespace OpenSim.Region.ScriptEngine.Shared.Tests
50{
51 /// <summary>
52 /// Tests for HTTP related functions in LSL
53 /// </summary>
54 [TestFixture]
55 public class LSL_ApiHttpTests : OpenSimTestCase
56 {
57 private Scene m_scene;
58 private MockScriptEngine m_engine;
59 private UrlModule m_urlModule;
60
61 private TaskInventoryItem m_scriptItem;
62 private LSL_Api m_lslApi;
63
64 [TestFixtureSetUp]
65 public void TestFixtureSetUp()
66 {
67 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
68 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
69 }
70
71 [TestFixtureTearDown]
72 public void TestFixureTearDown()
73 {
74 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
75 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
76 // tests really shouldn't).
77 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
78 }
79
80 [SetUp]
81 public override void SetUp()
82 {
83 base.SetUp();
84
85 // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
86 // variables and the VM is not restarted between tests.
87 uint port = 9999;
88 MainServer.RemoveHttpServer(port);
89
90 BaseHttpServer server = new BaseHttpServer(port, false, 0, "");
91 MainServer.AddHttpServer(server);
92 MainServer.Instance = server;
93
94 server.Start();
95
96 m_engine = new MockScriptEngine();
97 m_urlModule = new UrlModule();
98
99 m_scene = new SceneHelpers().SetupScene();
100 SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine, m_urlModule);
101
102 SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
103 m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, so.RootPart);
104
105 // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm.
106 // Possibly this could be done and we could obtain it directly from the MockScriptEngine.
107 m_lslApi = new LSL_Api();
108 m_lslApi.Initialize(m_engine, so.RootPart, m_scriptItem);
109 }
110
111 [TearDown]
112 public void TearDown()
113 {
114 MainServer.Instance.Stop();
115 }
116
117 [Test]
118 public void TestLlReleaseUrl()
119 {
120 TestHelpers.InMethod();
121
122 m_lslApi.llRequestURL();
123 string returnedUri = m_engine.PostedEvents[m_scriptItem.ItemID][0].Params[2].ToString();
124
125 {
126 // Check that the initial number of URLs is correct
127 Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
128 }
129
130 {
131 // Check releasing a non-url
132 m_lslApi.llReleaseURL("GARBAGE");
133 Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
134 }
135
136 {
137 // Check releasing a non-existing url
138 m_lslApi.llReleaseURL("http://example.com");
139 Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
140 }
141
142 {
143 // Check URL release
144 m_lslApi.llReleaseURL(returnedUri);
145 Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls));
146
147 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri);
148
149 bool gotExpectedException = false;
150
151 try
152 {
153 using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
154 {}
155 }
156 catch (WebException e)
157 {
158 using (HttpWebResponse response = (HttpWebResponse)e.Response)
159 gotExpectedException = response.StatusCode == HttpStatusCode.NotFound;
160 }
161
162 Assert.That(gotExpectedException, Is.True);
163 }
164
165 {
166 // Check releasing the same URL again
167 m_lslApi.llReleaseURL(returnedUri);
168 Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls));
169 }
170 }
171
172 [Test]
173 public void TestLlRequestUrl()
174 {
175 TestHelpers.InMethod();
176
177 string requestId = m_lslApi.llRequestURL();
178 Assert.That(requestId, Is.Not.EqualTo(UUID.Zero.ToString()));
179 string returnedUri;
180
181 {
182 // Check that URL is correctly set up
183 Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
184
185 Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID));
186
187 List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID];
188 Assert.That(events.Count, Is.EqualTo(1));
189 EventParams eventParams = events[0];
190 Assert.That(eventParams.EventName, Is.EqualTo("http_request"));
191
192 UUID returnKey;
193 string rawReturnKey = eventParams.Params[0].ToString();
194 string method = eventParams.Params[1].ToString();
195 returnedUri = eventParams.Params[2].ToString();
196
197 Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True);
198 Assert.That(method, Is.EqualTo(ScriptBaseClass.URL_REQUEST_GRANTED));
199 Assert.That(Uri.IsWellFormedUriString(returnedUri, UriKind.Absolute), Is.True);
200 }
201
202 {
203 // Check that request to URL works.
204 string testResponse = "Hello World";
205
206 m_engine.ClearPostedEvents();
207 m_engine.PostEventHook
208 += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse);
209
210// Console.WriteLine("Trying {0}", returnedUri);
211
212 AssertHttpResponse(returnedUri, testResponse);
213
214 Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID));
215
216 List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID];
217 Assert.That(events.Count, Is.EqualTo(1));
218 EventParams eventParams = events[0];
219 Assert.That(eventParams.EventName, Is.EqualTo("http_request"));
220
221 UUID returnKey;
222 string rawReturnKey = eventParams.Params[0].ToString();
223 string method = eventParams.Params[1].ToString();
224 string body = eventParams.Params[2].ToString();
225
226 Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True);
227 Assert.That(method, Is.EqualTo("GET"));
228 Assert.That(body, Is.EqualTo(""));
229 }
230 }
231
232 private void AssertHttpResponse(string uri, string expectedResponse)
233 {
234 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
235
236 using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
237 {
238 using (Stream stream = webResponse.GetResponseStream())
239 {
240 using (StreamReader reader = new StreamReader(stream))
241 {
242 Assert.That(reader.ReadToEnd(), Is.EqualTo(expectedResponse));
243 }
244 }
245 }
246 }
247 }
248}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index cb7291a..9b7cab2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -41,9 +41,10 @@ using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared; 42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api; 43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance;
44using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common; 46using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 47using PermissionMask = OpenSim.Framework.PermissionMask;
47 48
48namespace OpenSim.Region.ScriptEngine.Shared.Tests 49namespace OpenSim.Region.ScriptEngine.Shared.Tests
49{ 50{
@@ -90,7 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
90 91
91 // Create an object embedded inside the first 92 // Create an object embedded inside the first
92 UUID itemId = TestHelpers.ParseTail(0x20); 93 UUID itemId = TestHelpers.ParseTail(0x20);
93 TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); 94 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, userId);
94 95
95 LSL_Api api = new LSL_Api(); 96 LSL_Api api = new LSL_Api();
96 api.Initialize(m_engine, so1.RootPart, null); 97 api.Initialize(m_engine, so1.RootPart, null);
@@ -130,7 +131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
130 131
131 // Create an object embedded inside the first 132 // Create an object embedded inside the first
132 UUID itemId = TestHelpers.ParseTail(0x20); 133 UUID itemId = TestHelpers.ParseTail(0x20);
133 TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); 134 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);
134 135
135 // Create a second object 136 // Create a second object
136 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); 137 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100);
@@ -166,5 +167,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
166 Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); 167 Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName));
167 } 168 }
168 } 169 }
170
171 /// <summary>
172 /// Test giving inventory from an object to an avatar that is not the object's owner.
173 /// </summary>
174 [Test]
175 public void TestLlGiveInventoryO2DifferentAvatar()
176 {
177 TestHelpers.InMethod();
178 // TestHelpers.EnableLogging();
179
180 UUID user1Id = TestHelpers.ParseTail(0x1);
181 UUID user2Id = TestHelpers.ParseTail(0x2);
182 string inventoryItemName = "item1";
183
184 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10);
185 m_scene.AddSceneObject(so1);
186 LSL_Api api = new LSL_Api();
187 api.Initialize(m_engine, so1.RootPart, null);
188
189 // Create an object embedded inside the first
190 UUID itemId = TestHelpers.ParseTail(0x20);
191 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);
192
193 UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
194
195 api.llGiveInventory(user2Id.ToString(), inventoryItemName);
196
197 InventoryItemBase receivedItem
198 = UserInventoryHelpers.GetInventoryItem(
199 m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName));
200
201 Assert.IsNotNull(receivedItem);
202 }
203
204 /// <summary>
205 /// Test giving inventory from an object to an avatar that is not the object's owner and where the next
206 /// permissions do not include mod.
207 /// </summary>
208 [Test]
209 public void TestLlGiveInventoryO2DifferentAvatarNoMod()
210 {
211 TestHelpers.InMethod();
212// TestHelpers.EnableLogging();
213
214 UUID user1Id = TestHelpers.ParseTail(0x1);
215 UUID user2Id = TestHelpers.ParseTail(0x2);
216 string inventoryItemName = "item1";
217
218 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10);
219 m_scene.AddSceneObject(so1);
220 LSL_Api api = new LSL_Api();
221 api.Initialize(m_engine, so1.RootPart, null);
222
223 // Create an object embedded inside the first
224 UUID itemId = TestHelpers.ParseTail(0x20);
225 TaskInventoryItem tii
226 = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);
227 tii.NextPermissions &= ~((uint)PermissionMask.Modify);
228
229 UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
230
231 api.llGiveInventory(user2Id.ToString(), inventoryItemName);
232
233 InventoryItemBase receivedItem
234 = UserInventoryHelpers.GetInventoryItem(
235 m_scene.InventoryService, user2Id, string.Format("Objects/{0}", inventoryItemName));
236
237 Assert.IsNotNull(receivedItem);
238 Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)PermissionMask.Modify);
239 }
240
241 [Test]
242 public void TestLlRemoteLoadScriptPin()
243 {
244 TestHelpers.InMethod();
245// TestHelpers.EnableLogging();
246
247 UUID user1Id = TestHelpers.ParseTail(0x1);
248 UUID user2Id = TestHelpers.ParseTail(0x2);
249
250 SceneObjectGroup sourceSo = SceneHelpers.AddSceneObject(m_scene, "sourceSo", user1Id);
251 m_scene.AddSceneObject(sourceSo);
252 LSL_Api api = new LSL_Api();
253 api.Initialize(m_engine, sourceSo.RootPart, null);
254 TaskInventoryHelpers.AddScript(m_scene.AssetService, sourceSo.RootPart, "script", "Hello World");
255
256 SceneObjectGroup targetSo = SceneHelpers.AddSceneObject(m_scene, "targetSo", user1Id);
257 SceneObjectGroup otherOwnedTargetSo = SceneHelpers.AddSceneObject(m_scene, "otherOwnedTargetSo", user2Id);
258
259 // Test that we cannot load a script when the target pin has never been set (i.e. it is zero)
260 api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 0, 0, 0);
261 Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script"));
262
263 // Test that we cannot load a script when the given pin does not match the target
264 targetSo.RootPart.ScriptAccessPin = 5;
265 api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0);
266 Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script"));
267
268 // Test that we cannot load into a prim with a different owner
269 otherOwnedTargetSo.RootPart.ScriptAccessPin = 3;
270 api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0);
271 Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script"));
272
273 // Test that we can load a script when given pin and dest pin match.
274 targetSo.RootPart.ScriptAccessPin = 3;
275 api.llRemoteLoadScriptPin(targetSo.UUID.ToString(), "script", 3, 0, 0);
276 TaskInventoryItem insertedItem = targetSo.RootPart.Inventory.GetInventoryItem("script");
277 Assert.IsNotNull(insertedItem);
278
279 // Test that we can no longer load if access pin is unset
280 targetSo.RootPart.Inventory.RemoveInventoryItem(insertedItem.ItemID);
281 Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem("script"));
282
283 targetSo.RootPart.ScriptAccessPin = 0;
284 api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(), "script", 3, 0, 0);
285 Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem("script"));
286 }
169 } 287 }
170} \ No newline at end of file 288}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
index d9b17d7..14b1890 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
@@ -41,10 +41,10 @@ using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared; 42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api; 43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance;
44using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 45using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
45using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common; 47using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48 48
49namespace OpenSim.Region.ScriptEngine.Shared.Tests 49namespace OpenSim.Region.ScriptEngine.Shared.Tests
50{ 50{
@@ -92,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
92 // FIXME: This should really be a script item (with accompanying script) 92 // FIXME: This should really be a script item (with accompanying script)
93 TaskInventoryItem grp1Item 93 TaskInventoryItem grp1Item
94 = TaskInventoryHelpers.AddNotecard( 94 = TaskInventoryHelpers.AddNotecard(
95 m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); 95 m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
96 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 96 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
97 97
98 SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); 98 SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20);
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
126 // FIXME: This should really be a script item (with accompanying script) 126 // FIXME: This should really be a script item (with accompanying script)
127 TaskInventoryItem grp1Item 127 TaskInventoryItem grp1Item
128 = TaskInventoryHelpers.AddNotecard( 128 = TaskInventoryHelpers.AddNotecard(
129 m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900)); 129 m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
130 130
131 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 131 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
132 132
@@ -140,5 +140,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
140 SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1"); 140 SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1");
141 Assert.That(grp2, Is.Not.Null); 141 Assert.That(grp2, Is.Not.Null);
142 } 142 }
143
144 [Test]
145 public void TestllBreakAllLinks()
146 {
147 TestHelpers.InMethod();
148
149 UUID ownerId = TestHelpers.ParseTail(0x1);
150
151 SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(3, ownerId, "grp1-", 0x10);
152 grp1.AbsolutePosition = new Vector3(10, 10, 10);
153 m_scene.AddSceneObject(grp1);
154
155 // FIXME: This should really be a script item (with accompanying script)
156 TaskInventoryItem grp1Item
157 = TaskInventoryHelpers.AddNotecard(
158 m_scene.AssetService, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!");
159
160 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
161
162 LSL_Api apiGrp1 = new LSL_Api();
163 apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item);
164
165 apiGrp1.llBreakAllLinks();
166
167 {
168 SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part1");
169 Assert.That(nowGrp, Is.Not.Null);
170 Assert.That(nowGrp.Parts.Length, Is.EqualTo(1));
171 }
172
173 {
174 SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part2");
175 Assert.That(nowGrp, Is.Not.Null);
176 Assert.That(nowGrp.Parts.Length, Is.EqualTo(1));
177 }
178
179 {
180 SceneObjectGroup nowGrp = m_scene.GetSceneObjectGroup("grp1-Part3");
181 Assert.That(nowGrp, Is.Not.Null);
182 Assert.That(nowGrp.Parts.Length, Is.EqualTo(1));
183 }
184 }
143 } 185 }
144} \ No newline at end of file 186}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
index 98017d8..34a29e6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
@@ -34,9 +34,9 @@ using OpenSim.Region.ScriptEngine.Shared;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using Nini.Config; 35using Nini.Config;
36using OpenSim.Region.ScriptEngine.Shared.Api; 36using OpenSim.Region.ScriptEngine.Shared.Api;
37using OpenSim.Region.ScriptEngine.Shared.Instance;
37using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 38using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
38using OpenMetaverse; 39using OpenMetaverse;
39using OpenSim.Tests.Common.Mock;
40 40
41using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; 41using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
42using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; 42using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
@@ -133,4 +133,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
133 } 133 }
134 } 134 }
135 } 135 }
136 } \ No newline at end of file 136 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs
new file mode 100644
index 0000000..9ab3115
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiNotecardTests.cs
@@ -0,0 +1,269 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Net;
5using System.Reflection;
6using System.Text;
7using log4net;
8using Nini.Config;
9using NUnit.Framework;
10using OpenMetaverse;
11using OpenSim.Framework;
12using OpenSim.Framework.Servers;
13using OpenSim.Framework.Servers.HttpServer;
14using OpenSim.Region.CoreModules.Scripting.LSLHttp;
15using OpenSim.Region.Framework.Scenes;
16using OpenSim.Region.ScriptEngine.Shared;
17using OpenSim.Region.ScriptEngine.Shared.Api;
18using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
19using OpenSim.Services.Interfaces;
20using OpenSim.Tests.Common;
21
22namespace OpenSim.Region.ScriptEngine.Shared.Tests
23{
24 /// <summary>
25 /// Tests for notecard related functions in LSL
26 /// </summary>
27 [TestFixture]
28 public class LSL_ApiNotecardTests : OpenSimTestCase
29 {
30 private Scene m_scene;
31 private MockScriptEngine m_engine;
32
33 private SceneObjectGroup m_so;
34 private TaskInventoryItem m_scriptItem;
35 private LSL_Api m_lslApi;
36
37 [TestFixtureSetUp]
38 public void TestFixtureSetUp()
39 {
40 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
41 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
42 }
43
44 [TestFixtureTearDown]
45 public void TestFixureTearDown()
46 {
47 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
48 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
49 // tests really shouldn't).
50 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
51 }
52
53 [SetUp]
54 public override void SetUp()
55 {
56 base.SetUp();
57
58 m_engine = new MockScriptEngine();
59
60 m_scene = new SceneHelpers().SetupScene();
61 SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine);
62
63 m_so = SceneHelpers.AddSceneObject(m_scene);
64 m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart);
65
66 // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm.
67 // Possibly this could be done and we could obtain it directly from the MockScriptEngine.
68 m_lslApi = new LSL_Api();
69 m_lslApi.Initialize(m_engine, m_so.RootPart, m_scriptItem);
70 }
71
72 [Test]
73 public void TestLlGetNotecardLine()
74 {
75 TestHelpers.InMethod();
76
77 string[] ncLines = { "One", "Twoè", "Three" };
78
79 TaskInventoryItem ncItem
80 = TaskInventoryHelpers.AddNotecard(m_scene.AssetService, m_so.RootPart, "nc", "1", "10", string.Join("\n", ncLines));
81
82 AssertValidNotecardLine(ncItem.Name, 0, ncLines[0]);
83 AssertValidNotecardLine(ncItem.Name, 2, ncLines[2]);
84 AssertValidNotecardLine(ncItem.Name, 3, ScriptBaseClass.EOF);
85 AssertValidNotecardLine(ncItem.Name, 4, ScriptBaseClass.EOF);
86
87 // XXX: Is this correct or do we really expect no dataserver event to fire at all?
88 AssertValidNotecardLine(ncItem.Name, -1, "");
89 AssertValidNotecardLine(ncItem.Name, -2, "");
90 }
91
92 [Test]
93 public void TestLlGetNotecardLine_NoNotecard()
94 {
95 TestHelpers.InMethod();
96
97 AssertInValidNotecardLine("nc", 0);
98 }
99
100 [Test]
101 public void TestLlGetNotecardLine_NotANotecard()
102 {
103 TestHelpers.InMethod();
104
105 TaskInventoryItem ncItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart, "nc1", "Not important");
106
107 AssertInValidNotecardLine(ncItem.Name, 0);
108 }
109
110 private void AssertValidNotecardLine(string ncName, int lineNumber, string assertLine)
111 {
112 string key = m_lslApi.llGetNotecardLine(ncName, lineNumber);
113 Assert.That(key, Is.Not.EqualTo(UUID.Zero.ToString()));
114
115 Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(1));
116 Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID));
117
118 List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID];
119 Assert.That(events.Count, Is.EqualTo(1));
120 EventParams eventParams = events[0];
121
122 Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));
123 Assert.That(eventParams.Params[0].ToString(), Is.EqualTo(key));
124 Assert.That(eventParams.Params[1].ToString(), Is.EqualTo(assertLine));
125
126 m_engine.ClearPostedEvents();
127 }
128
129 private void AssertInValidNotecardLine(string ncName, int lineNumber)
130 {
131 string key = m_lslApi.llGetNotecardLine(ncName, lineNumber);
132 Assert.That(key, Is.EqualTo(UUID.Zero.ToString()));
133
134 Assert.That(m_engine.PostedEvents.Count, Is.EqualTo(0));
135 }
136
137// [Test]
138// public void TestLlReleaseUrl()
139// {
140// TestHelpers.InMethod();
141//
142// m_lslApi.llRequestURL();
143// string returnedUri = m_engine.PostedEvents[m_scriptItem.ItemID][0].Params[2].ToString();
144//
145// {
146// // Check that the initial number of URLs is correct
147// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
148// }
149//
150// {
151// // Check releasing a non-url
152// m_lslApi.llReleaseURL("GARBAGE");
153// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
154// }
155//
156// {
157// // Check releasing a non-existing url
158// m_lslApi.llReleaseURL("http://example.com");
159// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
160// }
161//
162// {
163// // Check URL release
164// m_lslApi.llReleaseURL(returnedUri);
165// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls));
166//
167// HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri);
168//
169// bool gotExpectedException = false;
170//
171// try
172// {
173// using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
174// {}
175// }
176// catch (WebException e)
177// {
178// using (HttpWebResponse response = (HttpWebResponse)e.Response)
179// gotExpectedException = response.StatusCode == HttpStatusCode.NotFound;
180// }
181//
182// Assert.That(gotExpectedException, Is.True);
183// }
184//
185// {
186// // Check releasing the same URL again
187// m_lslApi.llReleaseURL(returnedUri);
188// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls));
189// }
190// }
191//
192// [Test]
193// public void TestLlRequestUrl()
194// {
195// TestHelpers.InMethod();
196//
197// string requestId = m_lslApi.llRequestURL();
198// Assert.That(requestId, Is.Not.EqualTo(UUID.Zero.ToString()));
199// string returnedUri;
200//
201// {
202// // Check that URL is correctly set up
203// Assert.That(m_lslApi.llGetFreeURLs().value, Is.EqualTo(m_urlModule.TotalUrls - 1));
204//
205// Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID));
206//
207// List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID];
208// Assert.That(events.Count, Is.EqualTo(1));
209// EventParams eventParams = events[0];
210// Assert.That(eventParams.EventName, Is.EqualTo("http_request"));
211//
212// UUID returnKey;
213// string rawReturnKey = eventParams.Params[0].ToString();
214// string method = eventParams.Params[1].ToString();
215// returnedUri = eventParams.Params[2].ToString();
216//
217// Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True);
218// Assert.That(method, Is.EqualTo(ScriptBaseClass.URL_REQUEST_GRANTED));
219// Assert.That(Uri.IsWellFormedUriString(returnedUri, UriKind.Absolute), Is.True);
220// }
221//
222// {
223// // Check that request to URL works.
224// string testResponse = "Hello World";
225//
226// m_engine.ClearPostedEvents();
227// m_engine.PostEventHook
228// += (itemId, evp) => m_lslApi.llHTTPResponse(evp.Params[0].ToString(), 200, testResponse);
229//
230//// Console.WriteLine("Trying {0}", returnedUri);
231// HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(returnedUri);
232//
233// AssertHttpResponse(returnedUri, testResponse);
234//
235// Assert.That(m_engine.PostedEvents.ContainsKey(m_scriptItem.ItemID));
236//
237// List<EventParams> events = m_engine.PostedEvents[m_scriptItem.ItemID];
238// Assert.That(events.Count, Is.EqualTo(1));
239// EventParams eventParams = events[0];
240// Assert.That(eventParams.EventName, Is.EqualTo("http_request"));
241//
242// UUID returnKey;
243// string rawReturnKey = eventParams.Params[0].ToString();
244// string method = eventParams.Params[1].ToString();
245// string body = eventParams.Params[2].ToString();
246//
247// Assert.That(UUID.TryParse(rawReturnKey, out returnKey), Is.True);
248// Assert.That(method, Is.EqualTo("GET"));
249// Assert.That(body, Is.EqualTo(""));
250// }
251// }
252//
253// private void AssertHttpResponse(string uri, string expectedResponse)
254// {
255// HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
256//
257// using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
258// {
259// using (Stream stream = webResponse.GetResponseStream())
260// {
261// using (StreamReader reader = new StreamReader(stream))
262// {
263// Assert.That(reader.ReadToEnd(), Is.EqualTo(expectedResponse));
264// }
265// }
266// }
267// }
268 }
269}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs
new file mode 100644
index 0000000..d957bf2
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs
@@ -0,0 +1,398 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance;
45using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
46using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common;
48using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
49using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
50
51namespace OpenSim.Region.ScriptEngine.Shared.Tests
52{
53 [TestFixture]
54 public class LSL_ApiObjectTests : OpenSimTestCase
55 {
56 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
57 private const float FLOAT_ACCURACY = 0.00005f;
58
59 protected Scene m_scene;
60 protected XEngine.XEngine m_engine;
61
62 [SetUp]
63 public override void SetUp()
64 {
65 base.SetUp();
66
67 IConfigSource initConfigSource = new IniConfigSource();
68 IConfig config = initConfigSource.AddConfig("XEngine");
69 config.Set("Enabled", "true");
70
71 m_scene = new SceneHelpers().SetupScene();
72 SceneHelpers.SetupSceneModules(m_scene, initConfigSource);
73
74 m_engine = new XEngine.XEngine();
75 m_engine.Initialise(initConfigSource);
76 m_engine.AddRegion(m_scene);
77 }
78
79 [Test]
80 public void TestllGetLinkPrimitiveParams()
81 {
82 TestHelpers.InMethod();
83 TestHelpers.EnableLogging();
84
85 UUID ownerId = TestHelpers.ParseTail(0x1);
86
87 SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10);
88 grp1.AbsolutePosition = new Vector3(10, 11, 12);
89 m_scene.AddSceneObject(grp1);
90
91 LSL_Api apiGrp1 = new LSL_Api();
92 apiGrp1.Initialize(m_engine, grp1.RootPart, null);
93
94 // Check simple 1 prim case
95 {
96 LSL_List resList
97 = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
98
99 Assert.That(resList.Length, Is.EqualTo(1));
100 }
101
102 // Check 2 prim case
103 {
104 LSL_List resList
105 = apiGrp1.llGetLinkPrimitiveParams(
106 1,
107 new LSL_List(
108 new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
109 new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
110 new LSL_Integer(2),
111 new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
112
113 Assert.That(resList.Length, Is.EqualTo(2));
114 }
115
116 // Check invalid parameters are ignored
117 {
118 LSL_List resList
119 = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
120
121 Assert.That(resList.Length, Is.EqualTo(0));
122 }
123
124 // Check all parameters are ignored if an initial bad link is given
125 {
126 LSL_List resList
127 = apiGrp1.llGetLinkPrimitiveParams(
128 3,
129 new LSL_List(
130 new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
131 new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
132 new LSL_Integer(1),
133 new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
134
135 Assert.That(resList.Length, Is.EqualTo(0));
136 }
137
138 // Check only subsequent parameters are ignored when we hit the first bad link number
139 {
140 LSL_List resList
141 = apiGrp1.llGetLinkPrimitiveParams(
142 1,
143 new LSL_List(
144 new LSL_Integer(ScriptBaseClass.PRIM_ROTATION),
145 new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET),
146 new LSL_Integer(3),
147 new LSL_Integer(ScriptBaseClass.PRIM_ROTATION)));
148
149 Assert.That(resList.Length, Is.EqualTo(1));
150 }
151 }
152
153 [Test]
154 // llSetPrimitiveParams and llGetPrimitiveParams test.
155 public void TestllSetPrimitiveParams()
156 {
157 TestHelpers.InMethod();
158
159 // Create Prim1.
160 Scene scene = new SceneHelpers().SetupScene();
161 string obj1Name = "Prim1";
162 UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
163 SceneObjectPart part1 =
164 new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
165 Vector3.Zero, Quaternion.Identity,
166 Vector3.Zero) { Name = obj1Name, UUID = objUuid };
167 Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);
168
169 LSL_Api apiGrp1 = new LSL_Api();
170 apiGrp1.Initialize(m_engine, part1, null);
171
172 // Note that prim hollow check is passed with the other prim params in order to allow the
173 // specification of a different check value from the prim param. A cylinder, prism, sphere,
174 // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below
175 // specifies a value of 95% and checks to see if 70% was properly returned.
176
177 // Test a sphere.
178 CheckllSetPrimitiveParams(
179 apiGrp1,
180 "test 1", // Prim test identification string
181 new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
182 ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
183 ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
184 new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
185 0.80f, // Prim hollow
186 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
187 new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple
188 0.80f); // Prim hollow check
189
190 // Test a prism.
191 CheckllSetPrimitiveParams(
192 apiGrp1,
193 "test 2", // Prim test identification string
194 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
195 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
196 ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
197 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
198 0.90f, // Prim hollow
199 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
200 new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
201 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
202 0.90f); // Prim hollow check
203
204 // Test a box.
205 CheckllSetPrimitiveParams(
206 apiGrp1,
207 "test 3", // Prim test identification string
208 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
209 ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
210 ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
211 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
212 0.99f, // Prim hollow
213 new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
214 new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
215 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
216 0.99f); // Prim hollow check
217
218 // Test a tube.
219 CheckllSetPrimitiveParams(
220 apiGrp1,
221 "test 4", // Prim test identification string
222 new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size
223 ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type
224 ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
225 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
226 0.00f, // Prim hollow
227 new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
228 new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size
229 // Expression for y selected to test precision problems during byte
230 // cast in SetPrimitiveShapeParams.
231 new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear
232 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
233 // Expression for y selected to test precision problems during sbyte
234 // cast in SetPrimitiveShapeParams.
235 new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper
236 1.11f, // Prim revolutions
237 0.88f, // Prim radius
238 0.95f, // Prim skew
239 0.00f); // Prim hollow check
240
241 // Test a prism.
242 CheckllSetPrimitiveParams(
243 apiGrp1,
244 "test 5", // Prim test identification string
245 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
246 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
247 ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
248 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
249 0.99f, // Prim hollow
250 // Expression for x selected to test precision problems during sbyte
251 // cast in SetPrimitiveShapeBlockParams.
252 new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist
253 // Expression for y selected to test precision problems during sbyte
254 // cast in SetPrimitiveShapeParams.
255 new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper
256 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
257 0.70f); // Prim hollow check
258
259 // Test a sculpted prim.
260 CheckllSetPrimitiveParams(
261 apiGrp1,
262 "test 6", // Prim test identification string
263 new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size
264 ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type
265 "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map
266 ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type
267 }
268
269 // Set prim params for a box, cylinder or prism and check results.
270 public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
271 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
272 float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear,
273 float primHollowCheck)
274 {
275 // Set the prim params.
276 api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
277 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
278 primCut, primHollow, primTwist, primTaper, primShear));
279
280 // Get params for prim to validate settings.
281 LSL_Types.list primParams =
282 api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
283
284 // Validate settings.
285 CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
286 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
287 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
288 Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
289 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
290 CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut");
291 Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
292 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
293 CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist");
294 CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 6), primTest + " prim taper");
295 CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear");
296 }
297
298 // Set prim params for a sphere and check results.
299 public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
300 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
301 float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck)
302 {
303 // Set the prim params.
304 api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
305 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
306 primCut, primHollow, primTwist, primDimple));
307
308 // Get params for prim to validate settings.
309 LSL_Types.list primParams =
310 api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
311
312 // Validate settings.
313 CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
314 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
315 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
316 Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
317 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
318 CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut");
319 Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
320 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
321 CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist");
322 CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple");
323 }
324
325 // Set prim params for a torus, tube or ring and check results.
326 public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
327 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
328 float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
329 LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
330 float primRev, float primRadius, float primSkew, float primHollowCheck)
331 {
332 // Set the prim params.
333 api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
334 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
335 primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
336 primTaper, primRev, primRadius, primSkew));
337
338 // Get params for prim to validate settings.
339 LSL_Types.list primParams =
340 api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
341
342 // Valdate settings.
343 CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
344 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
345 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
346 Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2),
347 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
348 CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut");
349 Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY,
350 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
351 CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist");
352 CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size");
353 CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear");
354 CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut");
355 CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper");
356 Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY,
357 "TestllSetPrimitiveParams " + primTest + " prim revolutions fail");
358 Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY,
359 "TestllSetPrimitiveParams " + primTest + " prim radius fail");
360 Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY,
361 "TestllSetPrimitiveParams " + primTest + " prim skew fail");
362 }
363
364 // Set prim params for a sculpted prim and check results.
365 public void CheckllSetPrimitiveParams(LSL_Api api, string primTest,
366 LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType)
367 {
368 // Set the prim params.
369 api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
370 ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType));
371
372 // Get params for prim to validate settings.
373 LSL_Types.list primParams =
374 api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
375
376 // Validate settings.
377 CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size");
378 Assert.AreEqual(primType, api.llList2Integer(primParams, 1),
379 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
380 Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2),
381 "TestllSetPrimitiveParams " + primTest + " prim map check fail");
382 Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3),
383 "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail");
384 }
385
386 public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
387 {
388 // Check each vector component against expected result.
389 Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
390 "TestllSetPrimitiveParams " + msg + " vector check fail on x component");
391 Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
392 "TestllSetPrimitiveParams " + msg + " vector check fail on y component");
393 Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
394 "TestllSetPrimitiveParams " + msg + " vector check fail on z component");
395 }
396
397 }
398}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index c41d1e7..d929da8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -33,10 +33,10 @@ using OpenSim.Region.ScriptEngine.Shared;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
36using OpenSim.Region.ScriptEngine.Shared.Instance;
36using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 37using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
37using OpenMetaverse; 38using OpenMetaverse;
38using System; 39using System;
39using OpenSim.Tests.Common.Mock;
40 40
41namespace OpenSim.Region.ScriptEngine.Shared.Tests 41namespace OpenSim.Region.ScriptEngine.Shared.Tests
42{ 42{
@@ -46,9 +46,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
46 [TestFixture, LongRunning] 46 [TestFixture, LongRunning]
47 public class LSL_ApiTest 47 public class LSL_ApiTest
48 { 48 {
49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
50 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; 49 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
51 private const float FLOAT_ACCURACY = 0.00005f; 50 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
52 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
53 52
54 [SetUp] 53 [SetUp]
@@ -254,241 +253,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
254 } 253 }
255 254
256 [Test] 255 [Test]
257 // llSetPrimitiveParams and llGetPrimitiveParams test.
258 public void TestllSetPrimitiveParams()
259 {
260 TestHelpers.InMethod();
261
262 // Create Prim1.
263 Scene scene = new SceneHelpers().SetupScene();
264 string obj1Name = "Prim1";
265 UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
266 SceneObjectPart part1 =
267 new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default,
268 Vector3.Zero, Quaternion.Identity,
269 Vector3.Zero) { Name = obj1Name, UUID = objUuid };
270 Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True);
271
272 // Note that prim hollow check is passed with the other prim params in order to allow the
273 // specification of a different check value from the prim param. A cylinder, prism, sphere,
274 // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below
275 // specifies a value of 95% and checks to see if 70% was properly returned.
276
277 // Test a sphere.
278 CheckllSetPrimitiveParams(
279 "test 1", // Prim test identification string
280 new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
281 ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
282 ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
283 new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
284 0.80f, // Prim hollow
285 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
286 new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple
287 0.80f); // Prim hollow check
288
289 // Test a prism.
290 CheckllSetPrimitiveParams(
291 "test 2", // Prim test identification string
292 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
293 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
294 ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
295 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
296 0.90f, // Prim hollow
297 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
298 new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
299 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
300 0.90f); // Prim hollow check
301
302 // Test a box.
303 CheckllSetPrimitiveParams(
304 "test 3", // Prim test identification string
305 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
306 ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
307 ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
308 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
309 0.95f, // Prim hollow
310 new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
311 new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
312 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
313 0.95f); // Prim hollow check
314
315 // Test a tube.
316 CheckllSetPrimitiveParams(
317 "test 4", // Prim test identification string
318 new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size
319 ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type
320 ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
321 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
322 0.00f, // Prim hollow
323 new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
324 new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size
325 // Expression for y selected to test precision problems during byte
326 // cast in SetPrimitiveShapeParams.
327 new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear
328 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
329 // Expression for y selected to test precision problems during sbyte
330 // cast in SetPrimitiveShapeParams.
331 new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper
332 1.11f, // Prim revolutions
333 0.88f, // Prim radius
334 0.95f, // Prim skew
335 0.00f); // Prim hollow check
336
337 // Test a prism.
338 CheckllSetPrimitiveParams(
339 "test 5", // Prim test identification string
340 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
341 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
342 ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type
343 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
344 0.95f, // Prim hollow
345 // Expression for x selected to test precision problems during sbyte
346 // cast in SetPrimitiveShapeBlockParams.
347 new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist
348 // Expression for y selected to test precision problems during sbyte
349 // cast in SetPrimitiveShapeParams.
350 new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper
351 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
352 0.70f); // Prim hollow check
353
354 // Test a sculpted prim.
355 CheckllSetPrimitiveParams(
356 "test 6", // Prim test identification string
357 new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size
358 ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type
359 "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map
360 ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type
361 }
362
363 // Set prim params for a box, cylinder or prism and check results.
364 public void CheckllSetPrimitiveParams(string primTest,
365 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
366 float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear,
367 float primHollowCheck)
368 {
369 // Set the prim params.
370 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
371 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
372 primCut, primHollow, primTwist, primTaper, primShear));
373
374 // Get params for prim to validate settings.
375 LSL_Types.list primParams =
376 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
377
378 // Validate settings.
379 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
380 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
381 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
382 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
383 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
384 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
385 Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
386 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
387 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
388 CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper");
389 CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
390 }
391
392 // Set prim params for a sphere and check results.
393 public void CheckllSetPrimitiveParams(string primTest,
394 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
395 float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck)
396 {
397 // Set the prim params.
398 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
399 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
400 primCut, primHollow, primTwist, primDimple));
401
402 // Get params for prim to validate settings.
403 LSL_Types.list primParams =
404 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
405
406 // Validate settings.
407 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
408 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
409 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
410 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
411 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
412 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
413 Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
414 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
415 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
416 CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple");
417 }
418
419 // Set prim params for a torus, tube or ring and check results.
420 public void CheckllSetPrimitiveParams(string primTest,
421 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
422 float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
423 LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
424 float primRev, float primRadius, float primSkew, float primHollowCheck)
425 {
426 // Set the prim params.
427 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
428 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
429 primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
430 primTaper, primRev, primRadius, primSkew));
431
432 // Get params for prim to validate settings.
433 LSL_Types.list primParams =
434 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
435
436 // Valdate settings.
437 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
438 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
439 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
440 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
441 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
442 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
443 Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
444 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
445 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
446 CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size");
447 CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
448 CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut");
449 CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper");
450 Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY,
451 "TestllSetPrimitiveParams " + primTest + " prim revolutions fail");
452 Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY,
453 "TestllSetPrimitiveParams " + primTest + " prim radius fail");
454 Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY,
455 "TestllSetPrimitiveParams " + primTest + " prim skew fail");
456 }
457
458 // Set prim params for a sculpted prim and check results.
459 public void CheckllSetPrimitiveParams(string primTest,
460 LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType)
461 {
462 // Set the prim params.
463 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
464 ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType));
465
466 // Get params for prim to validate settings.
467 LSL_Types.list primParams =
468 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
469
470 // Validate settings.
471 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
472 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
473 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
474 Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2),
475 "TestllSetPrimitiveParams " + primTest + " prim map check fail");
476 Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3),
477 "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail");
478 }
479
480 public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
481 {
482 // Check each vector component against expected result.
483 Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
484 "TestllSetPrimitiveParams " + msg + " vector check fail on x component");
485 Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
486 "TestllSetPrimitiveParams " + msg + " vector check fail on y component");
487 Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
488 "TestllSetPrimitiveParams " + msg + " vector check fail on z component");
489 }
490
491 [Test]
492 public void TestllVecNorm() 256 public void TestllVecNorm()
493 { 257 {
494 TestHelpers.InMethod(); 258 TestHelpers.InMethod();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs
new file mode 100644
index 0000000..a8964bf
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiUserTests.cs
@@ -0,0 +1,157 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Threading;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.ScriptEngine.Shared.Api;
37using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
38using OpenSim.Services.Interfaces;
39using OpenSim.Tests.Common;
40
41namespace OpenSim.Region.ScriptEngine.Shared.Tests
42{
43 [TestFixture]
44 public class LSL_ApiUserTests : OpenSimTestCase
45 {
46 private Scene m_scene;
47 private MockScriptEngine m_engine;
48
49 [SetUp]
50 public override void SetUp()
51 {
52 base.SetUp();
53
54 m_engine = new MockScriptEngine();
55
56 m_scene = new SceneHelpers().SetupScene();
57 SceneHelpers.SetupSceneModules(m_scene, m_engine);
58 }
59
60 [Test]
61 public void TestLlRequestAgentDataOnline()
62 {
63 TestHelpers.InMethod();
64// TestHelpers.EnableLogging();
65
66 UUID userId = TestHelpers.ParseTail(0x1);
67
68 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
69
70 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
71 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, part);
72
73 LSL_Api apiGrp1 = new LSL_Api();
74 apiGrp1.Initialize(m_engine, part, scriptItem);
75
76 // Initially long timeout to test cache
77 apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20000;
78
79 // Offline test
80 {
81 apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);
82
83 Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));
84
85 List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
86 Assert.That(events.Count, Is.EqualTo(1));
87 EventParams eventParams = events[0];
88 Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));
89
90 string data = eventParams.Params[1].ToString();
91 Assert.AreEqual(0, int.Parse(data));
92
93 m_engine.PostedEvents.Clear();
94 }
95
96 // Online test. Should get the 'wrong' result because of caching.
97 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1);
98
99 {
100 apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);
101
102 Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));
103
104 List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
105 Assert.That(events.Count, Is.EqualTo(1));
106 EventParams eventParams = events[0];
107 Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));
108
109 string data = eventParams.Params[1].ToString();
110 Assert.AreEqual(0, int.Parse(data));
111
112 m_engine.PostedEvents.Clear();
113 }
114
115 apiGrp1.LlRequestAgentDataCacheTimeoutMs = 1;
116
117 // Make absolutely sure that we should trigger cache timeout.
118 Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 1);
119
120 {
121 apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);
122
123 Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));
124
125 List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
126 Assert.That(events.Count, Is.EqualTo(1));
127 EventParams eventParams = events[0];
128 Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));
129
130 string data = eventParams.Params[1].ToString();
131 Assert.AreEqual(1, int.Parse(data));
132
133 m_engine.PostedEvents.Clear();
134 }
135
136 m_scene.CloseAgent(userId, false);
137
138 Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 1 + 1);
139
140 {
141 apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);
142
143 Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));
144
145 List<EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
146 Assert.That(events.Count, Is.EqualTo(1));
147 EventParams eventParams = events[0];
148 Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));
149
150 string data = eventParams.Params[1].ToString();
151 Assert.AreEqual(0, int.Parse(data));
152
153 m_engine.PostedEvents.Clear();
154 }
155 }
156 }
157}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index 1381d2b..2f9a564 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -41,9 +41,9 @@ using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared; 42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api; 43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance;
44using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common; 46using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47 47
48namespace OpenSim.Region.ScriptEngine.Shared.Tests 48namespace OpenSim.Region.ScriptEngine.Shared.Tests
49{ 49{
@@ -158,4 +158,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
158 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); 158 Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight));
159 } 159 }
160 } 160 }
161} \ No newline at end of file 161}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs
index 5ed1f3d..b6b3f12 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs
@@ -41,9 +41,9 @@ using OpenSim.Region.CoreModules.Framework.InventoryAccess;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared; 42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api; 43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance;
44using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common; 46using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47 47
48namespace OpenSim.Region.ScriptEngine.Shared.Tests 48namespace OpenSim.Region.ScriptEngine.Shared.Tests
49{ 49{
@@ -96,7 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
96 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); 96 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
97 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); 97 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
98 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); 98 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
99 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); 99 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart);
100 100
101 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); 101 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
102 OSSL_Api osslApi = new OSSL_Api(); 102 OSSL_Api osslApi = new OSSL_Api();
@@ -105,7 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
105// SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); 105// SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID);
106 106
107 // Create an object embedded inside the first 107 // Create an object embedded inside the first
108 TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); 108 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);
109 109
110 osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); 110 osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
111 111
@@ -142,7 +142,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
142 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1); 142 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
143 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID); 143 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
144 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); 144 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
145 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); 145 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart);
146 146
147 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); 147 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
148 OSSL_Api osslApi = new OSSL_Api(); 148 OSSL_Api osslApi = new OSSL_Api();
@@ -150,7 +150,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
150 150
151 // Create an object embedded inside the first 151 // Create an object embedded inside the first
152 TaskInventoryHelpers.AddNotecard( 152 TaskInventoryHelpers.AddNotecard(
153 m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900)); 153 m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!");
154 154
155 bool exceptionCaught = false; 155 bool exceptionCaught = false;
156 156
@@ -190,14 +190,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
190 190
191 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1); 191 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1);
192 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID); 192 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
193 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart); 193 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart);
194 194
195 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem); 195 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
196 OSSL_Api osslApi = new OSSL_Api(); 196 OSSL_Api osslApi = new OSSL_Api();
197 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); 197 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
198 198
199 // Create an object embedded inside the first 199 // Create an object embedded inside the first
200 TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); 200 TaskInventoryHelpers.AddSceneObject(
201 m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);
201 202
202 ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2); 203 ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2);
203 204
@@ -228,4 +229,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
228 Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint)); 229 Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint));
229 } 230 }
230 } 231 }
231} \ No newline at end of file 232}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index d6c82f1..99bff83 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -42,10 +42,10 @@ using OpenSim.Region.OptionalModules.World.NPC;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.ScriptEngine.Shared; 43using OpenSim.Region.ScriptEngine.Shared;
44using OpenSim.Region.ScriptEngine.Shared.Api; 44using OpenSim.Region.ScriptEngine.Shared.Api;
45using OpenSim.Region.ScriptEngine.Shared.Instance;
45using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 46using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
46using OpenSim.Services.Interfaces; 47using OpenSim.Services.Interfaces;
47using OpenSim.Tests.Common; 48using OpenSim.Tests.Common;
48using OpenSim.Tests.Common.Mock;
49 49
50namespace OpenSim.Region.ScriptEngine.Shared.Tests 50namespace OpenSim.Region.ScriptEngine.Shared.Tests
51{ 51{
@@ -179,6 +179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
179 public void TestOsNpcLoadAppearance() 179 public void TestOsNpcLoadAppearance()
180 { 180 {
181 TestHelpers.InMethod(); 181 TestHelpers.InMethod();
182 //TestHelpers.EnableLogging();
182 183
183 // Store an avatar with a different height from default in a notecard. 184 // Store an avatar with a different height from default in a notecard.
184 UUID userId = TestHelpers.ParseTail(0x1); 185 UUID userId = TestHelpers.ParseTail(0x1);
@@ -221,7 +222,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
221 // Store an avatar with a different height from default in a notecard. 222 // Store an avatar with a different height from default in a notecard.
222 UUID userId = TestHelpers.ParseTail(0x1); 223 UUID userId = TestHelpers.ParseTail(0x1);
223 float firstHeight = 1.9f; 224 float firstHeight = 1.9f;
224 float secondHeight = 2.1f; 225// float secondHeight = 2.1f;
225 string firstAppearanceNcName = "appearanceNc1"; 226 string firstAppearanceNcName = "appearanceNc1";
226 string secondAppearanceNcName = "appearanceNc2"; 227 string secondAppearanceNcName = "appearanceNc2";
227 228
@@ -347,4 +348,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
347 Assert.That(npc, Is.Null); 348 Assert.That(npc, Is.Null);
348 } 349 }
349 } 350 }
350} \ No newline at end of file 351}