Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
commit
51207c24a0
|
@ -54,9 +54,28 @@ namespace OpenSim.Framework.Tests
|
|||
Location TestLocation2 = new Location(1099511628032000);
|
||||
Assert.That(TestLocation1 == TestLocation2);
|
||||
|
||||
Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
|
||||
|
||||
Assert.That(TestLocation2.RegionHandle == 1099511628032000,
|
||||
"Location RegionHandle Property didn't match regionhandle provided in constructor");
|
||||
|
||||
|
||||
TestLocation1 = new Location(256001, 256001);
|
||||
TestLocation2 = new Location(1099511628032000);
|
||||
Assert.That(TestLocation1 != TestLocation2);
|
||||
|
||||
Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor");
|
||||
|
||||
Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode");
|
||||
|
||||
Location TestLocation3;
|
||||
object cln = TestLocation2.Clone();
|
||||
TestLocation3 = (Location) cln;
|
||||
Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y,
|
||||
"Cloned Location values do not match");
|
||||
|
||||
Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,12 +29,19 @@ using NUnit.Framework;
|
|||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class MundaneFrameworkTests
|
||||
{
|
||||
private bool m_RegionSettingsOnSaveEventFired;
|
||||
private bool m_RegionLightShareDataOnSaveEventFired;
|
||||
|
||||
|
||||
[Test]
|
||||
public void ChildAgentDataUpdate01()
|
||||
{
|
||||
|
@ -124,8 +131,181 @@ namespace OpenSim.Framework.Tests
|
|||
Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RegionSettingsTest01()
|
||||
{
|
||||
RegionSettings settings = new RegionSettings();
|
||||
settings.OnSave += RegionSaveFired;
|
||||
settings.Save();
|
||||
settings.OnSave -= RegionSaveFired;
|
||||
|
||||
string str = settings.LoadedCreationDate;
|
||||
int dt = settings.LoadedCreationDateTime;
|
||||
string id = settings.LoadedCreationID;
|
||||
string time = settings.LoadedCreationTime;
|
||||
|
||||
Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
|
||||
|
||||
}
|
||||
public void RegionSaveFired(RegionSettings settings)
|
||||
{
|
||||
m_RegionSettingsOnSaveEventFired = true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InventoryItemBaseConstructorTest01()
|
||||
{
|
||||
InventoryItemBase b1 = new InventoryItemBase();
|
||||
Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero");
|
||||
Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero");
|
||||
|
||||
UUID ItemID = UUID.Random();
|
||||
UUID OwnerID = UUID.Random();
|
||||
|
||||
InventoryItemBase b2 = new InventoryItemBase(ItemID);
|
||||
Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID");
|
||||
Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero");
|
||||
|
||||
InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID);
|
||||
Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID");
|
||||
Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssetMetaDataNonNullContentTypeTest01()
|
||||
{
|
||||
AssetMetadata assetMetadata = new AssetMetadata();
|
||||
assetMetadata.ContentType = "image/jp2";
|
||||
Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture");
|
||||
Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2");
|
||||
UUID rndID = UUID.Random();
|
||||
assetMetadata.ID = rndID.ToString();
|
||||
Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent");
|
||||
DateTime fixedTime = DateTime.Now;
|
||||
assetMetadata.CreationDate = fixedTime;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RegionLightShareDataCloneSaveTest01()
|
||||
{
|
||||
RegionLightShareData rlsd = new RegionLightShareData();
|
||||
rlsd.OnSave += RegionLightShareDataSaveFired;
|
||||
rlsd.Save();
|
||||
rlsd.OnSave -= RegionLightShareDataSaveFired;
|
||||
Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired");
|
||||
|
||||
object o = rlsd.Clone();
|
||||
RegionLightShareData dupe = (RegionLightShareData) o;
|
||||
Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed");
|
||||
}
|
||||
public void RegionLightShareDataSaveFired(RegionLightShareData settings)
|
||||
{
|
||||
m_RegionLightShareDataOnSaveEventFired = true;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EstateSettingsMundateTests()
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
es.AddBan(null);
|
||||
UUID bannedUserId = UUID.Random();
|
||||
es.AddBan(new EstateBan()
|
||||
{ BannedHostAddress = string.Empty,
|
||||
BannedHostIPMask = string.Empty,
|
||||
BannedHostNameMask = string.Empty,
|
||||
BannedUserID = bannedUserId}
|
||||
);
|
||||
Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not.");
|
||||
Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is.");
|
||||
|
||||
es.RemoveBan(bannedUserId);
|
||||
|
||||
Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is.");
|
||||
|
||||
es.AddEstateManager(UUID.Zero);
|
||||
|
||||
es.AddEstateManager(bannedUserId);
|
||||
Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't.");
|
||||
|
||||
es.RemoveEstateManager(bannedUserId);
|
||||
Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be");
|
||||
|
||||
Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't");
|
||||
|
||||
es.AddEstateUser(bannedUserId);
|
||||
|
||||
Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
|
||||
es.RemoveEstateUser(bannedUserId);
|
||||
|
||||
es.AddEstateManager(bannedUserId);
|
||||
|
||||
Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should");
|
||||
|
||||
Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length");
|
||||
|
||||
es.AddEstateGroup(bannedUserId);
|
||||
|
||||
Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length");
|
||||
|
||||
Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InventoryFolderBaseConstructorTest01()
|
||||
{
|
||||
UUID uuid1 = UUID.Random();
|
||||
UUID uuid2 = UUID.Random();
|
||||
|
||||
InventoryFolderBase fld = new InventoryFolderBase(uuid1);
|
||||
Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field.");
|
||||
|
||||
fld = new InventoryFolderBase(uuid1, uuid2);
|
||||
Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field.");
|
||||
Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AsssetBaseConstructorTest01()
|
||||
{
|
||||
AssetBase abase = new AssetBase();
|
||||
Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't.");
|
||||
UUID itemID = UUID.Random();
|
||||
UUID creatorID = UUID.Random();
|
||||
abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString());
|
||||
|
||||
Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't.");
|
||||
Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property");
|
||||
Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID");
|
||||
|
||||
|
||||
abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString());
|
||||
Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't.");
|
||||
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");
|
||||
|
||||
AssetMetadata metts = new AssetMetadata();
|
||||
metts.FullID = itemID;
|
||||
metts.ID = string.Empty;
|
||||
metts.Name = "test item";
|
||||
abase.Metadata = metts;
|
||||
|
||||
Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()");
|
||||
Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CultureSetCultureTest01()
|
||||
{
|
||||
CultureInfo ci = new CultureInfo("en-US", false);
|
||||
Culture.SetCurrentCulture();
|
||||
Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,5 +170,119 @@ namespace OpenSim.Framework.Tests
|
|||
// Varying secrets should not eqal the same
|
||||
Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SLUtilTypeConvertTests()
|
||||
{
|
||||
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
|
||||
,23,24,25,46,47,48};
|
||||
string[] contenttypes = new string[]
|
||||
{
|
||||
"application/octet-stream",
|
||||
"image/x-j2c",
|
||||
"audio/ogg",
|
||||
"application/vnd.ll.callingcard",
|
||||
"application/vnd.ll.landmark",
|
||||
"application/vnd.ll.clothing",
|
||||
"application/vnd.ll.primitive",
|
||||
"application/vnd.ll.notecard",
|
||||
"application/vnd.ll.folder",
|
||||
"application/vnd.ll.rootfolder",
|
||||
"application/vnd.ll.lsltext",
|
||||
"application/vnd.ll.lslbyte",
|
||||
"image/tga",
|
||||
"application/vnd.ll.bodypart",
|
||||
"application/vnd.ll.trashfolder",
|
||||
"application/vnd.ll.snapshotfolder",
|
||||
"application/vnd.ll.lostandfoundfolder",
|
||||
"audio/x-wav",
|
||||
"image/tga",
|
||||
"image/jpeg",
|
||||
"application/vnd.ll.animation",
|
||||
"application/vnd.ll.gesture",
|
||||
"application/x-metaverse-simstate",
|
||||
"application/vnd.ll.favoritefolder",
|
||||
"application/vnd.ll.link",
|
||||
"application/vnd.ll.linkfolder",
|
||||
"application/vnd.ll.currentoutfitfolder",
|
||||
"application/vnd.ll.outfitfolder",
|
||||
"application/vnd.ll.myoutfitsfolder"
|
||||
};
|
||||
for (int i=0;i<assettypes.Length;i++)
|
||||
{
|
||||
Assert.That(SLUtil.SLAssetTypeToContentType(assettypes[i]) == contenttypes[i], "Expecting {0} but got {1}", contenttypes[i], SLUtil.SLAssetTypeToContentType(assettypes[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; i < contenttypes.Length; i++)
|
||||
{
|
||||
if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18)
|
||||
{
|
||||
Assert.That(contenttypes[i] == "image/tga");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i],
|
||||
"Expecting {0} but got {1}", assettypes[i],
|
||||
SLUtil.ContentTypeToSLAssetType(contenttypes[i]));
|
||||
}
|
||||
}
|
||||
|
||||
int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20};
|
||||
string[] invcontenttypes = new string[]
|
||||
{
|
||||
"application/octet-stream",
|
||||
"image/x-j2c",
|
||||
"audio/ogg",
|
||||
"application/vnd.ll.callingcard",
|
||||
"application/vnd.ll.landmark",
|
||||
"application/vnd.ll.primitive",
|
||||
"application/vnd.ll.notecard",
|
||||
"application/vnd.ll.folder",
|
||||
"application/octet-stream",
|
||||
"application/vnd.ll.lsltext",
|
||||
"image/x-j2c",
|
||||
"application/vnd.ll.primitive",
|
||||
"application/vnd.ll.clothing",
|
||||
"application/vnd.ll.gesture"
|
||||
};
|
||||
|
||||
for (int i=0;i<inventorytypes.Length;i++)
|
||||
{
|
||||
Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]));
|
||||
}
|
||||
|
||||
invcontenttypes = new string[]
|
||||
{
|
||||
"image/x-j2c","image/jp2","image/tga",
|
||||
"image/jpeg","application/ogg","audio/ogg",
|
||||
"audio/x-wav","application/vnd.ll.callingcard",
|
||||
"application/x-metaverse-callingcard",
|
||||
"application/vnd.ll.landmark",
|
||||
"application/x-metaverse-landmark",
|
||||
"application/vnd.ll.clothing",
|
||||
"application/x-metaverse-clothing","application/vnd.ll.bodypart",
|
||||
"application/x-metaverse-bodypart","application/vnd.ll.primitive",
|
||||
"application/x-metaverse-primitive","application/vnd.ll.notecard",
|
||||
"application/x-metaverse-notecard","application/vnd.ll.folder",
|
||||
"application/vnd.ll.rootfolder","application/vnd.ll.lsltext",
|
||||
"application/x-metaverse-lsl","application/vnd.ll.lslbyte",
|
||||
"application/x-metaverse-lso","application/vnd.ll.trashfolder",
|
||||
"application/vnd.ll.snapshotfolder",
|
||||
"application/vnd.ll.lostandfoundfolder","application/vnd.ll.animation",
|
||||
"application/x-metaverse-animation","application/vnd.ll.gesture",
|
||||
"application/x-metaverse-gesture","application/x-metaverse-simstate",
|
||||
"application/octet-stream"
|
||||
};
|
||||
sbyte[] invtypes = new sbyte[]
|
||||
{
|
||||
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
|
||||
, 8, 8, 8, 19, 19, 20, 20, 15, -1
|
||||
};
|
||||
|
||||
for (int i = 0; i < invtypes.Length; i++)
|
||||
{
|
||||
Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,8 +330,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
get { return m_rootPart.UUID; }
|
||||
set
|
||||
{
|
||||
m_rootPart.UUID = value;
|
||||
m_parts.AddOrReplace(value, m_rootPart);
|
||||
lock (m_parts.SyncRoot)
|
||||
{
|
||||
m_parts.Remove(m_rootPart.UUID);
|
||||
m_rootPart.UUID = value;
|
||||
m_parts.Add(value, m_rootPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,5 +189,40 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
|||
// SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
|
||||
// Assert.That(retrievedPart, Is.Null);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not
|
||||
/// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by
|
||||
/// OpenSim.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestChangeSceneObjectUuid()
|
||||
{
|
||||
string rootPartName = "rootpart";
|
||||
UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
|
||||
string childPartName = "childPart";
|
||||
UUID childPartUuid = new UUID("00000000-0000-0000-0001-000000000000");
|
||||
|
||||
SceneObjectPart rootPart
|
||||
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
|
||||
{ Name = rootPartName, UUID = rootPartUuid };
|
||||
SceneObjectPart linkPart
|
||||
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
|
||||
{ Name = childPartName, UUID = childPartUuid };
|
||||
|
||||
SceneObjectGroup sog = new SceneObjectGroup(rootPart);
|
||||
sog.AddPart(linkPart);
|
||||
|
||||
Assert.That(sog.UUID, Is.EqualTo(rootPartUuid));
|
||||
Assert.That(sog.RootPart.UUID, Is.EqualTo(rootPartUuid));
|
||||
Assert.That(sog.Parts.Length, Is.EqualTo(2));
|
||||
|
||||
UUID newRootPartUuid = new UUID("00000000-0000-0000-0000-000000000002");
|
||||
sog.UUID = newRootPartUuid;
|
||||
|
||||
Assert.That(sog.UUID, Is.EqualTo(newRootPartUuid));
|
||||
Assert.That(sog.RootPart.UUID, Is.EqualTo(newRootPartUuid));
|
||||
Assert.That(sog.Parts.Length, Is.EqualTo(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue