124 lines
4.6 KiB
C#
124 lines
4.6 KiB
C#
|
|
using System.Collections;
|
||
|
|
using NUnit.Framework;
|
||
|
|
using TKS.OutGame;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.SceneManagement;
|
||
|
|
using UnityEngine.TestTools;
|
||
|
|
|
||
|
|
namespace TKS.Tests
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 해상도 대응 · Google Play 요건(PD 2026-11-26) — 물리 뒤로 가기(Android 백키 = Esc) 순서 · 앱 전환 일시정지 · 안전 영역(노치) · 유닛 그림 원본 px.
|
||
|
|
/// </summary>
|
||
|
|
public class BackKeyTests
|
||
|
|
{
|
||
|
|
OutGameRoot og;
|
||
|
|
BattleManager bm;
|
||
|
|
|
||
|
|
[TearDown]
|
||
|
|
public void TearDown()
|
||
|
|
{
|
||
|
|
ExitConfirm.Close();
|
||
|
|
SettingsPopup.Close();
|
||
|
|
UiSafeArea.Simulate = null;
|
||
|
|
SaveStore.UseMemory(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
IEnumerator Boot()
|
||
|
|
{
|
||
|
|
WorldProgress.Reset();
|
||
|
|
SaveStore.UseMemory(true);
|
||
|
|
SceneManager.LoadScene("Battle");
|
||
|
|
yield return null;
|
||
|
|
yield return null;
|
||
|
|
og = OutGameRoot.Instance;
|
||
|
|
bm = BattleManager.Instance;
|
||
|
|
Assert.IsNotNull(og);
|
||
|
|
}
|
||
|
|
|
||
|
|
[UnityTest]
|
||
|
|
public IEnumerator Back_Modal_Then_Screen_Then_LobbyExitConfirm()
|
||
|
|
{
|
||
|
|
yield return Boot();
|
||
|
|
Assert.IsTrue(og.LobbyVisible);
|
||
|
|
og.OnTab(0);
|
||
|
|
Assert.AreEqual(og.HeroList, og.Current);
|
||
|
|
og.Modal("시험", "본문", new OutGameRoot.ModalButton("확인", UiKit.Dark, null));
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.AreEqual(og.HeroList, og.Current, "백키 1 = 팝업만 닫힘(화면 그대로)");
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.AreEqual(og.Lobby, og.Current, "백키 2 = 이전 화면(로비)");
|
||
|
|
Assert.IsFalse(ExitConfirm.IsOpen);
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.IsTrue(ExitConfirm.IsOpen, "로비에서 백키 = 게임 종료 확인");
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.IsFalse(ExitConfirm.IsOpen, "종료 확인에서 백키 = 취소");
|
||
|
|
Assert.AreEqual(og.Lobby, og.Current);
|
||
|
|
}
|
||
|
|
|
||
|
|
[UnityTest]
|
||
|
|
public IEnumerator Back_Settings_ClosesOnlySettings()
|
||
|
|
{
|
||
|
|
yield return Boot();
|
||
|
|
SettingsPopup.Open(og);
|
||
|
|
yield return null;
|
||
|
|
Assert.IsTrue(SettingsPopup.IsOpen);
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.IsFalse(SettingsPopup.IsOpen, "설정 창 닫힘");
|
||
|
|
Assert.IsFalse(ExitConfirm.IsOpen, "한 번에 하나만(종료 확인 안 뜸)");
|
||
|
|
}
|
||
|
|
|
||
|
|
[UnityTest]
|
||
|
|
public IEnumerator Back_InBattle_TogglesPause_AndAppPauseOpensIt()
|
||
|
|
{
|
||
|
|
yield return Boot();
|
||
|
|
bm.StartStage(0);
|
||
|
|
float t0 = Time.realtimeSinceStartup;
|
||
|
|
while ((bm.Hud == null || !bm.Hud.GiveUpVisible) && Time.realtimeSinceStartup - t0 < 30f)
|
||
|
|
{
|
||
|
|
if (ScenarioEvent.Running) ScenarioEvent.SkipForTest();
|
||
|
|
yield return null;
|
||
|
|
}
|
||
|
|
Assert.IsTrue(bm.Hud.GiveUpVisible, "전투 중(중단 가능)");
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.IsTrue(bm.Hud.GiveUpOpen, "전투 중 백키 = 중단(일시정지) 팝업");
|
||
|
|
BackKeyRouter.Handle();
|
||
|
|
yield return null;
|
||
|
|
Assert.IsFalse(bm.Hud.GiveUpOpen, "다시 백키 = 계속");
|
||
|
|
og.OnAppPause();
|
||
|
|
Assert.IsTrue(bm.Hud.GiveUpOpen, "앱이 백그라운드로 가면 중단 팝업(복귀 시 일시정지 상태)");
|
||
|
|
}
|
||
|
|
|
||
|
|
[UnityTest]
|
||
|
|
public IEnumerator SafeArea_InsetsScreensAndBars()
|
||
|
|
{
|
||
|
|
UiSafeArea.Simulate = new Vector4(0f, 0.02f, 0f, 0.05f);
|
||
|
|
yield return Boot();
|
||
|
|
yield return null;
|
||
|
|
yield return null;
|
||
|
|
var rt = og.Lobby.Rt;
|
||
|
|
Assert.Greater(-rt.offsetMax.y, 1f, "화면 위 = 노치만큼 들임");
|
||
|
|
Assert.Greater(rt.offsetMin.y, 1f, "화면 아래 = 제스처 바만큼 들임");
|
||
|
|
}
|
||
|
|
|
||
|
|
[Test]
|
||
|
|
public void UnitArt_SrcPx_IsOriginalFramePixels()
|
||
|
|
{
|
||
|
|
var a = UnitArt.Load("liubei");
|
||
|
|
Assert.IsNotNull(a);
|
||
|
|
Sprite[] fr;
|
||
|
|
Assert.IsTrue(a.Clips.TryGetValue("front_idle", out fr) && fr.Length > 0);
|
||
|
|
var src = a.SrcPx(fr[0]);
|
||
|
|
Assert.IsNotNull(a.Meta.frame);
|
||
|
|
Assert.AreEqual(a.Meta.frame[0], src.x, 1.5f, "원본 프레임 폭(Android 임포트 축소와 무관)");
|
||
|
|
Assert.AreEqual(a.Meta.frame[1], src.y, 1.5f, "원본 프레임 높이");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|