29 using System.Collections.Generic;
30 using System.Reflection;
34 using NUnit.Framework;
36 using OpenMetaverse.Assets;
37 using OpenMetaverse.StructuredData;
38 using OpenSim.Framework;
39 using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40 using OpenSim.Region.OptionalModules.World.NPC;
41 using OpenSim.Region.Framework.Scenes;
42 using OpenSim.Region.ScriptEngine.Shared;
43 using OpenSim.Region.ScriptEngine.Shared.Api;
44 using OpenSim.Region.ScriptEngine.Shared.Instance;
45 using OpenSim.Services.Interfaces;
46 using OpenSim.Tests.Common;
49 namespace OpenSim.
Region.ScriptEngine.Shared.Tests
65 IConfigSource initConfigSource =
new IniConfigSource();
66 IConfig config = initConfigSource.AddConfig(
"XEngine");
67 config.Set(
"Enabled",
"true");
70 SceneHelpers.SetupSceneModules(m_scene, initConfigSource);
73 m_engine.Initialise(initConfigSource);
74 m_engine.AddRegion(m_scene);
83 TestHelpers.InMethod();
86 UUID userId = TestHelpers.ParseTail(0x1);
87 string inventoryItemName =
"item1";
89 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, userId,
"so1", 0x10);
90 m_scene.AddSceneObject(so1);
93 UUID itemId = TestHelpers.ParseTail(0x20);
94 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, userId);
97 api.Initialize(m_engine, so1.RootPart, null);
100 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId,
"so2", 0x100);
101 m_scene.AddSceneObject(so2);
103 api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);
106 List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems();
107 Assert.That(originalItems.Count, Is.EqualTo(1));
109 List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName);
110 Assert.That(copiedItems.Count, Is.EqualTo(1));
111 Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName));
120 TestHelpers.InMethod();
123 UUID user1Id = TestHelpers.ParseTail(0x1);
124 UUID user2Id = TestHelpers.ParseTail(0x2);
125 string inventoryItemName =
"item1";
127 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id,
"so1", 0x10);
128 m_scene.AddSceneObject(so1);
130 api.Initialize(m_engine, so1.RootPart, null);
133 UUID itemId = TestHelpers.ParseTail(0x20);
134 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);
137 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id,
"so2", 0x100);
138 m_scene.AddSceneObject(so2);
140 api2.Initialize(m_engine, so2.RootPart, null);
143 api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);
147 List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems();
148 Assert.That(originalItems.Count, Is.EqualTo(1));
151 List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName);
152 Assert.That(copiedItems.Count, Is.EqualTo(0));
156 api2.llAllowInventoryDrop(1);
157 api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);
161 List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems();
162 Assert.That(originalItems.Count, Is.EqualTo(1));
165 List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName);
166 Assert.That(copiedItems.Count, Is.EqualTo(1));
167 Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName));
177 TestHelpers.InMethod();
180 UUID user1Id = TestHelpers.ParseTail(0x1);
181 UUID user2Id = TestHelpers.ParseTail(0x2);
182 string inventoryItemName =
"item1";
184 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id,
"so1", 0x10);
185 m_scene.AddSceneObject(so1);
187 api.Initialize(m_engine, so1.RootPart, null);
190 UUID itemId = TestHelpers.ParseTail(0x20);
191 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);
193 UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
195 api.llGiveInventory(user2Id.ToString(), inventoryItemName);
198 = UserInventoryHelpers.GetInventoryItem(
199 m_scene.InventoryService, user2Id, string.Format(
"Objects/{0}", inventoryItemName));
201 Assert.IsNotNull(receivedItem);
211 TestHelpers.InMethod();
214 UUID user1Id = TestHelpers.ParseTail(0x1);
215 UUID user2Id = TestHelpers.ParseTail(0x2);
216 string inventoryItemName =
"item1";
218 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id,
"so1", 0x10);
219 m_scene.AddSceneObject(so1);
221 api.Initialize(m_engine, so1.RootPart, null);
224 UUID itemId = TestHelpers.ParseTail(0x20);
226 = TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, so1.RootPart, inventoryItemName, itemId, user1Id);
229 UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id);
231 api.llGiveInventory(user2Id.ToString(), inventoryItemName);
234 = UserInventoryHelpers.GetInventoryItem(
235 m_scene.InventoryService, user2Id, string.Format(
"Objects/{0}", inventoryItemName));
237 Assert.IsNotNull(receivedItem);
238 Assert.AreEqual(0, receivedItem.CurrentPermissions & (uint)
PermissionMask.Modify);
244 TestHelpers.InMethod();
247 UUID user1Id = TestHelpers.ParseTail(0x1);
248 UUID user2Id = TestHelpers.ParseTail(0x2);
250 SceneObjectGroup sourceSo = SceneHelpers.AddSceneObject(m_scene,
"sourceSo", user1Id);
251 m_scene.AddSceneObject(sourceSo);
253 api.Initialize(m_engine, sourceSo.RootPart, null);
254 TaskInventoryHelpers.AddScript(m_scene.AssetService, sourceSo.RootPart,
"script",
"Hello World");
256 SceneObjectGroup targetSo = SceneHelpers.AddSceneObject(m_scene,
"targetSo", user1Id);
257 SceneObjectGroup otherOwnedTargetSo = SceneHelpers.AddSceneObject(m_scene,
"otherOwnedTargetSo", user2Id);
260 api.llRemoteLoadScriptPin(targetSo.UUID.ToString(),
"script", 0, 0, 0);
261 Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem(
"script"));
264 targetSo.RootPart.ScriptAccessPin = 5;
265 api.llRemoteLoadScriptPin(targetSo.UUID.ToString(),
"script", 3, 0, 0);
266 Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem(
"script"));
269 otherOwnedTargetSo.RootPart.ScriptAccessPin = 3;
270 api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(),
"script", 3, 0, 0);
271 Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem(
"script"));
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);
280 targetSo.RootPart.Inventory.RemoveInventoryItem(insertedItem.ItemID);
281 Assert.IsNull(targetSo.RootPart.Inventory.GetInventoryItem(
"script"));
283 targetSo.RootPart.ScriptAccessPin = 0;
284 api.llRemoteLoadScriptPin(otherOwnedTargetSo.UUID.ToString(),
"script", 3, 0, 0);
285 Assert.IsNull(otherOwnedTargetSo.RootPart.Inventory.GetInventoryItem(
"script"));
void TestLlGiveInventoryO2DifferentAvatarNoMod()
Test giving inventory from an object to an avatar that is not the object's owner and where the next p...
OpenSim.Framework.PermissionMask PermissionMask
Contains all LSL ll-functions. This class will be in Default AppDomain.
void TestLlRemoteLoadScriptPin()
Tests for inventory functions in LSL
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Represents an item in a task inventory
Inventory Item - contains all the properties associated with an individual inventory piece...
Helpers for setting up scenes.
void TestLlGiveInventoryO2OSameOwner()
Test giving inventory from an object to an object where both are owned by the same user...
void TestLlGiveInventoryO2DifferentAvatar()
Test giving inventory from an object to an avatar that is not the object's owner. ...
void TestLlGiveInventoryO2ODifferentOwners()
Test giving inventory from an object to an object where they have different owners ...