diff --git a/Assets/MiyamasuTestRunner/Runtime/Generated.meta b/Assets/MiyamasuTestRunner/Runtime/Generated.meta deleted file mode 100644 index 9ab3a6c..0000000 --- a/Assets/MiyamasuTestRunner/Runtime/Generated.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 2d3afa40adf46445ba5b53e10ad12f82 -folderAsset: yes -timeCreated: 1511942387 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/MiyamasuTestRunner/Runtime/MainThreadRunner.cs b/Assets/MiyamasuTestRunner/Runtime/MainThreadRunner.cs index 9f60088..63786a4 100644 --- a/Assets/MiyamasuTestRunner/Runtime/MainThreadRunner.cs +++ b/Assets/MiyamasuTestRunner/Runtime/MainThreadRunner.cs @@ -22,20 +22,17 @@ public class MainThreadRunner : MonoBehaviour, IUUebViewEventHandler { private string htmlContent = @""; IEnumerator Start () { + var scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); + if (scene.name.StartsWith("InitTestScene") && "InitTestScene".Length < scene.name.Length) { + Destroy(this); + yield break; + } + while (testEnumerators == null) { // wait to set enumGens; yield return null; } - // wait for check UnityTest is running or not. - yield return new WaitForSeconds(1); - - Debug.Log("Editorの一覧からテストを実行した場合にテストを開始すると重複するので、停止させる、みたいな奴。"); - // if (isRunning) { - // Destroy(this); - // yield break; - // } - var canvasCor = Resources.LoadAsync("MiyamasuPrefabs/MiyamasuCanvas"); while (!canvasCor.isDone) { @@ -174,7 +171,6 @@ public void AddLog (ReportSource reportSource, ReportType type, Exception e, str var id = Guid.NewGuid().ToString(); error = @" button='true' src='" + Base64Encode(e.ToString()) + @"' id='" + id + @"'"; } - logList.Add(@" @@ -183,17 +179,18 @@ public void AddLog (ReportSource reportSource, ReportType type, Exception e, str <" + icon + @"/>
"); + var coroutines = new List(); // send result to slack. switch (type) { case ReportType.AssertionFailed: case ReportType.FailedByTimeout: case ReportType.Error: { - StartCoroutine(new SlackIntegration._SendLog("device:" + SystemInfo.deviceName + " failed " + reportSource.Description() + "\n" + e.ToString(), 0)); + coroutines.Add(new SlackIntegration._SendLog("device:" + SystemInfo.deviceName + " failed " + reportSource.Description() + "\n" + e.ToString(), 0)); break; } case ReportType.Passed: { - StartCoroutine(new SlackIntegration._SendLog("device:" + SystemInfo.deviceName + " passed " + reportSource.Description(), 0)); + coroutines.Add(new SlackIntegration._SendLog("device:" + SystemInfo.deviceName + " passed " + reportSource.Description(), 0)); break; } default: { @@ -218,7 +215,11 @@ public void AddLog (ReportSource reportSource, ReportType type, Exception e, str if (testEnumerators.Count == 0) { var reportEndCor = new SlackIntegration._SendLog("all " + testCount + " tests finished. passed:" + passed + " failed:" + failed, 0); - StartCoroutine(reportEndCor); + coroutines.Add(reportEndCor); + } + + if (coroutines.Any()) { + StartCoroutine(RunLogCoroutines(coroutines)); } // restart test. @@ -236,6 +237,12 @@ public void AddLog (ReportSource reportSource, ReportType type, Exception e, str } } + private IEnumerator RunLogCoroutines (List coroutines) { + foreach (var cor in coroutines) { + yield return cor; + } + } + private static string Base64Encode(string plainText) { var plainTextBytes = Encoding.UTF8.GetBytes(plainText); return Convert.ToBase64String(plainTextBytes); @@ -345,4 +352,4 @@ void IUUebViewEventHandler.OnElementLongTapped (ContentType type, string param, // throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/Assets/MiyamasuTestRunner/Runtime/Resources/MiyamasuPrefabs/MiyamasuCanvas.prefab b/Assets/MiyamasuTestRunner/Runtime/Resources/MiyamasuPrefabs/MiyamasuCanvas.prefab index bfcbce0..94a3ab2 100644 Binary files a/Assets/MiyamasuTestRunner/Runtime/Resources/MiyamasuPrefabs/MiyamasuCanvas.prefab and b/Assets/MiyamasuTestRunner/Runtime/Resources/MiyamasuPrefabs/MiyamasuCanvas.prefab differ diff --git a/Assets/MiyamasuTestRunner/Runtime/SlackIntegration.cs b/Assets/MiyamasuTestRunner/Runtime/SlackIntegration.cs index f98f43c..ad9aeae 100644 --- a/Assets/MiyamasuTestRunner/Runtime/SlackIntegration.cs +++ b/Assets/MiyamasuTestRunner/Runtime/SlackIntegration.cs @@ -80,7 +80,7 @@ private IEnumerator _WaitCor (string message, int type) { /** take screenshot then send to server. - */ + */ public class _SendScreenshot : CustomYieldInstruction { private readonly IEnumerator t; @@ -105,12 +105,31 @@ private IEnumerator _WaitCor (string message) { var fileName = message.Replace(" ", "_") + "_screenshot_" + DateTime.Now.ToString().Replace(":", "_").Replace(" ", "_").Replace("/", "_"); var basePath = Path.Combine(Application.persistentDataPath, fileName); + // hide miyamasu UI. + var testCanvas = GameObject.Find("MiyamasuCanvas"); + if (testCanvas != null) { + var canvasAlpha = testCanvas.GetComponent(); + canvasAlpha.alpha = 0; + } + + // 古いUnityだと、end of frameで処理をしないとUIが撮影できない、みたいなことがあるかもしれない。 + // Unity5.6だとそのまま実行してUIが映る。 + if (Application.isMobilePlatform) { Application.CaptureScreenshot(fileName);// supersize = 0. } else { Application.CaptureScreenshot(basePath);// supersize = 0. } + // wait 1 frame. + yield return null; + + // show Miyamasu UI. + if (testCanvas != null) { + var canvasAlpha = testCanvas.GetComponent(); + canvasAlpha.alpha = 1; + } + while (!File.Exists(basePath)) { yield return null; } @@ -247,4 +266,4 @@ private void SendScreenshotBytesAsync (byte[] bytes, Stream writeStream, FileStr ); } } -} \ No newline at end of file +} diff --git a/Assets/MiyamasuTestRunnerTests/Editor/PackageGenerator.cs b/Assets/MiyamasuTestRunnerTests/Editor/PackageGenerator.cs index af87c2d..bef6734 100644 --- a/Assets/MiyamasuTestRunnerTests/Editor/PackageGenerator.cs +++ b/Assets/MiyamasuTestRunnerTests/Editor/PackageGenerator.cs @@ -8,12 +8,17 @@ public class PackageGenerator { // remove generated entry points. Directory.Delete("Assets/MiyamasuTestRunner/Runtime/Generated", true); + var settings = Miyamasu.Settings.LoadSettings(); + File.Delete("Assets/MiyamasuTestRunner/Runtime/Resources/MiyamasuSettings.txt"); + Miyamasu.Settings.WriteSettings(new Miyamasu.RunnerSettings()); + var assetPaths = new List(); var packageSourcePath = "Assets/MiyamasuTestRunner"; CollectPathsRecursively(packageSourcePath, assetPaths); AssetDatabase.ExportPackage(assetPaths.ToArray(), "MiyamasuTestRunner.unitypackage", ExportPackageOptions.IncludeDependencies); + Miyamasu.Settings.WriteSettings(settings); } private static void CollectPathsRecursively (string path, List assetPaths) { diff --git a/MiyamasuTestRunner.unitypackage b/MiyamasuTestRunner.unitypackage index d132851..6b67cc2 100644 Binary files a/MiyamasuTestRunner.unitypackage and b/MiyamasuTestRunner.unitypackage differ