extends SceneTree const EntryShell = preload("res://entry/entry_shell.gd") const SettingsStore = preload("res://entry/settings_store.gd") const FIXTURES := [ {"width": 760, "height": 360, "locale": "zh_CN", "scale": 1.0}, {"width": 844, "height": 390, "locale": "zh_CN", "scale": 1.3}, {"width": 844, "height": 390, "locale": "en", "scale": 1.0}, {"width": 1280, "height": 720, "locale": "en", "scale": 1.3}, ] const STATES := ["loading", "error"] var failures: Array[String] = [] var output_root := "" func _initialize() -> void: call_deferred("run_test") func run_test() -> void: output_root = OS.get_environment("ABG_EVIDENCE_DIR") if output_root.is_empty(): output_root = "/tmp/abg-sys001-boot-captures" DirAccess.make_dir_recursive_absolute(output_root) var count := 0 for fixture in FIXTURES: for state in STATES: await _capture(fixture, state) count += 1 if failures.is_empty(): print("ABG_SYS001_BOOT_CAPTURE_OK frames=%d states=loading,error viewports=760x360,844x390,1280x720 locales=zh_CN,en text=100,130 renderer=normal" % count) quit(0) else: for failure in failures: push_error(failure) quit(1) func _capture(fixture: Dictionary, state: String) -> void: var viewport := SubViewport.new() viewport.size = Vector2i(int(fixture.width), int(fixture.height)) viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS root.add_child(viewport) var shell := EntryShell.new() shell.auto_start = false viewport.add_child(shell) await _frames(3) shell.settings = SettingsStore.new().defaults() shell.settings.locale = String(fixture.locale) shell.settings.text_scale = float(fixture.scale) if state == "error": shell.boot_snapshot = {"state": "error", "completed": 2, "total": 4, "step": "preferences", "code": "SETTINGS_FILE_INVALID"} else: shell.boot_snapshot = {"state": "running", "completed": 2, "total": 4, "step": "preferences", "code": ""} shell._render_boot_state() await _frames(4) _verify(shell, fixture, state) await RenderingServer.frame_post_draw var image := viewport.get_texture().get_image() var file_name := "boot-%s-%dx%d-%s-%d.png" % [state, int(fixture.width), int(fixture.height), String(fixture.locale), int(round(float(fixture.scale) * 100.0))] var error := image.save_png(output_root.path_join(file_name)) if error != OK: failures.append("capture %s failed: %s" % [file_name, error]) viewport.queue_free() await _frames(4) func _verify(shell: Control, fixture: Dictionary, state: String) -> void: var bounds := Rect2(Vector2.ZERO, Vector2(float(fixture.width), float(fixture.height))) for node_name in ["BootIdentityPlaque", "BootVerificationRail"]: var control := shell.find_child(node_name, true, false) as Control if control == null or not bounds.encloses(control.get_global_rect()): failures.append("%s %s outside %s" % [state, node_name, bounds]) var retry := shell.find_child("BootRetry", true, false) as Control var diagnostics := shell.find_child("BootDiagnosticsAction", true, false) as Control var exit_button := shell.find_child("BootExit", true, false) as Control var expected_visible := state == "error" if retry == null or retry.visible != expected_visible or diagnostics == null or diagnostics.visible != expected_visible or exit_button == null or exit_button.visible != expected_visible: failures.append("%s action visibility is not state-bound" % state) if state == "error" and String(fixture.locale) == "en": # M63 moved visible command copy to the shared ButtonLabel child. var retry_label := retry.get_node_or_null("ButtonLabel") as Label var diagnostics_label := diagnostics.get_node_or_null("ButtonLabel") as Label var exit_label := exit_button.get_node_or_null("ButtonLabel") as Label if ( retry_label == null or retry_label.text != "Retry" or diagnostics_label == null or diagnostics_label.text != "Diagnostics" or exit_label == null or exit_label.text != "Exit" ): failures.append("English error actions were not refreshed from runtime locale") func _frames(count: int) -> void: for frame in range(count): await process_frame