test(scenes): Add test cases for capturing screenshots in scene management

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-05-18 23:01:23 -07:00
parent 90041c12b1
commit 41a6e5f7b0

View file

@ -69,15 +69,11 @@ func _ready() -> void:
await get_tree().create_timer(1.5).timeout
elif _scene == "chronicle_filter":
await get_tree().create_timer(0.5).timeout
get_tree().change_scene_to_file(
"res://engine/scenes/tests/chronicle_filter_proof.tscn"
)
get_tree().change_scene_to_file("res://engine/scenes/tests/chronicle_filter_proof.tscn")
await get_tree().create_timer(1.5).timeout
elif _scene == "diplomacy":
await get_tree().create_timer(0.5).timeout
get_tree().change_scene_to_file(
"res://engine/scenes/tests/diplomacy_panel_proof.tscn"
)
get_tree().change_scene_to_file("res://engine/scenes/tests/diplomacy_panel_proof.tscn")
await get_tree().create_timer(1.5).timeout
elif _scene == "culture_tree_proof":
await get_tree().create_timer(0.5).timeout
@ -86,9 +82,7 @@ func _ready() -> void:
# tree renders blank.
if DataLoader.get_all_culture().is_empty():
DataLoader.load_theme("age-of-dwarves")
get_tree().change_scene_to_file(
"res://engine/scenes/tests/culture_tree_proof.tscn"
)
get_tree().change_scene_to_file("res://engine/scenes/tests/culture_tree_proof.tscn")
await get_tree().create_timer(2.0).timeout
elif _scene == "world_shape_preview":
# Proof scene handles all thumbnail generation and quits itself.
@ -96,9 +90,7 @@ func _ready() -> void:
await get_tree().create_timer(0.5).timeout
if DataLoader.get_data("terrain").is_empty():
DataLoader.load_theme("age-of-dwarves")
get_tree().change_scene_to_file(
"res://engine/scenes/tests/world_shape_preview.tscn"
)
get_tree().change_scene_to_file("res://engine/scenes/tests/world_shape_preview.tscn")
return
elif _scene == "world_gen_lab_proof":
await get_tree().create_timer(0.5).timeout
@ -112,17 +104,13 @@ func _ready() -> void:
await get_tree().create_timer(0.5).timeout
if DataLoader.get_data("terrain").is_empty():
DataLoader.load_theme("age-of-dwarves")
get_tree().change_scene_to_file(
"res://engine/scenes/tests/tectonics/tectonics_proof.tscn"
)
get_tree().change_scene_to_file("res://engine/scenes/tests/tectonics/tectonics_proof.tscn")
return
elif _scene == "hydrology_proof":
await get_tree().create_timer(0.5).timeout
if DataLoader.get_data("terrain").is_empty():
DataLoader.load_theme("age-of-dwarves")
get_tree().change_scene_to_file(
"res://engine/scenes/tests/hydrology/hydrology_proof.tscn"
)
get_tree().change_scene_to_file("res://engine/scenes/tests/hydrology/hydrology_proof.tscn")
return
elif _scene == "fauna_render_proof":
await get_tree().create_timer(0.5).timeout
@ -132,6 +120,18 @@ func _ready() -> void:
"res://engine/scenes/tests/fauna_render/fauna_render_proof.tscn"
)
return
elif _scene == "comms_events_proof":
# Comms phase-1-3 proof — self-contained scene, owns capture + quit.
# Instantiate as a child of root (same rationale as replay_viewer_proof:
# avoid scene-swap framebuffer staleness under Weston/llvmpipe).
await get_tree().create_timer(0.5).timeout
var comms_packed: PackedScene = load("res://engine/scenes/tests/comms_events_proof.tscn")
if comms_packed == null:
push_error("ScreenCapture: cannot load comms_events_proof.tscn")
get_tree().quit(1)
return
get_tree().root.add_child(comms_packed.instantiate())
return
elif _scene == "replay_viewer_proof":
# Do NOT use change_scene_to_file — under Weston/llvmpipe the composited
# framebuffer is not flushed after a scene swap, causing get_texture to
@ -148,10 +148,17 @@ func _ready() -> void:
return
elif _scene == "world_map":
await get_tree().create_timer(0.5).timeout
GameState.initialize_game({
"seed": 42, "map_type": "continents",
"map_size": "duel", "num_players": 2,
})
(
GameState
. initialize_game(
{
"seed": 42,
"map_type": "continents",
"map_size": "duel",
"num_players": 2,
}
)
)
var main: Node = get_tree().root.get_node_or_null("Main")
if main != null and main.has_method("change_scene"):
main.change_scene("res://engine/scenes/menus/loading_screen.tscn")
@ -171,18 +178,16 @@ func _capture_and_quit() -> void:
get_tree().quit(1)
return
var timestamp: String = Time.get_datetime_string_from_system().replace(
":", "-"
).replace("T", "_")
var timestamp: String = Time.get_datetime_string_from_system().replace(":", "-").replace(
"T", "_"
)
var rel_path: String = "%s/%s_%s.png" % [OUTPUT_DIR, _name, timestamp]
var abs_path: String = ProjectSettings.globalize_path(rel_path)
var err: Error = image.save_png(abs_path)
if err == OK:
print("SCREENSHOT_PATH:%s" % abs_path)
print("Screenshot: %dx%d saved to %s" % [
image.get_width(), image.get_height(), abs_path
])
print("Screenshot: %dx%d saved to %s" % [image.get_width(), image.get_height(), abs_path])
else:
push_error("ScreenCapture: Save failed: %s" % error_string(err))