using System.Collections; using System.IO; using NUnit.Framework; using TKS.OutGame; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; namespace TKS.Tests { /// /// 열린 에디터에서 고친 화면만 찍기(PD 2026-11-09 「수정된 화면만 체크」 · 「에디터는 닫지 않음」) — UICaptureDriver 를 에디터를 닫지 않는 방식으로 돌린다. /// 찍을 화면 = Logs/ui_capture_only.txt 한 줄(쉼표 · 정확한 이름 또는 「접두*」 · 이름 = UICaptureDriver 의 shot 이름) · 결과 = Logs/ui_capture/. /// 실행: test run --mode playmode --filter Capture_UiOnly --include-explicit --async-tests /// public class UiCaptureTests { [TearDown] public void TearDown() { SaveStore.UseMemory(false); UICaptureDriver.SizeOverride = Vector2Int.zero; UiSafeArea.Simulate = null; } [UnityTest, Explicit, Timeout(1800000)] // 전 화면 · 해상도 검수 = 수 분(NUnit 기본 180 초 넘음 · 2026-11-26) public IEnumerator Capture_UiOnly() { string logs = Path.Combine(Path.GetDirectoryName(Application.dataPath), "Logs"); string listPath = Path.Combine(logs, "ui_capture_only.txt"); Assert.IsTrue(File.Exists(listPath), "찍을 화면 목록 없음: " + listPath); string only = File.ReadAllText(listPath).Trim(); Assert.IsNotEmpty(only, "찍을 화면 목록이 빔"); LogAssert.ignoreFailingMessages = true; // 캡처 전용 — 같은 에디터를 쓰는 다른 세션의 명령 오류 로그로 캡처가 끊기지 않게 WorldProgress.Reset(); SaveStore.UseMemory(true); SceneManager.LoadScene("Battle"); yield return null; yield return null; // 해상도 대응 검수(PD 2026-11-26): Logs/ui_capture_size.txt 1줄 = 「1080x2400」(모든 샷 크기) + 선택 「 safe 0.045 0.02」(가짜 노치 위 · 아래 여백 = 화면 비율) // → 결과 = Logs/ui_capture_x[_safe]/ · 파일이 없으면 예전 그대로 string outDir = Path.Combine(logs, "ui_capture"); float limit = 300f; string sizePath = Path.Combine(logs, "ui_capture_size.txt"); if (File.Exists(sizePath)) { var p = File.ReadAllText(sizePath).Trim().Split(new[] { ' ', 'x', 'X', '\t' }, System.StringSplitOptions.RemoveEmptyEntries); int w, h; if (p.Length >= 2 && int.TryParse(p[0], out w) && int.TryParse(p[1], out h)) { UICaptureDriver.SizeOverride = new Vector2Int(w, h); outDir = Path.Combine(logs, "ui_capture_" + w + "x" + h); limit = 1500f; float top, bottom; if (p.Length >= 5 && p[2] == "safe" && float.TryParse(p[3], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out top) && float.TryParse(p[4], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out bottom)) { UiSafeArea.Simulate = new Vector4(0f, bottom, 0f, top); outDir += "_safe"; } } } var d = UICaptureDriver.Spawn(outDir, only); float t0 = Time.realtimeSinceStartup; while (!d.Finished && Time.realtimeSinceStartup - t0 < limit) yield return null; Assert.IsTrue(d.Finished, "캡처가 제한 시간 안에 끝나지 않음"); } } }