using System.Linq; using DevilLink2.Gameplay; using DevilLink2.UI; using NUnit.Framework; using UnityEngine; using UnityEngine.UI; namespace DevilLink2.Tests { public sealed partial class UIScreenTests { private Button[] PolishButtons() => new[] { ui.Lobby.DailyButton, ui.Lobby.WheelButton, ui.Lobby.ShopButton, ui.Lobby.ProfileButton, ui.Lobby.SettingsButton, ui.Lobby.HelpButton }; [TestCase(0)] [TestCase(1)] [TestCase(2)] [TestCase(3)] [TestCase(4)] [TestCase(5)] public void PolishedNavigationRetainsEachExistingFunctionalBinding(int index) { ui.ShowLobby(); PolishButtons()[index].onClick.Invoke(); var panels = new UIScreen[] { ui.Daily, ui.Wheel, ui.Shop, ui.Profile, ui.Settings, ui.Help }; Assert.That(panels[index].IsVisible, Is.True); Assert.That(panels.Count(p=>p.IsVisible), Is.EqualTo(1)); } [TestCase(0)] [TestCase(1)] [TestCase(2)] public void PolishedProgressUsesTwoCenteredDynamicLines(int index) { ui.ShowLobby(); var mode=(GameMode)index; player.Progress.RecordClear(mode,20); ui.Lobby.Refresh(player); var label=ui.Lobby.Cards[index].ProgressLabel; Assert.That(label.text,Is.EqualTo("LEVEL 20 / 20\nCLEARED 20/20")); Assert.That(label.text.Split('\n').Length,Is.EqualTo(2)); Assert.That(label.fontSize,Is.EqualTo(13)); Assert.That(label.alignment,Is.EqualTo(TextAnchor.MiddleCenter)); Assert.That(label.rectTransform.anchoredPosition,Is.EqualTo(new Vector2(2,-243))); Assert.That(label.rectTransform.sizeDelta,Is.EqualTo(new Vector2(126,42))); Assert.That(label.GetComponent(),Is.Not.Null); Assert.That(ui.Lobby.Cards[index].transform.Find("ProgressBacking"),Is.Not.Null); } [Test] public void SixNavigationControlsShareVisualParametersAndDoNotOverlap() { var buttons=PolishButtons();var reference=buttons[0]; for(int i=0;i()); Assert.That(button.colors,Is.EqualTo(reference.colors)); Assert.That(button.GetComponent().Radius,Is.EqualTo(12)); Assert.That(button.targetGraphic,Is.SameAs(button.transform.Find("NavigationFace").GetComponent())); var label=button.transform.Find("Label").GetComponent(); Assert.That(label.fontSize,Is.EqualTo(10)); Assert.That(label.font,Is.SameAs(reference.transform.Find("Label").GetComponent().font)); Assert.That(label.rectTransform.anchoredPosition,Is.EqualTo(new Vector2(2,-54))); Assert.That(label.alignment,Is.EqualTo(TextAnchor.MiddleCenter)); if(i<5) Assert.That(rect.anchoredPosition.x+rect.sizeDelta.x,Is.LessThan(((RectTransform)buttons[i+1].transform).anchoredPosition.x)); } } [Test] public void HelpQuestionIconAndCloseRetainCachedPage() { ui.ShowLobby();var help=ui.Help; var icon=ui.Lobby.HelpButton.transform.Find("NavigationArtwork"); Assert.That(icon,Is.Not.Null); Assert.That(icon.GetComponent().sprite,Is.Not.Null); Assert.That(icon.GetComponent().preserveAspect,Is.True); Assert.That(ui.Lobby.HelpButton.transform.Find("CaptionBacking"),Is.Null); ui.Lobby.HelpButton.onClick.Invoke(); ui.CloseHelp(); ui.Lobby.HelpButton.onClick.Invoke(); Assert.That(ui.Help,Is.SameAs(help)); Assert.That(help.IsVisible,Is.True); } [TestCase(430,932)] [TestCase(320,568)] [TestCase(390,844)] [TestCase(768,1024)] public void PolishedFooterAndProgressFitScaledPortraitDesign(float width,float height) { float scale=ScreenLayout.FitScale(width,height); foreach(var button in PolishButtons()) { var r=(RectTransform)button.transform; Assert.That((r.anchoredPosition.x+r.sizeDelta.x)*scale,Is.LessThanOrEqualTo(width+.01f)); Assert.That((-r.anchoredPosition.y+r.sizeDelta.y)*scale,Is.LessThanOrEqualTo(height+.01f)); } foreach(var card in ui.Lobby.Cards) { var label=card.ProgressLabel.rectTransform; Assert.That(-((RectTransform)card.transform).anchoredPosition.y-label.anchoredPosition.y+label.sizeDelta.y,Is.LessThan(836)); } } } }