opensim-development – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 | |||
28 | using System; |
||
29 | using System.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | using System.Text; |
||
32 | using log4net; |
||
33 | using Nini.Config; |
||
34 | using NUnit.Framework; |
||
35 | using OpenMetaverse; |
||
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.Region.ScriptEngine.Shared.ScriptBase; |
||
46 | using OpenSim.Services.Interfaces; |
||
47 | using OpenSim.Tests.Common; |
||
48 | using OpenSim.Tests.Common.Mock; |
||
49 | |||
50 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
||
51 | { |
||
52 | /// <summary> |
||
53 | /// Tests for linking functions in LSL |
||
54 | /// </summary> |
||
55 | /// <remarks> |
||
56 | /// This relates to LSL. Actual linking functionality should be tested in the main |
||
57 | /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. |
||
58 | /// </remarks> |
||
59 | [TestFixture] |
||
60 | public class LSL_ApiLinkingTests : OpenSimTestCase |
||
61 | { |
||
62 | protected Scene m_scene; |
||
63 | protected XEngine.XEngine m_engine; |
||
64 | |||
65 | [SetUp] |
||
66 | public override void SetUp() |
||
67 | { |
||
68 | base.SetUp(); |
||
69 | |||
70 | IConfigSource initConfigSource = new IniConfigSource(); |
||
71 | IConfig config = initConfigSource.AddConfig("XEngine"); |
||
72 | config.Set("Enabled", "true"); |
||
73 | |||
74 | m_scene = new SceneHelpers().SetupScene(); |
||
75 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); |
||
76 | |||
77 | m_engine = new XEngine.XEngine(); |
||
78 | m_engine.Initialise(initConfigSource); |
||
79 | m_engine.AddRegion(m_scene); |
||
80 | } |
||
81 | |||
82 | [Test] |
||
83 | public void TestllCreateLink() |
||
84 | { |
||
85 | TestHelpers.InMethod(); |
||
86 | |||
87 | UUID ownerId = TestHelpers.ParseTail(0x1); |
||
88 | |||
89 | SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); |
||
90 | grp1.AbsolutePosition = new Vector3(10, 10, 10); |
||
91 | m_scene.AddSceneObject(grp1); |
||
92 | |||
93 | // FIXME: This should really be a script item (with accompanying script) |
||
94 | TaskInventoryItem grp1Item |
||
95 | = TaskInventoryHelpers.AddNotecard( |
||
96 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
||
97 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
||
98 | |||
99 | SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); |
||
100 | grp2.AbsolutePosition = new Vector3(20, 20, 20); |
||
101 | |||
102 | // <180,0,0> |
||
103 | grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); |
||
104 | |||
105 | m_scene.AddSceneObject(grp2); |
||
106 | |||
107 | LSL_Api apiGrp1 = new LSL_Api(); |
||
108 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); |
||
109 | |||
110 | apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE); |
||
111 | |||
112 | Assert.That(grp1.Parts.Length, Is.EqualTo(4)); |
||
113 | Assert.That(grp2.IsDeleted, Is.True); |
||
114 | } |
||
115 | |||
116 | [Test] |
||
117 | public void TestllBreakLink() |
||
118 | { |
||
119 | TestHelpers.InMethod(); |
||
120 | |||
121 | UUID ownerId = TestHelpers.ParseTail(0x1); |
||
122 | |||
123 | SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); |
||
124 | grp1.AbsolutePosition = new Vector3(10, 10, 10); |
||
125 | m_scene.AddSceneObject(grp1); |
||
126 | |||
127 | // FIXME: This should really be a script item (with accompanying script) |
||
128 | TaskInventoryItem grp1Item |
||
129 | = TaskInventoryHelpers.AddNotecard( |
||
130 | m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900), "Hello World!"); |
||
131 | |||
132 | grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
||
133 | |||
134 | LSL_Api apiGrp1 = new LSL_Api(); |
||
135 | apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item, null); |
||
136 | |||
137 | apiGrp1.llBreakLink(2); |
||
138 | |||
139 | Assert.That(grp1.Parts.Length, Is.EqualTo(1)); |
||
140 | |||
141 | SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1"); |
||
142 | Assert.That(grp2, Is.Not.Null); |
||
143 | } |
||
144 | } |
||
145 | } |