|
|
|
@@ -112,6 +112,53 @@ public class CombatLayoutTests
|
|
|
|
|
enemies.Add(new EnemyInstance(EnemyArchetypeCatalog.Get("memory_leak"), 4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator NixGovernorAndGoSchedulerStayReadableAndAcceptKeyboardActions()
|
|
|
|
|
{
|
|
|
|
|
var cards = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
|
|
|
|
var nix = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/NixOS.asset");
|
|
|
|
|
var config = new RunConfig(nix, Language.Haskell, Language.Go, nix.ExclusiveCards.Take(4).ToArray(), 73, 3);
|
|
|
|
|
_run.StartRun(config); Set(_combat, "_runConfig", config);
|
|
|
|
|
Set(_combat, "_playerState", new CombatantState(60, 6, 3));
|
|
|
|
|
Set(_combat, "_handController", new HandController(6));
|
|
|
|
|
_combat.Compilation.BeginWave(0);
|
|
|
|
|
for (int i = 0; i < 3; i++) _combat.Go.Deploy(new CardInstance(cards.FindById("lang_go_worker")), 3, 3, 1, _combat.Enemies[0].State);
|
|
|
|
|
foreach (var size in Viewports)
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
{
|
|
|
|
|
Resize(size); UIPreferences.TextSize = textSize; _combat.Nix.BeginWave(3);
|
|
|
|
|
Call(_combat, "ApplyGovernorModifiers");
|
|
|
|
|
Call(_view, "RefreshPlayer"); Call(_view, "RefreshTracks");
|
|
|
|
|
for (int frame = 0; frame < 6; frame++) yield return null;
|
|
|
|
|
string context = $"{size}/{textSize}";
|
|
|
|
|
var panel = _root.Q("NixGovernorPanel");
|
|
|
|
|
foreach (var button in panel.Query<Button>().ToList()) AssertContainedHorizontally(button, panel, context);
|
|
|
|
|
Assert.That(_root.Q<Button>("GovernorSchedutil").text, Does.Contain("ACTIVE"));
|
|
|
|
|
Assert.That(panel.Q<Label>(className: "nix-switch-cost").text, Does.Contain("FREE"));
|
|
|
|
|
var performance = _root.Q<Button>("GovernorPerformance");
|
|
|
|
|
var shortcut = _root.Q<Button>("GovernorShortcut");
|
|
|
|
|
Assert.That(shortcut.text, Does.Contain("schedutil"));
|
|
|
|
|
using (var submit = NavigationSubmitEvent.GetPooled()) { submit.target = shortcut; shortcut.SendEvent(submit); }
|
|
|
|
|
for (int frame = 0; frame < 2; frame++) yield return null;
|
|
|
|
|
Assert.That(_root.focusController.focusedElement, Is.SameAs(performance), context + ": configuration shortcut focuses an available policy");
|
|
|
|
|
using (var submit = NavigationSubmitEvent.GetPooled()) { submit.target = performance; performance.SendEvent(submit); }
|
|
|
|
|
Assert.That(_combat.Nix.Governor, Is.EqualTo(NixGovernor.Performance));
|
|
|
|
|
Call(_view, "RefreshPlayer"); // This fixture drives refreshes without the scene's Start subscription.
|
|
|
|
|
Assert.That(shortcut.text, Does.Contain("performance"));
|
|
|
|
|
Assert.That(_combat.PlayerState.Cycles, Is.EqualTo(3));
|
|
|
|
|
var scheduler = _root.Q("GoroutineScheduler");
|
|
|
|
|
var rows = scheduler.Query<Button>(className: "goroutine-row").ToList();
|
|
|
|
|
Assert.That(rows.Count, Is.EqualTo(3));
|
|
|
|
|
foreach (var row in rows)
|
|
|
|
|
{
|
|
|
|
|
AssertContainedHorizontally(row, scheduler, context);
|
|
|
|
|
Assert.That(row.text, Does.Contain("3 ticks")); Assert.That(row.text, Does.Contain("starts next round"));
|
|
|
|
|
}
|
|
|
|
|
using (var submit = NavigationSubmitEvent.GetPooled()) { submit.target = rows[1]; rows[1].SendEvent(submit); }
|
|
|
|
|
Assert.That(_combat.SelectedGoroutine, Is.SameAs(_combat.Go.Active[1]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator PythonChoicesFitViewportsAndResolveThroughAKeyboardSubmit()
|
|
|
|
|
{
|
|
|
|
@@ -177,44 +224,54 @@ public class CombatLayoutTests
|
|
|
|
|
public IEnumerator HandFocusRevealsNameAndCostAndStillAllowsRulesScrolling()
|
|
|
|
|
{
|
|
|
|
|
bool testedOversizedCard = false;
|
|
|
|
|
foreach (var size in Viewports)
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
foreach (bool python in new[] { false, true })
|
|
|
|
|
{
|
|
|
|
|
UIPreferences.TextSize = textSize;
|
|
|
|
|
Resize(size);
|
|
|
|
|
Call(_view, "RefreshHand");
|
|
|
|
|
for (int frame = 0; frame < 5; frame++) yield return null;
|
|
|
|
|
var scroll = _root.Q<ScrollView>(className: "hand-scroll");
|
|
|
|
|
var faces = scroll.Query<Button>(className: "hand-card").ToList();
|
|
|
|
|
string context = $"{size}, {textSize}";
|
|
|
|
|
testedOversizedCard |= faces.Any(face => face.worldBound.height > scroll.contentViewport.worldBound.height);
|
|
|
|
|
scroll.scrollOffset = new Vector2(scroll.horizontalScroller.highValue, scroll.verticalScroller.highValue);
|
|
|
|
|
// Moving focus twice before layout must not restore a stale card's position.
|
|
|
|
|
faces[0].Focus();
|
|
|
|
|
faces[faces.Count - 1].Focus();
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
foreach (var face in new[] { faces[faces.Count - 1], faces[0] })
|
|
|
|
|
if (python)
|
|
|
|
|
{
|
|
|
|
|
face.Focus();
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
foreach (string className in new[] { "software-name", "software-cost" })
|
|
|
|
|
{
|
|
|
|
|
var label = face.Q<Label>(className: className);
|
|
|
|
|
AssertContainedHorizontally(label, scroll.contentViewport, context);
|
|
|
|
|
Assert.That(label.worldBound.yMin, Is.GreaterThanOrEqualTo(scroll.contentViewport.worldBound.yMin - 1),
|
|
|
|
|
$"{context}; {className}; face={face.worldBound}; viewport={scroll.contentViewport.worldBound}; content={scroll.contentContainer.worldBound}; offset={scroll.scrollOffset}; focus={_root.focusController.focusedElement == face}");
|
|
|
|
|
Assert.That(label.worldBound.yMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1), context);
|
|
|
|
|
}
|
|
|
|
|
var database = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
|
|
|
|
_combat.HandController.Clear();
|
|
|
|
|
foreach (string id in new[] { "mint_timeshift", "lang_py_print", "mint_cinnamon" })
|
|
|
|
|
_combat.HandController.Add(new CardInstance(database.FindById(id)));
|
|
|
|
|
}
|
|
|
|
|
foreach (var size in Viewports)
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
{
|
|
|
|
|
UIPreferences.TextSize = textSize;
|
|
|
|
|
Resize(size);
|
|
|
|
|
Call(_view, "RefreshHand");
|
|
|
|
|
for (int frame = 0; frame < 5; frame++) yield return null;
|
|
|
|
|
var scroll = _root.Q<ScrollView>(className: "hand-scroll");
|
|
|
|
|
var faces = scroll.Query<Button>(className: "hand-card").ToList();
|
|
|
|
|
string context = $"{size}, {textSize}, Python={python}";
|
|
|
|
|
testedOversizedCard |= faces.Any(face => face.worldBound.height > scroll.contentViewport.worldBound.height);
|
|
|
|
|
scroll.scrollOffset = new Vector2(scroll.horizontalScroller.highValue, scroll.verticalScroller.highValue);
|
|
|
|
|
// Moving focus twice before layout must not restore a stale card's position.
|
|
|
|
|
faces[0].Focus();
|
|
|
|
|
faces[faces.Count - 1].Focus();
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
foreach (var face in new[] { faces[faces.Count - 1], faces[0] })
|
|
|
|
|
{
|
|
|
|
|
face.Focus();
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
foreach (string className in new[] { "software-name", "software-cost" })
|
|
|
|
|
{
|
|
|
|
|
var label = face.Q<Label>(className: className);
|
|
|
|
|
AssertContainedHorizontally(label, scroll.contentViewport, context);
|
|
|
|
|
Assert.That(label.worldBound.yMin, Is.GreaterThanOrEqualTo(scroll.contentViewport.worldBound.yMin - 1),
|
|
|
|
|
$"{context}; {className}; face={face.worldBound}; viewport={scroll.contentViewport.worldBound}; content={scroll.contentContainer.worldBound}; offset={scroll.scrollOffset}; focus={_root.focusController.focusedElement == face}");
|
|
|
|
|
Assert.That(label.worldBound.yMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1), context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Call(_view, "RefreshHand");
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
Assert.That(_root.focusController.focusedElement, Is.SameAs(faces[0]), context);
|
|
|
|
|
scroll.scrollOffset = new Vector2(scroll.scrollOffset.x, scroll.verticalScroller.highValue);
|
|
|
|
|
float rulesOffset = scroll.scrollOffset.y;
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
Assert.That(rulesOffset, Is.EqualTo(scroll.verticalScroller.highValue).Within(1), context);
|
|
|
|
|
Assert.That(scroll.scrollOffset.y, Is.EqualTo(rulesOffset).Within(1), context + ": focus must not pin scrolling");
|
|
|
|
|
faces[0].Blur();
|
|
|
|
|
}
|
|
|
|
|
Call(_view, "RefreshHand");
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
Assert.That(_root.focusController.focusedElement, Is.SameAs(faces[0]), context);
|
|
|
|
|
scroll.scrollOffset = new Vector2(scroll.scrollOffset.x, scroll.verticalScroller.highValue);
|
|
|
|
|
float rulesOffset = scroll.scrollOffset.y;
|
|
|
|
|
for (int frame = 0; frame < 3; frame++) yield return null;
|
|
|
|
|
Assert.That(rulesOffset, Is.EqualTo(scroll.verticalScroller.highValue).Within(1), context);
|
|
|
|
|
Assert.That(scroll.scrollOffset.y, Is.EqualTo(rulesOffset).Within(1), context + ": focus must not pin scrolling");
|
|
|
|
|
faces[0].Blur();
|
|
|
|
|
}
|
|
|
|
|
Assert.That(testedOversizedCard, Is.True, "Exercise at least one card taller than the hand viewport.");
|
|
|
|
|
}
|
|
|
|
@@ -300,6 +357,113 @@ public class CombatLayoutTests
|
|
|
|
|
((IDisposable)flow).Dispose(); Set(_view, "_tutorial", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator PythonIntroductionFitsAndLeadsToTheExistingPayloadPractice()
|
|
|
|
|
{
|
|
|
|
|
var cards = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
|
|
|
|
var config = TutorialCampaign.CreateConfig(_gentoo, cards, 2);
|
|
|
|
|
_run.StartRun(config); Set(_combat, "_runConfig", config);
|
|
|
|
|
Set(_combat, "_handController", new HandController(6));
|
|
|
|
|
foreach (var card in _run.RunDeck) _combat.HandController.Add(card);
|
|
|
|
|
var overlay = _root.Q(className: "overlay");
|
|
|
|
|
var type = typeof(CombatSceneController).Assembly.GetType("KernelPanic.UI.TutorialFlow");
|
|
|
|
|
var flow = Activator.CreateInstance(type, new object[] { overlay, _run, _combat, cards, null, null, config, (Action)(() => {}) });
|
|
|
|
|
Set(_view, "_tutorial", flow);
|
|
|
|
|
Set(flow, "_resuming", false);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
foreach (var size in Viewports)
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
{
|
|
|
|
|
UIPreferences.TextSize = textSize; Resize(size);
|
|
|
|
|
Call(flow, "SetGuide", 2);
|
|
|
|
|
Call(_view, "RefreshPlayer"); Call(_view, "RefreshTurnPanel");
|
|
|
|
|
Call(_view, "RefreshHand"); Call(_view, "RefreshTracks"); Call(_view, "RefreshEnemies");
|
|
|
|
|
var guide = _combat.TutorialGuide;
|
|
|
|
|
int pages = 0;
|
|
|
|
|
while (guide.Reading && pages++ < guide.Count)
|
|
|
|
|
{
|
|
|
|
|
type.GetMethod("Refresh").Invoke(flow, null);
|
|
|
|
|
for (int frame = 0; frame < 5; frame++) yield return null;
|
|
|
|
|
if (guide.Step.Id == "queue-intro" || guide.Step.Id.StartsWith("python-"))
|
|
|
|
|
{
|
|
|
|
|
string context = $"{guide.Step.Id}, {size}, {textSize}";
|
|
|
|
|
var panel = overlay.Q("TutorialCallout");
|
|
|
|
|
var next = panel.Q<Button>("TutorialNext");
|
|
|
|
|
var copy = panel.Q<Label>("TutorialInstruction");
|
|
|
|
|
Assert.That(copy.text, Is.EqualTo(guide.Step.Copy), context);
|
|
|
|
|
AssertContainedHorizontally(panel, _root, context);
|
|
|
|
|
AssertContainedHorizontally(copy, panel, context);
|
|
|
|
|
AssertContainedHorizontally(next, panel, context);
|
|
|
|
|
Assert.That(next.enabledInHierarchy, Is.True, context);
|
|
|
|
|
Assert.That(next.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), context);
|
|
|
|
|
Assert.That(panel.Q<ScrollView>("TutorialStepScroll").contentViewport.worldBound.height, Is.GreaterThan(25), context);
|
|
|
|
|
Assert.That(overlay.Q("TutorialHighlight").worldBound.width, Is.GreaterThan(20), context);
|
|
|
|
|
Assert.That(panel.worldBound.Overlaps(overlay.Q("TutorialHighlight").worldBound), Is.False, context);
|
|
|
|
|
}
|
|
|
|
|
type.GetMethod("AdvancePage").Invoke(flow, null);
|
|
|
|
|
}
|
|
|
|
|
Assert.That(guide.Step.Id, Is.EqualTo("select-python"));
|
|
|
|
|
Assert.That(guide.Card.Definition.Id, Is.EqualTo("lang_py_print"));
|
|
|
|
|
Assert.That(guide.AllowsCard(guide.Card), Is.True);
|
|
|
|
|
type.GetMethod("AdvancePage").Invoke(flow, null);
|
|
|
|
|
Assert.That(guide.Step.Id, Is.EqualTo("select-python"), "Reading must lead to a real play, not skip it.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally { ((IDisposable)flow).Dispose(); Set(_view, "_tutorial", null); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator OptionalLanguageStepsKeepInstructionsAndExitReachable()
|
|
|
|
|
{
|
|
|
|
|
var cards = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
|
|
|
|
var type = typeof(CombatSceneController).Assembly.GetType("KernelPanic.UI.TutorialFlow");
|
|
|
|
|
var overlay = _root.Q(className: "overlay");
|
|
|
|
|
foreach (var language in LanguageTraining.Supported)
|
|
|
|
|
{
|
|
|
|
|
var config = LanguageTraining.CreateConfig(language, _gentoo, cards);
|
|
|
|
|
_run.StartRun(config); Set(_combat, "_runConfig", config);
|
|
|
|
|
Set(_combat, "_handController", new HandController(12));
|
|
|
|
|
Set(_combat, "_playerState", new CombatantState(60, 12, 6));
|
|
|
|
|
foreach (var card in _run.RunDeck) _combat.HandController.Add(card);
|
|
|
|
|
var enemies = (List<EnemyInstance>)_combat.Enemies;
|
|
|
|
|
enemies.Clear();
|
|
|
|
|
enemies.Add(new EnemyInstance(EnemyArchetypeCatalog.Get("orphan_process"), 30));
|
|
|
|
|
enemies.Add(new EnemyInstance(EnemyArchetypeCatalog.Get("orphan_process"), 24));
|
|
|
|
|
var flow = Activator.CreateInstance(type, new object[] { overlay, _run, _combat, cards, null, null, config, (Action)(() => {}) });
|
|
|
|
|
Set(_view, "_tutorial", flow);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
foreach (var size in new[] { new Vector2(1280, 720), new Vector2(390, 844), new Vector2(960, 400) })
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
{
|
|
|
|
|
Resize(size); UIPreferences.TextSize = textSize;
|
|
|
|
|
for (int index = 0; index < _combat.TutorialGuide.Count; index++)
|
|
|
|
|
{
|
|
|
|
|
var guide = _combat.TutorialGuide;
|
|
|
|
|
Set(guide, "<Index>k__BackingField", index);
|
|
|
|
|
Set(guide, "<Card>k__BackingField", null);
|
|
|
|
|
guide.Update(_combat);
|
|
|
|
|
Call(_view, "RefreshPlayer"); Call(_view, "RefreshTurnPanel");
|
|
|
|
|
Call(_view, "RefreshHand"); Call(_view, "RefreshTracks"); Call(_view, "RefreshEnemies");
|
|
|
|
|
type.GetMethod("Refresh").Invoke(flow, null);
|
|
|
|
|
for (int frame = 0; frame < 4; frame++) yield return null;
|
|
|
|
|
string context = $"{language}, {guide.Step.Id}, {size}, {textSize}";
|
|
|
|
|
var panel = overlay.Q("TutorialCallout");
|
|
|
|
|
var exit = panel.Q<Button>("ExitLanguageTraining");
|
|
|
|
|
Assert.That(exit.enabledInHierarchy, Is.True, context);
|
|
|
|
|
AssertContainedHorizontally(panel, _root, context);
|
|
|
|
|
AssertContainedHorizontally(exit, panel, context);
|
|
|
|
|
Assert.That(exit.worldBound.yMax, Is.LessThanOrEqualTo(panel.worldBound.yMax + 1), context);
|
|
|
|
|
Assert.That(panel.Q<ScrollView>("TutorialStepScroll").contentViewport.worldBound.height, Is.GreaterThan(15), context);
|
|
|
|
|
Assert.That(panel.Q<Label>("TutorialInstruction").text, Is.EqualTo(guide.Step.Copy), context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally { ((IDisposable)flow).Dispose(); Set(_view, "_tutorial", null); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator GuidedCardIsFullyVisibleOnNarrowScreensAndCannotBeSkipped()
|
|
|
|
|
{
|
|
|
|
@@ -330,6 +494,56 @@ public class CombatLayoutTests
|
|
|
|
|
((IDisposable)flow).Dispose(); Set(_view, "_tutorial", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator RepositoryPreviewsStayInsideOffersWithLongPythonRules()
|
|
|
|
|
{
|
|
|
|
|
var database = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
|
|
|
|
var offers = (List<RepositoryOffer>)typeof(RunManager).GetField("_repositoryOffers", Private).GetValue(_run);
|
|
|
|
|
offers.Clear();
|
|
|
|
|
offers.Add(RepositoryOffer.NewCard(database.FindById("mint_timeshift"), 2));
|
|
|
|
|
offers.Add(RepositoryOffer.CardUpgrade(new CardInstance(database.FindById("mint_cinnamon")), CardUpgradeKind.MagnitudeUp, 2));
|
|
|
|
|
offers.Add(RepositoryOffer.StatUpgrade(RunStatUpgradeKind.MaxCycles, 3));
|
|
|
|
|
offers.Add(RepositoryOffer.NewCard(database.FindById("lang_py_print"), 2));
|
|
|
|
|
offers.Add(RepositoryOffer.NewCard(database.FindById("ubuntu_snap_install"), 2));
|
|
|
|
|
foreach (var size in Viewports)
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
{
|
|
|
|
|
UIPreferences.TextSize = textSize;
|
|
|
|
|
Resize(size);
|
|
|
|
|
var overlay = _root.Q(className: "overlay");
|
|
|
|
|
overlay.Clear(); overlay.style.display = DisplayStyle.Flex;
|
|
|
|
|
overlay.Add((VisualElement)Call(_view, "BuildRepositoryView"));
|
|
|
|
|
for (int frame = 0; frame < 6; frame++) yield return null;
|
|
|
|
|
string context = $"{size}, {textSize}";
|
|
|
|
|
var repository = overlay.Q(className: "repository");
|
|
|
|
|
var scroll = repository.Q<ScrollView>(className: "repository-body");
|
|
|
|
|
var tiles = repository.Query(className: "repository-tile").ToList();
|
|
|
|
|
Assert.That(tiles.Count, Is.EqualTo(5));
|
|
|
|
|
foreach (var tile in tiles)
|
|
|
|
|
{
|
|
|
|
|
AssertContainedHorizontally(tile, scroll.contentViewport, context);
|
|
|
|
|
var face = tile.Q(className: "software-card");
|
|
|
|
|
if (face != null)
|
|
|
|
|
{
|
|
|
|
|
AssertContainedHorizontally(face, face.parent, context + ": preview stays within its content column");
|
|
|
|
|
Assert.That(face.resolvedStyle.marginRight, Is.Zero, context);
|
|
|
|
|
foreach (var label in face.Query<Label>().ToList())
|
|
|
|
|
AssertContainedHorizontally(label, face, context + ": " + label.text);
|
|
|
|
|
}
|
|
|
|
|
var action = tile.Q<Button>(className: "repository-action");
|
|
|
|
|
var content = tile.ElementAt(1);
|
|
|
|
|
Assert.That(action.worldBound.yMin, Is.GreaterThanOrEqualTo(content.worldBound.yMax - 1), context);
|
|
|
|
|
AssertContainedHorizontally(action, tile, context);
|
|
|
|
|
scroll.ScrollTo(action);
|
|
|
|
|
for (int frame = 0; frame < 2; frame++) yield return null;
|
|
|
|
|
Assert.That(action.worldBound.yMax, Is.LessThanOrEqualTo(scroll.contentViewport.worldBound.yMax + 1), context);
|
|
|
|
|
}
|
|
|
|
|
var footer = repository.Q(className: "repository-footer");
|
|
|
|
|
Assert.That(footer.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), context);
|
|
|
|
|
LogAssert.NoUnexpectedReceived();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator VictoryUsesSuccessColourAndExplainsAnUnavailableResumedRecap()
|
|
|
|
|
{
|
|
|
|
@@ -898,6 +1112,26 @@ public class CombatLayoutTests
|
|
|
|
|
Assert.That(textWidth, Is.LessThanOrEqualTo(label.contentRect.width + 2), context + ": " + label.text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator PythonQueueKeepsVisibleCardsOnNarrowScreens()
|
|
|
|
|
{
|
|
|
|
|
var cards = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
|
|
|
|
|
foreach (string id in new[] { "shop_py_async_def", "lang_py_for_loop", "lang_py_print", "mint_cinnamon" })
|
|
|
|
|
_combat.InterpreterQueue.Enqueue(new CardInstance(cards.FindById(id)));
|
|
|
|
|
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
|
|
|
|
|
{
|
|
|
|
|
Resize(new Vector2(390, 844)); UIPreferences.TextSize = textSize;
|
|
|
|
|
Call(_view, "RefreshTracks");
|
|
|
|
|
for (int frame = 0; frame < 6; frame++) yield return null;
|
|
|
|
|
var queue = _root.Q("TutorialQueue");
|
|
|
|
|
var scroll = queue.GetFirstAncestorOfType<ScrollView>();
|
|
|
|
|
Assert.That(scroll.contentViewport.worldBound.width, Is.GreaterThan(200), textSize.ToString());
|
|
|
|
|
AssertContainedHorizontally(scroll.contentViewport, _root, textSize.ToString());
|
|
|
|
|
Assert.That(queue.Query(className: "card-chip").ToList().Any(chip =>
|
|
|
|
|
chip.worldBound.Overlaps(scroll.contentViewport.worldBound)), Is.True, "Queued combo must be visible.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[UnityTest]
|
|
|
|
|
public IEnumerator PendingStackTooltipsUseCapturedMultipliersAndCurrentCompilation()
|
|
|
|
|
{
|
|
|
|
@@ -962,8 +1196,16 @@ public class CombatLayoutTests
|
|
|
|
|
var preview = face.Q<Label>(className: "software-live-preview");
|
|
|
|
|
Assert.That(preview, Is.Not.Null, context);
|
|
|
|
|
AssertContainedHorizontally(preview, face, context);
|
|
|
|
|
Assert.That(preview.text, Does.StartWith("preview:"), context);
|
|
|
|
|
Assert.That(face.tooltip, Is.EqualTo("Current estimate; targets, defenses and later effects can change the result."), context);
|
|
|
|
|
var expected = CardPreviewService.Build(_combat, (CardInstance)face.userData);
|
|
|
|
|
Assert.That(preview.text, Is.EqualTo(expected.Summary), context);
|
|
|
|
|
var critical = face.Q<Label>(className: "software-live-crit");
|
|
|
|
|
if (!string.IsNullOrEmpty(expected.CriticalSummary))
|
|
|
|
|
{
|
|
|
|
|
Assert.That(critical.text, Is.EqualTo(expected.CriticalSummary), context);
|
|
|
|
|
AssertContainedHorizontally(critical, face, context);
|
|
|
|
|
Assert.That(critical.worldBound.yMin, Is.GreaterThanOrEqualTo(preview.worldBound.yMax), context);
|
|
|
|
|
}
|
|
|
|
|
Assert.That(face.tooltip, Is.EqualTo("Based on the current setup. Targets, defenses and later effects can change the result."), context);
|
|
|
|
|
Assert.That(face.tooltip.Length, Is.LessThan(160), "Hover help must not repeat the full calculation breakdown.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|