extends SceneTree const EntryShell = preload("res://entry/entry_shell.gd") const SettingsStore = preload("res://entry/settings_store.gd") const DraftService = preload("res://entry/initial_company_draft_service.gd") const DRAFT_PATH := "user://dev2_initial_company_touch_test.json" const SEED := "abcdef01234567899876543210fedcba" var failures: Array[String] = [] func _initialize() -> void: call_deferred("run_test") func run_test() -> void: root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS # Single target size (owner policy): every screen is authored at 1280x720. root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_KEEP root.content_scale_size = Vector2i(1280, 720) root.size = Vector2i(1280, 720) _cleanup() var service = DraftService.new() service.path = DRAFT_PATH service.company_path = "%s.company" % DRAFT_PATH service.begin_or_load(SEED) var shell = EntryShell.new() shell.auto_start = false shell.initial_company_service.path = DRAFT_PATH shell.initial_company_service.company_path = "%s.company" % DRAFT_PATH root.add_child(shell) await _frames(3) shell.settings = SettingsStore.new().defaults() shell.settings.setup_completed = true shell.settings.locale = "en" shell.show_title() await _frames(3) await _touch(shell.find_child("TitleNewGame", true, false)) expect(shell.current_screen == "initial_company", "parsed touch reaches Initial Company from Title") var page = shell.initial_company_page await _touch(page.find_child("CandidateInspect_1", true, false)) expect(page.mode == "inspect" and page.inspected_index == 1, "parsed touch inspects candidate 2") await _touch(page.find_child("InspectBack", true, false)) await _touch(page.find_child("SetCompareA", true, false)) await _touch(page.find_child("CandidateInspect_2", true, false)) await _touch(page.find_child("InspectBack", true, false)) await _touch(page.find_child("SetCompareB", true, false)) await _touch(page.find_child("OpenCompare", true, false)) expect(page.mode == "compare", "parsed touch opens Compare A/B") await _touch(page.find_child("CompareBack", true, false)) await _touch(page.find_child("CandidateSelect_0", true, false)) await _touch(page.find_child("CandidateSelect_1", true, false)) expect(page.draft.selected_offer_ids.size() == 2 and not page.find_child("ReviewCompany", true, false).disabled, "parsed touch selects exactly two and enables Review") await _touch(page.find_child("ReviewCompany", true, false)) expect(page.mode == "review" and page.find_child("CreateCompany", true, false) != null, "parsed touch Review reaches the real review state") await _touch(page.find_child("ReviewRevise", true, false)) expect(page.mode == "choice", "parsed touch Revise returns to the same choices") await _touch(page.find_child("ChoiceBack", true, false)) expect(shell.current_screen == "title", "parsed touch returns to Title") shell.queue_free() await _frames(3) _cleanup() if failures.is_empty(): print("ABG_DEV2_CHOICE_TOUCH_OK parsed_screen_touch=true title_choice_inspect_compare_select_review_back=true") quit(0) else: for failure in failures: push_error(failure) quit(1) func _touch(control: Control) -> void: var center := root.get_final_transform() * control.get_global_rect().get_center() var press := InputEventScreenTouch.new() press.position = center press.pressed = true press.index = 0 Input.parse_input_event(press) await _frames(2) var release := InputEventScreenTouch.new() release.position = center release.pressed = false release.index = 0 Input.parse_input_event(release) await _frames(4) func _cleanup() -> void: for suffix in ["", ".bak", ".candidate", ".bak.candidate", ".corrupt"]: var file_path := "%s%s" % [DRAFT_PATH, suffix] if FileAccess.file_exists(file_path): DirAccess.remove_absolute(file_path) var company_file := "%s.company%s" % [DRAFT_PATH, suffix] if FileAccess.file_exists(company_file): DirAccess.remove_absolute(company_file) func _frames(count: int) -> void: for frame in range(count): await process_frame func expect(condition: bool, message: String) -> void: if not condition: failures.append("DEV-2 Recruit choice touch: %s" % message)