52 lines
1.5 KiB
GDScript
52 lines
1.5 KiB
GDScript
extends SceneTree
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
root.size = Vector2i(1152, 648)
|
|
var main_scene: PackedScene = load("res://scenes/main/main.tscn")
|
|
if main_scene == null:
|
|
failures.append("main.tscn should load")
|
|
_finish()
|
|
return
|
|
var main := main_scene.instantiate()
|
|
root.add_child(main)
|
|
await process_frame
|
|
|
|
_expect_bool(main.get_node_or_null("UILayer") is CanvasLayer, true, "Main UI should stay in the x1 CanvasLayer")
|
|
var ui := main.get_node_or_null("UILayer/UI") as Control
|
|
_expect_bool(ui != null, true, "Main UI should be under UILayer/UI")
|
|
if ui != null:
|
|
_expect_vector(ui.position, Vector2.ZERO, "Main UI should start at the viewport origin inside the CanvasLayer")
|
|
_expect_vector(ui.size, Vector2(1152.0, 648.0), "Main UI should fill the viewport")
|
|
_expect_vector(ui.scale, Vector2.ONE, "Main UI should not counter-scale against the world camera")
|
|
|
|
main.queue_free()
|
|
await process_frame
|
|
_finish()
|
|
|
|
|
|
func _expect_vector(actual: Vector2, expected: Vector2, label: String) -> void:
|
|
if actual.distance_to(expected) > 0.03:
|
|
failures.append("%s: expected %s, got %s" % [label, expected, actual])
|
|
|
|
|
|
func _expect_bool(actual: bool, expected: bool, label: String) -> void:
|
|
if actual != expected:
|
|
failures.append("%s: expected %s, got %s" % [label, expected, actual])
|
|
|
|
|
|
func _finish() -> void:
|
|
if failures.is_empty():
|
|
print("PASS main ui camera canvas")
|
|
quit(0)
|
|
else:
|
|
for failure: String in failures:
|
|
push_error(failure)
|
|
quit(1)
|