Compare commits

..
3 Commits
3 changed files with 16 additions and 3 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Character Editor Test",
"description": "GUI test of the character editor in rpg_demo: opens rpg_demo_game's characters, shows the slime's localized name, adds a character with the New button, types its name, health and RPG charset into the form, saves; the game must know the character with its stats and name at once, and the RPG map editor's characters tab must offer it with its charset. The new file and the locale edits are removed again. Activated by --itest=characters_editor_edit with --game=rpg_demo --new.",
"description": "GUI test of the character editor in rpg_plus: opens rpg_demo_game's characters, shows the slime's localized name, adds a character with the New button, types its name, health and RPG charset into the form, saves; the game must know the character with its stats and name at once, and the RPG map editor's characters tab must offer it with its charset. The new file and the locale edits are removed again. Activated by --itest=characters_editor_edit with --game=rpg_plus --new (the prologue is clicked through first).",
"sources": [
"src/*.cs"
],
@@ -8,6 +8,7 @@ using Cthangover.Core.Mods;
using Cthangover.Core.Mods.Resolvers;
using Cthangover.Core.Utils;
using Cthangover.Mods.Interface.Tool;
using Cthangover.Mods.Interface.View;
using Cthangover.Mods.Rpg;
using Cthangover.Tools.RpgEditor;
using Cthangover.Tools.Services;
@@ -40,11 +41,13 @@ namespace Cthangover.Tools.CharactersEditor.Tests
private int passed;
private int step;
private double elapsed;
private readonly string shotsDir;
private CharacterEditorWindow window;
/// <summary>Creates the driver; <paramref name="shotsDir"/> is unused (no screenshots).</summary>
/// <summary>Creates the driver; with <paramref name="shotsDir"/> it saves a shot of the list and form.</summary>
public CharacterEditorTestDriver(string shotsDir)
{
this.shotsDir = shotsDir;
Name = "CharacterEditorTestDriver";
var timer = new Timer { WaitTime = TickSeconds, Autostart = true };
AddChild(timer);
@@ -110,6 +113,8 @@ namespace Cthangover.Tools.CharactersEditor.Tests
step++;
return;
case 2:
// The list's portraits are fitted into the panel (FilteredList.FitIcons).
Shot("editor");
try
{
Press("tools/common/save");
@@ -198,6 +203,14 @@ namespace Cthangover.Tools.CharactersEditor.Tests
GameLogger.Log("TEST", $"[FAIL] {what}", LogLevel.Error);
}
private void Shot(string name)
{
if (string.IsNullOrEmpty(shotsDir) || DisplayServer.GetName() == "headless")
return;
DirAccess.MakeDirRecursiveAbsolute(shotsDir);
ViewportCapture.SavePng(GetViewport(), shotsDir.TrimEnd('/') + "/characters_editor_" + name + ".png");
}
private void Finish()
{
step = -1;
@@ -27,7 +27,7 @@ namespace Cthangover.Tools.CharactersEditor.Tests
.Select(a => a.Substring("--shots=".Length))
.FirstOrDefault();
GameLogger.Log("TEST", $"CharacterEditorTestInitializer: activating characters_editor_edit, shots={shots ?? "off"}");
(Godot.Engine.GetMainLoop() as SceneTree)?.Root?.CallDeferred("add_child", new CharacterEditorTestDriver(shots));
ModRoot.AddDeferred(new CharacterEditorTestDriver(shots));
}
}
}