47 lines
1.2 KiB
GDScript
47 lines
1.2 KiB
GDScript
extends SceneTree
|
|
|
|
var failures: Array[String] = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
var scene: PackedScene = load("res://scenes/ui/rhythm_track.tscn")
|
|
if scene == null:
|
|
push_error("Could not load rhythm_track.tscn")
|
|
quit(1)
|
|
return
|
|
|
|
var track := scene.instantiate() as Control
|
|
root.add_child(track)
|
|
await process_frame
|
|
|
|
_expect_float(track.anchor_left, 0.5, "RhythmTrack should stay centered")
|
|
_expect_float(track.anchor_right, 0.5, "RhythmTrack should stay centered")
|
|
_expect_bool(track.has_node("JudgementLabel"), true, "RhythmTrack should own its judgement label")
|
|
|
|
track.free()
|
|
_finish()
|
|
|
|
|
|
func _expect_float(actual: float, expected: float, label: String) -> void:
|
|
if not is_equal_approx(actual, expected):
|
|
failures.append("%s: expected %.3f, got %.3f" % [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 rhythm ui layout")
|
|
quit(0)
|
|
else:
|
|
for failure: String in failures:
|
|
push_error(failure)
|
|
quit(1)
|