opensim-development – Blame information for rev 1

Subversion Repositories:
Rev:
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 Nini.Config;
31 using NUnit.Framework;
32 using OpenMetaverse;
33 using OpenSim.Framework;
34 using OpenSim.Region.CoreModules.Asset;
35 using OpenSim.Region.Framework.Scenes;
36 using OpenSim.Tests.Common;
37 using OpenSim.Tests.Common.Mock;
38  
39 namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
40 {
41 [TestFixture]
42 public class AvatarFactoryModuleTests : OpenSimTestCase
43 {
44 /// <summary>
45 /// Only partial right now since we don't yet test that it's ended up in the avatar appearance service.
46 /// </summary>
47 [Test]
48 public void TestSetAppearance()
49 {
50 TestHelpers.InMethod();
51 // log4net.Config.XmlConfigurator.Configure();
52  
53 UUID userId = TestHelpers.ParseTail(0x1);
54  
55 AvatarFactoryModule afm = new AvatarFactoryModule();
56 TestScene scene = new SceneHelpers().SetupScene();
57 SceneHelpers.SetupSceneModules(scene, afm);
58 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
59  
60 byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
61 for (byte i = 0; i < visualParams.Length; i++)
62 visualParams[i] = i;
63  
64 // afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams);
65  
66 // TODO: Check baked texture
67 // Assert.AreEqual(visualParams, sp.Appearance.VisualParams);
68 }
69  
70 [Test]
71 public void TestSaveBakedTextures()
72 {
73 TestHelpers.InMethod();
74 // log4net.Config.XmlConfigurator.Configure();
75  
76 UUID userId = TestHelpers.ParseTail(0x1);
77 UUID eyesTextureId = TestHelpers.ParseTail(0x2);
78  
79 // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly
80 // to the AssetService, which will then store temporary and local assets permanently
81 CoreAssetCache assetCache = new CoreAssetCache();
82  
83 AvatarFactoryModule afm = new AvatarFactoryModule();
84 TestScene scene = new SceneHelpers(assetCache).SetupScene();
85 SceneHelpers.SetupSceneModules(scene, afm);
86 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
87  
88 // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules
89 AssetBase uploadedAsset;
90 uploadedAsset = new AssetBase(eyesTextureId, "Baked Texture", (sbyte)AssetType.Texture, userId.ToString());
91 uploadedAsset.Data = new byte[] { 2 };
92 uploadedAsset.Temporary = true;
93 uploadedAsset.Local = true; // Local assets aren't persisted, non-local are
94 scene.AssetService.Store(uploadedAsset);
95  
96 byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
97 for (byte i = 0; i < visualParams.Length; i++)
98 visualParams[i] = i;
99  
100 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
101 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
102 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
103 eyesFace.TextureID = eyesTextureId;
104  
105 /*
106 afm.SetAppearance(sp, bakedTextureEntry, visualParams);
107 afm.SaveBakedTextures(userId);
108 // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);
109  
110 // We should also inpsect the asset data store layer directly, but this is difficult to get at right now.
111 assetCache.Clear();
112  
113 AssetBase eyesBake = scene.AssetService.Get(eyesTextureId.ToString());
114 Assert.That(eyesBake, Is.Not.Null);
115 Assert.That(eyesBake.Temporary, Is.False);
116 Assert.That(eyesBake.Local, Is.False);
117 */
118 }
119 }
120 }