From c1a9a6113d88a225fa00c6fd25f6f5fa01a732f8 Mon Sep 17 00:00:00 2001 From: hadashi Date: Wed, 12 May 2021 16:01:22 +0900 Subject: [PATCH] Re-install RuntimeUnitTestToolkit via upm --- VContainer/Assets/RuntimeUnitTestToolkit.meta | 8 - .../Assets/RuntimeUnitTestToolkit/Editor.meta | 8 - .../Editor/HierarchyTreeBuilder.cs | 133 ----- .../Editor/HierarchyTreeBuilder.cs.meta | 11 - .../Editor/UnitTestBuilder.MenuItems.cs | 345 ----------- .../Editor/UnitTestBuilder.MenuItems.cs.meta | 11 - .../Editor/UnitTestBuilder.cs | 546 ------------------ .../Editor/UnitTestBuilder.cs.meta | 11 - .../RuntimeUnitTestToolkit.asmdef | 16 - .../RuntimeUnitTestToolkit.asmdef.meta | 7 - .../RuntimeUnitTestToolkit/UnitTestData.cs | 391 ------------- .../UnitTestData.cs.meta | 11 - .../RuntimeUnitTestToolkit/UnitTestRunner.cs | 450 --------------- .../UnitTestRunner.cs.meta | 11 - .../RuntimeUnitTestToolkit/package.json | 11 - .../RuntimeUnitTestToolkit/package.json.meta | 7 - VContainer/Packages/manifest.json | 3 +- VContainer/Packages/packages-lock.json | 13 +- 18 files changed, 13 insertions(+), 1980 deletions(-) delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/UnitTestData.cs delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/UnitTestData.cs.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs.meta delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/package.json delete mode 100644 VContainer/Assets/RuntimeUnitTestToolkit/package.json.meta diff --git a/VContainer/Assets/RuntimeUnitTestToolkit.meta b/VContainer/Assets/RuntimeUnitTestToolkit.meta deleted file mode 100644 index 1decb1cf..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2fa044ce1aef84c9b8cf998f69afea09 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VContainer/Assets/RuntimeUnitTestToolkit/Editor.meta b/VContainer/Assets/RuntimeUnitTestToolkit/Editor.meta deleted file mode 100644 index bc12fae1..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 000065f769e72469489929158112f8f5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs b/VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs deleted file mode 100644 index 9a2adc2b..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -#if UNITY_EDITOR - -using System; -using UnityEngine; - -namespace RuntimeUnitTestToolkit.Editor -{ - // functional declarative construction like flutter. - - internal interface IBuilder - { - GameObject GameObject { get; } - T GetComponent(); - } - - internal class Builder : IBuilder - where T : Component - { - public T Component1 { get; private set; } - public GameObject GameObject { get; private set; } - - public Transform Transform { get { return GameObject.transform; } } - public RectTransform RectTransform { get { return GameObject.GetComponent(); } } - - public Action SetTarget - { - set - { - value(this.GameObject); - } - } - - - public IBuilder Child - { - set - { - value.GameObject.transform.SetParent(GameObject.transform); - } - } - - public IBuilder[] Children - { - set - { - foreach (var item in value) - { - item.GameObject.transform.SetParent(GameObject.transform); - } - } - } - - public Builder(string name) - { - this.GameObject = new GameObject(name); - this.Component1 = GameObject.AddComponent(); - } - - public Builder(string name, out T referenceSelf) // out primary reference. - { - this.GameObject = new GameObject(name); - this.Component1 = GameObject.AddComponent(); - referenceSelf = this.Component1; - } - - public TComponent GetComponent() - { - return this.GameObject.GetComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - { - public T2 Component2 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component2 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component2 = GameObject.AddComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - where T3 : Component - { - public T3 Component3 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component3 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component3 = GameObject.AddComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - where T3 : Component - where T4 : Component - { - public T4 Component4 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component4 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component4 = GameObject.AddComponent(); - } - } -} - -#endif \ No newline at end of file diff --git a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta b/VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta deleted file mode 100644 index bb605280..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d35e851bf492448cb47afb87bf13e2c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs b/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs deleted file mode 100644 index 94508b51..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs +++ /dev/null @@ -1,345 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; - -// Settings MenuItems. - -public static partial class UnitTestBuilder -{ - [MenuItem("Test/Settings/ScriptBackend/Mono", validate = true, priority = 1)] - static bool ValidateScriptBackendMono() - { - Menu.SetChecked("Test/Settings/ScriptBackend/Mono", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.Mono2x); - return true; - } - - [MenuItem("Test/Settings/ScriptBackend/Mono", validate = false, priority = 1)] - static void ScriptBackendMono() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentScriptBackend = false; - settings.ScriptBackend = ScriptingImplementation.Mono2x; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = true, priority = 2)] - static bool ValidateScriptBackendIL2CPP() - { - Menu.SetChecked("Test/Settings/ScriptBackend/IL2CPP", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.IL2CPP); - return true; - } - - [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = false, priority = 2)] - static void ScriptBackendIL2CPP() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentScriptBackend = false; - settings.ScriptBackend = ScriptingImplementation.IL2CPP; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/AutoRunPlayer", validate = true, priority = 3)] - static bool ValidateAutoRun() - { - Menu.SetChecked("Test/Settings/AutoRunPlayer", LoadOrGetDefaultSettings().AutoRunPlayer); - return true; - } - - [MenuItem("Test/Settings/AutoRunPlayer", validate = false, priority = 3)] - static void AutoRun() - { - var settings = LoadOrGetDefaultSettings(); - settings.AutoRunPlayer = !settings.AutoRunPlayer; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/Headless", validate = true, priority = 4)] - static bool ValidateHeadless() - { - Menu.SetChecked("Test/Settings/Headless", LoadOrGetDefaultSettings().Headless); - return true; - } - - [MenuItem("Test/Settings/Headless", validate = false, priority = 4)] - static void Headless() - { - var settings = LoadOrGetDefaultSettings(); - settings.Headless = !settings.Headless; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/DisableAutoClose", validate = true, priority = 5)] - static bool ValidateDisableAutoClose() - { - Menu.SetChecked("Test/Settings/DisableAutoClose", LoadOrGetDefaultSettings().DisableAutoClose); - return true; - } - - [MenuItem("Test/Settings/DisableAutoClose", validate = false, priority = 5)] - static void DisableAutoClose() - { - var settings = LoadOrGetDefaultSettings(); - settings.DisableAutoClose = !settings.DisableAutoClose; - SaveSettings(settings); - } - - // generated - - /* - * - void Main() -{ -var sb = new StringBuilder(); - -var p = 1; -foreach (var target in Enum.GetNames(typeof(BuildTarget))) -{ - var path = $"Test/Settings/BuildTarget/{target}"; - var priority = p++; - - var template = $@" -[MenuItem(""{path}"", validate = true, priority = {priority})] -static bool ValidateBuildTarget{target}() -{{ -Menu.SetChecked(""{path}"", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.{target}); -return true; -}} - -[MenuItem(""{path}"", validate = false, priority = {priority})] -static void BuildTarget{target}() -{{ -var settings = LoadOrGetDefaultSettings(); -settings.UseCurrentBuildTarget = false; -settings.BuildTarget = BuildTarget.{target}; -SaveSettings(settings); -}}"; - - sb.AppendLine(template); -} - -sb.ToString().Dump(); -} - -public enum BuildTarget -{ -StandaloneWindows, -StandaloneWindows64, -StandaloneLinux, -StandaloneLinux64, -StandaloneOSX, -WebGL, -iOS, -Android, -WSAPlayer, -PS4, -XboxOne, -Switch, -} - */ - - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = true, priority = 1)] - static bool ValidateBuildTargetStandaloneWindows() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = false, priority = 1)] - static void BuildTargetStandaloneWindows() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneWindows; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = true, priority = 2)] - static bool ValidateBuildTargetStandaloneWindows64() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows64); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = false, priority = 2)] - static void BuildTargetStandaloneWindows64() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneWindows64; - SaveSettings(settings); - } - -#if !UNITY_2019_2_OR_NEWER - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = true, priority = 3)] - static bool ValidateBuildTargetStandaloneLinux() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = false, priority = 3)] - static void BuildTargetStandaloneLinux() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneLinux; - SaveSettings(settings); - } - -#endif - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = true, priority = 4)] - static bool ValidateBuildTargetStandaloneLinux64() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux64); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = false, priority = 4)] - static void BuildTargetStandaloneLinux64() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneLinux64; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = true, priority = 5)] - static bool ValidateBuildTargetStandaloneOSX() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneOSX", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneOSX); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = false, priority = 5)] - static void BuildTargetStandaloneOSX() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneOSX; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/WebGL", validate = true, priority = 6)] - static bool ValidateBuildTargetWebGL() - { - Menu.SetChecked("Test/Settings/BuildTarget/WebGL", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WebGL); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/WebGL", validate = false, priority = 6)] - static void BuildTargetWebGL() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.WebGL; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/iOS", validate = true, priority = 7)] - static bool ValidateBuildTargetiOS() - { - Menu.SetChecked("Test/Settings/BuildTarget/iOS", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.iOS); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/iOS", validate = false, priority = 7)] - static void BuildTargetiOS() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.iOS; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/Android", validate = true, priority = 8)] - static bool ValidateBuildTargetAndroid() - { - Menu.SetChecked("Test/Settings/BuildTarget/Android", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Android); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/Android", validate = false, priority = 8)] - static void BuildTargetAndroid() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.Android; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = true, priority = 9)] - static bool ValidateBuildTargetWSAPlayer() - { - Menu.SetChecked("Test/Settings/BuildTarget/WSAPlayer", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WSAPlayer); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = false, priority = 9)] - static void BuildTargetWSAPlayer() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.WSAPlayer; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/PS4", validate = true, priority = 10)] - static bool ValidateBuildTargetPS4() - { - Menu.SetChecked("Test/Settings/BuildTarget/PS4", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.PS4); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/PS4", validate = false, priority = 10)] - static void BuildTargetPS4() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.PS4; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = true, priority = 11)] - static bool ValidateBuildTargetXboxOne() - { - Menu.SetChecked("Test/Settings/BuildTarget/XboxOne", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.XboxOne); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = false, priority = 11)] - static void BuildTargetXboxOne() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.XboxOne; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/Switch", validate = true, priority = 12)] - static bool ValidateBuildTargetSwitch() - { - Menu.SetChecked("Test/Settings/BuildTarget/Switch", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Switch); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/Switch", validate = false, priority = 12)] - static void BuildTargetSwitch() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.Switch; - SaveSettings(settings); - } - - - - - - - - -} - -#endif diff --git a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta b/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta deleted file mode 100644 index cc7429f1..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3798791f3a5404b8fad6bab104514dd8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs b/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs deleted file mode 100644 index ca45d0b9..00000000 --- a/VContainer/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs +++ /dev/null @@ -1,546 +0,0 @@ -#if UNITY_EDITOR - -using RuntimeUnitTestToolkit; -using RuntimeUnitTestToolkit.Editor; -using System; -using UnityEditor; -using UnityEditor.Build.Reporting; -using UnityEditor.SceneManagement; -using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.SceneManagement; -using UnityEngine.UI; - -internal class RuntimeUnitTestSettings -{ - public ScriptingImplementation ScriptBackend; - public bool UseCurrentScriptBackend; - public BuildTarget BuildTarget; - public bool UseCurrentBuildTarget; - - public bool Headless; - public bool AutoRunPlayer; - public bool DisableAutoClose; - - public RuntimeUnitTestSettings() - { - UseCurrentBuildTarget = true; - UseCurrentScriptBackend = true; - Headless = false; - AutoRunPlayer = true; - DisableAutoClose = false; - } - - public override string ToString() - { - return $"{ScriptBackend} {BuildTarget} Headless:{Headless} AutoRunPlayer:{AutoRunPlayer} DisableAutoClose:{DisableAutoClose}"; - } -} - -// no namespace(because invoke from commandline) -public static partial class UnitTestBuilder -{ - const string SettingsKeyBase = "RuntimeUnitTest.Settings."; - - [MenuItem("Test/BuildUnitTest")] - public static void BuildUnitTest() - { - var settings = new RuntimeUnitTestSettings(); // default - - string buildPath = null; - - if (Application.isBatchMode) // from commandline - { - settings.AutoRunPlayer = false; - settings.DisableAutoClose = false; - - var cmdArgs = Environment.GetCommandLineArgs(); - for (int i = 0; i < cmdArgs.Length; i++) - { - if (string.Equals(cmdArgs[i].Trim('-', '/'), "ScriptBackend", StringComparison.OrdinalIgnoreCase)) - { - settings.UseCurrentScriptBackend = false; - var str = cmdArgs[++i]; - if (str.StartsWith("mono", StringComparison.OrdinalIgnoreCase)) - { - settings.ScriptBackend = ScriptingImplementation.Mono2x; - } - else if (str.StartsWith("IL2CPP", StringComparison.OrdinalIgnoreCase)) - { - settings.ScriptBackend = ScriptingImplementation.IL2CPP; - } - else - { - settings.ScriptBackend = (ScriptingImplementation)Enum.Parse(typeof(ScriptingImplementation), str, true); - } - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "BuildTarget", StringComparison.OrdinalIgnoreCase)) - { - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = (BuildTarget)Enum.Parse(typeof(BuildTarget), cmdArgs[++i], true); - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "Headless", StringComparison.OrdinalIgnoreCase)) - { - settings.Headless = true; - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "buildPath", StringComparison.OrdinalIgnoreCase)) - { - buildPath = cmdArgs[++i]; - } - } - } - else - { - var key = SettingsKeyBase + Application.productName; - var settingsValue = EditorPrefs.GetString(key, null); - try - { - if (!string.IsNullOrWhiteSpace(settingsValue)) - { - settings = JsonUtility.FromJson(settingsValue); - } - } - catch - { - UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); - EditorPrefs.SetString(key, null); - } - } - - if (settings.UseCurrentBuildTarget) - { - settings.BuildTarget = EditorUserBuildSettings.activeBuildTarget; - } - if (settings.UseCurrentScriptBackend) - { - settings.ScriptBackend = PlayerSettings.GetScriptingBackend(ToBuildTargetGroup(settings.BuildTarget)); - } - - if (buildPath == null) - { - buildPath = $"bin/UnitTest/{settings.BuildTarget}_{settings.ScriptBackend}/test" + GetExtensionForBuildTarget(settings.BuildTarget); - } - - var originalScene = SceneManager.GetActiveScene().path; - - BuildUnitTest(buildPath, settings.ScriptBackend, settings.BuildTarget, settings.Headless, settings.AutoRunPlayer, settings.DisableAutoClose); - - // reopen original scene - if (!string.IsNullOrWhiteSpace(originalScene)) - { - EditorSceneManager.OpenScene(originalScene, OpenSceneMode.Single); - } - else - { - EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); - } - } - - - [MenuItem("Test/LoadUnitTestScene")] - public static void LoadUnitTestScene() - { - var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); - BuildUnitTestRunnerScene(); - EditorSceneManager.MarkSceneDirty(scene); - } - - static RuntimeUnitTestSettings LoadOrGetDefaultSettings() - { - var key = SettingsKeyBase + Application.productName; - - var settingsValue = EditorPrefs.GetString(key, null); - RuntimeUnitTestSettings settings = null; - try - { - if (!string.IsNullOrWhiteSpace(settingsValue)) - { - settings = JsonUtility.FromJson(settingsValue); - } - } - catch - { - UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); - EditorPrefs.SetString(key, null); - settings = null; - } - - if (settings == null) - { - // default - settings = new RuntimeUnitTestSettings - { - UseCurrentBuildTarget = true, - UseCurrentScriptBackend = true, - Headless = false, - AutoRunPlayer = true, - }; - } - - return settings; - } - - static void SaveSettings(RuntimeUnitTestSettings settings) - { - var key = SettingsKeyBase + Application.productName; - EditorPrefs.SetString(key, JsonUtility.ToJson(settings)); - } - - public static void BuildUnitTest(string buildPath, ScriptingImplementation scriptBackend, BuildTarget buildTarget, bool headless, bool autoRunPlayer, bool disableAutoClose) - { - var sceneName = "Assets/TempRuntimeUnitTestScene_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - if (disableAutoClose) - { - sceneName += "_DisableAutoClose"; - } - sceneName += ".unity"; - - var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); - - BuildUnitTestRunnerScene(); - - EditorSceneManager.MarkSceneDirty(scene); - AssetDatabase.SaveAssets(); - EditorSceneManager.SaveScene(scene, sceneName, false); - try - { - Build(sceneName, buildPath, new RuntimeUnitTestSettings { ScriptBackend = scriptBackend, BuildTarget = buildTarget, Headless = headless, AutoRunPlayer = autoRunPlayer, DisableAutoClose = disableAutoClose }); - } - finally - { - AssetDatabase.DeleteAsset(sceneName); - } - } - - public static UnitTestRunner BuildUnitTestRunnerScene() - { - const string kStandardSpritePath = "UI/Skin/UISprite.psd"; - const string kBackgroundSpritePath = "UI/Skin/Background.psd"; - var uisprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); - var background = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpritePath); - - ScrollRect buttonList; - VerticalLayoutGroup listLayout; - Scrollbar refListScrollbar; - ScrollRect logList; - Scrollbar refLogScrollbar; - Button clearButton; - Text logText; - - // Flutter like coded build utility - - var rootObject = new Builder("SceneRoot") - { - Children = new IBuilder[] { - new Builder("EventSystem"), - new Builder("Canvas") { - Component1 = { renderMode = RenderMode.ScreenSpaceOverlay }, - Children = new IBuilder[] { - new Builder("HorizontalSplitter") { - RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1) }, - Component1 = { childControlWidth = true, childControlHeight = true, spacing = 10 }, - Children = new IBuilder[] { - new Builder("ButtonList", out buttonList) { - RectTransform = { pivot = new Vector2(0.5f, 0.5f) }, - Component1 = { horizontal =false, vertical = true, movementType = ScrollRect.MovementType.Clamped }, - Children = new IBuilder[] { - new Builder("ListLayoutToAttach", out listLayout) { - RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1), pivot = new Vector2(0, 1) }, - Component1 = { childControlWidth = true, childControlHeight = true, childForceExpandWidth = true, childForceExpandHeight = false, spacing = 10, padding = new RectOffset(10,20,10,10) }, - Component2 = { horizontalFit = ContentSizeFitter.FitMode.Unconstrained, verticalFit = ContentSizeFitter.FitMode.PreferredSize }, - SetTarget = self => { buttonList.content = self.GetComponent(); }, - Child = new Builder("ClearButton", out clearButton) { - Component2 = { sprite = uisprite, type = Image.Type.Sliced }, - Component3 = { minHeight = 50 }, - SetTarget = self => { self.GetComponent