diff --git a/Assets/Tests/LMV_ExtendedTests/Helpers.cs b/Assets/Tests/LMV_ExtendedTests/Helpers.cs index 4d54a98..06bea2c 100644 --- a/Assets/Tests/LMV_ExtendedTests/Helpers.cs +++ b/Assets/Tests/LMV_ExtendedTests/Helpers.cs @@ -2,6 +2,7 @@ using OpenMetaverse; using Tests; using UnityEngine; +using UnityScripts.Disk; namespace Raindrop.Tests.LMV_ExtendedTests { @@ -59,5 +60,14 @@ namespace Raindrop.Tests.LMV_ExtendedTests instance.Client.Network.Connected, "Client is not connected to the grid"); } + + // Copies the OMV assets + // from the StreamingAssets folder, into the runtime folder + public static void DoStartupCopy() + { + var copier = StaticFilesCopier.GetInstance(); + copier.Work(); + Assert.True(copier.CopyIsDoneAndNoErrors); + } } } \ No newline at end of file diff --git a/Assets/Tests/LMV_ExtendedTests/README.md b/Assets/Tests/LMV_ExtendedTests/README.md new file mode 100644 index 0000000..fcefb8b --- /dev/null +++ b/Assets/Tests/LMV_ExtendedTests/README.md @@ -0,0 +1,3 @@ +These tests check for dependencies required for the LMV library to run in Unity. + +For example there is the hack, where we copy files (such as /openmetaverse_data/) from StreamingAssets to the folder that LMV library uses at runtime. \ No newline at end of file diff --git a/Assets/Tests/LMV_ExtendedTests/README.md.meta b/Assets/Tests/LMV_ExtendedTests/README.md.meta new file mode 100644 index 0000000..8e821fe --- /dev/null +++ b/Assets/Tests/LMV_ExtendedTests/README.md.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 512f75f645214ae7b873e7d256d6bdb6 +timeCreated: 1657297890 \ No newline at end of file diff --git a/Assets/Tests/LMV_ExtendedTests/ResourceLoadTests.cs b/Assets/Tests/LMV_ExtendedTests/ResourceLoadTests.cs index a077a47..fbf13c2 100644 --- a/Assets/Tests/LMV_ExtendedTests/ResourceLoadTests.cs +++ b/Assets/Tests/LMV_ExtendedTests/ResourceLoadTests.cs @@ -3,6 +3,7 @@ using System.IO; using NUnit.Framework; using OpenMetaverse; using OpenMetaverse.Imaging; +using UnityEngine; using UnityEngine.TestTools; namespace Raindrop.Tests.LMV_ExtendedTests @@ -11,46 +12,54 @@ namespace Raindrop.Tests.LMV_ExtendedTests public class ResourceLoadTests { + #region Setup, teardown + private static RaindropInstance instance; + + [OneTimeTearDown] + public void OneTimeTearDown() + { + instance.CleanUp(); + } + + [OneTimeSetUp] + public void OneTimeSetUp() + { + GameObject mainThreadDispatcher = + new GameObject("mainThreadDispatcher"); + mainThreadDispatcher.AddComponent(); + + // make sure the Files are already copied to the runtime folder! + Helpers.DoStartupCopy(); + + instance = new RaindropInstance(new GridClient()); + } + #endregion + [UnityTest] public IEnumerator ResourceLoad_TGA_GetResourceStream() { - //create - var instance = new RaindropInstance(new GridClient()); - string res_file_name = "upperbody_color.tga"; - using (Stream stream = OpenMetaverse.Helpers.GetResourceStream(res_file_name, OpenMetaverse.Settings.RESOURCE_DIR)) + using (Stream stream = + OpenMetaverse.Helpers.GetResourceStream( + res_file_name, + OpenMetaverse.Settings.RESOURCE_DIR)) { - //can open => passed! :) - Assert.Pass(); + Assert.True(stream != null, + "Unable to open resource file " + + $"{res_file_name}" + + "in dir " + + $"{OpenMetaverse.Settings.RESOURCE_DIR}"); } - - //cleanup - if (instance != null) - { - instance.CleanUp(); - instance = null; - } - yield break; } [UnityTest] public IEnumerator ResourceLoad_TGA_LoadResourceLayer() { - //create - var instance = new RaindropInstance(new GridClient()); - string res_file_name = "upperbody_color.tga"; var res = Baker.LoadResourceLayer(res_file_name); - //cleanup - if (instance != null) - { - instance.CleanUp(); - instance = null; - } - yield break; } } diff --git a/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs b/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs index dbd0235..e60d62b 100644 --- a/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs +++ b/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs @@ -82,14 +82,8 @@ namespace Raindrop.Tests.DiskAndCache File.WriteAllBytes(GridsXmlFile, new byte[]{0x01}); //2. do the startup copy. - var copier = StaticFilesCopier.GetInstance(); - copier.Work(); - // var startupCopierObj = GameObject.CreatePrimitive(PrimitiveType.Cube); - // var startupCopier = startupCopierObj.AddComponent(); + LMV_ExtendedTests.Helpers.DoStartupCopy(); - //wait for files to be copied... - yield return new WaitForSeconds(3); - Assert.True(copier.CopyIsDoneAndNoErrors); //3. grids.xml is expected to be copied Assert.True(File.Exists(GridsXmlFile), diff --git a/Assets/UnityScripts/Disk/StaticFilesCopier.cs b/Assets/UnityScripts/Disk/StaticFilesCopier.cs index acc902e..7f37f2b 100644 --- a/Assets/UnityScripts/Disk/StaticFilesCopier.cs +++ b/Assets/UnityScripts/Disk/StaticFilesCopier.cs @@ -23,6 +23,7 @@ namespace UnityScripts.Disk { if (_instance == null) { + BetterStreamingAssets.Initialize(); //fuck, this is easy to forget. _instance = new StaticFilesCopier(); } return _instance; @@ -33,7 +34,6 @@ namespace UnityScripts.Disk // do copy (scan the files in device, copy if not same as staticassets.). public int Work() { - BetterStreamingAssets.Initialize(); //fuck, this is easy to forget. int res = CheckOmvDataFolderAndUpdateItIfNecessary(); if (res != -1) CopyIsDoneAndNoErrors = true;