using System.Collections;
using Luneraria.View;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
namespace Luneraria.UI.Tests
{
///
/// U4 addendum: the G1 scene starts with the start screen (LuneNetPlay from the scene
/// builder), not with a running match. Runs the player's smoke test in the editor without
/// photos: start screen, offline match into the combat, "Menü" → "Zum Menü", start screen
/// again, a second offline match.
///
public sealed class StartScreenTests
{
[UnityTest]
[Timeout(300000)]
public IEnumerator StartScreenLeadsIntoTheMatchAndBack()
{
LunePreferences.ResetSession();
LuneMatchDriver.DirectStart = false;
AsyncOperation loading = SceneManager.LoadSceneAsync("G1_Map", LoadSceneMode.Single);
while (!loading.isDone)
yield return null;
yield return null;
var net = Object.FindAnyObjectByType();
Assert.IsNotNull(net, "the scene builder puts the start screen into the scene");
Assert.IsTrue(net.enabled && net.Menu != null, "without DirectStart the shell takes over");
Assert.AreSame(net, net.Game.Net, "the game controller knows its shell");
var smoke = net.gameObject.AddComponent();
smoke.Net = net;
smoke.QuitWhenDone = false;
float start = Time.realtimeSinceStartup;
while (!smoke.Done && Time.realtimeSinceStartup - start < 180f)
yield return null;
LuneMatchDriver.DirectStart = true;
Assert.IsTrue(smoke.Done, "the smoke test finished");
Assert.IsEmpty(smoke.Failed, string.Join("\n", smoke.Failed));
Debug.Log("LUNE_START_SCREEN " + smoke.Passed.Count + " checks passed");
}
}
}