aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-02-24 19:43:06 +0000
committerJustin Clark-Casey (justincc)2014-02-24 19:43:06 +0000
commit26fe59c35e987283e5df07d3d06b00a886b7fbc4 (patch)
treef0a79fbfe96ddbc2ac7479c210ead0e9972599f2 /OpenSim
parentRe-enable regression TestSaveBakedTextures() (diff)
downloadopensim-SC_OLD-26fe59c35e987283e5df07d3d06b00a886b7fbc4.zip
opensim-SC_OLD-26fe59c35e987283e5df07d3d06b00a886b7fbc4.tar.gz
opensim-SC_OLD-26fe59c35e987283e5df07d3d06b00a886b7fbc4.tar.bz2
opensim-SC_OLD-26fe59c35e987283e5df07d3d06b00a886b7fbc4.tar.xz
Improve regression test TestSetAppearance()
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs111
1 files changed, 69 insertions, 42 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
index b1f26ef..de014ba 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs
@@ -48,33 +48,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
48 public void TestSetAppearance() 48 public void TestSetAppearance()
49 { 49 {
50 TestHelpers.InMethod(); 50 TestHelpers.InMethod();
51// log4net.Config.XmlConfigurator.Configure(); 51// TestHelpers.EnableLogging();
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 52
76 UUID userId = TestHelpers.ParseTail(0x1); 53 UUID userId = TestHelpers.ParseTail(0x1);
77 UUID eyesTextureId = TestHelpers.ParseTail(0x2); 54 UUID bakedTextureID = TestHelpers.ParseTail(0x2);
78 55
79 // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly 56 // 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 57 // to the AssetService, which will then store temporary and local assets permanently
@@ -86,12 +63,14 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
86 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); 63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
87 64
88 // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules 65 // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules
89 AssetBase uploadedAsset; 66 AssetBase bakedTextureAsset;
90 uploadedAsset = new AssetBase(eyesTextureId, "Baked Texture", (sbyte)AssetType.Texture, userId.ToString()); 67 bakedTextureAsset
91 uploadedAsset.Data = new byte[] { 2 }; 68 = new AssetBase(
92 uploadedAsset.Temporary = true; 69 bakedTextureID, "Test Baked Texture", (sbyte)AssetType.Texture, userId.ToString());
93 uploadedAsset.Local = true; // Local assets aren't persisted, non-local are 70 bakedTextureAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet
94 scene.AssetService.Store(uploadedAsset); 71 bakedTextureAsset.Temporary = true;
72 bakedTextureAsset.Local = true;
73 scene.AssetService.Store(bakedTextureAsset);
95 74
96 byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; 75 byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
97 for (byte i = 0; i < visualParams.Length; i++) 76 for (byte i = 0; i < visualParams.Length; i++)
@@ -100,19 +79,20 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
100 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); 79 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
101 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); 80 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
102 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); 81 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
103 eyesFace.TextureID = eyesTextureId;
104 82
105 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null); 83 int rebakeRequestsReceived = 0;
106 afm.SaveBakedTextures(userId); 84 ((TestClient)sp.ControllingClient).OnReceivedSendRebakeAvatarTextures += id => rebakeRequestsReceived++;
107// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);
108 85
109 // We should also inpsect the asset data store layer directly, but this is difficult to get at right now. 86 // This is the alpha texture
110 assetCache.Clear(); 87 eyesFace.TextureID = bakedTextureID;
88 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
89
90 Assert.That(rebakeRequestsReceived, Is.EqualTo(0));
111 91
112 AssetBase eyesBake = scene.AssetService.Get(eyesTextureId.ToString()); 92 AssetBase eyesBake = scene.AssetService.Get(bakedTextureID.ToString());
113 Assert.That(eyesBake, Is.Not.Null); 93 Assert.That(eyesBake, Is.Not.Null);
114 Assert.That(eyesBake.Temporary, Is.False); 94 Assert.That(eyesBake.Temporary, Is.True);
115 Assert.That(eyesBake.Local, Is.False); 95 Assert.That(eyesBake.Local, Is.True);
116 } 96 }
117 97
118 /// <summary> 98 /// <summary>
@@ -131,7 +111,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
131 UUID userId = TestHelpers.ParseTail(0x1); 111 UUID userId = TestHelpers.ParseTail(0x1);
132 UUID alphaTextureID = new UUID("3a367d1c-bef1-6d43-7595-e88c1e3aadb3"); 112 UUID alphaTextureID = new UUID("3a367d1c-bef1-6d43-7595-e88c1e3aadb3");
133 113
134
135 // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly 114 // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly
136 // to the AssetService, which will then store temporary and local assets permanently 115 // to the AssetService, which will then store temporary and local assets permanently
137 CoreAssetCache assetCache = new CoreAssetCache(); 116 CoreAssetCache assetCache = new CoreAssetCache();
@@ -144,7 +123,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
144 AssetBase libraryAsset; 123 AssetBase libraryAsset;
145 libraryAsset 124 libraryAsset
146 = new AssetBase( 125 = new AssetBase(
147 alphaTextureID, "Default Alpha Layer Texturee", (sbyte)AssetType.Texture, userId.ToString()); 126 alphaTextureID, "Default Alpha Layer Texture", (sbyte)AssetType.Texture, userId.ToString());
148 libraryAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet 127 libraryAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet
149 libraryAsset.Temporary = false; 128 libraryAsset.Temporary = false;
150 libraryAsset.Local = false; 129 libraryAsset.Local = false;
@@ -167,5 +146,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
167 146
168 Assert.That(rebakeRequestsReceived, Is.EqualTo(0)); 147 Assert.That(rebakeRequestsReceived, Is.EqualTo(0));
169 } 148 }
149
150 [Test]
151 public void TestSaveBakedTextures()
152 {
153 TestHelpers.InMethod();
154// log4net.Config.XmlConfigurator.Configure();
155
156 UUID userId = TestHelpers.ParseTail(0x1);
157 UUID eyesTextureId = TestHelpers.ParseTail(0x2);
158
159 // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly
160 // to the AssetService, which will then store temporary and local assets permanently
161 CoreAssetCache assetCache = new CoreAssetCache();
162
163 AvatarFactoryModule afm = new AvatarFactoryModule();
164 TestScene scene = new SceneHelpers(assetCache).SetupScene();
165 SceneHelpers.SetupSceneModules(scene, afm);
166 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
167
168 // TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules
169 AssetBase uploadedAsset;
170 uploadedAsset = new AssetBase(eyesTextureId, "Baked Texture", (sbyte)AssetType.Texture, userId.ToString());
171 uploadedAsset.Data = new byte[] { 2 };
172 uploadedAsset.Temporary = true;
173 uploadedAsset.Local = true; // Local assets aren't persisted, non-local are
174 scene.AssetService.Store(uploadedAsset);
175
176 byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
177 for (byte i = 0; i < visualParams.Length; i++)
178 visualParams[i] = i;
179
180 Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
181 uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
182 Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
183 eyesFace.TextureID = eyesTextureId;
184
185 afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
186 afm.SaveBakedTextures(userId);
187// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);
188
189 // We should also inpsect the asset data store layer directly, but this is difficult to get at right now.
190 assetCache.Clear();
191
192 AssetBase eyesBake = scene.AssetService.Get(eyesTextureId.ToString());
193 Assert.That(eyesBake, Is.Not.Null);
194 Assert.That(eyesBake.Temporary, Is.False);
195 Assert.That(eyesBake.Local, Is.False);
196 }
170 } 197 }
171} \ No newline at end of file 198} \ No newline at end of file