86 lines
4.9 KiB
GDScript
86 lines
4.9 KiB
GDScript
extends SceneTree
|
|
|
|
const Style := preload("res://scripts/ui/ui_style.gd")
|
|
const Brand := preload("res://scripts/ui/medmind_style.gd")
|
|
|
|
var failures := 0
|
|
|
|
|
|
func _initialize() -> void:
|
|
_assert(ProjectSettings.get_setting("application/config/name") == "RanaZe: Step 3 Trainer", "the public application name should use the RanaZe brand")
|
|
_assert(bool(ProjectSettings.get_setting("application/config/use_custom_user_dir")), "the rebrand should preserve a stable custom user-data directory")
|
|
_assert(ProjectSettings.get_setting("application/config/custom_user_dir_name") == "MedMind", "existing standalone user data should remain discoverable after the rebrand")
|
|
Style.set_dark_mode(true)
|
|
var root := Control.new()
|
|
var background := ColorRect.new()
|
|
background.color = Style.BACKGROUND
|
|
root.add_child(background)
|
|
var panel := PanelContainer.new()
|
|
panel.add_theme_stylebox_override("panel", Style.panel_box(Color("172337"), Color("405475")))
|
|
root.add_child(panel)
|
|
|
|
Style.set_dark_mode(false)
|
|
Style.refresh_tree(root, true)
|
|
_assert(background.color.is_equal_approx(Style.BACKGROUND), "background should switch to light mode")
|
|
_assert(root.theme.get_color("default_color", "RichTextLabel").is_equal_approx(Style.TEXT), "rich text should use the light text color")
|
|
var light_box := panel.get_theme_stylebox("panel") as StyleBoxFlat
|
|
_assert(light_box.bg_color.is_equal_approx(Color("fffffe")), "custom panel surface should switch to light mode")
|
|
_assert(Brand.background_color(false).is_equal_approx(Color("f1f5f9")), "RanaZe light background should match the style guide")
|
|
var light_card := Brand.content_card_box(false, true, Brand.ROYAL_BLUE)
|
|
_assert(light_card.bg_color.is_equal_approx(Color.WHITE), "RanaZe light cards should use white surfaces")
|
|
_assert(light_card.border_color.is_equal_approx(Brand.ROYAL_BLUE), "active light cards should use the primary blue border")
|
|
var light_field := Brand.field_box(false)
|
|
_assert(light_field.border_color.is_equal_approx(Brand.LIGHT_BORDER), "light fields should use the semantic cool-gray border")
|
|
var explicitly_light_panel := PanelContainer.new()
|
|
explicitly_light_panel.add_theme_stylebox_override("panel", Brand.content_card_box(false, false))
|
|
root.add_child(explicitly_light_panel)
|
|
Style.refresh_tree(root, true)
|
|
var preserved_light_box := explicitly_light_panel.get_theme_stylebox("panel") as StyleBoxFlat
|
|
_assert(preserved_light_box.bg_color.is_equal_approx(Color.WHITE), "a screen's explicit light styles should not be translated back to dark")
|
|
var theme_toggle := Button.new()
|
|
Brand.set_theme_toggle_icon(theme_toggle, true)
|
|
_assert(theme_toggle.text.is_empty() and theme_toggle.icon == Brand.SUN_ICON, "dark mode should use the bundled sun icon")
|
|
Brand.set_theme_toggle_icon(theme_toggle, false)
|
|
_assert(theme_toggle.text.is_empty() and theme_toggle.icon == Brand.MOON_ICON, "light mode should use the bundled moon icon")
|
|
var login = load("res://scripts/ui/login_screen.gd").new()
|
|
var password := LineEdit.new()
|
|
var password_reveal := Button.new()
|
|
password.secret = true
|
|
login._refresh_password_reveal(password, password_reveal)
|
|
var show_icon := password_reveal.icon
|
|
password.secret = false
|
|
login._refresh_password_reveal(password, password_reveal)
|
|
_assert(show_icon != null and password_reveal.icon != null and show_icon != password_reveal.icon, "password visibility should switch bundled eye icons")
|
|
password_reveal.free()
|
|
password.free()
|
|
|
|
var field_parent := VBoxContainer.new()
|
|
login.add_child(field_parent)
|
|
var auth_field: LineEdit = login._add_field(field_parent, "Email", "[email protected]")
|
|
_assert(auth_field.caret_blink, "authentication fields should display a blinking caret")
|
|
_assert(is_equal_approx(auth_field.caret_blink_interval, 0.5), "authentication field caret should blink at a visible interval")
|
|
login._style_auth_field(auth_field, false)
|
|
var editable_box := auth_field.get_theme_stylebox("normal") as StyleBoxFlat
|
|
var read_only_box := auth_field.get_theme_stylebox("read_only") as StyleBoxFlat
|
|
_assert(read_only_box.bg_color.is_equal_approx(editable_box.bg_color), "authentication fields should retain their surface while a request is pending")
|
|
_assert(is_equal_approx(read_only_box.content_margin_left, editable_box.content_margin_left), "authentication fields should retain their text inset while a request is pending")
|
|
login.free()
|
|
theme_toggle.free()
|
|
|
|
Style.set_dark_mode(true)
|
|
Style.refresh_tree(root, false)
|
|
_assert(background.color.is_equal_approx(Style.BACKGROUND), "background should switch back to dark mode")
|
|
_assert(root.theme.get_color("default_color", "RichTextLabel").is_equal_approx(Style.TEXT), "rich text should use the dark text color")
|
|
var dark_box := panel.get_theme_stylebox("panel") as StyleBoxFlat
|
|
_assert(dark_box.bg_color.is_equal_approx(Color("172337")), "custom panel surface should switch back to dark mode")
|
|
|
|
root.free()
|
|
quit(1 if failures > 0 else 0)
|
|
|
|
|
|
func _assert(condition: bool, message: String) -> void:
|
|
if condition:
|
|
return
|
|
failures += 1
|
|
push_error(message)
|