using DevilLink2.UI; using NUnit.Framework; using UnityEngine; namespace DevilLink2.Tests { public sealed class StaticPopupLifecycleTests { private GameObject root;private RectTransform card; [SetUp] public void Setup(){root=new GameObject("StaticPopup",typeof(RectTransform));card=(RectTransform)new GameObject("Card",typeof(RectTransform)).transform;card.SetParent(root.transform,false);card.anchoredPosition=new Vector2(37,-143);card.sizeDelta=new Vector2(350,400);} [TearDown] public void Cleanup(){Object.DestroyImmediate(root);} [Test] public void TenCyclesImmediatelyReleaseMaskWithoutMovingCard(){ for(int i=0;i<10;i++){ UITransition.Show(root,true);var gate=root.GetComponent(); Assert.That(root.activeSelf,Is.True);Assert.That(gate.alpha,Is.EqualTo(1));Assert.That(gate.interactable&&gate.blocksRaycasts,Is.True); UITransition.Show(root,false);Assert.That(root.activeSelf,Is.False);Assert.That(gate.interactable||gate.blocksRaycasts,Is.False); Assert.That(card.anchoredPosition,Is.EqualTo(new Vector2(37,-143)));Assert.That(card.localScale,Is.EqualTo(Vector3.one)); Assert.That(root.GetComponent().IsTransitioning,Is.False); } } [Test] public void OldSwitchAndOverrideCannotReenableAnimations(){UITransition.EnablePopupAnimations=true;UITransition.Show(root,true);root.GetComponent().SetPopupAnimationOverride(true);UITransition.Show(root,false);Assert.That(root.activeSelf,Is.False);Assert.That(UITransition.EnablePopupAnimations,Is.False);} [Test] public void ExplicitUnderlyingInputGateIsPreserved(){UITransition.Show(root,true);UITransition.SetInput(root,false);UITransition.Show(root,true);Assert.That(root.GetComponent().interactable,Is.False);UITransition.SetInput(root,true);Assert.That(root.GetComponent().interactable,Is.True);} [Test] public void ExternalDisableImmediatelyReleasesRaycasts(){UITransition.Show(root,true);root.SetActive(false);Assert.That(root.GetComponent().blocksRaycasts,Is.False);UITransition.Show(root,true);Assert.That(root.GetComponent().interactable,Is.True);} } }