Files
DungeonCrawlerWorld/tests/unit/test_inventory_panel_layout.gd

26 lines
1.4 KiB
GDScript

extends GutTest
const GameScene = preload("res://scenes/Game.tscn")
func test_inventory_title_columns_and_footer_have_distinct_contained_layout_zones() -> void:
var game := GameScene.instantiate() as Game
add_child_autofree(game)
await get_tree().process_frame
var panel := game.get_node("HUD/InventoryPanel") as InventoryPanel
panel.present(game.get_run_state().inventory, game.get_run_state().equipment, game.get_run_state().identification)
await get_tree().process_frame
var title := panel.get_node("Layout/Title") as Control
var entries := panel.get_node("Layout/Columns/Entries") as Control
var details := panel.get_node("Layout/Columns/Details") as Control
var footer := panel.get_node("Layout/Footer") as Control
var panel_rect := panel.get_global_rect()
for control in [title, entries, details, footer]:
assert_true(panel_rect.encloses(control.get_global_rect()), "%s stays inside inventory panel" % control.name)
assert_false(title.get_global_rect().intersects(entries.get_global_rect()))
assert_false(title.get_global_rect().intersects(details.get_global_rect()))
assert_false(entries.get_global_rect().intersects(details.get_global_rect()))
assert_false(entries.get_global_rect().intersects(footer.get_global_rect()))
assert_false(details.get_global_rect().intersects(footer.get_global_rect()))
assert_string_contains((footer as Label).text, "I Fermer")