2026-10-29 22:31:17 +02:00
|
|
|
extends RefCounted
|
|
|
|
|
## Exercise the same rendered buttons as a player. Wall-clock jumps only
|
|
|
|
|
## replace waiting; no direct invocation of task completion or ending selection.
|
|
|
|
|
var game: Node
|
|
|
|
|
var errors: Array[String] = []
|
|
|
|
|
var results: Array = []
|
|
|
|
|
var checks := 0
|
|
|
|
|
|
|
|
|
|
func check(ok: bool, message: String) -> void:
|
|
|
|
|
checks += 1
|
|
|
|
|
if not ok:
|
|
|
|
|
errors.append(message)
|
|
|
|
|
push_error("PHONE QA: " + message)
|
|
|
|
|
|
|
|
|
|
func click(id: String) -> void:
|
|
|
|
|
var control: Button = game.action_button(id)
|
|
|
|
|
check(control != null, "Visible button: " + id)
|
|
|
|
|
if control != null:
|
|
|
|
|
check(not control.disabled, "Enabled button: " + id)
|
|
|
|
|
control.pressed.emit()
|
|
|
|
|
|
|
|
|
|
func at(second: float) -> void:
|
|
|
|
|
game.start_tick = Time.get_ticks_msec() - int(second * 1000.0)
|
|
|
|
|
game._process(0)
|
|
|
|
|
|
|
|
|
|
func perform(id: String) -> void:
|
|
|
|
|
click(id)
|
|
|
|
|
check(not game.busy.is_empty(), "Command accepted: " + id)
|
|
|
|
|
if not game.busy.is_empty():
|
|
|
|
|
at(game.reply_at + 0.02)
|
|
|
|
|
at(game.busy_end + 0.03)
|
|
|
|
|
|
|
|
|
|
func start(number: int, knowledge: int = 0) -> void:
|
|
|
|
|
game.show_test_menu()
|
|
|
|
|
var selection: OptionButton = null
|
|
|
|
|
var memories: OptionButton = null
|
|
|
|
|
for node in game.overlay.find_children("*", "OptionButton", true, false):
|
|
|
|
|
if node.has_meta("test_chapter"): selection = node
|
|
|
|
|
if node.has_meta("test_knowledge"): memories = node
|
|
|
|
|
check(selection != null and memories != null, "Test menu selectors")
|
|
|
|
|
selection.select(number - 1)
|
|
|
|
|
memories.select(knowledge)
|
|
|
|
|
click("test_start")
|
|
|
|
|
|
|
|
|
|
func render() -> void:
|
|
|
|
|
await game.get_tree().process_frame
|
|
|
|
|
await game.get_tree().process_frame
|
|
|
|
|
if DisplayServer.get_name() != "headless":
|
|
|
|
|
await RenderingServer.frame_post_draw
|
|
|
|
|
|
|
|
|
|
func capture(name: String) -> void:
|
|
|
|
|
await render()
|
|
|
|
|
if DisplayServer.get_name() != "headless":
|
|
|
|
|
game.get_viewport().get_texture().get_image().save_png(directory().path_join(name + ".png"))
|
|
|
|
|
|
|
|
|
|
func directory() -> String:
|
|
|
|
|
return OS.get_executable_path().get_base_dir().path_join("captures") if OS.has_feature("template") else ProjectSettings.globalize_path("res://../qa")
|
|
|
|
|
|
|
|
|
|
func finish(expected: String) -> void:
|
|
|
|
|
at(90.1)
|
|
|
|
|
check(game.impacted and not game.running, "Strike finishes")
|
|
|
|
|
check(game.busy.is_empty() and game.events.is_empty(), "Strike clears pending work")
|
|
|
|
|
check(not game.voice.playing, "Strike cuts dialogue")
|
|
|
|
|
check(game.outcome == expected, "Expected " + expected + ", got " + game.outcome)
|
|
|
|
|
results.append({"chapter": game.chapter, "outcome": game.outcome, "facts": game.facts.keys()})
|
|
|
|
|
game.show_ending()
|
|
|
|
|
|
|
|
|
|
func realtime_check() -> void:
|
|
|
|
|
# Opt-in, genuinely wait for the complete prologue and production transition.
|
|
|
|
|
start(1)
|
|
|
|
|
game.qa_mode = false
|
|
|
|
|
var began := Time.get_ticks_msec()
|
|
|
|
|
for step in range(3):
|
|
|
|
|
await game.get_tree().create_timer(30.0).timeout
|
|
|
|
|
print("PHONE_REALTIME elapsed=", (Time.get_ticks_msec() - began) / 1000.0)
|
|
|
|
|
await game.get_tree().create_timer(9.0).timeout
|
|
|
|
|
check(game.impacted and not game.running, "Real 90-second strike")
|
|
|
|
|
for beat in game.story.intro:
|
|
|
|
|
check(beat.line in game.heard, "Real prologue " + str(beat.line))
|
|
|
|
|
check("after_call" in game.heard, "Production post-impact reply")
|
|
|
|
|
check(game.action_button("next") != null, "Production ending overlay")
|
|
|
|
|
await capture("phone-real-ending")
|
|
|
|
|
click("next")
|
|
|
|
|
await game.get_tree().create_timer(5.0).timeout
|
|
|
|
|
check(game.chapter == 2 and game.running, "Production redial")
|
|
|
|
|
check("greeting" in game.heard and "call_02_k" in game.heard, "Production second opening")
|
|
|
|
|
game.qa_mode = true
|
|
|
|
|
start(10, 2)
|
|
|
|
|
for id in ["keys_fast", "lamp_fast", "safe", "front", "side_open", "phone_shelf"]: perform(id)
|
|
|
|
|
game.qa_mode = false
|
|
|
|
|
at(90.1)
|
|
|
|
|
await game.get_tree().create_timer(8.0).timeout
|
|
|
|
|
check(game.outcome == "connected" and "after_alive" in game.heard, "Production mother reply after impact")
|
|
|
|
|
check(game.action_button("next") != null, "Production connected ending overlay")
|
|
|
|
|
game.qa_mode = true
|
|
|
|
|
print("PHONE_REALTIME complete")
|
|
|
|
|
|
|
|
|
|
func run(target: Node) -> void:
|
|
|
|
|
game = target
|
|
|
|
|
DirAccess.make_dir_recursive_absolute(directory())
|
|
|
|
|
check(game.story.chapters.size() == 10, "Ten chapters")
|
|
|
|
|
check(game.story.lines.size() == 102, "All 102 spoken lines")
|
|
|
|
|
for id in game.story.lines:
|
|
|
|
|
check(game.voice_stream(id) != null and game.voice_length(id) > 0.1, "Playable audio " + id)
|
|
|
|
|
await capture("phone-menu")
|
|
|
|
|
for number in range(1, 11):
|
|
|
|
|
start(number)
|
|
|
|
|
check(game.chapter == number and game.place == "flat" and game.items.is_empty(), "Fresh chapter " + str(number))
|
|
|
|
|
check(game.heard == ["greeting"], "Identical opening " + str(number))
|
|
|
|
|
if number == 1:
|
|
|
|
|
check(game.action_button("keys_search") == null, "Prologue has no commands")
|
|
|
|
|
check(game.clock_label.text == "Разговор", "Prologue hides time")
|
|
|
|
|
for beat in game.story.intro: at(beat.at + 0.01)
|
|
|
|
|
check(game.heard.size() == 10, "All ordinary conversation lines")
|
|
|
|
|
else:
|
|
|
|
|
var entry: Dictionary = game.story.chapters[number - 1]
|
|
|
|
|
var opening_at: float = game.events[0].at
|
|
|
|
|
var reply_time: float = game.events[1].at
|
|
|
|
|
check(opening_at >= game.voice_length("greeting"), "Greeting is not truncated")
|
|
|
|
|
at(opening_at + 0.01)
|
|
|
|
|
at(reply_time + 0.01)
|
|
|
|
|
check(entry.opening in game.heard and entry.reply in game.heard, "Unique opening " + str(number))
|
|
|
|
|
perform("question")
|
|
|
|
|
check(entry.question in game.heard and entry.answer in game.heard, "Unique exchange " + str(number))
|
|
|
|
|
at(85.01)
|
|
|
|
|
check(game.heard[-1] == "hum", "Hum before strike")
|
|
|
|
|
finish("flat")
|
|
|
|
|
await capture("phone-ending")
|
|
|
|
|
|
|
|
|
|
# Learn through real commands. Precise instructions require discoveries,
|
|
|
|
|
# rather than the chapter index or a hidden action.
|
|
|
|
|
start(2)
|
|
|
|
|
check(game.action_button("safe") == null, "Safe requires remembered code")
|
|
|
|
|
game.choose_action("safe")
|
|
|
|
|
check(game.busy.is_empty(), "Hidden action rejected")
|
|
|
|
|
perform("keys_search")
|
|
|
|
|
check(game.facts.has("keys") and game.items.has("keys"), "Key discovery")
|
|
|
|
|
perform("lamp_search")
|
|
|
|
|
check(game.facts.has("lamp") and game.items.has("lamp"), "Lamp discovery")
|
|
|
|
|
finish("flat")
|
|
|
|
|
click("next")
|
|
|
|
|
check(game.chapter == 3 and game.facts.has("keys") and game.items.is_empty(), "Redial remembers knowledge only")
|
|
|
|
|
check(game.action_button("keys_fast") != null and game.action_button("keys_search") == null, "Shortcut replaces slow search")
|
|
|
|
|
|
|
|
|
|
start(4)
|
|
|
|
|
perform("mail_hint")
|
|
|
|
|
perform("read_mail")
|
|
|
|
|
check(game.facts.has("code"), "Code obtainable before blackout")
|
|
|
|
|
at(45.01)
|
|
|
|
|
check(game.action_button("read_mail") == null, "No laptop after blackout")
|
|
|
|
|
finish("flat")
|
|
|
|
|
click("next")
|
|
|
|
|
perform("safe")
|
|
|
|
|
check(game.items.has("spare") and game.facts.has("route"), "Code opens safe on next call")
|
|
|
|
|
|
|
|
|
|
start(4)
|
|
|
|
|
perform("mail_hint")
|
|
|
|
|
at(40)
|
|
|
|
|
click("read_mail")
|
|
|
|
|
at(46)
|
|
|
|
|
check(game.busy.is_empty() and not game.facts.has("code"), "Power cancels unfinished mail")
|
|
|
|
|
check("late_mail" in game.heard, "Power failure dialogue")
|
|
|
|
|
|
|
|
|
|
start(4, 2)
|
|
|
|
|
game.facts.erase("code")
|
|
|
|
|
at(28)
|
|
|
|
|
click("read_mail")
|
|
|
|
|
check(game.busy_end < 45, "Mail scheduled before blackout")
|
|
|
|
|
at(46)
|
|
|
|
|
check(game.facts.has("code"), "Late frame preserves pre-blackout completion")
|
|
|
|
|
|
|
|
|
|
start(5, 2)
|
|
|
|
|
perform("keys_fast")
|
|
|
|
|
click("front")
|
|
|
|
|
at(92)
|
|
|
|
|
check(game.outcome == "landing", "Late frame resolves movement before impact")
|
|
|
|
|
|
|
|
|
|
start(2)
|
|
|
|
|
click("keys_search")
|
|
|
|
|
at(8)
|
|
|
|
|
click("cancel")
|
|
|
|
|
at(21)
|
|
|
|
|
check(not game.facts.has("keys") and not game.items.has("keys"), "Cancelled search grants nothing")
|
|
|
|
|
check(game.elapsed >= 21, "Cancellation never refunds time")
|
|
|
|
|
at(89)
|
|
|
|
|
click("keys_search")
|
|
|
|
|
finish("flat")
|
|
|
|
|
check(not game.items.has("keys"), "Impact rejects unfinished search")
|
|
|
|
|
|
|
|
|
|
start(3)
|
|
|
|
|
perform("inner")
|
|
|
|
|
finish("inner")
|
|
|
|
|
start(5)
|
|
|
|
|
perform("keys_search")
|
|
|
|
|
perform("front")
|
|
|
|
|
perform("stairs")
|
|
|
|
|
check(game.facts.has("stairs"), "Blocked stairs discovered")
|
|
|
|
|
finish("landing")
|
|
|
|
|
|
|
|
|
|
# Full route with learned facts is feasible at normal production durations,
|
|
|
|
|
# including both speakers' complete audio lengths.
|
|
|
|
|
start(7, 2)
|
|
|
|
|
game.facts.erase("latch")
|
|
|
|
|
for id in ["keys_fast", "lamp_fast", "safe", "front", "side_try"]: perform(id)
|
|
|
|
|
check(game.facts.has("latch"), "Latch discovered from physical attempt")
|
|
|
|
|
finish("landing")
|
|
|
|
|
click("next")
|
|
|
|
|
for id in ["keys_fast", "lamp_fast", "safe", "front", "side_open"]: perform(id)
|
|
|
|
|
check(game.place == "alcove" and game.elapsed < 75, "Reach alcove in time")
|
|
|
|
|
finish("alcove")
|
|
|
|
|
|
|
|
|
|
start(8, 2)
|
|
|
|
|
game.facts.erase("signal")
|
|
|
|
|
for id in ["keys_fast", "lamp_fast", "safe", "front", "side_open", "phone_test"]: perform(id)
|
|
|
|
|
check(game.facts.has("signal"), "Signal location found")
|
|
|
|
|
perform("phone_shelf")
|
|
|
|
|
check(game.items.has("connected") and game.elapsed < 90, "Reach responsive ending through discovery")
|
|
|
|
|
var route_time: float = game.elapsed
|
|
|
|
|
await capture("phone-gameplay")
|
|
|
|
|
finish("connected")
|
|
|
|
|
await capture("phone-connected")
|
|
|
|
|
|
|
|
|
|
# A late frame cannot complete a task after the impact. Old callbacks and
|
|
|
|
|
# popup buttons cannot apply a task twice.
|
|
|
|
|
start(10, 2)
|
|
|
|
|
at(82)
|
|
|
|
|
click("safe")
|
|
|
|
|
at(92)
|
|
|
|
|
check(game.outcome == "flat" and not game.items.has("spare"), "Low-FPS deadline wins over pending safe")
|
|
|
|
|
game.choose_action("keys_fast")
|
|
|
|
|
check(game.busy.is_empty(), "Post-impact commands ignored")
|
|
|
|
|
|
|
|
|
|
var save_file := directory().path_join("phone-profile-test.cfg")
|
|
|
|
|
check(game.Profile.write_profile(save_file, {"code": true}, {"connected": true}, 10) == OK, "Profile writes")
|
|
|
|
|
var saved: Dictionary = game.Profile.read_profile(save_file, game.story.facts, game.story.endings)
|
|
|
|
|
check(saved.facts == {"code": true} and saved.endings == {"connected": true} and saved.loops == 10, "Profile disk roundtrip")
|
|
|
|
|
var cfg := ConfigFile.new()
|
|
|
|
|
cfg.set_value("save", "facts", {"code": 1, "unknown": true, "lamp": true})
|
|
|
|
|
cfg.set_value("save", "loops", -3)
|
|
|
|
|
cfg.save(save_file)
|
|
|
|
|
saved = game.Profile.read_profile(save_file, game.story.facts, game.story.endings)
|
|
|
|
|
check(saved.facts == {"lamp": true} and saved.loops == 0, "Invalid save data filtered")
|
2026-10-29 22:36:22 +02:00
|
|
|
# Notifications are an independent clock: four during the call, the fifth
|
|
|
|
|
# two seconds after the strike. Reading never pauses or cancels mom's task.
|
|
|
|
|
start(2)
|
|
|
|
|
at(16.9)
|
|
|
|
|
check(game.notifications.is_empty(), "No early push")
|
|
|
|
|
at(17)
|
|
|
|
|
check(game.notifications.size() == 1 and game.unread == 1, "First push at 17 seconds")
|
|
|
|
|
check(game.notification_card.visible, "Push is visible")
|
|
|
|
|
click("dismiss_push")
|
|
|
|
|
check(not game.notification_card.visible and game.unread == 1, "Dismiss keeps message unread")
|
|
|
|
|
click("keys_search")
|
|
|
|
|
at(34)
|
|
|
|
|
check(game.notifications.size() == 2 and not game.busy.is_empty(), "Second push during mom task")
|
|
|
|
|
click("open_push")
|
|
|
|
|
check(game.viewing_messages and game.unread == 0, "Open push reads inbox")
|
|
|
|
|
at(40)
|
|
|
|
|
check(game.items.has("keys") and game.elapsed >= 40, "Mom task and clock continue while reading")
|
|
|
|
|
click("close_messages")
|
|
|
|
|
check(not game.viewing_messages and game.overlay == null, "Return to call")
|
|
|
|
|
at(56)
|
|
|
|
|
check(game.notifications.size() == 3, "Third push")
|
|
|
|
|
at(76)
|
|
|
|
|
check(game.notifications.size() == 4, "Fourth push")
|
|
|
|
|
check(game.notifications[3].text == "Ты читала новости? Там переговоры, походу скоро все закончится", "Exact fourth text")
|
|
|
|
|
await capture("phone-fourth-push")
|
|
|
|
|
at(90)
|
|
|
|
|
check(game.impacted and game.notifications.size() == 4, "No fifth message before impact")
|
|
|
|
|
at(91.9)
|
|
|
|
|
check(game.notifications.size() == 4, "Fifth push waits until after impact")
|
|
|
|
|
game.show_ending()
|
|
|
|
|
at(92)
|
|
|
|
|
check(game.notifications.size() == 5 and game.notification_card.visible, "Fifth push over ending screen")
|
|
|
|
|
check(game.notifications[4].text == "Кать в твой дом походу попали...", "Exact fifth text")
|
|
|
|
|
await capture("phone-after-impact-push")
|
|
|
|
|
check(game.notification_card.size.y < 300, "Toast stays compact across all five pushes")
|
|
|
|
|
click("open_push")
|
|
|
|
|
check(game.viewing_messages and game.notifications.size() == 5, "All messages readable after impact")
|
|
|
|
|
await capture("phone-inbox")
|
|
|
|
|
at(96)
|
|
|
|
|
check(game.notifications.size() == 5, "No duplicate messages")
|
|
|
|
|
click("close_messages")
|
|
|
|
|
click("next")
|
|
|
|
|
check(game.notifications.is_empty() and game.unread == 0 and not game.notification_card.visible, "Redial resets message history")
|
|
|
|
|
# Use the production delayed transition once: a reader who opens the final
|
|
|
|
|
# push must not have the inbox closed by the ending coroutine a moment later.
|
|
|
|
|
start(2)
|
|
|
|
|
game.qa_mode = false
|
|
|
|
|
at(90)
|
|
|
|
|
await game.get_tree().create_timer(2.2).timeout
|
|
|
|
|
check(game.notifications.size() == 5 and game.notification_card.visible, "Production post-impact push arrives")
|
|
|
|
|
click("open_push")
|
|
|
|
|
await game.get_tree().create_timer(8.0).timeout
|
|
|
|
|
check(game.viewing_messages and game.action_button("close_messages") != null, "Ending transition preserves open inbox")
|
|
|
|
|
click("close_messages")
|
|
|
|
|
check(game.action_button("next") != null, "Inbox returns to production ending")
|
|
|
|
|
game.qa_mode = true
|
2026-10-29 22:31:17 +02:00
|
|
|
if "--phone-real-time" in OS.get_cmdline_user_args():
|
|
|
|
|
await realtime_check()
|
|
|
|
|
var file := FileAccess.open(directory().path_join("phone-result.json"), FileAccess.WRITE)
|
|
|
|
|
file.store_string(JSON.stringify({"passed": errors.is_empty(), "checks": checks, "errors": errors, "routes": results, "full_route_seconds": route_time}, " "))
|
|
|
|
|
file.close()
|
|
|
|
|
print("PHONE_QA ", "PASS" if errors.is_empty() else "FAIL", " checks=", checks, " route=", route_time, " errors=", errors)
|
|
|
|
|
await render()
|
2026-10-29 22:36:22 +02:00
|
|
|
for player in [game.voice, game.room, game.siren, game.effect, game.hum, game.notification_sound]:
|
2026-10-29 22:31:17 +02:00
|
|
|
player.stop()
|
|
|
|
|
player.stream = null
|
|
|
|
|
await game.get_tree().create_timer(0.1).timeout
|
|
|
|
|
var tree: SceneTree = game.get_tree()
|
|
|
|
|
game = null
|
|
|
|
|
tree.quit(0 if errors.is_empty() else 1)
|