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.Attachments;
40 using OpenSim.Region.CoreModules.Framework.InventoryAccess;
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;
48 namespace OpenSim.
Region.ScriptEngine.Shared.Tests
67 IConfigSource initConfigSource =
new IniConfigSource();
69 IConfig xengineConfig = initConfigSource.AddConfig(
"XEngine");
70 xengineConfig.Set(
"Enabled",
"true");
71 xengineConfig.Set(
"AllowOSFunctions",
"true");
72 xengineConfig.Set(
"OSFunctionThreatLevel",
"Severe");
74 IConfig modulesConfig = initConfigSource.AddConfig(
"Modules");
75 modulesConfig.Set(
"InventoryAccessModule",
"BasicInventoryAccessModule");
78 SceneHelpers.SetupSceneModules(
82 m_engine.Initialise(initConfigSource);
83 m_engine.AddRegion(m_scene);
89 TestHelpers.InMethod();
92 string taskInvObjItemName =
"sphere";
93 UUID taskInvObjItemId = UUID.Parse(
"00000000-0000-0000-0000-100000000000");
96 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
97 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
98 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene,
"inWorldObj", ua1.PrincipalID);
99 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart);
101 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
103 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
108 TaskInventoryHelpers.AddSceneObject(m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);
110 osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
113 Assert.That(sp.HasAttachments(), Is.True);
114 List<SceneObjectGroup> attachments = sp.GetAttachments();
115 Assert.That(attachments.Count, Is.EqualTo(1));
117 Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName));
118 Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint));
119 Assert.That(attSo.IsAttachment);
120 Assert.That(attSo.UsesPhysics, Is.False);
121 Assert.That(attSo.IsTemporary, Is.False);
124 List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
125 Assert.That(attachmentsInAppearance.Count, Is.EqualTo(1));
126 Assert.That(sp.Appearance.GetAttachpoint(attachmentsInAppearance[0].ItemID), Is.EqualTo((uint)attachPoint));
135 TestHelpers.InMethod();
138 string taskInvObjItemName =
"sphere";
139 UUID taskInvObjItemId = UUID.Parse(
"00000000-0000-0000-0000-100000000000");
142 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
143 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
144 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene,
"inWorldObj", ua1.PrincipalID);
145 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart);
147 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
149 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
152 TaskInventoryHelpers.AddNotecard(
153 m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900),
"Hello World!");
155 bool exceptionCaught =
false;
159 osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
163 exceptionCaught =
true;
166 Assert.That(exceptionCaught, Is.True);
169 Assert.That(sp.HasAttachments(), Is.False);
170 List<SceneObjectGroup> attachments = sp.GetAttachments();
171 Assert.That(attachments.Count, Is.EqualTo(0));
174 List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
175 Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));
181 TestHelpers.InMethod();
184 string taskInvObjItemName =
"sphere";
185 UUID taskInvObjItemId = UUID.Parse(
"00000000-0000-0000-0000-100000000000");
188 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene,
"user",
"one", 0x1,
"pass");
189 UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene,
"user",
"two", 0x2,
"pass");
191 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1);
192 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene,
"inWorldObj", ua1.PrincipalID);
193 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, inWorldObj.RootPart);
195 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
197 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
200 TaskInventoryHelpers.AddSceneObject(
201 m_scene.AssetService, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);
203 ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2);
205 osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (
int)attachPoint);
208 Assert.That(sp.HasAttachments(), Is.False);
209 List<SceneObjectGroup> attachments = sp.GetAttachments();
210 Assert.That(attachments.Count, Is.EqualTo(0));
212 Assert.That(sp2.HasAttachments(), Is.True);
213 List<SceneObjectGroup> attachments2 = sp2.GetAttachments();
214 Assert.That(attachments2.Count, Is.EqualTo(1));
216 Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName));
217 Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID));
218 Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint));
219 Assert.That(attSo.IsAttachment);
220 Assert.That(attSo.UsesPhysics, Is.False);
221 Assert.That(attSo.IsTemporary, Is.False);
224 List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
225 Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));
227 List<AvatarAttachment> attachmentsInAppearance2 = sp2.Appearance.GetAttachments();
228 Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1));
229 Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint));
Contains all LSL ll-functions. This class will be in Default AppDomain.
Tests for OSSL attachment functions
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
Represents an item in a task inventory
void TestOsForceAttachToOtherAvatarFromInventory()
void TestOsForceAttachToAvatarFromInventory()
Helpers for setting up scenes.
void TestOsForceAttachToAvatarFromInventoryNotObject()
Make sure we can't force attach anything other than objects.