Files
Diabolo/DoOtboy/do-otboy/scripts/phone_session_qa.gd
T

48 lines
3.1 KiB
GDScript
Raw Normal View History

2026-10-30 17:31:47 +02:00
extends RefCounted
## Run in a fresh process with --phone-session-qa and an isolated APPDATA
## containing an old phone_memory.cfg. Unlike --phone-qa, production startup,
## normal session snapshots and the animated redial are all enabled here.
func run(game: Node) -> void:
var qa = load("res://scripts/phone_qa.gd").new()
qa.game = game
DirAccess.make_dir_recursive_absolute(qa.directory())
var old: Dictionary = game.Profile.read_profile("user://profile/phone_memory.cfg",game.story.facts,game.story.endings)
qa.check(old.facts.has("lamp") and old.loops == 10,"Regression fixture contains previous-launch discoveries")
qa.check(not game.qa_mode,"Exercise production startup rather than the ordinary QA bypass")
qa.check(game.facts.is_empty() and game.endings.is_empty() and game.completed == 0,"Every process starts with empty progress despite an old save")
qa.check(game.action_button("start").text == "Позвонить маме","Main menu starts the first call")
qa.click("start")
await game.get_tree().create_timer(2.6).timeout
qa.check(game.chapter == 1 and game.facts.is_empty(),"First greeting has no inherited clues")
qa.click("memory")
qa.check(game.memory_content.get_parsed_text().contains("Мама ещё не рассказала"),"First-call memory shows the empty explanation")
qa.click("close_memory")
qa.finish("flat")
qa.check(game.completed == 1 and game.session_progress.loops == 1,"Completed call stays in this run")
qa.click("next")
await game.get_tree().create_timer(2.6).timeout
qa.check(game.chapter == 2 and game.facts.has("key_letter") and not game.facts.has("lamp"),"Redial retains only the first call's actual discoveries")
qa.perform("lamp_search")
qa.check(game.facts.has("lamp") and game.session_progress.facts.has("lamp"),"New flashlight discovery is remembered within this run")
game.begin_call(3,false)
qa.check(game.facts.has("lamp") and game.items.is_empty(),"Normal next call keeps knowledge while resetting physical items")
qa.start(10,2)
await game.get_tree().create_timer(2.6).timeout
qa.check(game.facts.has("code") and not game.session_progress.facts.has("code"),"All-knowledge scene test cannot alter normal memory")
game.begin_call(2,false)
qa.check(game.facts.has("lamp") and not game.facts.has("code") and game.completed == 1,"Returning from a scene test restores only this run's normal progress")
old = game.Profile.read_profile("user://profile/phone_memory.cfg",game.story.facts,game.story.endings)
qa.check(old.loops == 10,"The legacy disk file is ignored, not used as session storage")
var file := FileAccess.open(qa.directory().path_join("phone-session-result.json"),FileAccess.WRITE)
file.store_string(JSON.stringify({"passed":qa.errors.is_empty(),"checks":qa.checks,"errors":qa.errors}," "))
file.close()
print("PHONE_SESSION_QA ","PASS" if qa.errors.is_empty() else "FAIL"," checks=",qa.checks," errors=",qa.errors)
game.soundscape.stop()
for player in [game.voice,game.siren,game.effect,game.hum,game.notification_sound]:
player.stop()
player.stream = null
var exit_code := 0 if qa.errors.is_empty() else 1
qa.game = null
await game.get_tree().create_timer(0.1).timeout
game.get_tree().quit(exit_code)