95 lines
3.2 KiB
GDScript
95 lines
3.2 KiB
GDScript
extends SceneTree
|
|
|
|
const MainScene = preload("res://main.tscn")
|
|
const SETTINGS_PATH := "user://aetherbound_guild_settings.json"
|
|
|
|
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
|
|
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_EXPAND
|
|
root.content_scale_size = Vector2i(844, 390)
|
|
root.size = Vector2i(844, 390)
|
|
_cleanup()
|
|
var game = MainScene.instantiate()
|
|
root.add_child(game)
|
|
await _frames(50)
|
|
var shell = game.entry_shell
|
|
expect(shell != null and shell.current_screen == "boot", "normal launch creates the entry shell")
|
|
var apply: Button = shell.find_child("SetupApply", true, false)
|
|
await _touch(apply)
|
|
expect(shell.current_screen == "title", "parsed ScreenTouch applies first launch and reaches Title")
|
|
var settings_button: Button = shell.find_child("TitleSettings", true, false)
|
|
await _touch(settings_button)
|
|
expect(shell.current_screen == "settings", "parsed ScreenTouch opens Settings")
|
|
var language_category: Button = shell.find_child("SettingsCategory_language", true, false)
|
|
await _touch(language_category)
|
|
var locale_button: Button = shell.find_child("SettingLocale", true, false)
|
|
await _touch(locale_button)
|
|
var apply_settings: Button = shell.find_child("SettingsApply", true, false)
|
|
await _touch(apply_settings)
|
|
var back: Button = shell.find_child("SettingsBack", true, false)
|
|
await _touch(back)
|
|
expect(shell.current_screen == "title" and shell.settings.locale == "en", "locale applies and Back returns to Title")
|
|
game.queue_free()
|
|
await _frames(20)
|
|
|
|
var restarted = MainScene.instantiate()
|
|
root.add_child(restarted)
|
|
await _frames(50)
|
|
expect(restarted.entry_shell.current_screen == "title", "restart skips completed first launch")
|
|
restarted.queue_free()
|
|
await _frames(20)
|
|
_cleanup()
|
|
var reset_game = MainScene.instantiate()
|
|
root.add_child(reset_game)
|
|
await _frames(50)
|
|
expect(reset_game.entry_shell.get_node_or_null("FirstLaunchResponsiveLayout") != null, "settings reset restores first-launch setup")
|
|
reset_game.queue_free()
|
|
await _frames(20)
|
|
_cleanup()
|
|
if failures.is_empty():
|
|
print("ABG_DEV1_ENTRY_TOUCH_OK parsed_screen_touch=true boot_setup_title_settings_apply_back=true restart=title reset=first_launch")
|
|
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 _frames(count: int) -> void:
|
|
for frame in range(count):
|
|
await process_frame
|
|
|
|
|
|
func _cleanup() -> void:
|
|
for path in [SETTINGS_PATH, "%s.bak" % SETTINGS_PATH, "%s.candidate" % SETTINGS_PATH]:
|
|
if FileAccess.file_exists(path):
|
|
DirAccess.remove_absolute(path)
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("DEV-1 entry touch: %s" % message)
|