diff options
author | Justin Clark-Casey (justincc) | 2014-02-26 23:13:42 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-02-26 23:13:56 +0000 |
commit | ce5d308d232a37ea3840185bb513b83c1254d7f0 (patch) | |
tree | 9b780fa31217dad41fe8744717596245796f1269 /OpenSim | |
parent | Implement PRIM_ROTATION, PRIM_ROT_LOCAL, PRIM_POSITION and PRIM_POS_LOCAL whe... (diff) | |
download | opensim-SC_OLD-ce5d308d232a37ea3840185bb513b83c1254d7f0.zip opensim-SC_OLD-ce5d308d232a37ea3840185bb513b83c1254d7f0.tar.gz opensim-SC_OLD-ce5d308d232a37ea3840185bb513b83c1254d7f0.tar.bz2 opensim-SC_OLD-ce5d308d232a37ea3840185bb513b83c1254d7f0.tar.xz |
Add some regression tests for previous commit 0e23374
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs | 115 |
1 files changed, 115 insertions, 0 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..167fe78 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs | |||
@@ -0,0 +1,115 @@ | |||
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 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
50 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
51 | |||
52 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
53 | { | ||
54 | /// <summary> | ||
55 | /// Tests relating directly to avatars | ||
56 | /// </summary> | ||
57 | [TestFixture] | ||
58 | public class LSL_ApiAvatarTests : OpenSimTestCase | ||
59 | { | ||
60 | protected Scene m_scene; | ||
61 | protected XEngine.XEngine m_engine; | ||
62 | |||
63 | [SetUp] | ||
64 | public override void SetUp() | ||
65 | { | ||
66 | base.SetUp(); | ||
67 | |||
68 | IConfigSource initConfigSource = new IniConfigSource(); | ||
69 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
70 | config.Set("Enabled", "true"); | ||
71 | |||
72 | m_scene = new SceneHelpers().SetupScene(); | ||
73 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | ||
74 | |||
75 | m_engine = new XEngine.XEngine(); | ||
76 | m_engine.Initialise(initConfigSource); | ||
77 | m_engine.AddRegion(m_scene); | ||
78 | } | ||
79 | |||
80 | [Test] | ||
81 | public void TestllSetLinkPrimitiveParamsForAgent() | ||
82 | { | ||
83 | TestHelpers.InMethod(); | ||
84 | |||
85 | UUID userId = TestHelpers.ParseTail(0x1); | ||
86 | |||
87 | new SceneHelpers().SetupScene(); | ||
88 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; | ||
89 | |||
90 | LSL_Api apiGrp1 = new LSL_Api(); | ||
91 | apiGrp1.Initialize(m_engine, part, null, null); | ||
92 | |||
93 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
94 | |||
95 | // sp has to be less than 10 meters away from 0, 0, 0 (default part position) | ||
96 | Vector3 startPos = new Vector3(3, 2, 1); | ||
97 | sp.AbsolutePosition = startPos; | ||
98 | |||
99 | sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); | ||
100 | |||
101 | // Test position | ||
102 | Vector3 newPos = new Vector3(1, 2, 3); | ||
103 | apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); | ||
104 | |||
105 | Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); | ||
106 | |||
107 | // Test rotation | ||
108 | Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); | ||
109 | apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); | ||
110 | |||
111 | Assert.That( | ||
112 | sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); | ||
113 | } | ||
114 | } | ||
115 | } \ No newline at end of file | ||