SelectCard (a Button whose `pressed` IS the chosen ring), SkillChip (a toggle with unpicked/picked/granted-so-inert), the CHOSEN and PRIMARY tags, and the gold PrimaryCard ring. Plus INK_LABEL_MUTED for the sheet's section headers. Built by build_game_theme.gd and regenerated; the .tres is never hand-edited.
77 lines
2.9 KiB
GDScript
77 lines
2.9 KiB
GDScript
# client/tests/unit/test_theme_resource.gd
|
|
extends "res://addons/gut/test.gd"
|
|
|
|
const Builder = preload("res://scripts/theme/build_game_theme.gd")
|
|
const THEME_PATH := "res://assets/theme/game_theme.tres"
|
|
|
|
|
|
func test_theme_loads():
|
|
assert_true(FileAccess.file_exists(THEME_PATH), "theme not built — run build_game_theme.gd")
|
|
var t = load(THEME_PATH)
|
|
assert_true(t is Theme)
|
|
|
|
|
|
func test_every_variation_resolves():
|
|
var t: Theme = load(THEME_PATH)
|
|
for key in ThemeKeys.ALL:
|
|
var base: String = ThemeKeys.ALL[key]
|
|
assert_eq(t.get_type_variation_base(key), StringName(base),
|
|
"variation %s missing or wrong base" % key)
|
|
|
|
|
|
func test_cta_has_normal_stylebox():
|
|
var t: Theme = load(THEME_PATH)
|
|
assert_true(t.has_stylebox(&"normal", ThemeKeys.PRIMARY_CTA))
|
|
|
|
|
|
func test_default_font_is_set():
|
|
var t: Theme = load(THEME_PATH)
|
|
assert_true(t.default_font is FontFile)
|
|
|
|
|
|
func test_committed_tres_matches_builder():
|
|
# Catches "palette/builder changed but nobody regenerated game_theme.tres."
|
|
# Preloading the builder script and calling its static build_theme() does
|
|
# NOT run _init() (that only fires on .new()), so this is side-effect-free.
|
|
var fresh: Theme = Builder.build_theme()
|
|
var committed: Theme = load(THEME_PATH)
|
|
|
|
var checks := [
|
|
[ThemeKeys.PRIMARY_CTA, &"normal"],
|
|
[ThemeKeys.PARCHMENT_CARD, &"panel"],
|
|
[ThemeKeys.DARK_PANEL, &"panel"],
|
|
]
|
|
for pair in checks:
|
|
var variation: StringName = pair[0]
|
|
var state: StringName = pair[1]
|
|
var fresh_box: StyleBoxFlat = fresh.get_stylebox(state, variation)
|
|
var committed_box: StyleBoxFlat = committed.get_stylebox(state, variation)
|
|
assert_eq(fresh_box.bg_color, committed_box.bg_color,
|
|
"stale game_theme.tres — %s/%s bg_color drifted from the builder; re-run build_game_theme.gd" % [variation, state])
|
|
|
|
|
|
func test_creation_variations_exist_with_the_states_the_screen_needs():
|
|
var t: Theme = load(THEME_PATH)
|
|
|
|
# A race/calling card is a Button that must show a CHOSEN state.
|
|
assert_true(t.has_stylebox(&"normal", ThemeKeys.SELECT_CARD))
|
|
assert_true(t.has_stylebox(&"hover", ThemeKeys.SELECT_CARD))
|
|
assert_true(t.has_stylebox(&"pressed", ThemeKeys.SELECT_CARD), "pressed IS the chosen ring")
|
|
assert_true(t.has_stylebox(&"disabled", ThemeKeys.SELECT_CARD), "an origin may disallow a calling")
|
|
|
|
# A skill chip is a toggle with three states: unpicked, picked, and granted-so-inert.
|
|
assert_true(t.has_stylebox(&"normal", ThemeKeys.SKILL_CHIP))
|
|
assert_true(t.has_stylebox(&"pressed", ThemeKeys.SKILL_CHIP))
|
|
assert_true(t.has_stylebox(&"disabled", ThemeKeys.SKILL_CHIP))
|
|
|
|
# The tags and the primary ring.
|
|
assert_true(t.has_stylebox(&"normal", ThemeKeys.CHOSEN_TAG))
|
|
assert_true(t.has_stylebox(&"normal", ThemeKeys.PRIMARY_TAG))
|
|
assert_true(t.has_stylebox(&"panel", ThemeKeys.PRIMARY_CARD))
|
|
|
|
|
|
func test_section_label_is_a_font_role_on_parchment():
|
|
var t: Theme = load(THEME_PATH)
|
|
assert_true(t.has_font(&"font", ThemeKeys.SECTION_LABEL))
|
|
assert_eq(t.get_color(&"font_color", ThemeKeys.SECTION_LABEL), Palette.INK_LABEL_MUTED)
|