Files
aetherbound-guild/runtime/tests/p9_0r2_dynamic_slice_test.gd
T

67 lines
2.2 KiB
GDScript

extends SceneTree
const MainScene = preload("res://main.tscn")
var game: Control
var failures: Array[String] = []
func _initialize() -> void:
call_deferred("run_test")
func run_test() -> void:
game = MainScene.instantiate()
game.auto_boot = false
root.add_child(game)
await settle(12)
game.locale = "zh_CN"
game.text_scale = 1.0
game.reduced_motion = false
game.muted = true
game.boot_verified = true
game.front_choice = OS.get_environment("ABG_P9_0R2_FRONT")
game.rear_choice = OS.get_environment("ABG_P9_0R2_REAR")
if game.front_choice.is_empty():
game.front_choice = "Hearthguard"
if game.rear_choice.is_empty():
game.rear_choice = "Farstring"
game.depart()
var seen_front_frames: Dictionary = {}
var seen_rear_frames: Dictionary = {}
var seen_enemy_frames: Dictionary = {}
var elapsed := 0.0
while game.page != game.AppPage.VICTORY and elapsed < 22.0:
await process_frame
elapsed += 1.0 / 30.0
if game.front_sprite != null:
seen_front_frames[game.front_sprite.texture.resource_path] = true
seen_rear_frames[game.rear_sprite.texture.resource_path] = true
seen_enemy_frames[game.enemy_sprite.texture.resource_path] = true
if game.page != game.AppPage.VICTORY:
failures.append("dynamic slice did not reach victory")
if game.guard_events != 1 or game.rear_events != 1 or game.victory_events != 1:
failures.append("dynamic slice role events were not committed exactly once")
if seen_front_frames.size() < 4 or seen_rear_frames.size() < 4 or seen_enemy_frames.size() < 8:
failures.append("dynamic slice did not render enough distinct body-pose frames")
await create_timer(1.6).timeout
game.queue_free()
game = null
await settle(120)
if failures.is_empty():
print("ABG_P9_0R2_DYNAMIC_SLICE_OK duration=%.2f front=%s front_frames=%d rear=%s rear_frames=%d enemy_frames=%d impact_once=true renderer=normal" % [elapsed, OS.get_environment("ABG_P9_0R2_FRONT"), seen_front_frames.size(), OS.get_environment("ABG_P9_0R2_REAR"), seen_rear_frames.size(), seen_enemy_frames.size()])
call_deferred("finish", 0)
else:
for failure in failures:
push_error(failure)
call_deferred("finish", 1)
func finish(exit_code: int) -> void:
quit(exit_code)
func settle(frames: int) -> void:
for frame in range(frames):
await process_frame