Revamp UI a whole lot
This commit is contained in:
@@ -178,6 +178,40 @@ public class TerminalUiTests
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PullHistoryIsAToolbarModalAndNotABanner()
|
||||
{
|
||||
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
|
||||
var screen = new GachaScreenController();
|
||||
screen.Bind(root, null, null, null, new GachaService(), new PlayerCollection(), new EntropyWallet(),
|
||||
null, null, () => { }, () => { }, null);
|
||||
screen.Open();
|
||||
|
||||
var bannerList = root.Q("GachaBannerList");
|
||||
var branches = bannerList.Query<Button>(className: "gacha-banner-row").ToList();
|
||||
Assert.That(branches.Count, Is.EqualTo(3));
|
||||
Assert.That(bannerList.Q<Label>(className: "gacha-branch-command").text, Is.EqualTo("$ git branch --list"));
|
||||
Assert.That(branches[0].Q<Label>(className: "command-cursor").text, Is.EqualTo("*"));
|
||||
Assert.That(branches[0].Q<Label>(className: "command-text").text, Is.EqualTo("beginner"));
|
||||
Assert.That(branches[1].Q<Label>(className: "command-text").text, Is.EqualTo("stable"));
|
||||
Assert.That(branches[2].Q<Label>(className: "command-text").text, Is.EqualTo("feature/nixos"));
|
||||
Assert.That(bannerList.Q("GachaPullHistoryButton"), Is.Null);
|
||||
Assert.That(root.Q<Button>("GachaPullHistoryButton"), Is.Not.Null);
|
||||
Assert.That(root.Q("GachaBannerDetail").Query<Label>(className: "gacha-detail-title").ToList(), Is.Empty,
|
||||
"The selected branch already identifies the banner; the detail pane should not repeat its title.");
|
||||
|
||||
screen.OpenPullHistory();
|
||||
var overlay = root.Q("GachaPullHistoryOverlay");
|
||||
Assert.That(overlay, Is.Not.Null);
|
||||
Assert.That(overlay.ClassListContains("modal-open"), Is.True);
|
||||
Assert.That(overlay.ClassListContains("hidden"), Is.False);
|
||||
Assert.That(overlay.Q<Label>(className: "gacha-detail-title").text, Is.EqualTo("[ git log --pulls ]"));
|
||||
Assert.That(overlay.Q<Label>(className: "gacha-history-empty").text, Does.StartWith("fatal: no committed pulls found"));
|
||||
Assert.That(overlay.Q<Button>("ClosePullHistory"), Is.Not.Null);
|
||||
Assert.That(bannerList.Query<Button>(className: "selected").ToList().Count, Is.EqualTo(1),
|
||||
"Opening history must not replace the selected banner.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitIdentityAndTabsSurviveAllFourDetailViews()
|
||||
{
|
||||
@@ -206,6 +240,31 @@ public class TerminalUiTests
|
||||
Assert.That(root.Q("CollectionContextHeader").ClassListContains("hidden"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnitOverviewListsEquippedPackageLoadout()
|
||||
{
|
||||
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
|
||||
var unit = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
|
||||
var package = AssetDatabase.LoadAssetAtPath<PackageDefinition>("Assets/Data/Packages/AptFast.asset");
|
||||
var database = AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset");
|
||||
var owned = new PlayerCollection();
|
||||
owned.Add(unit);
|
||||
owned.AddPackage(package);
|
||||
var loadout = new PackageLoadout(owned, database);
|
||||
Assert.That(loadout.TryEquip(unit.Id, package.Slot, package.Id, out _), Is.True);
|
||||
|
||||
var screen = new CollectionScreenController();
|
||||
screen.Bind(root, null, null, null, owned, packageDatabase: database, packageLoadout: loadout);
|
||||
screen.RefreshUnits(owned.OwnedUnits);
|
||||
|
||||
var row = root.Q<Button>(className: "unit-overview-row");
|
||||
var packages = row.Q<Label>(className: "unit-loadout-line");
|
||||
Assert.That(packages, Is.Not.Null);
|
||||
Assert.That(packages.text, Does.Contain(package.DisplayName));
|
||||
Assert.That(packages.text, Does.Contain("system=").And.Contain("tools=").And.Contain("services="));
|
||||
Assert.That(row.tooltip, Does.Contain(package.DisplayName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InventoryRowsUseCompactMetadataAndKeepEffectsInDetails()
|
||||
{
|
||||
@@ -338,7 +397,7 @@ public class TerminalUiTests
|
||||
var commands = (string[])type.GetField("Commands", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
|
||||
Assert.That(commands, Is.EqualTo(new[]
|
||||
{
|
||||
"./start_run", "ls ~/collection", "curl gacha.sh | sh", "dpkg-reconfigure", "history --runs", "shutdown -h now", "cat /etc/cron.daily/quests"
|
||||
"./start_run", "ls ~/collection", "curl gacha.sh | sh", "dpkg-reconfigure", "history --runs", "shutdown -h now", "cat /etc/cron.daily/quests", "git log --pulls"
|
||||
}));
|
||||
for (int i = 0; i < commands.Length; i++)
|
||||
{
|
||||
@@ -349,13 +408,14 @@ public class TerminalUiTests
|
||||
}
|
||||
input.value = "./start_run; shutdown";
|
||||
type.GetMethod("Submit", Private).Invoke(line, null);
|
||||
Assert.That(activated, Is.EqualTo(6));
|
||||
Assert.That(activated, Is.EqualTo(7));
|
||||
Assert.That(root.Q<Label>("CommandOutput").text, Does.Contain("command not found"));
|
||||
}
|
||||
|
||||
[TestCase("his", "history --runs", 4)]
|
||||
[TestCase("shut", "shutdown -h now", 5)]
|
||||
[TestCase("cat /etc/cron", "cat /etc/cron.daily/quests", 6)]
|
||||
[TestCase("git log", "git log --pulls", 7)]
|
||||
public void ArchiveAndQuitCommandsCompleteAndKeepTheirOwnActionIndices(string prefix, string command, int index)
|
||||
{
|
||||
var root = new VisualElement();
|
||||
@@ -494,7 +554,12 @@ public class TerminalUiTests
|
||||
Assert.That(root.Q(id), Is.Not.Null, id);
|
||||
Assert.That(root.Q<TextField>("CommandInput"), Is.Not.Null);
|
||||
Assert.That(root.Q<Toggle>("ReducedMotionToggle"), Is.Not.Null);
|
||||
Assert.That(root.Q<SliderInt>("SoundVolumeSlider"), Is.Not.Null);
|
||||
Assert.That(root.Q<Button>("SoundVolumeButton"), Is.Null);
|
||||
Assert.That(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Resources/KernelTheme.uss"), Is.Not.Null);
|
||||
Assert.That(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Resources/TerminalProgram.uss"), Is.Not.Null);
|
||||
Assert.That(AssetDatabase.LoadAssetAtPath<Font>("Assets/Resources/Fonts/JetBrainsMono-Regular.ttf"), Is.Not.Null,
|
||||
"The terminal must ship one deterministic monospace font instead of depending on the host OS.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user