92 lines
4.2 KiB
GDScript
92 lines
4.2 KiB
GDScript
extends SceneTree
|
|
|
|
const EntryShell = preload("res://entry/entry_shell.gd")
|
|
const SettingsStore = preload("res://entry/settings_store.gd")
|
|
|
|
const SIZES := [Vector2i(1280, 720)]
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run_test")
|
|
|
|
|
|
func run_test() -> void:
|
|
var viewport := SubViewport.new()
|
|
viewport.size = SIZES[0]
|
|
viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
|
|
root.add_child(viewport)
|
|
var shell := EntryShell.new()
|
|
shell.auto_start = false
|
|
viewport.add_child(shell)
|
|
await _frames(3)
|
|
shell.settings = SettingsStore.new().defaults()
|
|
shell.settings.locale = "zh_CN"
|
|
shell.settings.text_scale = 1.3
|
|
shell.boot_snapshot = shell.boot_service.begin()
|
|
shell._render_boot_state()
|
|
await _frames(3)
|
|
for viewport_size in SIZES:
|
|
viewport.size = viewport_size
|
|
await _frames(3)
|
|
_verify_layout(shell, viewport_size, false)
|
|
await _verify_error_state(shell, viewport.size)
|
|
viewport.queue_free()
|
|
await _frames(4)
|
|
if failures.is_empty():
|
|
print("ABG_DEV1_BOOT_RESPONSIVE_OK sizes=1280x720 background=aspect_cover rail=nine_patch actions=state_bound resize=true")
|
|
quit(0)
|
|
else:
|
|
for failure in failures:
|
|
push_error(failure)
|
|
quit(1)
|
|
|
|
|
|
func _verify_layout(shell: Control, viewport_size: Vector2i, error_state: bool) -> void:
|
|
var bounds := Rect2(Vector2.ZERO, Vector2(viewport_size))
|
|
var world := shell.find_child("BootWorld", true, false) as TextureRect
|
|
# M63: the rail and plaque are shared-chrome layout containers now, so the
|
|
# focused layout contract checks their bounds, not their old texture types.
|
|
var rail := shell.find_child("BootVerificationRail", true, false) as Control
|
|
var plaque := shell.find_child("BootIdentityPlaque", true, false) as Control
|
|
expect(world != null and rail != null and plaque != null, "%dx%d boot layers exist" % [viewport_size.x, viewport_size.y])
|
|
if world == null or rail == null or plaque == null:
|
|
return
|
|
expect(world.get_global_rect().is_equal_approx(bounds), "%dx%d world fills viewport" % [viewport_size.x, viewport_size.y])
|
|
expect(bounds.encloses(rail.get_global_rect()), "%dx%d rail stays inside viewport" % [viewport_size.x, viewport_size.y])
|
|
expect(bounds.encloses(plaque.get_global_rect()), "%dx%d identity plaque stays inside viewport" % [viewport_size.x, viewport_size.y])
|
|
expect(rail.size.y >= 96.0, "%dx%d rail keeps stable minimum height" % [viewport_size.x, viewport_size.y])
|
|
for index in range(3):
|
|
var seal := shell.find_child("BootStatusSeal%d" % index, true, false) as Control
|
|
if seal == null:
|
|
continue
|
|
if not error_state:
|
|
expect(is_equal_approx(seal.size.x, seal.size.y), "%dx%d seal %d remains square" % [viewport_size.x, viewport_size.y, index])
|
|
var retry := shell.find_child("BootRetry", true, false) as Control
|
|
expect(retry != null and retry.get_global_rect().size.y >= 48.0, "%dx%d Retry keeps touch height" % [viewport_size.x, viewport_size.y])
|
|
|
|
|
|
func _verify_error_state(shell: Control, viewport_size: Vector2i) -> void:
|
|
var retry := shell.find_child("BootRetry", true, false) as Control
|
|
var diagnostics := shell.find_child("BootDiagnosticsAction", true, false) as Control
|
|
var exit_button := shell.find_child("BootExit", true, false) as Control
|
|
expect(retry != null and not retry.visible, "%dx%d normal state hides Retry" % [viewport_size.x, viewport_size.y])
|
|
expect(diagnostics != null and not diagnostics.visible, "%dx%d normal state hides Diagnostics" % [viewport_size.x, viewport_size.y])
|
|
expect(exit_button != null and not exit_button.visible, "%dx%d normal state hides Exit" % [viewport_size.x, viewport_size.y])
|
|
shell.boot_snapshot = {"state": "error", "completed": 2, "total": 4, "step": "preferences", "code": "SETTINGS_FILE_INVALID"}
|
|
shell._render_boot_state()
|
|
await _frames(2)
|
|
expect(retry.visible and diagnostics.visible and exit_button.visible, "%dx%d error state reveals legal actions" % [viewport_size.x, viewport_size.y])
|
|
expect(retry.get_global_rect().size.y >= 48.0 and diagnostics.get_global_rect().size.y >= 48.0 and exit_button.get_global_rect().size.y >= 48.0, "%dx%d error actions keep touch height" % [viewport_size.x, viewport_size.y])
|
|
|
|
|
|
func _frames(count: int) -> void:
|
|
for frame in range(count):
|
|
await process_frame
|
|
|
|
|
|
func expect(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
failures.append("DEV-1 Boot responsive: %s" % message)
|