aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-09 22:05:47 +0100
committerJustin Clark-Casey (justincc)2011-08-09 22:05:47 +0100
commit795c8e6c22d4174d942ad56e70a0acbe507e2ec7 (patch)
treeb5eef28c55c1eeeb9d20c52d320de6f1037880bd /OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.zip
opensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.gz
opensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.bz2
opensim-SC-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/OSSL_ApiAppearanceTest.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs105
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
28using System;
29using System.Collections.Generic;
30using System.Text;
31using Nini.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenMetaverse.Assets;
35using OpenMetaverse.StructuredData;
36using OpenSim.Framework;
37using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.ScriptEngine.Shared;
40using OpenSim.Region.ScriptEngine.Shared.Api;
41using OpenSim.Services.Interfaces;
42using OpenSim.Tests.Common;
43using OpenSim.Tests.Common.Mock;
44
45namespace 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