From 1ec4c7ca1f529036dd8a66c3e786a02c11bb8672 Mon Sep 17 00:00:00 2001 From: alexiscatnip Date: Sun, 6 Feb 2022 13:11:48 +0800 Subject: [PATCH] move tests --- Assets/Tests/DiskAndCache/DiskTests.cs | 24 -- Assets/Tests/HeadlessBootstrapScene.unity | 254 ++++++++++++++++++ .../Tests/HeadlessBootstrapScene.unity.meta | 7 + Assets/Tests/Helper.cs | 22 -- Assets/Tests/Helper.cs.meta | 3 - .../LMVLibraryImageFetchingTests.cs | 5 +- Assets/Tests/Raindrop.meta | 3 + Assets/Tests/{ => Raindrop}/DiskAndCache.meta | 0 .../Tests/Raindrop/DiskAndCache/DiskTests.cs | 62 +++++ .../DiskAndCache/DiskTests.cs.meta | 0 Assets/Tests/{ => Raindrop}/ImagingTests.meta | 0 .../ImagingTests/ImagingTests.cs | 3 +- .../ImagingTests/ImagingTests.cs.meta | 0 Assets/Tests/{ => Raindrop}/NetTests.meta | 0 .../{ => Raindrop}/NetTests/NetworkTests.cs | 0 .../NetTests/NetworkTests.cs.meta | 0 .../RaindropFullIntegrationTests.meta} | 0 .../InputSubroutines.meta | 0 .../InputSubroutines/Login.cs | 13 +- .../InputSubroutines/Login.cs.meta | 0 .../InputSubroutines/UIHelpers.cs | 3 +- .../InputSubroutines/UIHelpers.cs.meta | 0 .../LoginTests.cs | 27 +- .../LoginTests.cs.meta | 0 .../MapServiceTests.cs | 8 +- .../MapServiceTests.cs.meta | 0 .../Raindrop/RaindropIntegrationTests.meta | 3 + .../RaindropIntegrationTests/GridManager.meta | 3 + .../GridManager/GridTests.cs | 48 ++++ .../GridManager/GridTests.cs.meta | 3 + .../GridSelectorTests.meta | 3 + .../GridSelectorTests/GridSelectorTests.cs | 72 +++++ .../GridSelectorTests.cs.meta | 3 + .../RaindropIntegrationTests/Helpers.meta | 3 + .../Helpers/SceneLoader.cs | 37 +++ .../Helpers/SceneLoader.cs.meta | 3 + .../StaticAssetsCopierTests.cs | 47 ++++ .../StaticAssetsCopierTests.cs.meta | 3 + .../TestSceneConstructionTests.meta | 3 + .../TestSceneConstructionTests.cs | 23 ++ .../TestSceneConstructionTests.cs.meta | 3 + Assets/Tests/Raindrop/SoundTests.cs | 50 ++++ Assets/Tests/Raindrop/SoundTests.cs.meta | 3 + 43 files changed, 667 insertions(+), 77 deletions(-) delete mode 100644 Assets/Tests/DiskAndCache/DiskTests.cs create mode 100644 Assets/Tests/HeadlessBootstrapScene.unity create mode 100644 Assets/Tests/HeadlessBootstrapScene.unity.meta delete mode 100644 Assets/Tests/Helper.cs delete mode 100644 Assets/Tests/Helper.cs.meta create mode 100644 Assets/Tests/Raindrop.meta rename Assets/Tests/{ => Raindrop}/DiskAndCache.meta (100%) create mode 100644 Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs rename Assets/Tests/{ => Raindrop}/DiskAndCache/DiskTests.cs.meta (100%) rename Assets/Tests/{ => Raindrop}/ImagingTests.meta (100%) rename Assets/Tests/{ => Raindrop}/ImagingTests/ImagingTests.cs (98%) rename Assets/Tests/{ => Raindrop}/ImagingTests/ImagingTests.cs.meta (100%) rename Assets/Tests/{ => Raindrop}/NetTests.meta (100%) rename Assets/Tests/{ => Raindrop}/NetTests/NetworkTests.cs (100%) rename Assets/Tests/{ => Raindrop}/NetTests/NetworkTests.cs.meta (100%) rename Assets/Tests/{RaindropIntegrationTests.meta => Raindrop/RaindropFullIntegrationTests.meta} (100%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/InputSubroutines.meta (100%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/InputSubroutines/Login.cs (78%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/InputSubroutines/Login.cs.meta (100%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/InputSubroutines/UIHelpers.cs (91%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/InputSubroutines/UIHelpers.cs.meta (100%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/LoginTests.cs (85%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/LoginTests.cs.meta (100%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/MapServiceTests.cs (89%) rename Assets/Tests/{RaindropIntegrationTests => Raindrop/RaindropFullIntegrationTests}/MapServiceTests.cs.meta (100%) create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests.meta create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs create mode 100644 Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs.meta create mode 100644 Assets/Tests/Raindrop/SoundTests.cs create mode 100644 Assets/Tests/Raindrop/SoundTests.cs.meta diff --git a/Assets/Tests/DiskAndCache/DiskTests.cs b/Assets/Tests/DiskAndCache/DiskTests.cs deleted file mode 100644 index 0ff29c3..0000000 --- a/Assets/Tests/DiskAndCache/DiskTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using NUnit.Framework; -using UnityEngine; - -namespace Raindrop.Tests.DiskAndCache -{ - public class DiskTests - { - // fixme: after implementing on-sd/on-device caching preferences - [Test] - public void printImportantPaths_Platforms() - { - Debug.Log("Application.persistentDataPath, usually the internal SD for android" + Application.persistentDataPath); - // should be /storage/emulated/0/Android/data/com.UnityTestRunner.UnityTestRunner/files/Pictures/ - - Debug.Log("Application.dataPath, usually not usable for cache " + Application.dataPath); - // Debug.Log("GetAndroidExternalFilesDir internal"+ Disk.DirectoryHelpers.GetAndroidExternalFilesDir(true)); - // should be /storage/6106-8710/Android/data/com.UnityTestRunner.UnityTestRunner/files - - // Debug.Log("GetAndroidExternalFilesDir prefersdcard"+ Disk.DirectoryHelpers.GetAndroidExternalFilesDir(false)); - //should be /storage/emulated/0/Android/data/com.UnityTestRunner.UnityTestRunner/files/Pictures/ - - } - } -} \ No newline at end of file diff --git a/Assets/Tests/HeadlessBootstrapScene.unity b/Assets/Tests/HeadlessBootstrapScene.unity new file mode 100644 index 0000000..ed57b80 --- /dev/null +++ b/Assets/Tests/HeadlessBootstrapScene.unity @@ -0,0 +1,254 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &184716086 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 184716088} + - component: {fileID: 184716087} + m_Layer: 0 + m_Name: Bootstrapper + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &184716087 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 184716086} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fa61eabca29ec274e822d94f50702a99, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &184716088 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 184716086} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &374547285 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 374547287} + - component: {fileID: 374547286} + m_Layer: 0 + m_Name: MainthreadDispatcher + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &374547286 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 374547285} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 166e46cf3e858f546afb5238ba99e9bd, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &374547287 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 374547285} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1665976367 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1665976369} + - component: {fileID: 1665976368} + m_Layer: 0 + m_Name: UIBootstrapper + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!114 &1665976368 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1665976367} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5dbfabecbcda5bb47b7800f9d748db3b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1665976369 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1665976367} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Tests/HeadlessBootstrapScene.unity.meta b/Assets/Tests/HeadlessBootstrapScene.unity.meta new file mode 100644 index 0000000..cdaa0e0 --- /dev/null +++ b/Assets/Tests/HeadlessBootstrapScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a9f35cb3e179fef4389cf769af057e55 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Helper.cs b/Assets/Tests/Helper.cs deleted file mode 100644 index 8f6620d..0000000 --- a/Assets/Tests/Helper.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.IO; -using UnityEngine; - -namespace Raindrop.Tests -{ - public class Helper - { - - //easily write to a file - //filePath = fully-specified file path - public static void WriteToFile(byte[] outbytes, string filePath) - { - //create parent subfolders - var parentDir = Path.GetDirectoryName(filePath); - System.IO.Directory.CreateDirectory(parentDir); - - //write file - System.IO.File.WriteAllBytes(filePath, outbytes); - Debug.Log($"write: {filePath} "); - } - } -} \ No newline at end of file diff --git a/Assets/Tests/Helper.cs.meta b/Assets/Tests/Helper.cs.meta deleted file mode 100644 index 8b99876..0000000 --- a/Assets/Tests/Helper.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 651250a02e4a4314917e0f38c7b077a8 -timeCreated: 1642607248 \ No newline at end of file diff --git a/Assets/Tests/LMV_ExtendedTests/LMVLibraryImageFetchingTests.cs b/Assets/Tests/LMV_ExtendedTests/LMVLibraryImageFetchingTests.cs index f2ca8e9..8289ae7 100644 --- a/Assets/Tests/LMV_ExtendedTests/LMVLibraryImageFetchingTests.cs +++ b/Assets/Tests/LMV_ExtendedTests/LMVLibraryImageFetchingTests.cs @@ -13,6 +13,7 @@ using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; using System.Net; +using Disk; using OpenMetaverse.Http; using Raindrop.Map.Model; using Raindrop.ServiceLocator; @@ -326,7 +327,7 @@ namespace Raindrop.Tests //save that image, j2p var basepath = instance.ClientDir + "/test_cache/"; var relativepath1 = assettexture.AssetID.ToString() + ".j2p"; - Helper.WriteToFile(assettexture.AssetData, Path.Combine(basepath, relativepath1)); + DirectoryHelpers.WriteToFile(assettexture.AssetData, Path.Combine(basepath, relativepath1)); //j2p -> t2d -> png //needs to be on main thread... @@ -338,7 +339,7 @@ namespace Raindrop.Tests //save that image, png var relativepath2 = assettexture.AssetID.ToString() + ".png"; - Helper.WriteToFile(bytes, Path.Combine(basepath, relativepath2)); + DirectoryHelpers.WriteToFile(bytes, Path.Combine(basepath, relativepath2)); }); diff --git a/Assets/Tests/Raindrop.meta b/Assets/Tests/Raindrop.meta new file mode 100644 index 0000000..3750a59 --- /dev/null +++ b/Assets/Tests/Raindrop.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9fb310862a5446dfa7835cd73a33b13c +timeCreated: 1643134294 \ No newline at end of file diff --git a/Assets/Tests/DiskAndCache.meta b/Assets/Tests/Raindrop/DiskAndCache.meta similarity index 100% rename from Assets/Tests/DiskAndCache.meta rename to Assets/Tests/Raindrop/DiskAndCache.meta diff --git a/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs b/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs new file mode 100644 index 0000000..2a4ee98 --- /dev/null +++ b/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using System.IO; +using Disk; +using NUnit.Framework; +using NUnit.Framework.Constraints; +using UnityEngine; +using UnityEngine.TestTools; + +namespace Raindrop.Tests.DiskAndCache +{ + public class DiskTests + { + // fixme: after implementing on-sd/on-device caching preferences + [Test] + public void ImportantPaths_Platforms_IsWritable() + { + Debug.Log("Application.persistentDataPath, usually the internal SD for android" + Application.persistentDataPath); + // should be /storage/emulated/0/Android/data/com.UnityTestRunner.UnityTestRunner/files/Pictures/ + var target = Path.Combine(Application.persistentDataPath, "ImportantPaths_Platforms_IsWritable.txt"); + File.WriteAllLines(target, new List {"success!"}); + + + Debug.Log("Application.dataPath, usually not usable for cache " + Application.dataPath); + // Debug.Log("GetAndroidExternalFilesDir internal"+ Disk.DirectoryHelpers.GetAndroidExternalFilesDir(true)); + // should be /storage/6106-8710/Android/data/com.UnityTestRunner.UnityTestRunner/files + target = Path.Combine(Application.dataPath, "ImportantPaths_Platforms_IsWritable.txt"); + File.WriteAllLines(target, new List {"success!"}); + Assert.Fail(); + + + Debug.Log("GetInternalCacheDir "+ Disk.DirectoryHelpers.GetInternalCacheDir()); + //should be /storage/emulated/0/Android/data/com.UnityTestRunner.UnityTestRunner/files/Pictures/ + target = Path.Combine(DirectoryHelpers.GetInternalCacheDir(), "ImportantPaths_Platforms_IsWritable.txt"); + File.WriteAllLines(target, new List {"success!"}); + } + + [UnityTest] + public IEnumerator StaticAssets_MonobehaviorOnInstantiate_AreCopied() + { + string expectedToBeDeleted = Path.Combine(DirectoryHelpers.GetInternalCacheDir(), + "grids.xml"); + Assert.False(File.Exists(expectedToBeDeleted), + "please manually delete this folder to start the test : " + DirectoryHelpers.GetInternalCacheDir()); + + + var startupCopierObj = GameObject.CreatePrimitive(PrimitiveType.Cube); + var startupCopier = startupCopierObj.AddComponent(); + + //wait for abit... + yield return new WaitForSeconds(3); + Assert.True(startupCopier.copyIsDone); + + string expectedToExist = Path.Combine(DirectoryHelpers.GetInternalCacheDir(), + "grids.xml"); + + Assert.True(File.Exists(expectedToExist),"file not exist: " + expectedToExist); + + yield break; + } + } +} \ No newline at end of file diff --git a/Assets/Tests/DiskAndCache/DiskTests.cs.meta b/Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs.meta similarity index 100% rename from Assets/Tests/DiskAndCache/DiskTests.cs.meta rename to Assets/Tests/Raindrop/DiskAndCache/DiskTests.cs.meta diff --git a/Assets/Tests/ImagingTests.meta b/Assets/Tests/Raindrop/ImagingTests.meta similarity index 100% rename from Assets/Tests/ImagingTests.meta rename to Assets/Tests/Raindrop/ImagingTests.meta diff --git a/Assets/Tests/ImagingTests/ImagingTests.cs b/Assets/Tests/Raindrop/ImagingTests/ImagingTests.cs similarity index 98% rename from Assets/Tests/ImagingTests/ImagingTests.cs rename to Assets/Tests/Raindrop/ImagingTests/ImagingTests.cs index 3827b20..29a2713 100644 --- a/Assets/Tests/ImagingTests/ImagingTests.cs +++ b/Assets/Tests/Raindrop/ImagingTests/ImagingTests.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using Disk; using NUnit.Framework; using OpenMetaverse; using OpenMetaverse.Imaging; @@ -61,7 +62,7 @@ namespace Raindrop.Tests.ImagingTests var outbytes = texture.EncodeToJPG(100); string appDataDir = clientDir + "/ImagingTests/menhara_out_clientDir.jpg"; - Helper.WriteToFile(outbytes, appDataDir); + DirectoryHelpers.WriteToFile(outbytes, appDataDir); #if UNITY_EDITOR #elif UNITY_ANDROID //warn, this is true if we are in editor... string outPath_GetAndroidExternalFilesDir_internal = diff --git a/Assets/Tests/ImagingTests/ImagingTests.cs.meta b/Assets/Tests/Raindrop/ImagingTests/ImagingTests.cs.meta similarity index 100% rename from Assets/Tests/ImagingTests/ImagingTests.cs.meta rename to Assets/Tests/Raindrop/ImagingTests/ImagingTests.cs.meta diff --git a/Assets/Tests/NetTests.meta b/Assets/Tests/Raindrop/NetTests.meta similarity index 100% rename from Assets/Tests/NetTests.meta rename to Assets/Tests/Raindrop/NetTests.meta diff --git a/Assets/Tests/NetTests/NetworkTests.cs b/Assets/Tests/Raindrop/NetTests/NetworkTests.cs similarity index 100% rename from Assets/Tests/NetTests/NetworkTests.cs rename to Assets/Tests/Raindrop/NetTests/NetworkTests.cs diff --git a/Assets/Tests/NetTests/NetworkTests.cs.meta b/Assets/Tests/Raindrop/NetTests/NetworkTests.cs.meta similarity index 100% rename from Assets/Tests/NetTests/NetworkTests.cs.meta rename to Assets/Tests/Raindrop/NetTests/NetworkTests.cs.meta diff --git a/Assets/Tests/RaindropIntegrationTests.meta b/Assets/Tests/Raindrop/RaindropFullIntegrationTests.meta similarity index 100% rename from Assets/Tests/RaindropIntegrationTests.meta rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests.meta diff --git a/Assets/Tests/RaindropIntegrationTests/InputSubroutines.meta b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines.meta similarity index 100% rename from Assets/Tests/RaindropIntegrationTests/InputSubroutines.meta rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines.meta diff --git a/Assets/Tests/RaindropIntegrationTests/InputSubroutines/Login.cs b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/Login.cs similarity index 78% rename from Assets/Tests/RaindropIntegrationTests/InputSubroutines/Login.cs rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/Login.cs index fe5b076..94734a1 100644 --- a/Assets/Tests/RaindropIntegrationTests/InputSubroutines/Login.cs +++ b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/Login.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections; +using System.Collections; using UnityEngine; using UnityEngine.Assertions; using UnityEngine.UI; -namespace Tests.RaindropIntegrationTests.InputSubroutines +namespace Tests.Raindrop.RaindropFullIntegrationTests.InputSubroutines { - // Subroutines to perform login. + // Subroutines to perform login. (in full integration mode.) public class Login { // type user creds and click the login button. @@ -15,7 +14,7 @@ namespace Tests.RaindropIntegrationTests.InputSubroutines TypeUserAndPassIntoLoginPanel(username, password); yield return new WaitForSeconds(2); UIHelpers.Click_ButtonByUnityName("LoginBtn"); - yield return new WaitForSeconds(20); + yield return new WaitForSeconds(12); } public static void TypeUserAndPassIntoLoginPanel(string _username, string _password) @@ -31,15 +30,17 @@ namespace Tests.RaindropIntegrationTests.InputSubroutines */ // on the welcome screen, click the go button. - public static void accepttheeula() + public static IEnumerator accepttheeula() { string eulaCheckbox = "AgreeToggle"; var checkboxEULA = GameObject.Find(eulaCheckbox); Assert.IsNotNull(checkboxEULA, "Missing checkbox " + eulaCheckbox); checkboxEULA.GetComponent().onValueChanged.Invoke(true); + yield return new WaitForSeconds(2); string eulaCloseBtn = "NextButton"; Assert.IsTrue(UIHelpers.Click_ButtonByUnityName(eulaCloseBtn)); + yield return new WaitForSeconds(2); } diff --git a/Assets/Tests/RaindropIntegrationTests/InputSubroutines/Login.cs.meta b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/Login.cs.meta similarity index 100% rename from Assets/Tests/RaindropIntegrationTests/InputSubroutines/Login.cs.meta rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/Login.cs.meta diff --git a/Assets/Tests/RaindropIntegrationTests/InputSubroutines/UIHelpers.cs b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/UIHelpers.cs similarity index 91% rename from Assets/Tests/RaindropIntegrationTests/InputSubroutines/UIHelpers.cs rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/UIHelpers.cs index 4b63a18..650371a 100644 --- a/Assets/Tests/RaindropIntegrationTests/InputSubroutines/UIHelpers.cs +++ b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/UIHelpers.cs @@ -4,8 +4,9 @@ using TMPro; using UnityEngine; using UnityEngine.UI; -namespace Tests.RaindropIntegrationTests.InputSubroutines +namespace Tests.Raindrop.RaindropFullIntegrationTests.InputSubroutines { + //static methods to help you click buttons! static internal class UIHelpers { public static bool Click_ButtonByUnityName(string gameObjectName) diff --git a/Assets/Tests/RaindropIntegrationTests/InputSubroutines/UIHelpers.cs.meta b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/UIHelpers.cs.meta similarity index 100% rename from Assets/Tests/RaindropIntegrationTests/InputSubroutines/UIHelpers.cs.meta rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/InputSubroutines/UIHelpers.cs.meta diff --git a/Assets/Tests/RaindropIntegrationTests/LoginTests.cs b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/LoginTests.cs similarity index 85% rename from Assets/Tests/RaindropIntegrationTests/LoginTests.cs rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/LoginTests.cs index d587af6..16892e2 100644 --- a/Assets/Tests/RaindropIntegrationTests/LoginTests.cs +++ b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/LoginTests.cs @@ -1,17 +1,16 @@ using System.Collections; -using Lean.Gui; using NUnit.Framework; using Raindrop; using Raindrop.Netcom; using Raindrop.Presenters; +using Raindrop.ServiceLocator; using Raindrop.Services; -using TMPro; +using Tests.Raindrop.RaindropFullIntegrationTests.InputSubroutines; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; -using UnityEngine.UI; -namespace Tests.RaindropIntegrationTests +namespace Tests.Raindrop.RaindropFullIntegrationTests { /* * UI-intensive tests for the login functionality. the main scene will be loaded. @@ -23,7 +22,7 @@ namespace Tests.RaindropIntegrationTests private static string _username = "***REMOVED*** Resident"; // fixme: move this to some xml private static string _password = "***REMOVED***"; private RaindropNetcom netcom { get { return instance.Netcom; } } - private RaindropInstance instance { get { return Raindrop.ServiceLocator.ServiceLocator.Instance.Get(); } } + private RaindropInstance instance { get { return ServiceLocator.Instance.Get(); } } [OneTimeSetUp] public void OneTimeSetUp() @@ -56,7 +55,7 @@ namespace Tests.RaindropIntegrationTests var vm = Get_ViewsManager(); //1. get the refence to the UI service. - var srvLocator = Raindrop.ServiceLocator.ServiceLocator.Instance; + var srvLocator = ServiceLocator.Instance; UIService uiSrv = null; try { @@ -69,10 +68,10 @@ namespace Tests.RaindropIntegrationTests // uiSrv.resetUI(); //1a. accept the eula if needed. - if (uiSrv.ScreensManager.topCanvas.canvasType == CanvasType.Eula) + if (uiSrv.ScreensManager.TopCanvas.canvasType == CanvasType.Eula) { // well, we need to agree to eula first. - InputSubroutines.Login.accepttheeula(); + yield return Login.accepttheeula(); yield return new WaitForSeconds(2); } @@ -82,7 +81,7 @@ namespace Tests.RaindropIntegrationTests for (int i = 0; i < times; i++) { //1b. we are on the welcome screen. now navigate to the login screen. - if (uiSrv.ScreensManager.topCanvas.canvasType == CanvasType.Welcome) + if (uiSrv.ScreensManager.TopCanvas.canvasType == CanvasType.Welcome) { yield return new WaitForSeconds(2); yield return Utils.UIHelpers.Click_Button_Welcome2LoginScreen(); @@ -93,20 +92,20 @@ namespace Tests.RaindropIntegrationTests } //1b. we are on the login screen. do login. assert logged in. - Assert.IsTrue(uiSrv.ScreensManager.topCanvas.canvasType == CanvasType.Login); + Assert.IsTrue(uiSrv.ScreensManager.TopCanvas.canvasType == CanvasType.Login); LoginPresenterIsAvailable(vm); - yield return InputSubroutines.Login.StartLogin(_username, _password); + yield return Login.StartLogin(_username, _password); //assert the backend API; that we are logged in. Assert.True(instance.Client.Network.Connected == true, "check API that we are logged in"); //finally, disconnect. assert disconnected. - InputSubroutines.UIHelpers.Click_ButtonByUnityName("LogoutBtn"); - yield return new WaitForSeconds(12); + UIHelpers.Click_ButtonByUnityName("LogoutBtn"); + yield return new WaitForSeconds(10); Assert.True(instance.Client.Network.Connected == false, "check API that we are logged out"); - yield return new WaitForSeconds(12); + yield return new WaitForSeconds(4); } diff --git a/Assets/Tests/RaindropIntegrationTests/LoginTests.cs.meta b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/LoginTests.cs.meta similarity index 100% rename from Assets/Tests/RaindropIntegrationTests/LoginTests.cs.meta rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/LoginTests.cs.meta diff --git a/Assets/Tests/RaindropIntegrationTests/MapServiceTests.cs b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/MapServiceTests.cs similarity index 89% rename from Assets/Tests/RaindropIntegrationTests/MapServiceTests.cs rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/MapServiceTests.cs index 77dcc07..9cf3e64 100644 --- a/Assets/Tests/RaindropIntegrationTests/MapServiceTests.cs +++ b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/MapServiceTests.cs @@ -1,13 +1,13 @@ using System.Collections; using NUnit.Framework; -using OpenMetaverse; using Raindrop.Map.Model; using Raindrop.ServiceLocator; +using Raindrop.Unity; using UnityEngine; using UnityEngine.TestTools; using Utils = OpenMetaverse.Utils; -namespace Tests.RaindropIntegrationTests +namespace Tests.Raindrop.RaindropFullIntegrationTests { //test the map service. public class MapServiceTests @@ -17,10 +17,10 @@ namespace Tests.RaindropIntegrationTests [UnityTest] public IEnumerator Test_MapService_SingleTile() { - Raindrop.Unity.SceneBootstrapperGenerator.Init(); + SceneBootstrapperGenerator.Init(); yield return new WaitForSeconds(2); Assert.True(ServiceLocator.Instance != null); - Raindrop.Unity.SceneBootstrapperGenerator.AddMainThreadDispatcher(); + SceneBootstrapperGenerator.AddMainThreadDispatcher(); BeginMapFetcher(); var fetcher = ServiceLocator.Instance.Get(); diff --git a/Assets/Tests/RaindropIntegrationTests/MapServiceTests.cs.meta b/Assets/Tests/Raindrop/RaindropFullIntegrationTests/MapServiceTests.cs.meta similarity index 100% rename from Assets/Tests/RaindropIntegrationTests/MapServiceTests.cs.meta rename to Assets/Tests/Raindrop/RaindropFullIntegrationTests/MapServiceTests.cs.meta diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests.meta new file mode 100644 index 0000000..53725d6 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0b0d9cc06a564523ae176b5bdf7f0502 +timeCreated: 1643035471 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager.meta new file mode 100644 index 0000000..2dd1bbb --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7f763de27118482fa863410586d77d47 +timeCreated: 1643265431 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs new file mode 100644 index 0000000..b14757c --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Disk; +using NUnit.Framework; +using OpenMetaverse; +using Raindrop; + +namespace Raindrop.Tests.Raindrop.RaindropIntegrationTests.GridManager +{ + public class GridTests + { + /// + /// serialise list of grids into the LLSD xml file. + /// + [Test] + public void Serialisation_CustomGrids() + { + var instance = new RaindropInstance(new GridClient()); + + instance.GridManger.SaveCustomGrids( DirectoryHelpers.GetInternalCacheDir()); + + instance.CleanUp(); + } + + /// + /// Create 2 grids, save them to file. + /// + [Test] + public void Serialisation_CustomGrids_Two() + { + var instance = new RaindropInstance(new GridClient()); + + instance.GridManger.RegisterCustomGrid( + new Grid("lollll" + , "Second Life (agni)" + , "https://login.agni.lindenlab.com/cgi-bin/login.cgi") + ); + + + instance.GridManger.SaveCustomGrids( DirectoryHelpers.GetInternalCacheDir()); + + instance.CleanUp(); + } + + + } +} \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs.meta new file mode 100644 index 0000000..4128b45 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridManager/GridTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1e524358d56f42adaf8d8e8584779458 +timeCreated: 1643265444 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests.meta new file mode 100644 index 0000000..30327ca --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f2538726b18542279fff9be7fe3a32c7 +timeCreated: 1643132389 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs new file mode 100644 index 0000000..e253078 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections; +using NUnit.Framework; +using Raindrop; +using Raindrop.GridSelection; +using Raindrop.ServiceLocator; +using Raindrop.Tests; +using Tests.Raindrop.RaindropIntegrationTests.Helpers; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; +using UnityEngine.UI; + +namespace Tests.Raindrop.RaindropIntegrationTests.GridSelectorTests +{ + [TestFixture()] + public class GridSelectorTests + { + //https://forum.unity.com/threads/add-coroutine-version-of-onetimesetup.890092/ + private bool initialized = false; + [UnitySetUp] + public IEnumerator UnitySetup() + { + if (!initialized) + { + initialized = true; + + //+++++++++++++load test scene+++++++ + // load the base scene + yield return Helpers.SceneLoader.LoadHeadlessScene(); + + //at this point, raindropInstance is ready. + var instance = ServiceLocator.Instance.Get(); + Assert.True(instance!=null, "instance is null"); + + //open up the dropdown small ui. + string pathOfPrefabDirectory = "LoginUI/"; + string prefabName = "GridSelection"; + var dropdownUI = GameObject.Instantiate( + Resources.Load(pathOfPrefabDirectory+prefabName) + ) as GameObject; + Assert.True(dropdownUI!=null, "dropdown prefab not found in resources"); + //+++++++++++++finish load test scene+++++++ + yield return null; + + } + } + + [OneTimeTearDown] + public static void OneTimeTearDown() + { + SceneLoader.UnloadHeadlessScene(); + } + + + [UnityTest] + public IEnumerator GridDropdown_HasManyGrids() + { + //click dropdown UI to reveal its full content + var dropdown_GO = GameObject.Find("Dropdown"); + Assert.True(dropdown_GO,"the GO with name Dropdown is not found"); + DropdownViewPresenter gridDropdown = dropdown_GO.GetComponent(); + Assert.True(gridDropdown,"the dropdown doesnt have DropdownViewPresenter"); + + yield return new WaitForSeconds(2); // seems if you don't wait, the options count are not updated yet. + + //Assert that there is more than 5 grids in that list. + Assert.True(gridDropdown.GetOptionsCount() > 5 + , "dropdown has insufficient options : "+ gridDropdown.GetOptionsCount()); + } + } +} \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs.meta new file mode 100644 index 0000000..0e0c19f --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/GridSelectorTests/GridSelectorTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 302344801d784f8faf7e1984982c8b02 +timeCreated: 1643132403 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers.meta new file mode 100644 index 0000000..0846df1 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e27be3f16e6c478da2d22a136c9c3738 +timeCreated: 1643133902 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs b/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs new file mode 100644 index 0000000..d96c0f7 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs @@ -0,0 +1,37 @@ +using System.Collections; +using NUnit.Framework; +using Raindrop; +using Raindrop.ServiceLocator; +using Raindrop.Services.Bootstrap; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace Tests.Raindrop.RaindropIntegrationTests.Helpers +{ + public static class SceneLoader + { + // load a empty scene with : + // - bootstrapper (raindropinstance + servicelocator) + // - mainthreaddispatcher object + public static IEnumerator LoadHeadlessScene() + { + SceneManager.LoadScene("Tests/HeadlessBootstrapScene"); + yield return new WaitForFixedUpdate(); //testing out if this is a ok replacement to just witing an arbitrary amount of seconds. + + var bootstrap = GameObject.Find("Bootstrapper"); + Assert.True(bootstrap, "bootstrapper object not found"); + + var rdbs = bootstrap.GetComponent(); + Assert.True(rdbs); + + var instance = ServiceLocator.Instance.Get(); + Assert.True(instance != null); + } + + public static void UnloadHeadlessScene() + { + SceneManager.UnloadSceneAsync("Tests/HeadlessBootstrapScene"); + + } + } +} \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs.meta new file mode 100644 index 0000000..f3429e7 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/Helpers/SceneLoader.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0bdaa1a5de194aea9d8913484deb40da +timeCreated: 1643133911 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs b/Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs new file mode 100644 index 0000000..c531aca --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs @@ -0,0 +1,47 @@ +using System.Collections; +using System.IO; +using Disk; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; + +namespace Raindrop.Tests.Raindrop.RaindropIntegrationTests +{ + //test that the static copier works in the product. + public class StaticAssetsCopierTests + { + + [UnityTest] + public IEnumerator StaticAssets_MainSceneOnBoot_AreCopied() + { + //delete any files in the local cache folder + System.IO.DirectoryInfo localCacheFolder + = new DirectoryInfo(DirectoryHelpers.GetInternalCacheDir()); + foreach (FileInfo file in localCacheFolder.GetFiles()) + { + file.Delete(); + } + foreach (DirectoryInfo dir in localCacheFolder.GetDirectories()) + { + dir.Delete(true); + } + + // start main scene, which includes the startupCopier + SceneManager.LoadScene("Scenes/MainScene"); + // var startupCopierObj = GameObject.CreatePrimitive(PrimitiveType.Cube); + // var startupCopier = startupCopierObj.AddComponent(); + + //wait for abit... + yield return new WaitForSeconds(10); + // Assert.True(startupCopier.copyIsDone); + + string expectedToExist = Path.Combine(DirectoryHelpers.GetInternalCacheDir(), + "grids.xml"); + + Assert.True(File.Exists(expectedToExist),"file not exist: " + expectedToExist); + + yield break; + } + } +} \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs.meta new file mode 100644 index 0000000..fa82c0c --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/StaticAssetsCopierTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 021b88811717459fb1339d40a8d4f6cb +timeCreated: 1643179061 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests.meta new file mode 100644 index 0000000..6dc4618 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9a54191cad1c449bacaa1d997c06511b +timeCreated: 1643132770 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs b/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs new file mode 100644 index 0000000..53e866f --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs @@ -0,0 +1,23 @@ +using System.Collections; +using NUnit.Framework; +using Tests.Raindrop.RaindropIntegrationTests.Helpers; +using UnityEngine.TestTools; + +namespace Tests.Raindrop.RaindropIntegrationTests.TestSceneConstructionTests +{ + //test that it is possible to construct the test scene. + //the test scene contains no UI, but has a bootstrapped raindropinstance + [TestFixture()] + + public class TestSceneConstructionTests + { + [UnityTest] + public IEnumerator SceneLoading_Bootstrapper_IsSuccessful() + { + yield return SceneLoader.LoadHeadlessScene(); + + yield break; + } + + } +} \ No newline at end of file diff --git a/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs.meta b/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs.meta new file mode 100644 index 0000000..9327b18 --- /dev/null +++ b/Assets/Tests/Raindrop/RaindropIntegrationTests/TestSceneConstructionTests/TestSceneConstructionTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4d6b400e45794cbd8182e50e086352ac +timeCreated: 1643132785 \ No newline at end of file diff --git a/Assets/Tests/Raindrop/SoundTests.cs b/Assets/Tests/Raindrop/SoundTests.cs new file mode 100644 index 0000000..a9d0d56 --- /dev/null +++ b/Assets/Tests/Raindrop/SoundTests.cs @@ -0,0 +1,50 @@ +using System.Collections; +using NUnit.Framework; +using OpenMetaverse; +using Raindrop; +using UnityEngine; +using UnityEngine.TestTools; + +namespace Tests.Raindrop +{ + [TestFixture()] + public class SoundTests + { + // Prerequisite: you have copied a ogg file into the + // cache at /cache/0/0/00000000-0000-0000-0000-000000000000 + + // you will hear audio play. no exceptions thrown. green tick. + [UnityTest] + public IEnumerator Play_CachedSound_IsSuccessful() + { + RaindropInstance instance = new RaindropInstance(new GridClient()); + + instance.MediaManager.PlayUISound(UUID.Zero); + + yield break; + } + + // detect problems with raindrop instance starting and stopping again. + [UnityTest] + public IEnumerator StabilityTest_Restart_RaindropInstance() + { + int i = 8; + while (i-- > 0) + { + RaindropInstance instance = new RaindropInstance(new GridClient()); + instance.MediaManager.PlayUISound(UUID.Zero); + + yield return new WaitForSeconds(4); + + instance.CleanUp(); + instance = null; + } + + yield break; + } + + } + + + +} \ No newline at end of file diff --git a/Assets/Tests/Raindrop/SoundTests.cs.meta b/Assets/Tests/Raindrop/SoundTests.cs.meta new file mode 100644 index 0000000..32948c5 --- /dev/null +++ b/Assets/Tests/Raindrop/SoundTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 94ea0e5fcc374a4cb88871314a97165d +timeCreated: 1643995353 \ No newline at end of file