StaticPopupLifecycleTests.cs 2.2 KB

123456789101112131415161718192021222324
  1. using DevilLink2.UI;
  2. using NUnit.Framework;
  3. using UnityEngine;
  4. namespace DevilLink2.Tests
  5. {
  6. public sealed class StaticPopupLifecycleTests
  7. {
  8. private GameObject root;private RectTransform card;
  9. [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);}
  10. [TearDown] public void Cleanup(){Object.DestroyImmediate(root);}
  11. [Test] public void TenCyclesImmediatelyReleaseMaskWithoutMovingCard(){
  12. for(int i=0;i<10;i++){
  13. UITransition.Show(root,true);var gate=root.GetComponent<CanvasGroup>();
  14. Assert.That(root.activeSelf,Is.True);Assert.That(gate.alpha,Is.EqualTo(1));Assert.That(gate.interactable&&gate.blocksRaycasts,Is.True);
  15. UITransition.Show(root,false);Assert.That(root.activeSelf,Is.False);Assert.That(gate.interactable||gate.blocksRaycasts,Is.False);
  16. Assert.That(card.anchoredPosition,Is.EqualTo(new Vector2(37,-143)));Assert.That(card.localScale,Is.EqualTo(Vector3.one));
  17. Assert.That(root.GetComponent<UITransition>().IsTransitioning,Is.False);
  18. }
  19. }
  20. [Test] public void OldSwitchAndOverrideCannotReenableAnimations(){UITransition.EnablePopupAnimations=true;UITransition.Show(root,true);root.GetComponent<UITransition>().SetPopupAnimationOverride(true);UITransition.Show(root,false);Assert.That(root.activeSelf,Is.False);Assert.That(UITransition.EnablePopupAnimations,Is.False);}
  21. [Test] public void ExplicitUnderlyingInputGateIsPreserved(){UITransition.Show(root,true);UITransition.SetInput(root,false);UITransition.Show(root,true);Assert.That(root.GetComponent<CanvasGroup>().interactable,Is.False);UITransition.SetInput(root,true);Assert.That(root.GetComponent<CanvasGroup>().interactable,Is.True);}
  22. [Test] public void ExternalDisableImmediatelyReleasesRaycasts(){UITransition.Show(root,true);root.SetActive(false);Assert.That(root.GetComponent<CanvasGroup>().blocksRaycasts,Is.False);UITransition.Show(root,true);Assert.That(root.GetComponent<CanvasGroup>().interactable,Is.True);}
  23. }
  24. }