Files
Takeshi b84bade045 Save The Tree implementation and acceptance work in progress
Preserve production code, regression fixtures, audio assets and provenance, test infrastructure, and the original-completion plan and progress ledger. Final game and Windows acceptance remain pending; excluded local artifacts and native experiments are not part of this snapshot.
2026-10-11 15:58:00 +09:00

97 lines
5.9 KiB
GDScript

extends SceneTree
const FixtureCleanup := preload("res://tests/helpers/ui_audio_fixture_cleanup.gd")
var checks := 0
var failures := 0
func _initialize() -> void: call_deferred("run")
func expect(ok: bool, message: String) -> void:
checks += 1
if not ok: failures += 1;push_error(message)
func run() -> void:
var runtime: Variant=root.get_node("SimulationRuntime")
var clock: Variant=root.get_node("GameClock")
var state: Variant=root.get_node("GameState")
clock.reset(1,6,0);state.reset();runtime.initialize(clock,state,42511);clock.set_paused(true)
root.size=Vector2i(1440,810)
var main: Control=load("res://scenes/main/main.tscn").instantiate()
root.add_child(main)
main.call("_set_management_panel_open",true)
await process_frame;await process_frame
var side: PanelContainer=main.find_child("SidePanel",true,false)
var guide: PanelContainer = main.opening_guide
var guide_front: Color = guide.get_theme_stylebox("panel").bg_color
var guide_progress: Dictionary = guide.get_progress()
var front: Color=side.get_theme_stylebox("panel").bg_color
var detail: Label=main.get("selected_detail_label")
var front_text:=detail.get_theme_color("font_color")
var position: Vector2=main.world_preview.cell_to_canvas(Vector3i.ZERO)
await capture("front")
main.back_button.pressed.emit()
await process_frame;await process_frame
expect(state.active_layer==1 and main.world_preview.layer_mode==1,"normal back button switches layer")
expect(side.get_theme_stylebox("panel").bg_color==Color("202e34") and detail.get_theme_color("font_color")==Color("d8eeea"),"back panel and text adopt monitor palette")
var bottom: Control=main.find_child("BottomBar",true,false)
expect(bottom.position.y+bottom.size.y<=main.size.y+1,"back skin preserves toolbar bounds")
expect(main.world_preview.cell_to_canvas(Vector3i(0,0,1))==position,"skin does not change map coordinate mapping")
main.world_preview._process(1.0)
expect(guide.get_theme_stylebox("panel").bg_color == Color("172229"), "opening guide follows BACK skin")
expect(guide.get_progress() == guide_progress, "skin does not change opening instructions or action")
var expanded_height := guide.size.y
guide.get("_heading").pressed.emit()
await process_frame;await process_frame
expect(not guide.get("_body").visible and guide.size.y < expanded_height, "paused guide collapses immediately")
guide.get("_heading").pressed.emit()
await process_frame;await process_frame
expect(guide.get("_body").visible and guide.get("_action").visible, "guide reopens with normal action")
await capture("back")
for i in 4:
main.front_button.pressed.emit();main.back_button.pressed.emit()
main.front_button.pressed.emit()
await process_frame;await process_frame
expect(side.get_theme_stylebox("panel").bg_color==front and detail.get_theme_color("font_color")==front_text,"repeated toggles restore exact front palette")
expect(guide.get_theme_stylebox("panel").bg_color == guide_front, "guide restores FRONT skin")
expect(clock.paused and clock.absolute_minute==360,"skin changes never advance simulation")
var _audio_cleanup_0: Dictionary = await _cleanup_fixture_owner(main, "front-owner")
if not bool(_audio_cleanup_0.get(&"passed", false)):
push_error("Ordinary fixture audio cleanup failed: %s" % str(_audio_cleanup_0))
quit(96)
return
await process_frame
state.active_layer=1
main=load("res://scenes/main/main.tscn").instantiate()
root.add_child(main)
await process_frame;await process_frame
side=main.find_child("SidePanel",true,false)
bottom=main.find_child("BottomBar",true,false)
expect(side.get_theme_stylebox("panel").bg_color==Color("202e34") and main.opening_guide.get_theme_stylebox("panel").bg_color == Color("172229"),"new screen honors existing BACK selection including guide")
expect(bottom.position.y+bottom.size.y<=main.size.y+1,"BACK startup preserves toolbar bounds")
expect(main.rank_dialog.get_label().get_theme_color("font_color") == Color("d8eeea") and main.rank_dialog.theme.get_stylebox("panel", "AcceptDialog").bg_color == Color("202e34"), "rank dialog initializes in saved BACK skin")
expect(main.operating_ledger_panel.get("_cash_label").get_theme_color("font_color") == Color("d8eeea"), "ledger initialized before scene attachment honors saved BACK layer")
main.front_button.pressed.emit()
expect(side.get_theme_stylebox("panel").bg_color==front,"BACK startup still restores FRONT palette")
var _audio_cleanup_1: Dictionary = await _cleanup_fixture_owner(main, "back-owner")
if not bool(_audio_cleanup_1.get(&"passed", false)):
push_error("Ordinary fixture audio cleanup failed: %s" % str(_audio_cleanup_1))
quit(96)
return
await process_frame
print("Layer skin: %d checks, %d failures" % [checks,failures]);quit(failures)
func capture(label: String) -> void:
if DisplayServer.get_name()=="headless":return
await process_frame;await RenderingServer.frame_post_draw
expect(root.get_texture().get_image().save_png(ProjectSettings.globalize_path("res://artifacts/facility-dimensions-2026-09-29/guide-skin-%s.png" % label))==OK,"capture "+label)
## QA-only control proof routing for sequential ordinary Main owners.
## The old02cd/6be99 helpers and original Clock/Runtime values stay exact.
func _cleanup_fixture_owner(owner: Node, phase: String) -> Dictionary:
var original_control: String = OS.get_environment("THE_TREE_AUDIO_FIXTURE_CONTROL_PROOF")
if original_control.is_empty() or not original_control.is_absolute_path():
return {&"passed": false, &"reason": "fresh absolute owned control proof required"}
var phase_control: String = original_control.get_basename() + "-" + phase + ".json"
if FileAccess.file_exists(phase_control):
return {&"passed": false, &"reason": "ordinary owner control proof overwrite forbidden"}
OS.set_environment("THE_TREE_AUDIO_FIXTURE_CONTROL_PROOF", phase_control)
var report: Dictionary = await FixtureCleanup.free_owner_and_wait(self, owner)
OS.set_environment("THE_TREE_AUDIO_FIXTURE_CONTROL_PROOF", original_control)
return report