mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
remove this unneeded nested class
This commit is contained in:
committed by
alexiscatnip
parent
96e0ec7af7
commit
646175ff72
@@ -6,80 +6,79 @@ using Disk;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Imaging;
|
||||
using Raindrop;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace Tests.Raindrop
|
||||
{
|
||||
[TestFixture()]
|
||||
public class ImagingTests
|
||||
{
|
||||
// test if the j2p decode and encode can work.
|
||||
// test if able to write to disk.
|
||||
// have to manual check the images on the disk to see if the test passes.
|
||||
[TestFixture()]
|
||||
public class RaindropIntegrationTests
|
||||
private static RaindropInstance instance = new RaindropInstance(new GridClient());
|
||||
public static string clientDir = instance.ClientDir;
|
||||
public static string _inputImageSubPath = "test/menhara.jp2";
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void setup()
|
||||
{
|
||||
private static RaindropInstance instance = new RaindropInstance(new GridClient());
|
||||
public static string clientDir = instance.ClientDir;
|
||||
public static string _inputImageSubPath = "test/menhara.jp2";
|
||||
BetterStreamingAssets.Initialize(); //fuck, this is easy to forget.
|
||||
}
|
||||
|
||||
//can read the image data from path.
|
||||
[Test]
|
||||
public void readBytes_ImagePath()
|
||||
{
|
||||
Assert.True(BetterStreamingAssets.FileExists(_inputImageSubPath), "SA file not exist : \n " + _inputImageSubPath);
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void setup()
|
||||
{
|
||||
BetterStreamingAssets.Initialize(); //fuck, this is easy to forget.
|
||||
}
|
||||
byte[] thebytes = BetterStreamingAssets.ReadAllBytes(_inputImageSubPath);
|
||||
|
||||
Assert.True(thebytes.Length > 0, "File is empty size");
|
||||
}
|
||||
|
||||
//can read and decode the jp2 from streamingassets. then save to local caching directory.
|
||||
[Test]
|
||||
public void ImagingTests_ReadJP2FromDisk_LoadIntoTexture2D_WriteToDiskAsJpeg()
|
||||
{
|
||||
float timeStart = Time.realtimeSinceStartup;
|
||||
|
||||
Assert.True(BetterStreamingAssets.FileExists(_inputImageSubPath));
|
||||
|
||||
//can read the image data from path.
|
||||
[Test]
|
||||
public void readBytes_ImagePath()
|
||||
{
|
||||
Assert.True(BetterStreamingAssets.FileExists(_inputImageSubPath), "SA file not exist : \n " + _inputImageSubPath);
|
||||
byte[] thebytes = BetterStreamingAssets.ReadAllBytes(_inputImageSubPath);
|
||||
Assert.True(thebytes.Length > 0);
|
||||
|
||||
byte[] thebytes = BetterStreamingAssets.ReadAllBytes(_inputImageSubPath);
|
||||
|
||||
Assert.True(thebytes.Length > 0, "File is empty size");
|
||||
}
|
||||
Texture2D texture
|
||||
= new Texture2D(1, 1, TextureFormat.RGBA32, false);
|
||||
T2D_JP2.LoadT2DWithoutMipMaps(thebytes, texture);
|
||||
|
||||
//can read and decode the jp2 from streamingassets. then save to local caching directory.
|
||||
[Test]
|
||||
public void ImagingTests_ReadJP2FromDisk_LoadIntoTexture2D_WriteToDiskAsJpeg()
|
||||
{
|
||||
float timeStart = Time.realtimeSinceStartup;
|
||||
|
||||
Assert.True(BetterStreamingAssets.FileExists(_inputImageSubPath));
|
||||
Assert.True(texture.height > 5); //todo so arbitrary
|
||||
|
||||
var outbytes = texture.EncodeToJPG(100);
|
||||
|
||||
string appDataDir = clientDir + "/ImagingTests/menhara_out_clientDir.jpg";
|
||||
DirectoryHelpers.WriteToFile(outbytes, appDataDir);
|
||||
#if UNITY_EDITOR
|
||||
#elif UNITY_ANDROID //warn, this is true if we are in editor...
|
||||
string outPath_GetAndroidExternalFilesDir_internal =
|
||||
Disk.DirectoryHelpers.GetAndroidExternalFilesDir(false) + "/ImagingTests/menhara_out_GetAndroidExternalFilesDir_internal.jpg";
|
||||
string outPath_GetAndroidExternalFilesDir_external =
|
||||
Disk.DirectoryHelpers.GetAndroidExternalFilesDir(true) + "/ImagingTests/menhara_out_GetAndroidExternalFilesDir_external.jpg";
|
||||
|
||||
byte[] thebytes = BetterStreamingAssets.ReadAllBytes(_inputImageSubPath);
|
||||
Assert.True(thebytes.Length > 0);
|
||||
|
||||
|
||||
Texture2D texture
|
||||
= new Texture2D(1, 1, TextureFormat.RGBA32, false);
|
||||
T2D_JP2.LoadT2DWithoutMipMaps(thebytes, texture);
|
||||
|
||||
Assert.True(texture.height > 5); //todo so arbitrary
|
||||
|
||||
var outbytes = texture.EncodeToJPG(100);
|
||||
|
||||
string appDataDir = clientDir + "/ImagingTests/menhara_out_clientDir.jpg";
|
||||
DirectoryHelpers.WriteToFile(outbytes, appDataDir);
|
||||
#if UNITY_EDITOR
|
||||
#elif UNITY_ANDROID //warn, this is true if we are in editor...
|
||||
string outPath_GetAndroidExternalFilesDir_internal =
|
||||
Disk.DirectoryHelpers.GetAndroidExternalFilesDir(false) + "/ImagingTests/menhara_out_GetAndroidExternalFilesDir_internal.jpg";
|
||||
string outPath_GetAndroidExternalFilesDir_external =
|
||||
Disk.DirectoryHelpers.GetAndroidExternalFilesDir(true) + "/ImagingTests/menhara_out_GetAndroidExternalFilesDir_external.jpg";
|
||||
|
||||
Disk.DirectoryHelpers.WriteToFile(outbytes, outPath_GetAndroidExternalFilesDir_internal);
|
||||
Disk.DirectoryHelpers.WriteToFile(outbytes, outPath_GetAndroidExternalFilesDir_external);
|
||||
Disk.DirectoryHelpers.WriteToFile(outbytes, outPath_GetAndroidExternalFilesDir_internal);
|
||||
Disk.DirectoryHelpers.WriteToFile(outbytes, outPath_GetAndroidExternalFilesDir_external);
|
||||
#endif
|
||||
|
||||
float timeEnd = Time.realtimeSinceStartup;
|
||||
Debug.Log($"took time to read jp2, convert to jpg, and save : {(timeEnd - timeStart).ToString()} ");
|
||||
Debug.Log($"read : in StreamingAssets, - {_inputImageSubPath} ");
|
||||
float timeEnd = Time.realtimeSinceStartup;
|
||||
Debug.Log($"took time to read jp2, convert to jpg, and save : {(timeEnd - timeStart).ToString()} ");
|
||||
Debug.Log($"read : in StreamingAssets, - {_inputImageSubPath} ");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// [UnityTest]
|
||||
// // managedimage -> texture2d -> managed image test
|
||||
|
||||
Reference in New Issue
Block a user