| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.IO;
- using UnityEditor;
- using UnityEditor.TestTools.TestRunner.Api;
- using UnityEngine;
- namespace DevilLink2.Editor
- {
- /// <summary>Read-only asset previews and test execution; never saves scenes or prefabs.</summary>
- public sealed class TileArtValidation : EditorWindow
- {
- private static TestRunnerApi runner;
- private static string reportFolder = "Temp/DevilLink2Task10E3";
- private readonly string[] names = { "Imp", "Trident", "Potion", "Piggy", "Ring", "Candle", "Star", "A", "Q", "J", "Ten", "Nine" };
- [MenuItem("Tools/Devil Link 2/Preview Tile Art 64 and 48")]
- public static void Preview()
- {
- var window = GetWindow<TileArtValidation>("Tile Art 09B");
- window.minSize = new Vector2(840, 410);
- }
- private void OnGUI()
- {
- EditorGUILayout.LabelField("Tile artwork at 64 x 64 and 48 x 48", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Original PNGs, aspect preserved. Inset matches TileView (2px per side).");
- for (int i = 0; i < names.Length; i++)
- {
- float x = 18 + (i % 6) * 130;
- float y = (i / 6) * 180;
- GUI.Label(new Rect(x, 48 + y, 94, 22), names[i]);
- var sprite = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/DevilLink2/Sprites/Tiles/" + names[i] + ".png");
- foreach (int size in new[] { 64, 48 })
- {
- var rect = new Rect(x, y + (size == 64 ? 76 : 150), size, size);
- EditorGUI.DrawRect(rect, new Color32(55, 56, 77, 255));
- EditorGUI.DrawRect(new Rect(rect.x + 1, rect.y + 1, size - 2, size - 2), new Color32(24, 24, 40, 255));
- if (sprite) GUI.DrawTexture(new Rect(rect.x + 2, rect.y + 2, size - 4, size - 4), sprite.texture, ScaleMode.ScaleToFit, true);
- else GUI.Label(rect, "Not imported");
- }
- }
- }
- [MenuItem("Tools/Devil Link 2/Validate Tile Art")]
- [MenuItem("Tools/Devil Link 2/Validate Board Visuals")]
- [MenuItem("Tools/Devil Link 2/Validate Interaction Visuals")]
- [MenuItem("Tools/Devil Link 2/Validate Score Combo Visuals")]
- [MenuItem("Tools/Devil Link 2/Validate UI Transitions")]
- [MenuItem("Tools/Devil Link 2/Validate Audio Integration")]
- [MenuItem("Tools/Devil Link 2/Validate Audio Mix Calibration")]
- public static void Validate() { RunTests("Temp/DevilLink2Task10E3"); }
- [MenuItem("Tools/Devil Link 2/Validate Lobby Visual Integration")]
- public static void ValidateLobby() { RunTests("Temp/DevilLink2Task11A2"); }
- private static void RunTests(string folder)
- {
- if (EditorApplication.isCompiling || EditorApplication.isUpdating || EditorApplication.isPlayingOrWillChangePlaymode || runner)
- { Debug.LogWarning("[DevilLink2.Task10E3] Requires an idle EditMode editor."); return; }
- reportFolder = folder;
- runner = CreateInstance<TestRunnerApi>(); runner.RegisterCallbacks(new Results());
- runner.Execute(new ExecutionSettings(new Filter { testMode = TestMode.EditMode,
- assemblyNames = new[] { "DevilLink2.Core.Tests", "DevilLink2.Presentation.Tests", "DevilLink2.Interaction.Tests",
- "DevilLink2.Gameplay.Tests", "DevilLink2.Persistence.Tests", "DevilLink2.UI.Tests" } }));
- }
- private sealed class Results : ICallbacks
- {
- public void RunStarted(ITestAdaptor test) { }
- public void TestStarted(ITestAdaptor test) { }
- public void TestFinished(ITestResultAdaptor result)
- { if (result.TestStatus == TestStatus.Failed) Debug.LogError("[DevilLink2.Task10E3] " + result.FullName + " " + result.Message); }
- public void RunFinished(ITestResultAdaptor result)
- {
- Directory.CreateDirectory(reportFolder);
- TestRunnerApi.SaveResultToFile(result, Path.Combine(reportFolder, "UnityResults.xml"));
- Debug.Log($"[DevilLink2.Task10E3] passed={result.PassCount} failed={result.FailCount} skipped={result.SkipCount}");
- runner.UnregisterCallbacks(this); DestroyImmediate(runner); runner = null;
- }
- }
- }
- }
|