using System.Collections; using System.Reflection; using KernelPanic.Data; using KernelPanic.Meta; using KernelPanic.UI; using NUnit.Framework; using UnityEditor; using UnityEngine; using UnityEngine.TestTools; using UnityEngine.UIElements; public class CollectionLayoutTests { private static readonly Vector2[] Viewports = { new(1280, 720), new(1080, 600), new(390, 844), new(960, 400) }; [UnityTest] public IEnumerator EveryDistroOverviewKeepsReadableSpacingAndWrappedTextAcrossViewports() { if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null) Assert.Ignore("Collection layout tests require an editor panel; run Unity without -nographics."); var window = ScriptableObject.CreateInstance(); var originalTextSize = UIPreferences.TextSize; var originalDensity = UIPreferences.Density; try { window.titleContent = new GUIContent("Collection layout verification"); window.minSize = new Vector2(100, 100); window.maxSize = new Vector2(4000, 3000); window.Show(); var root = window.rootVisualElement; root.styleSheets.Add(AssetDatabase.LoadAssetAtPath("Assets/UI/MainMenu.uss")); typeof(MainMenuController).Assembly.GetType("KernelPanic.UI.TerminalTheme") .GetMethod("Attach", BindingFlags.Public | BindingFlags.Static) .Invoke(null, new object[] { root }); var template = AssetDatabase.LoadAssetAtPath("Assets/UI/CollectionScreen.uxml").CloneTree(); var panel = template.Q("CollectionPanel"); panel.RemoveFromClassList("hidden"); root.Add(panel); var database = AssetDatabase.LoadAssetAtPath("Assets/Data/Distros/DistroDatabase.asset"); Assert.That(database.AllDistros, Is.Not.Empty); var owned = new PlayerCollection(); foreach (var unit in database.AllDistros) owned.Add(unit); var screen = new CollectionScreenController(); screen.Bind(root, null, null, null, owned); var scroll = root.Q("CollectionDetail"); window.position = new Rect(32, 32, 1280, 720); root.style.width = 1280; root.style.height = 720; screen.RefreshUnits(database.AllDistros); for (int frame = 0; frame < 5; frame++) yield return null; var columns = scroll.Q