diff --git a/client/tests/unit/test_theme_resource.gd b/client/tests/unit/test_theme_resource.gd index 9c0e53f..7b8eedf 100644 --- a/client/tests/unit/test_theme_resource.gd +++ b/client/tests/unit/test_theme_resource.gd @@ -33,21 +33,52 @@ 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. + # + # Drives its checks off ThemeKeys.ALL so every variation is guarded, not just + # whichever three someone remembered to hardcode here. For each variation: + # every stylebox state the builder actually set (get_stylebox_list) is + # compared property-by-property when it's a StyleBoxFlat, and every font + # colour role the builder actually set (get_color_list) is compared too. + # Nothing the builder never touches is asserted on. 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]) + for variation in ThemeKeys.ALL: + for state in fresh.get_stylebox_list(variation): + var fresh_box: StyleBox = fresh.get_stylebox(state, variation) + var committed_box: StyleBox = committed.get_stylebox(state, variation) + assert_eq(committed_box.get_class(), fresh_box.get_class(), + "stale game_theme.tres — %s/%s stylebox type drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + + if fresh_box is StyleBoxFlat: + var f: StyleBoxFlat = fresh_box + var c: StyleBoxFlat = committed_box + assert_eq(c.bg_color, f.bg_color, + "stale game_theme.tres — %s/%s bg_color drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.border_color, f.border_color, + "stale game_theme.tres — %s/%s border_color drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.border_width_left, f.border_width_left, + "stale game_theme.tres — %s/%s border_width_left drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.border_width_top, f.border_width_top, + "stale game_theme.tres — %s/%s border_width_top drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.border_width_right, f.border_width_right, + "stale game_theme.tres — %s/%s border_width_right drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.border_width_bottom, f.border_width_bottom, + "stale game_theme.tres — %s/%s border_width_bottom drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.corner_radius_top_left, f.corner_radius_top_left, + "stale game_theme.tres — %s/%s corner_radius_top_left drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.corner_radius_top_right, f.corner_radius_top_right, + "stale game_theme.tres — %s/%s corner_radius_top_right drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.corner_radius_bottom_right, f.corner_radius_bottom_right, + "stale game_theme.tres — %s/%s corner_radius_bottom_right drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + assert_eq(c.corner_radius_bottom_left, f.corner_radius_bottom_left, + "stale game_theme.tres — %s/%s corner_radius_bottom_left drifted from the builder; re-run build_game_theme.gd" % [variation, state]) + + for color_name in fresh.get_color_list(variation): + var fresh_color: Color = fresh.get_color(color_name, variation) + var committed_color: Color = committed.get_color(color_name, variation) + assert_eq(committed_color, fresh_color, + "stale game_theme.tres — %s/%s drifted from the builder; re-run build_game_theme.gd" % [variation, color_name]) func test_creation_variations_exist_with_the_states_the_screen_needs():