From 1df69be9a6d7a1c7c0a5446c11fe9fde2c2b88f7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 22 Jan 2010 20:32:34 +0000
Subject: Add first part of test for checking restore of task inventory items
on oar load Passes but not yet complete
---
.../World/Archiver/Tests/ArchiverTests.cs | 50 ++++++++++++++++++++-
.../World/Archiver/Tests/Resources/test-sound.wav | Bin 0 -> 211648 bytes
prebuild.xml | 1 +
3 files changed, 50 insertions(+), 1 deletion(-)
create mode 100755 OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 9e9cedd..1200105 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -215,7 +215,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
-
+
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
string part1Name = "object1";
@@ -235,6 +235,45 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
UUID.Zero, shape, groupPosition, rotationOffset, offsetPosition);
part1.Name = part1Name;
SceneObjectGroup object1 = new SceneObjectGroup(part1);
+
+ // Let's put some inventory items into our object
+ UUID soundItemUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
+ Type type = GetType();
+ Assembly assembly = type.Assembly;
+ string soundDataResourceName = null;
+ string[] names = assembly.GetManifestResourceNames();
+ foreach (string name in names)
+ {
+ if (name.EndsWith(".Resources.test-sound.wav"))
+ soundDataResourceName = name;
+ }
+ Assert.That(soundDataResourceName, Is.Not.Null);
+
+ byte[] soundData;
+ Console.WriteLine("Loading " + soundDataResourceName);
+ using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName))
+ {
+ using (BinaryReader br = new BinaryReader(resource))
+ {
+ // FIXME: Use the inspector insteadthere are so many forums and lists already, though admittedly none of them are suitable for cross virtual-enivornemnt discussion
+ soundData = br.ReadBytes(99999999);
+ UUID soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
+ string soundAssetFileName
+ = ArchiveConstants.ASSETS_PATH + soundUuid
+ + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV];
+ tar.WriteFile(soundAssetFileName, soundData);
+
+ /*
+ AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData);
+ scene.AssetService.Store(soundAsset);
+ asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav";
+ */
+
+ TaskInventoryItem item1 = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid };
+ part1.Inventory.AddInventoryItem(item1, true);
+ }
+ }
+
scene.AddNewSceneObject(object1, false);
string object1FileName = string.Format(
@@ -266,6 +305,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Assert.That(
object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal");
+ // Need to implement a method to get the task inventory item by name (since the uuid will have changed on load)
+ /*
+ TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItem(soundItemUuid);
+ Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null");
+ AssetBase loadedSoundAsset = scene.AssetService.Get(loadedSoundItem.AssetID.ToString());
+ Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null");
+ Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match");
+ */
+
// Temporary
Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav b/OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav
new file mode 100755
index 0000000..b45ee54
Binary files /dev/null and b/OpenSim/Region/CoreModules/World/Archiver/Tests/Resources/test-sound.wav differ
diff --git a/prebuild.xml b/prebuild.xml
index 7881cd7..0ab7414 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3271,6 +3271,7 @@
+
--
cgit v1.1