- Types on every parameter, return value and variable, and snake_case names (the player name limit is the constant MAX_NAME_LENGTH). - Spelling fixes: *_triggered, character_selected, separator, caught_errors. The server's catched_errors key stays as the server sends it. - Signals are connected with signal.connect() instead of by name. - Code is ordered signals, constants, exported vars, vars, @onready vars, functions, with @onready on one line and two blank lines between functions. - Every script starts with a ## description. Template comments, old LOC notes and commented-out code are gone, apart from the local play code. - Lines are at most 100 characters, apart from the local play path. - The screenshot tour turns off the blinking text cursor so pictures match.
28 lines
999 B
GDScript
28 lines
999 B
GDScript
extends GdUnitTestSuite
|
|
## ListRow: text, alternating backgrounds and wrapping.
|
|
|
|
|
|
func _background(list_row: ListRow) -> Color:
|
|
return (list_row.get_theme_stylebox("panel") as StyleBoxFlat).bg_color
|
|
|
|
|
|
func test_row_shows_text() -> void:
|
|
var list_row: ListRow = auto_free(ListRow.create("Chrono Trigger", 0, 20))
|
|
|
|
assert_str(list_row.text).is_equal("Chrono Trigger")
|
|
|
|
|
|
func test_neighbouring_rows_have_different_backgrounds() -> void:
|
|
var first: ListRow = auto_free(ListRow.create("Chrono Trigger", 0, 20))
|
|
var second: ListRow = auto_free(ListRow.create("Chrono Cross", 1, 20))
|
|
var third: ListRow = auto_free(ListRow.create("Xenogears", 2, 20))
|
|
|
|
assert_that(_background(first)).is_not_equal(_background(second))
|
|
assert_that(_background(first)).is_equal(_background(third))
|
|
|
|
|
|
func test_long_text_wraps() -> void:
|
|
var list_row: ListRow = auto_free(ListRow.create("Castlevania: Symphony of the Night", 0, 20))
|
|
|
|
assert_int(list_row.label.autowrap_mode).is_equal(TextServer.AUTOWRAP_WORD_SMART)
|