diff options
author | Justin Clark-Casey (justincc) | 2011-08-09 22:05:47 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-09 22:05:47 +0100 |
commit | 795c8e6c22d4174d942ad56e70a0acbe507e2ec7 (patch) | |
tree | b5eef28c55c1eeeb9d20c52d320de6f1037880bd /OpenSim/Region/ScriptEngine/Shared/Tests | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.zip opensim-SC_OLD-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.gz opensim-SC_OLD-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.bz2 opensim-SC_OLD-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.xz |
Add osOwnerSaveAppearance() to help with setting up NPC appearances. Not yet ready for user use.
Adds regression test.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Tests')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs new file mode 100644 index 0000000..fc8b551 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -0,0 +1,105 @@ | |||
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.Text; | ||
31 | using Nini.Config; | ||
32 | using NUnit.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenMetaverse.Assets; | ||
35 | using OpenMetaverse.StructuredData; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | using OpenSim.Region.ScriptEngine.Shared; | ||
40 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Tests.Common; | ||
43 | using OpenSim.Tests.Common.Mock; | ||
44 | |||
45 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Tests for OSSL_Api | ||
49 | /// </summary> | ||
50 | [TestFixture] | ||
51 | public class OSSL_ApiAppearanceTest | ||
52 | { | ||
53 | [Test] | ||
54 | public void TestOsOwnerSaveAppearance() | ||
55 | { | ||
56 | TestHelpers.InMethod(); | ||
57 | // log4net.Config.XmlConfigurator.Configure(); | ||
58 | |||
59 | IConfigSource initConfigSource = new IniConfigSource(); | ||
60 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
61 | config.Set("Enabled", "true"); | ||
62 | config.Set("AllowOSFunctions", "true"); | ||
63 | config.Set("OSFunctionThreatLevel", "Severe"); | ||
64 | |||
65 | UUID userId = TestHelpers.ParseTail(0x1); | ||
66 | float newHeight = 1.9f; | ||
67 | |||
68 | Scene scene = SceneHelpers.SetupScene(); | ||
69 | SceneHelpers.SetupSceneModules(scene, new AvatarFactoryModule()); | ||
70 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | ||
71 | sp.Appearance.AvatarHeight = newHeight; | ||
72 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); | ||
73 | SceneObjectPart part = so.RootPart; | ||
74 | scene.AddSceneObject(so); | ||
75 | |||
76 | XEngine.XEngine engine = new XEngine.XEngine(); | ||
77 | engine.Initialise(initConfigSource); | ||
78 | engine.AddRegion(scene); | ||
79 | |||
80 | OSSL_Api osslApi = new OSSL_Api(); | ||
81 | osslApi.Initialize(engine, part, part.LocalId, part.UUID); | ||
82 | |||
83 | string notecardName = "appearanceNc"; | ||
84 | |||
85 | osslApi.osOwnerSaveAppearance(notecardName); | ||
86 | |||
87 | IList<TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName); | ||
88 | Assert.That(items.Count, Is.EqualTo(1)); | ||
89 | |||
90 | TaskInventoryItem ncItem = items[0]; | ||
91 | Assert.That(ncItem.Name, Is.EqualTo(notecardName)); | ||
92 | |||
93 | AssetBase ncAsset = scene.AssetService.Get(ncItem.AssetID.ToString()); | ||
94 | Assert.That(ncAsset, Is.Not.Null); | ||
95 | |||
96 | AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); | ||
97 | anc.Decode(); | ||
98 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); | ||
99 | AvatarAppearance savedAppearance = new AvatarAppearance(); | ||
100 | savedAppearance.Unpack(appearanceOsd); | ||
101 | |||
102 | Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); | ||
103 | } | ||
104 | } | ||
105 | } \ No newline at end of file | ||