improve disk test. looks nicer now.

This commit is contained in:
alexiscatnip
2022-08-06 02:43:06 +08:00
committed by alexiscatnip
parent 235debb5d6
commit 4c427f8019
6 changed files with 51 additions and 32 deletions
+10
View File
@@ -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);
}
}
}
+3
View File
@@ -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.
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 512f75f645214ae7b873e7d256d6bdb6
timeCreated: 1657297890
@@ -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<UnityMainThreadDispatcher>();
// 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;
}
}
@@ -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<CopyStreamingAssetsToPersistentDataPath>();
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),
@@ -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;