aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-09-21 01:04:08 +0100
committerJustin Clark-Casey (justincc)2010-09-21 01:04:08 +0100
commit51207c24a03b2f5741a886b1d5daaac8d2231c93 (patch)
tree360c993fafd29a32cc132e8c62d390ccdab9e01e
parentImprove the explanative text of migration failures (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-51207c24a03b2f5741a886b1d5daaac8d2231c93.zip
opensim-SC-51207c24a03b2f5741a886b1d5daaac8d2231c93.tar.gz
opensim-SC-51207c24a03b2f5741a886b1d5daaac8d2231c93.tar.bz2
opensim-SC-51207c24a03b2f5741a886b1d5daaac8d2231c93.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
-rw-r--r--OpenSim/Framework/Tests/LocationTest.cs19
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs180
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs114
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs35
5 files changed, 354 insertions, 2 deletions
diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs
index 237568f..2707afa 100644
--- a/OpenSim/Framework/Tests/LocationTest.cs
+++ b/OpenSim/Framework/Tests/LocationTest.cs
@@ -54,9 +54,28 @@ namespace OpenSim.Framework.Tests
54 Location TestLocation2 = new Location(1099511628032000); 54 Location TestLocation2 = new Location(1099511628032000);
55 Assert.That(TestLocation1 == TestLocation2); 55 Assert.That(TestLocation1 == TestLocation2);
56 56
57 Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
58
59 Assert.That(TestLocation2.RegionHandle == 1099511628032000,
60 "Location RegionHandle Property didn't match regionhandle provided in constructor");
61
62
57 TestLocation1 = new Location(256001, 256001); 63 TestLocation1 = new Location(256001, 256001);
58 TestLocation2 = new Location(1099511628032000); 64 TestLocation2 = new Location(1099511628032000);
59 Assert.That(TestLocation1 != TestLocation2); 65 Assert.That(TestLocation1 != TestLocation2);
66
67 Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor");
68
69 Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode");
70
71 Location TestLocation3;
72 object cln = TestLocation2.Clone();
73 TestLocation3 = (Location) cln;
74 Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y,
75 "Cloned Location values do not match");
76
77 Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test");
78
60 } 79 }
61 80
62 } 81 }
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
index e2e08c0..04be083 100644
--- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -29,12 +29,19 @@ using NUnit.Framework;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenMetaverse.StructuredData; 31using OpenMetaverse.StructuredData;
32using System;
33using System.Globalization;
34using System.Threading;
32 35
33namespace OpenSim.Framework.Tests 36namespace OpenSim.Framework.Tests
34{ 37{
35 [TestFixture] 38 [TestFixture]
36 public class MundaneFrameworkTests 39 public class MundaneFrameworkTests
37 { 40 {
41 private bool m_RegionSettingsOnSaveEventFired;
42 private bool m_RegionLightShareDataOnSaveEventFired;
43
44
38 [Test] 45 [Test]
39 public void ChildAgentDataUpdate01() 46 public void ChildAgentDataUpdate01()
40 { 47 {
@@ -124,8 +131,181 @@ namespace OpenSim.Framework.Tests
124 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); 131 Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
125 132
126 } 133 }
134
135 [Test]
136 public void RegionSettingsTest01()
137 {
138 RegionSettings settings = new RegionSettings();
139 settings.OnSave += RegionSaveFired;
140 settings.Save();
141 settings.OnSave -= RegionSaveFired;
142
143 string str = settings.LoadedCreationDate;
144 int dt = settings.LoadedCreationDateTime;
145 string id = settings.LoadedCreationID;
146 string time = settings.LoadedCreationTime;
147
148 Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
149
150 }
151 public void RegionSaveFired(RegionSettings settings)
152 {
153 m_RegionSettingsOnSaveEventFired = true;
154 }
127 155
156 [Test]
157 public void InventoryItemBaseConstructorTest01()
158 {
159 InventoryItemBase b1 = new InventoryItemBase();
160 Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero");
161 Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero");
162
163 UUID ItemID = UUID.Random();
164 UUID OwnerID = UUID.Random();
165
166 InventoryItemBase b2 = new InventoryItemBase(ItemID);
167 Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID");
168 Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero");
169
170 InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID);
171 Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID");
172 Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID");
173
174 }
175
176 [Test]
177 public void AssetMetaDataNonNullContentTypeTest01()
178 {
179 AssetMetadata assetMetadata = new AssetMetadata();
180 assetMetadata.ContentType = "image/jp2";
181 Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture");
182 Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2");
183 UUID rndID = UUID.Random();
184 assetMetadata.ID = rndID.ToString();
185 Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent");
186 DateTime fixedTime = DateTime.Now;
187 assetMetadata.CreationDate = fixedTime;
188 }
189
190 [Test]
191 public void RegionLightShareDataCloneSaveTest01()
192 {
193 RegionLightShareData rlsd = new RegionLightShareData();
194 rlsd.OnSave += RegionLightShareDataSaveFired;
195 rlsd.Save();
196 rlsd.OnSave -= RegionLightShareDataSaveFired;
197 Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired");
198
199 object o = rlsd.Clone();
200 RegionLightShareData dupe = (RegionLightShareData) o;
201 Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed");
202 }
203 public void RegionLightShareDataSaveFired(RegionLightShareData settings)
204 {
205 m_RegionLightShareDataOnSaveEventFired = true;
206 }
207
208 [Test]
209 public void EstateSettingsMundateTests()
210 {
211 EstateSettings es = new EstateSettings();
212 es.AddBan(null);
213 UUID bannedUserId = UUID.Random();
214 es.AddBan(new EstateBan()
215 { BannedHostAddress = string.Empty,
216 BannedHostIPMask = string.Empty,
217 BannedHostNameMask = string.Empty,
218 BannedUserID = bannedUserId}
219 );
220 Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not.");
221 Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is.");
222
223 es.RemoveBan(bannedUserId);
224
225 Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is.");
226
227 es.AddEstateManager(UUID.Zero);
228
229 es.AddEstateManager(bannedUserId);
230 Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't.");
231
232 es.RemoveEstateManager(bannedUserId);
233 Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be");
234
235 Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't");
236
237 es.AddEstateUser(bannedUserId);
238
239 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
240 es.RemoveEstateUser(bannedUserId);
241
242 es.AddEstateManager(bannedUserId);
243
244 Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
245
246 Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length");
247
248 es.AddEstateGroup(bannedUserId);
249
250 Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length");
251
252 Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups");
253
254 }
255
256 [Test]
257 public void InventoryFolderBaseConstructorTest01()
258 {
259 UUID uuid1 = UUID.Random();
260 UUID uuid2 = UUID.Random();
261
262 InventoryFolderBase fld = new InventoryFolderBase(uuid1);
263 Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field.");
264
265 fld = new InventoryFolderBase(uuid1, uuid2);
266 Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field.");
267 Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
268 }
128 269
270 [Test]
271 public void AsssetBaseConstructorTest01()
272 {
273 AssetBase abase = new AssetBase();
274 Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't.");
275 UUID itemID = UUID.Random();
276 UUID creatorID = UUID.Random();
277 abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString());
278
279 Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't.");
280 Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property");
281 Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID");
282
283
284 abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString());
285 Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't.");
286 Assert.That(abase.Metadata.Type == -1, "Unknown Type passed to string,string,sbyte,string constructor and was a known type when it came out again");
287
288 AssetMetadata metts = new AssetMetadata();
289 metts.FullID = itemID;
290 metts.ID = string.Empty;
291 metts.Name = "test item";
292 abase.Metadata = metts;
293
294 Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()");
295 Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property");
296 }
297
298 [Test]
299 public void CultureSetCultureTest01()
300 {
301 CultureInfo ci = new CultureInfo("en-US", false);
302 Culture.SetCurrentCulture();
303 Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US");
304
305 }
306
307
308
129 } 309 }
130} 310}
131 311
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index 45d822c..89f5c0c 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -170,5 +170,119 @@ namespace OpenSim.Framework.Tests
170 // Varying secrets should not eqal the same 170 // Varying secrets should not eqal the same
171 Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); 171 Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2"));
172 } 172 }
173
174 [Test]
175 public void SLUtilTypeConvertTests()
176 {
177 int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
178 ,23,24,25,46,47,48};
179 string[] contenttypes = new string[]
180 {
181 "application/octet-stream",
182 "image/x-j2c",
183 "audio/ogg",
184 "application/vnd.ll.callingcard",
185 "application/vnd.ll.landmark",
186 "application/vnd.ll.clothing",
187 "application/vnd.ll.primitive",
188 "application/vnd.ll.notecard",
189 "application/vnd.ll.folder",
190 "application/vnd.ll.rootfolder",
191 "application/vnd.ll.lsltext",
192 "application/vnd.ll.lslbyte",
193 "image/tga",
194 "application/vnd.ll.bodypart",
195 "application/vnd.ll.trashfolder",
196 "application/vnd.ll.snapshotfolder",
197 "application/vnd.ll.lostandfoundfolder",
198 "audio/x-wav",
199 "image/tga",
200 "image/jpeg",
201 "application/vnd.ll.animation",
202 "application/vnd.ll.gesture",
203 "application/x-metaverse-simstate",
204 "application/vnd.ll.favoritefolder",
205 "application/vnd.ll.link",
206 "application/vnd.ll.linkfolder",
207 "application/vnd.ll.currentoutfitfolder",
208 "application/vnd.ll.outfitfolder",
209 "application/vnd.ll.myoutfitsfolder"
210 };
211 for (int i=0;i<assettypes.Length;i++)
212 {
213 Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i]));
214 }
215
216 for (int i = 0; i < contenttypes.Length; i++)
217 {
218 if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18)
219 {
220 Assert.That(contenttypes[i] == "image/tga");
221 }
222 else
223 {
224 Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i],
225 "Expecting {0} but got {1}", assettypes[i],
226 SLUtil.ContentTypeToSLAssetType(contenttypes[i]));
227 }
228 }
229
230 int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20};
231 string[] invcontenttypes = new string[]
232 {
233 "application/octet-stream",
234 "image/x-j2c",
235 "audio/ogg",
236 "application/vnd.ll.callingcard",
237 "application/vnd.ll.landmark",
238 "application/vnd.ll.primitive",
239 "application/vnd.ll.notecard",
240 "application/vnd.ll.folder",
241 "application/octet-stream",
242 "application/vnd.ll.lsltext",
243 "image/x-j2c",
244 "application/vnd.ll.primitive",
245 "application/vnd.ll.clothing",
246 "application/vnd.ll.gesture"
247 };
248
249 for (int i=0;i<inventorytypes.Length;i++)
250 {
251 Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]));
252 }
253
254 invcontenttypes = new string[]
255 {
256 "image/x-j2c","image/jp2","image/tga",
257 "image/jpeg","application/ogg","audio/ogg",
258 "audio/x-wav","application/vnd.ll.callingcard",
259 "application/x-metaverse-callingcard",
260 "application/vnd.ll.landmark",
261 "application/x-metaverse-landmark",
262 "application/vnd.ll.clothing",
263 "application/x-metaverse-clothing","application/vnd.ll.bodypart",
264 "application/x-metaverse-bodypart","application/vnd.ll.primitive",
265 "application/x-metaverse-primitive","application/vnd.ll.notecard",
266 "application/x-metaverse-notecard","application/vnd.ll.folder",
267 "application/vnd.ll.rootfolder","application/vnd.ll.lsltext",
268 "application/x-metaverse-lsl","application/vnd.ll.lslbyte",
269 "application/x-metaverse-lso","application/vnd.ll.trashfolder",
270 "application/vnd.ll.snapshotfolder",
271 "application/vnd.ll.lostandfoundfolder","application/vnd.ll.animation",
272 "application/x-metaverse-animation","application/vnd.ll.gesture",
273 "application/x-metaverse-gesture","application/x-metaverse-simstate",
274 "application/octet-stream"
275 };
276 sbyte[] invtypes = new sbyte[]
277 {
278 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 18, 18, 18, 18, 6, 6, 7, 7, 8, 9, 10, 10, 10, 10
279 , 8, 8, 8, 19, 19, 20, 20, 15, -1
280 };
281
282 for (int i = 0; i < invtypes.Length; i++)
283 {
284 Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]));
285 }
286 }
173 } 287 }
174} 288}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 994b9e3..b655f39 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -330,8 +330,12 @@ namespace OpenSim.Region.Framework.Scenes
330 get { return m_rootPart.UUID; } 330 get { return m_rootPart.UUID; }
331 set 331 set
332 { 332 {
333 m_rootPart.UUID = value; 333 lock (m_parts.SyncRoot)
334 m_parts.AddOrReplace(value, m_rootPart); 334 {
335 m_parts.Remove(m_rootPart.UUID);
336 m_rootPart.UUID = value;
337 m_parts.Add(value, m_rootPart);
338 }
335 } 339 }
336 } 340 }
337 341
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 54b3260..e6ff0c0 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -189,5 +189,40 @@ namespace OpenSim.Region.Framework.Scenes.Tests
189 // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 189 // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
190 // Assert.That(retrievedPart, Is.Null); 190 // Assert.That(retrievedPart, Is.Null);
191 //} 191 //}
192
193 /// <summary>
194 /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not
195 /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by
196 /// OpenSim.
197 /// </summary>
198 [Test]
199 public void TestChangeSceneObjectUuid()
200 {
201 string rootPartName = "rootpart";
202 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
203 string childPartName = "childPart";
204 UUID childPartUuid = new UUID("00000000-0000-0000-0001-000000000000");
205
206 SceneObjectPart rootPart
207 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
208 { Name = rootPartName, UUID = rootPartUuid };
209 SceneObjectPart linkPart
210 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
211 { Name = childPartName, UUID = childPartUuid };
212
213 SceneObjectGroup sog = new SceneObjectGroup(rootPart);
214 sog.AddPart(linkPart);
215
216 Assert.That(sog.UUID, Is.EqualTo(rootPartUuid));
217 Assert.That(sog.RootPart.UUID, Is.EqualTo(rootPartUuid));
218 Assert.That(sog.Parts.Length, Is.EqualTo(2));
219
220 UUID newRootPartUuid = new UUID("00000000-0000-0000-0000-000000000002");
221 sog.UUID = newRootPartUuid;
222
223 Assert.That(sog.UUID, Is.EqualTo(newRootPartUuid));
224 Assert.That(sog.RootPart.UUID, Is.EqualTo(newRootPartUuid));
225 Assert.That(sog.Parts.Length, Is.EqualTo(2));
226 }
192 } 227 }
193} 228}