feat(title): TitleScreen composition, menu + selection, boot scene
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
52
client/tests/unit/test_title_screen.gd
Normal file
52
client/tests/unit/test_title_screen.gd
Normal file
@@ -0,0 +1,52 @@
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
const SCENE := "res://scenes/title/TitleScreen.tscn"
|
||||
|
||||
|
||||
func _title() -> TitleScreen:
|
||||
var t = load(SCENE).instantiate()
|
||||
add_child_autofree(t) # runs _ready()
|
||||
return t
|
||||
|
||||
|
||||
func _index_of(t: TitleScreen, action: StringName) -> int:
|
||||
for i in range(t._rows.size()):
|
||||
if t._rows[i].get_meta("action") == action:
|
||||
return i
|
||||
return -1
|
||||
|
||||
|
||||
func test_six_menu_rows_each_with_an_action():
|
||||
var t := _title()
|
||||
assert_eq(t._rows.size(), 6)
|
||||
for row in t._rows:
|
||||
assert_true(row.has_meta("action"))
|
||||
|
||||
|
||||
func test_down_moves_selection():
|
||||
var t := _title()
|
||||
assert_eq(t._sel, 0)
|
||||
t._move(1)
|
||||
assert_eq(t._sel, 1)
|
||||
|
||||
|
||||
func test_up_from_first_wraps_to_last():
|
||||
var t := _title()
|
||||
t._move(-1)
|
||||
assert_eq(t._sel, t._rows.size() - 1)
|
||||
|
||||
|
||||
func test_new_game_and_quit_emit_their_action():
|
||||
var t := _title()
|
||||
# Isolate the signal seam so the test does not actually change scene / quit.
|
||||
t.menu_activated.disconnect(t._on_menu_activated)
|
||||
watch_signals(t)
|
||||
t._activate(_index_of(t, &"new_game"))
|
||||
assert_signal_emitted_with_parameters(t, "menu_activated", [&"new_game"])
|
||||
t._activate(_index_of(t, &"quit"))
|
||||
assert_signal_emitted_with_parameters(t, "menu_activated", [&"quit"])
|
||||
|
||||
|
||||
func test_footer_shows_version():
|
||||
var t := _title()
|
||||
assert_string_contains(t._footer_left.text, Version.new().string())
|
||||
Reference in New Issue
Block a user