Files
uconsole_asw_game/tests/test_theme.py
T

40 lines
1.7 KiB
Python

"""Theme consolidation: high-contrast palette swap and reset."""
from types import SimpleNamespace
from src.core import config, preferences
from src.ui import editor_widgets, layout, sonar_view, theme
def test_standard_theme_is_the_start_screens_look():
theme.configure_for(None)
# Turquoise phosphor text and the splash frame colour for rings.
assert config.COLOR_TEXT == (150, 240, 205)
assert config.COLOR_SONAR_RING == (40, 96, 90)
assert sonar_view.NAVY == (6, 13, 25)
assert editor_widgets.PALETTE.text == (200, 232, 214)
def test_high_contrast_theme_swaps_and_reverts_module_colors():
game = SimpleNamespace(preferences=preferences.Preferences(high_contrast=True))
try:
assert theme.configure_for(game) is True
assert config.COLOR_TEXT == theme.CONFIG_COLORS_HIGH_CONTRAST["COLOR_TEXT"]
assert sonar_view.NAVY == theme.SONAR_COLORS_HIGH_CONTRAST["NAVY"]
assert editor_widgets.PALETTE.focus == theme.EDITOR_PALETTE_HIGH_CONTRAST["focus"]
finally:
theme.configure_for(None)
assert config.COLOR_TEXT == theme.CONFIG_COLORS_STANDARD["COLOR_TEXT"]
assert sonar_view.NAVY == theme.SONAR_COLORS_STANDARD["NAVY"]
assert editor_widgets.PALETTE.focus == theme.EDITOR_PALETTE_STANDARD["focus"]
def test_layout_configure_for_applies_theme_from_game_preferences():
game = SimpleNamespace(preferences=preferences.Preferences(high_contrast=True))
try:
layout.configure_for(game)
assert config.COLOR_TEXT == theme.CONFIG_COLORS_HIGH_CONTRAST["COLOR_TEXT"]
finally:
layout.configure_for(None, large_text=False)
assert config.COLOR_TEXT == theme.CONFIG_COLORS_STANDARD["COLOR_TEXT"]