collection_edit adds the dev_tools toolset and checks the studio
The test includes the whole developer toolset the way a player does and checks that the scenario studio is loaded with its toolbar button.
This commit is contained in:
1 parent
2f15bba00b
commit
75cc3c1279
2 files changed
+17
-9
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Collection Edit Test",
|
"name": "Collection Edit Test",
|
||||||
"description": "Integration test of editing the running game's collection: the novel template is entered, its collection gets the editors mechanic, back to the menu and New game of the same game must switch the mod set in-process so the editors are loaded. Activated only by --itest=collection_edit (with --game=novel_template).",
|
"description": "Integration test of editing the running game's collection: the novel template is entered, its collection gets the dev_tools toolset (editors, scenario studio), back to the menu and New game of the same game must switch the mod set in-process so the editors are loaded. Activated only by --itest=collection_edit (with --game=novel_template).",
|
||||||
"sources": [
|
"sources": [
|
||||||
"src/*.cs"
|
"src/*.cs"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ namespace Mods.CollectionEditTest
|
|||||||
/// <list type="number">
|
/// <list type="number">
|
||||||
/// <item>The novel template is entered; it matches its collection and the
|
/// <item>The novel template is entered; it matches its collection and the
|
||||||
/// editors are not loaded.</item>
|
/// editors are not loaded.</item>
|
||||||
/// <item>The collection gets the editors mechanic (<c>editor_tools</c>), saved
|
/// <item>The collection gets the developer toolset (<c>dev_tools</c>: editors,
|
||||||
/// the way the collection editor saves it (a user package with the same id):
|
/// the scenario studio, …), saved the way the collection editor saves it (a
|
||||||
/// the running game is now outdated.</item>
|
/// user package with the same id): the running game is now outdated.</item>
|
||||||
/// <item>Menu → Play → New game of the same game switches the mod set in
|
/// <item>Menu → Play → New game of the same game switches the mod set in
|
||||||
/// place: the editors are loaded and the game matches its collection again.</item>
|
/// place: the editors and the studio are loaded, the studio's button is on
|
||||||
|
/// the game's toolbar and the game matches its collection again.</item>
|
||||||
/// </list>
|
/// </list>
|
||||||
/// A player's own package of the game is moved aside for the run and put
|
/// A player's own package of the game is moved aside for the run and put
|
||||||
/// back afterwards. Prints <c>[TEST_RESULT] name=collection_edit</c>.
|
/// back afterwards. Prints <c>[TEST_RESULT] name=collection_edit</c>.
|
||||||
@@ -33,7 +34,9 @@ namespace Mods.CollectionEditTest
|
|||||||
public const string Flag = "--itest=collection_edit";
|
public const string Flag = "--itest=collection_edit";
|
||||||
|
|
||||||
private const string GameId = "novel_template";
|
private const string GameId = "novel_template";
|
||||||
|
private const string AddedToolset = "dev_tools";
|
||||||
private const string AddedMod = "editor_tools";
|
private const string AddedMod = "editor_tools";
|
||||||
|
private const string StudioMod = "scenario_studio";
|
||||||
private const float TimeoutSeconds = 240f;
|
private const float TimeoutSeconds = 240f;
|
||||||
|
|
||||||
private readonly List<string> failures = new();
|
private readonly List<string> failures = new();
|
||||||
@@ -132,6 +135,8 @@ namespace Mods.CollectionEditTest
|
|||||||
var reload = ModManager.Instance.LastReload;
|
var reload = ModManager.Instance.LastReload;
|
||||||
Check("New game after the edit switched the mod set", reload?.Applied == true && reload.Plan?.Load.Contains(AddedMod) == true);
|
Check("New game after the edit switched the mod set", reload?.Applied == true && reload.Plan?.Load.Contains(AddedMod) == true);
|
||||||
Check($"'{AddedMod}' is loaded after the edit", EditorsLoaded);
|
Check($"'{AddedMod}' is loaded after the edit", EditorsLoaded);
|
||||||
|
Check($"'{StudioMod}' is loaded after the edit", ModRegistry.Instance.Mods.ContainsKey(StudioMod));
|
||||||
|
Check("the studio's button is on the game's toolbar", HasToolbarButton(TranslationServer.Translate("studio/title").ToString()));
|
||||||
Check("the game matches its edited collection", !GameCatalog.IsActiveOutdated());
|
Check("the game matches its edited collection", !GameCatalog.IsActiveOutdated());
|
||||||
Check($"entered a scene of '{GameId}' ('{enteredScenes[0]}')", true);
|
Check($"entered a scene of '{GameId}' ('{enteredScenes[0]}')", true);
|
||||||
Finish();
|
Finish();
|
||||||
@@ -143,8 +148,8 @@ namespace Mods.CollectionEditTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the game's collection with an extra editors mechanic as a user
|
/// Saves the game's collection with the developer toolset included, as a
|
||||||
/// package — what the collection editor does when the player adds one.
|
/// user package — what the collection editor does when the player adds it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void AddEditorsToCollection()
|
private void AddEditorsToCollection()
|
||||||
{
|
{
|
||||||
@@ -152,8 +157,8 @@ namespace Mods.CollectionEditTest
|
|||||||
var source = GameCatalog.LoadCollections()[GameId];
|
var source = GameCatalog.LoadCollections()[GameId];
|
||||||
var edited = JsonSerializer.Deserialize<ModCollection>(JsonSerializer.Serialize(source));
|
var edited = JsonSerializer.Deserialize<ModCollection>(JsonSerializer.Serialize(source));
|
||||||
edited.Package = source.Package;
|
edited.Package = source.Package;
|
||||||
edited.Mechanics ??= new List<ModCollectionMechanic>();
|
edited.Includes ??= new List<ModCollectionInclude>();
|
||||||
edited.Mechanics.Add(new ModCollectionMechanic { Id = "editors", Name = "Editors", Mods = new List<string> { AddedMod + ">=1" } });
|
edited.Includes.Add(new ModCollectionInclude { Ref = AddedToolset + ">=1", Role = "tools" });
|
||||||
|
|
||||||
var user = ModCollectionStore.LoadUser().Where(c => !string.Equals(c.Id, GameId, StringComparison.OrdinalIgnoreCase)).ToList();
|
var user = ModCollectionStore.LoadUser().Where(c => !string.Equals(c.Id, GameId, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
user.Add(edited);
|
user.Add(edited);
|
||||||
@@ -188,6 +193,9 @@ namespace Mods.CollectionEditTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool HasToolbarButton(string tooltip)
|
||||||
|
=> GetTree().Root.FindChildren("*", "Button", true, false).OfType<Button>().Any(b => b.TooltipText == tooltip && b.IsVisibleInTree());
|
||||||
|
|
||||||
/// <summary>The main menu's Play button, pressed; false while it is not on screen.</summary>
|
/// <summary>The main menu's Play button, pressed; false while it is not on screen.</summary>
|
||||||
private bool PressMenuPlay()
|
private bool PressMenuPlay()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user