Files
security-game/src/test/tests/test_ui_art.gd
T
zwitschi 4745adeb13 Move screen designs to the runtime root and add the UI art loader
- screen_designs.py now reads/writes assets/images/ui/ (ADR-0014); docs/
  screens/designs/ stays the reference-only snapshot, documented as historical
- add src/game/ui/art.gd: cached loader for assets/images/ui|scenes with null
  fallbacks for missing files, plus headless tests
- start menu uses the start_menu scene art as a full-screen backdrop, covers the
  baked-in mockup panel with an opaque panel, and styles the venue rows to match
- update README/architecture/TODO path notes and mark the storage/code-path/loader
  items done; DONE records the historical path move
- compare still 11 good / 0 bad; headless 226/226

README/PLAN realism-pass edits from another workstream remain unstaged." && git log --oneline -1
2026-11-01 16:00:12 +01:00

39 lines
1.5 KiB
GDScript

extends RefCounted
## Headless tests for the runtime image loader (ADR-0014).
const UiArt := preload("res://src/game/ui/art.gd")
func test_loads_runtime_ui_art() -> bool:
var art := UiArt.new()
var start := art.texture("start_menu")
var venue := art.texture("venue_overview")
var a := TestUtils.check(start != null, "start_menu art loads from assets/images/ui")
var b := TestUtils.check(venue != null, "venue_overview art loads from assets/images/ui")
var c := TestUtils.check(art.has("start_menu"), "has() sees the runtime art")
return a and b and c
func test_missing_art_returns_null() -> bool:
var art := UiArt.new()
var missing := art.texture("does_not_exist")
var empty := art.texture("")
var a := TestUtils.check(missing == null, "missing art returns null for a fallback")
var b := TestUtils.check(empty == null, "empty name returns null")
return a and b
func test_explicit_relative_path() -> bool:
var art := UiArt.new()
var texture := art.texture_at("ui/start_menu.png")
var missing := art.texture_at("ui/nope.png")
var a := TestUtils.check(texture != null, "texture_at loads an explicit path")
var b := TestUtils.check(missing == null, "texture_at returns null when absent")
return a and b
func test_cache_returns_the_same_resource() -> bool:
var art := UiArt.new()
var first := art.texture("start_menu")
var second := art.texture("start_menu")
var a := TestUtils.check(first != null and first == second, "textures are cached")
art.clear_cache()
var b := TestUtils.check(art.texture("start_menu") != null, "cache can be cleared")
return a and b