Files
MusicPlayer/tests/integration/test_theme_picker.gd
SansanandClaude Opus 5.5 b9fa3c3d63 Add a Christmas theme
Christmas red window and panels with snow white buttons and red text, a thick
white "fur" trim on popups, cards, the lists and the player bar, the tree's
green for the chosen tab and the play button, and gold for the playing song and
highlights. Icons on buttons take the text's colour, and drop-down lists stay
dark red so their arrow shows. It uses Nord's round shapes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 21:18:19 +02:00

75 lines
2.5 KiB
GDScript

extends MainWindowTestSuite
## Picking a theme in Settings switches the whole game's look at once and is saved.
var _settings: SettingsPopup
func before_test() -> void:
await super()
_settings = _window.get_node("SettingsPopup")
func after_test() -> void:
Settings.apply_theme(Settings.THEMES[0].id)
await super()
func _pick(theme_name: String) -> void:
var index: int = Settings.THEMES.map(
func(entry: Dictionary) -> String: return entry.name).find(theme_name)
_settings.theme_button.select(index)
_settings.theme_button.item_selected.emit(index)
await _runner.simulate_frames(1)
func test_picker_lists_every_theme_and_shows_the_one_in_use() -> void:
var names: Array[String] = []
for index: int in _settings.theme_button.item_count:
names.append(_settings.theme_button.get_item_text(index))
assert_array(names).contains_exactly(["Classic", "Original web", "Nord", "Christmas"])
assert_str(_settings.theme_button.get_item_text(_settings.theme_button.selected)) \
.is_equal("Classic")
func test_picking_a_theme_switches_the_look_at_once() -> void:
var button: Button = _window.get_node("TopBar/%SyncButton")
var classic_text: Color = button.get_theme_color(&"font_color")
var panel: Panel = _window.get_node("SettingsPopup/SettingsPanel")
var popup_style: StyleBox = panel.get_theme_stylebox(&"panel")
await _pick("Original web")
assert_str(Settings.theme_id).is_equal("original_web")
assert_str(_window.get_tree().root.theme.resource_path) \
.is_equal("res://themes/original_web_theme.tres")
assert_object(panel.get_theme_stylebox(&"panel")).is_not_same(popup_style)
# The web version's buttons have orange text
assert_bool(button.get_theme_color(&"font_color") != classic_text).is_true()
func test_chosen_theme_is_saved() -> void:
await _pick("Original web")
var saved: ConfigFile = ConfigFile.new()
assert_int(saved.load(Settings.saved_settings_path())).is_equal(OK)
assert_str(saved.get_value("app", "theme_id")).is_equal("original_web")
func test_backdrop_and_graph_follow_the_theme() -> void:
var backdrop: PopupBackdrop = _window.get_node("PopupBackdrop")
var classic: Color = backdrop.color
await _pick("Original web")
assert_object(backdrop.color).is_equal(backdrop.get_theme_color(&"backdrop", &"Palette"))
assert_bool(backdrop.color != classic).is_true()
func test_unknown_theme_falls_back_to_the_default() -> void:
Settings.apply_theme("no_such_theme")
assert_str(Settings.theme_id).is_equal("classic")
assert_str(_window.get_tree().root.theme.resource_path) \
.is_equal("res://themes/main_theme.tres")