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

767 lines
37 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 check_clocks(expected: String, context: String) -> void:
check(game.clock_label.text == expected, "Katya call duration " + context)
check(game.stage.mother_clock.text == expected, "Mother call duration " + context)
func click(id: String) -> void:
var gameplay := id == "question"
for action in game.story.actions:
if action.id == id: gameplay = true
if gameplay: wait_for_speech()
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:
if second >= game.speech_until: game.voice.stop()
game.start_tick = Time.get_ticks_msec() - int(second * 1000.0)
game._process(0)
if second >= game.speech_until: game.voice.stop()
game.refresh_live()
func wait_for_speech() -> void:
for step in range(12):
if game.speech_finished() and game.events.is_empty(): return
var next: float = maxf(game.elapsed, game.speech_until) + 0.01
if not game.events.is_empty(): next = maxf(next, float(game.events[0].at) + 0.01)
at(next)
check(false, "Dialogue must finish before choosing")
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(maxf(game.busy_end,game.speech_until) + 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 start_with_letter(number: int) -> void:
start(1)
finish("flat")
check(game.facts.has("mail_request"),"First conversation establishes mother's request")
start(number,1)
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 escape() -> void:
var key := InputEventKey.new()
key.keycode = KEY_ESCAPE
key.physical_keycode = KEY_ESCAPE
key.pressed = true
game.get_viewport().push_input(key,true)
var release := key.duplicate()
release.pressed = false
game.get_viewport().push_input(release,true)
await render()
func capture(name: String) -> void:
if DisplayServer.get_name() != "headless":
await game.get_tree().create_timer(0.42).timeout
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)
for entry in game.archive:
if not entry.has("line"): continue
var rule: Dictionary = game.story.line_rules.get(entry.line,{})
for key in rule.get("facts",[]): check(key in entry.known,"Spoken line has prior evidence: " + entry.line + "/" + key)
for key in rule.get("items",[]): check(key in entry.items,"Spoken line uses a held item: " + entry.line + "/" + key)
if rule.has("places"): check(entry.place in rule.places,"Spoken line matches current place: " + entry.line)
results.append({"chapter": game.chapter, "outcome": game.outcome, "facts": game.facts.keys()})
# Fast route checks skip the production epilogue; separate checks below
# wait for the real audio and verify that it gates the redial control.
game.ending_ready = true
game.show_ending()
func check_black_frame(context: String) -> void:
await render()
check(not game.stage.call_layout.visible and game.screen_fade.color == Color.BLACK, "Black call stage: " + context)
check(game.action_button("next") == null, "No early redial: " + context)
if DisplayServer.get_name() != "headless":
var frame := game.get_viewport().get_texture().get_image()
frame.resize(32,20,Image.INTERPOLATE_NEAREST)
var black := true
for y in range(frame.get_height()):
for x in range(frame.get_width()):
var pixel := frame.get_pixel(x,y)
if pixel.r > 0.005 or pixel.g > 0.005 or pixel.b > 0.005: black = false
check(black,"Rendered screen is entirely black: " + context)
func production_ending_check(connected: bool = false) -> void:
start(10 if connected else 2,2 if connected else 0)
if connected:
for id in ["keys_fast","lamp_fast","safe","front","side_open","phone_shelf"]: perform(id)
game.qa_mode = false
at(90.1)
await check_black_frame("impact")
game.continue_call()
check(game.impacted and not game.dialing,"Direct redial is blocked during the epilogue")
await game.get_tree().create_timer(2.15).timeout
check(game.voice.playing and game.heard[-1] == ("after_alive" if connected else "after_call"),"Production epilogue starts after the impact")
check(game.notifications.size() == 5 and not game.notification_card.visible,"Fifth message is kept without covering the black screen")
await check_black_frame("voice")
if not connected: await capture("phone-black-voice")
for step in range(100):
if game.ending_ready: break
check(game.action_button("next") == null,"Redial waits for the complete epilogue")
await game.get_tree().create_timer(0.1).timeout
check(game.ending_ready and not game.voice.playing,"Epilogue finishes naturally before redial")
check(game.heard[-1] == ("here" if connected else "after_call"),"Katya has the final spoken line")
await render()
var redial: Button = game.action_button("next")
check(redial != null and redial.text == "Позвонить Маме","Single floating redial label")
if redial != null:
check(redial.get_global_rect().get_center().distance_to(game.ui.get_global_rect().get_center()) < 15,"Redial is centered in the viewport")
check(redial.get_parent().get_child_count() == 1,"Only one tag after the epilogue")
await capture("phone-redial-connected" if connected else "phone-redial")
await escape()
click("ending_messages")
check(game.viewing_messages and game.notifications.size() == 5,"All five messages remain readable from the menu")
await capture("phone-inbox")
click("close_messages")
click("outcome")
check(game.menu_screen == "outcome","Outcome remains available in the menu")
click("transcript")
check(game.archive[-1].speaker == "Катя","Final Katya line remains in the transcript")
click("back_ending")
click("end_menu")
click("resume")
await render()
redial = game.action_button("next")
if redial != null and DisplayServer.get_name() != "headless":
var cloud: Container = redial.get_parent()
cloud.mouse_filter = Control.MOUSE_FILTER_IGNORE
cloud.pointer_inside = false
cloud.hovered = null
await render()
var previous: Vector2 = redial.position
await game.get_tree().create_timer(0.6).timeout
check(redial.position.distance_to(previous)>0.05,"Redial tag drifts slowly")
var pointer := InputEventMouseMotion.new()
pointer.position = redial.position+redial.size/2
cloud._gui_input(pointer)
await game.get_tree().create_timer(0.4).timeout
check(redial.scale.x>1.1,"Redial tag grows on hover")
cloud.mouse_filter = Control.MOUSE_FILTER_STOP
await render()
var press := InputEventMouseButton.new()
press.button_index = MOUSE_BUTTON_LEFT
press.position = redial.get_global_rect().get_center()
press.pressed = true
game.get_viewport().push_input(press,true)
press = press.duplicate()
press.pressed = false
game.get_viewport().push_input(press,true)
else:
click("next")
check(game.dialing and not game.impacted,"Redial starts via the displayed tag")
await game.get_tree().create_timer(2.5).timeout
check(game.running and game.stage.call_layout.visible and game.screen_fade.color.a == 0,"Redial restores both phones and clears blackout")
check(game.notifications.is_empty() and not game.ending_ready,"New call clears epilogue state")
game.qa_mode = true
func realtime_check() -> void:
# Opt-in, genuinely wait for the complete prologue and production transition.
start(1)
game.qa_mode = false
var warning_finished: Array[float] = []
var record_warning := func():
if game.running and not game.heard.is_empty() and game.heard[-1] == "hum":
warning_finished.append(game.elapsed)
game.voice.finished.connect(record_warning)
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
game.voice.finished.disconnect(record_warning)
check(game.impacted and not game.running, "Real 90-second strike")
check_clocks("01:30", "real disconnected call")
check(warning_finished.size() == 1, "Real warning plays to its natural end")
if warning_finished.size() == 1:
var warning_gap := float(game.story.timeline.impact) - warning_finished[0]
check(warning_gap >= 5, "Real warning leaves five seconds before impact")
print("PHONE_REALTIME warning_gap=", warning_gap)
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")
while game.dialing: await game.get_tree().create_timer(0.1).timeout
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")
check(game.action_button("keys_search").disabled, "Real audio keeps early answers disabled")
for frame in range(100):
if game.can_respond(): break
await game.get_tree().create_timer(0.2).timeout
check(game.can_respond() and not game.action_button("keys_search").disabled, "Real audio completion unlocks answers")
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 realtime_final_check() -> void:
start(2)
wait_for_speech()
at(float(game.story.timeline.hum)-0.5)
click("keys_search")
var finished_at: Array[float] = []
var record_final := func():
if game.running and game.heard[-1] == "hum": finished_at.append(game.elapsed)
game.voice.finished.connect(record_final)
await game.get_tree().create_timer(10.0).timeout
game.voice.finished.disconnect(record_final)
check(game.impacted and game.heard[-1] == "hum", "Real late Katya request ends with mother's final line")
check(finished_at.size() == 1, "Real final mother recording finishes without interruption")
if finished_at.size() == 1:
var gap := float(game.story.timeline.impact)-finished_at[0]
check(gap >= 5.0, "Real final line still leaves five seconds before explosion")
print("PHONE_FINAL_REALTIME gap=",gap)
check("keys_search_m" not in game.heard and not game.items.has("keys"), "Real deferred reply cannot replace final mother line")
func run(target: Node) -> void:
game = target
DirAccess.make_dir_recursive_absolute(directory())
check(game.UI_FONT.get_string_size("Позвонить Маме",0,-1,34).x > game.UI_FONT.base_font.get_string_size("Позвонить Маме",0,-1,34).x,"Cyrillic uses the bold variation rather than the regular fallback")
check(game.story.chapters.size() == 10, "Ten chapters")
check(game.story.lines.size() == 110, "All 110 spoken lines")
for id in game.story.lines:
check(game.voice_stream(id) != null and game.voice_length(id) > 0.1, "Playable audio " + id)
var voices: Dictionary = JSON.parse_string(FileAccess.get_file_as_string("res://data/voice_manifest.json"))
var jessica_count := 0
var carol_count := 0
for id in game.story.lines:
if game.story.lines[id].speaker == "Катя":
check(voices[id].provider == "ElevenLabs" and voices[id].voice_id == "cgSgspJ2msm6clMCkdW9", "Jessica assigned: " + id)
jessica_count += 1
else:
check(voices[id].provider == "ElevenLabs" and voices[id].voice_id == "5u41aNhyCU6hXOcjPPv0", "Carol assigned: " + id)
carol_count += 1
check(jessica_count == 52, "All 52 Katya lines use Jessica")
check(carol_count == 58, "All 58 mother lines use Carol")
for id in game.story.lines:
check(voices[id].text == game.story.lines[id].text,"Audio manifest matches corrected dialogue: " + id)
check(game.voice_length("greeting") <= game.story.intro[0].at, "Greeting fits before prologue")
check(45 + game.voice_length("power") <= 51, "Blackout reaction fits before conversation resumes")
var warning_at: float = game.story.timeline.hum
check(90 - warning_at - game.voice_length("hum") >= 5, "At least five seconds after full warning before strike")
check(game.hum.stream.get_length() >= 90 - warning_at, "Background hum covers the longer wait until impact")
for index in range(game.story.intro.size()):
var beat: Dictionary = game.story.intro[index]
var next_at: float = game.story.intro[index + 1].at if index + 1 < game.story.intro.size() else warning_at
if float(beat.at) < 45: next_at = minf(next_at, 45)
check(float(beat.at) + game.voice_length(beat.line) <= next_at, "Intro line fits before next cue: " + str(beat.line))
await capture("phone-menu")
check(game.menu_screen == "main" and not game.stage.smartphone.is_visible_in_tree() and not game.stage.mother_phone.is_visible_in_tree(), "Main menu hides the call interface")
check(game.menu_content.get_global_rect().get_center().distance_to(game.ui.get_global_rect().get_center()) < 2, "Main menu is centered in the viewport")
check(game.stage.menu_mode and game.stage.glow.get_shader_parameter("menu_bokeh") == 1.0, "Main menu uses the bokeh background")
check(game.action_button("start") != null and game.action_button("quit") != null, "Main menu offers start and exit")
click("settings")
check(game.menu_screen == "settings" and not game.stage.call_layout.visible, "Settings stay on the menu background")
await capture("phone-credits")
click("back_menu")
click("testing")
check(game.menu_screen == "testing", "Scene selection opens from main menu")
await capture("phone-scene-menu")
await escape()
check(game.menu_screen == "main", "Escape returns from scene selection to main menu")
game.dial_call(1,true,0,true)
check(game.dialing and not game.running, "Dial animation precedes the 90-second clock")
check_clocks("", "hidden before connection")
check(game.stage.mother_status.text == "Входящий звонок", "Mother sees incoming daughter call")
await game.get_tree().create_timer(0.55).timeout
await capture("phone-dialing")
await game.get_tree().create_timer(1.9 if DisplayServer.get_name() == "headless" else 1.5).timeout
check(game.running and not game.dialing and game.elapsed < 1.0, "Connection starts a fresh full attempt")
check_clocks("00:00", "first connection")
check("greeting" in game.heard, "Mother answers after connection")
check(game.menu_screen.is_empty() and game.stage.call_layout.visible and not game.stage.menu_mode, "Call restores the gameplay background")
game.stage.update(1.0)
check(game.stage.purple_level > game.stage.pink_level, "Mother lights the violet background")
await capture("phone-mother-voice")
at(4.0)
game.stage.update(1.0)
check(game.stage.pink_level > game.stage.purple_level, "Katya lights the pink background")
await capture("phone-katya-voice")
start(2)
var blocked: Button = game.action_button("keys_search")
check(blocked != null and blocked.disabled, "Choices visible but disabled during greeting")
await capture("phone-locked-answers")
blocked.pressed.emit()
game.choose_action("keys_search")
check(game.busy.is_empty() and game.heard == ["greeting"], "Early clicks cannot cut off a speaker")
at(game.speech_until - 0.02)
check(game.action_button("keys_search").disabled, "Still blocked before audio end")
wait_for_speech()
check(not game.action_button("keys_search").disabled, "Choices enabled after complete opening exchange")
await capture("phone-answer-cloud")
check(absf(game.stage.center_region.get_global_rect().get_center().x-game.ui.size.x/2)<1,"Dialogue and answers share the screen center")
check(absf(game.stage.smartphone.get_global_rect().get_center().y-game.stage.mother_phone.get_global_rect().get_center().y)<2,"Phones have the same vertical center")
for answer in game.command_list.get_children():
if answer is Button: check(not answer.text.ends_with(" с"), "Answer has no duration: " + answer.text)
if DisplayServer.get_name() != "headless":
var tag: Button = game.action_button("keys_search")
# Keep the user's physical cursor from cancelling the timed synthetic hover.
# Click dispatch is still checked through the real viewport just below.
game.command_list.mouse_filter=Control.MOUSE_FILTER_IGNORE
await render()
game.command_list.hovered=null
game.command_list.pointer_inside=false
var previous: Vector2 = tag.position
await game.get_tree().create_timer(0.65).timeout
check(tag.position.distance_to(previous)>0.1, "Answer tags drift gently")
var pointer := InputEventMouseMotion.new()
pointer.position = tag.position+tag.size/2
game.command_list._gui_input(pointer)
await game.get_tree().create_timer(0.45).timeout
check(tag.scale.x>1.08, "Hovered answer grows")
var held: Vector2 = tag.position
await game.get_tree().create_timer(0.25).timeout
check(tag.position.distance_to(held)<0.1, "Hovered answer holds still for clicking")
await capture("phone-answer-hover")
pointer = InputEventMouseMotion.new()
pointer.position = Vector2(-20,-20)
game.command_list._gui_input(pointer)
await game.get_tree().create_timer(0.5).timeout
check(tag.scale.x<1.08, "Answer returns to its depth after hover")
game.command_list.mouse_filter=Control.MOUSE_FILTER_STOP
await render()
var press := InputEventMouseButton.new()
press.button_index=MOUSE_BUTTON_LEFT
press.position=tag.get_global_rect().get_center()
press.pressed=true
game.get_viewport().push_input(press,true)
var release := InputEventMouseButton.new()
release.button_index=MOUSE_BUTTON_LEFT
release.position=press.position
release.pressed=false
game.get_viewport().push_input(release,true)
check(game.busy.get("id","")=="keys_search", "Mouse selects the visible floating answer")
start(2)
wait_for_speech()
await render()
check(game.stage.memory_button.size.x >= 100 and game.action_button("menu") == null, "Call screen keeps memory without a menu button")
if DisplayServer.get_name() != "headless":
var original_size := DisplayServer.window_get_size()
DisplayServer.window_set_size(Vector2i(1366,768))
await capture("phone-wide-layout")
check(game.ui.get_global_rect().encloses(game.stage.mother_phone.get_global_rect()), "Mother phone fits wide viewport")
check(game.ui.get_global_rect().encloses(game.stage.smartphone.get_global_rect()), "Katya phone fits wide viewport")
DisplayServer.window_set_size(original_size)
await render()
var chapter_before_menu: int = game.chapter
var elapsed_before_menu: float = game.elapsed
await escape()
check(game.menu_screen == "main" and game.action_button("resume") != null, "Escape opens menu during a call")
check(not game.stage.call_layout.visible and game.action_button("keys_search") == null, "Menu hides gameplay choices")
await capture("phone-menu-during-call")
at(elapsed_before_menu + 1.0)
check(game.elapsed >= elapsed_before_menu + 1.0 and game.running, "Call clock continues in menu")
click("resume")
check(game.menu_screen.is_empty() and game.stage.call_layout.visible and game.chapter == chapter_before_menu, "Resume restores the same call")
await escape()
await escape()
check(game.menu_screen.is_empty() and game.running, "Escape also returns directly to the call")
var cloud_rect: Rect2 = game.stage.choice_scroll.get_global_rect()
check(cloud_rect.position.y > game.transcript_scroll.get_global_rect().position.y, "Answers below central dialogue")
for child in game.command_list.get_children():
if child is Button:
check(child.get_global_rect().position.x >= cloud_rect.position.x and child.get_global_rect().end.x <= cloud_rect.end.x + 1, "Answer fits cloud width: " + child.text)
click("memory")
check(game.action_button("close_memory") != null, "Notebook opens from call screen")
click("close_memory")
click("keys_search")
check(game.action_button("cancel") == null, "No change-answer control")
game.choose_action("lamp_search")
check(game.busy.get("id") == "keys_search", "Chosen request cannot be replaced while speaking")
at(game.speech_until + 0.1)
game.choose_action("lamp_search")
check(game.busy.get("id") == "keys_search" and not game.can_respond(), "Chosen request stays locked during the search")
at(game.reply_at + 0.01)
check(not game.can_respond(), "Mother's answer cannot be interrupted by a choice")
at(game.busy_end + 0.12)
check(game.can_respond(), "Next choices enabled after response and task completion")
start(1)
check(game.soundscape.streams.size() == 16, "All ambience and foley assets loaded")
check(game.soundscape.beds.fridge.playing and game.soundscape.beds.tv.playing, "Powered room starts alive")
check(game.soundscape.duck_db <= -11.9, "Background ducks under spoken greeting")
game.soundscape.update_mix(0.5, false)
check(game.soundscape.duck_db > -11 and game.soundscape.duck_db < 0, "Background recovers gently after speech")
game.soundscape.dialogue_started(-40)
check(game.soundscape.duck_db <= -23.9, "Very quiet voices receive extra background attenuation")
game.soundscape.set_volume(0)
check(AudioServer.get_bus_volume_db(game.soundscape.scene_bus) <= -79, "Independent background mute")
game.soundscape.set_volume(0.75)
at(36.1)
check(game.soundscape.history.any(func(cue): return cue.id == "kettle"), "Kettle follows the shared call clock")
at(45.01)
check(not game.soundscape.beds.fridge.playing and not game.soundscape.beds.tv.playing, "Power cut silences appliances")
check(game.soundscape.beds.room.playing and game.soundscape.beds.line.playing, "Room and telephone survive power cut")
finish("flat")
check(not game.soundscape.active and game.soundscape.queue.is_empty(), "Strike stops room and all pending sounds")
start(2)
perform("keys_search")
check(game.soundscape.history.any(func(cue): return cue.id == "keys"), "Key sound follows actual search")
click("lamp_search")
at(float(game.story.timeline.hum) + 0.01)
check(not game.soundscape.queue.any(func(cue): return cue.task), "Final reaction discards pending action sounds")
# Every redial repeats the same external world, including the first call.
for number in range(1, 11):
start(number)
check_clocks("00:00", "reset in call " + str(number))
at(0.95)
check_clocks("00:00", "before first full second")
at(1.05)
check_clocks("00:01", "one elapsed second")
at(23.99)
check(not game.fired.has("alarm"), "No early siren: " + str(number))
at(24.01)
check(game.fired.get("alarm") == 24.0, "Same siren time: " + str(number))
check(game.siren.playing and game.siren.volume_db < -60, "Siren starts softly: " + str(number))
at(27)
check(game.siren.volume_db > -20 and game.siren.volume_db < -10, "Siren rises gradually: " + str(number))
at(30)
check(absf(game.siren.volume_db+8)<0.1, "Siren reaches audible background level: " + str(number))
at(44.99)
check(not game.fired.has("power") and game.soundscape.powered, "Lights stay on until 45: " + str(number))
at(45.01)
check(game.fired.get("power") == 45.0 and game.archive.any(func(line): return line.text.begins_with("Свет в квартире погас.")), "Same visible blackout: " + str(number))
check("power" in game.heard, "Mother acknowledges blackout: " + str(number))
at(59.95)
check_clocks("00:59", "before minute rollover")
at(60.05)
check_clocks("01:00", "minute rollover")
at(warning_at - 0.01)
check(not game.fired.has("hum"), "No early hum: " + str(number))
at(warning_at + 0.01)
check(game.fired.get("hum") == warning_at, "Same hum time: " + str(number))
at(warning_at + game.voice_length("hum") + 0.01)
check(not game.impacted and game.heard[-1] == "hum", "Full warning leaves time before impact: " + str(number))
at(89.99)
check_clocks("01:29", "last second of call")
check(not game.impacted, "No early strike: " + str(number))
finish("flat")
check_clocks("01:30", "duration held after disconnect")
at(95)
check_clocks("01:30", "post-call notifications do not advance duration")
check(game.fired.get("impact") == 90.0, "Same strike time: " + str(number))
start(1)
at(45.01)
await capture("phone-first-blackout")
start(2)
at(45.01)
await capture("phone-second-blackout")
start(2)
at(38)
click("keys_search")
at(45.01)
check(not game.busy.is_empty() and "power" not in game.heard, "Blackout does not interrupt an unrelated spoken task")
check(game.fired.get("power") == 45.0 and not game.soundscape.powered, "Busy task cannot postpone blackout")
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_clocks("00:00", "prologue shows duration")
for beat in game.story.intro: at(beat.at + 0.01)
check(game.heard.size() == 19 and "power" in game.heard, "Ordinary conversation and blackout acknowledgement")
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)
var opening: Dictionary = game.opening_for(number)
check(opening.opening in game.heard and opening.reply in game.heard, "Knowledge-aware opening " + str(number))
if game.line_allowed(entry.question):
perform("question")
check(entry.question in game.heard and entry.answer in game.heard, "Contextual exchange " + str(number))
else:
check(game.action_button("question") == null,"No context-free question " + str(number))
at(warning_at + 0.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_exact") 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_exact") 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_with_letter(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_with_letter(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")
# The final mother line always wins, including a request spoken by Katya
# at the boundary and a queued answer that would overlap the ending.
for number in range(2,11):
start(number)
wait_for_speech()
at(warning_at - 0.5)
click("keys_search")
check(game.stage.speaker == "Катя" and game.speech_until > warning_at, "Late Katya request crosses final cue: " + str(number))
at(warning_at + 0.01)
check(game.heard[-1] == "hum" and game.stage.speaker == "Мама", "Mother interrupts Katya at final cue: " + str(number))
check(game.busy.is_empty() and game.events.is_empty() and game.command_list.get_child_count() == 0, "Final sequence clears pending choices: " + str(number))
game.choose_action("speak_love")
game.say("here")
at(89.99)
check(game.heard[-1] == "hum" and game.heard.count("hum") == 1 and not game.can_respond(), "Nothing replaces the final line: " + str(number))
finish("flat")
check(not game.items.has("keys") and not game.facts.has("keys_exact"), "Interrupted request grants nothing: " + str(number))
start(2)
wait_for_speech()
var search: Dictionary = game.story.actions.filter(func(action): return action.id == "keys_search")[0]
at(warning_at - game.action_duration(search) + game.voice_length(search.response)*0.5)
click("keys_search")
check(game.reply_at < warning_at and game.busy_end > warning_at, "Mother reply would overlap the final cue")
at(game.reply_at + 0.01)
check(search.response not in game.heard, "Do not start a mother reply that cannot finish before the final phrase")
at(89.99)
check(game.heard[-1] == "hum" and not game.items.has("keys"), "Skipped reply cannot overtake final phrase or grant an item")
finish("flat")
start(3)
perform("inner")
finish("inner")
start(5)
perform("keys_search")
perform("front")
perform("stairs")
check(game.facts.has("stairs"), "Unlit intact stairs discovered")
check("целая" in game.story.facts.stairs and "завален" not in game.story.facts.stairs, "Stairwell is intact")
await capture("phone-dark-stairwell")
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(80)
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")
# 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")
await render()
if DisplayServer.get_name() != "headless":
check(game.stage.smartphone.display.get_global_rect().encloses(game.notification_card.get_global_rect()), "Push stays on Katya's smartphone")
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 not game.notification_card.visible, "Fifth message arrives while screen stays black")
check(game.notifications[4].text == "Кать в твой дом походу попали...", "Exact fifth text")
game.ending_ready = true
game.show_menu()
click("ending_messages")
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("resume")
click("next")
check(game.notifications.is_empty() and game.unread == 0 and not game.notification_card.visible, "Redial resets message history")
await production_ending_check()
await production_ending_check(true)
# Opening message history during the epilogue does not get closed by audio.
start(2)
game.qa_mode = false
at(90)
await game.get_tree().create_timer(2.2).timeout
game.show_menu()
await render()
click("ending_messages")
await render()
check(game.menu_screen == "messages" and game.viewing_messages,"Production inbox opens during the final voice")
for frame in range(32):
await game.get_tree().create_timer(0.25).timeout
if game.menu_screen != "messages":
print("PHONE_INBOX_CHANGED menu=",game.menu_screen," running=",game.running," chapter=",game.chapter," ready=",game.ending_ready," heard=",game.heard[-1])
break
check(game.viewing_messages and game.action_button("close_messages") != null, "Ending transition preserves open inbox: " + game.menu_screen)
click("close_messages")
click("resume")
check(game.action_button("next") != null, "Inbox returns to production ending")
game.qa_mode = true
start(2)
await render()
await escape()
check(game.menu_screen == "main","Menu opens before the production impact")
game.qa_mode = false
at(90.1)
await game.get_tree().create_timer(9.0).timeout
check(game.impacted and game.menu_screen == "main", "Impact and ending transition preserve the open menu")
check(game.action_button("resume").text == "Вернуться", "Menu updates its return action after disconnect")
click("resume")
check(game.menu_screen.is_empty() and game.action_button("next") != null, "Menu returns to the completed call outcome")
game.qa_mode = true
var continuity = load("res://scripts/phone_continuity_qa.gd").new()
await continuity.run(self)
await realtime_final_check()
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()
game.soundscape.stop()
for player in [game.voice, game.siren, game.effect, game.hum, game.notification_sound]:
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)