godot-ui/tests/test_responsive.gd

50 lines
1.2 KiB
GDScript

extends "res://test_base.gd"
## Tests for core/responsive.gd
const ResponsiveScript = preload("res://addons/godot-ui/core/responsive.gd")
func run_all() -> void:
_begin_suite("Responsive")
_test_setup_defaults()
_test_setup_custom()
_test_empty_children()
_end_suite()
func _test_setup_defaults() -> void:
_test("setup with defaults sets breakpoint and gap")
var container: Container = ResponsiveScript.new()
add_child(container)
container.setup()
_assert_eq(container._breakpoint, 480.0, "default breakpoint")
_assert_eq(container._gap, 8, "default gap")
container.queue_free()
func _test_setup_custom() -> void:
_test("setup with custom values")
var container: Container = ResponsiveScript.new()
add_child(container)
container.setup(600.0, 12)
_assert_eq(container._breakpoint, 600.0, "custom breakpoint")
_assert_eq(container._gap, 12, "custom gap")
container.queue_free()
func _test_empty_children() -> void:
_test("relayout with no children does not crash")
var container: Container = ResponsiveScript.new()
add_child(container)
container.setup()
container._relayout()
_assert_true(true, "no crash on empty relayout")
container.queue_free()