Make the music list, player list and inspiration list their own scenes
MusicListPanel, PlayersPanel (was Players) and InspirationList (was ScrollContainer) each get their own scene and script. They report what happens through signals, and the quiz wires them to the playlist, the music player, the log and the popups. Every node keeps its place on screen. Screenshots of every UI state are pixel-identical to before, the layout test still matches the original baseline, and each part is tested on its own as well as through the quiz.
This commit is contained in:
1 parent
3c7b4e5c9d
commit
8c1987807c
24 files changed
+932
-466
No files matched your search
@@ -0,0 +1,79 @@
|
||||
extends GdUnitTestSuite
|
||||
## The music list on its own: one row per song in the playlist, and clicking a row
|
||||
## tells which song was clicked.
|
||||
|
||||
var _snapshot: AutoloadSnapshot
|
||||
var _runner: GdUnitSceneRunner
|
||||
var _panel: MusicListPanel
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_snapshot = AutoloadSnapshot.take([Settings, Playlist])
|
||||
Playlist.reset_playlist()
|
||||
for i: int in 3:
|
||||
var song: SongObject = SongObject.new()
|
||||
song.song_number = i
|
||||
song.soundtrack_title = "Soundtrack %d" % i
|
||||
song.song_title = "Song %d" % i
|
||||
song.has_played = true
|
||||
Playlist.add_to_playlist(song)
|
||||
_runner = scene_runner("res://MusicListPanel.tscn")
|
||||
_panel = _runner.scene()
|
||||
|
||||
|
||||
func after_test() -> void:
|
||||
await await_idle_frame()
|
||||
_snapshot.restore()
|
||||
|
||||
|
||||
func _rows() -> Array[Node]:
|
||||
return _panel.get_node("ScrollContainer/MusicList").get_children()
|
||||
|
||||
|
||||
func test_starts_empty() -> void:
|
||||
assert_array(_rows()).is_empty()
|
||||
|
||||
|
||||
func test_refresh_shows_one_row_per_song_in_order() -> void:
|
||||
_panel.refresh()
|
||||
|
||||
assert_array(_rows().map(func(row: SongListObject) -> int: return row.song_object.song_number)) \
|
||||
.contains_exactly([0, 1, 2])
|
||||
|
||||
|
||||
func test_refresh_again_replaces_the_rows() -> void:
|
||||
_panel.refresh()
|
||||
Playlist.song_object_array.pop_back()
|
||||
|
||||
_panel.refresh()
|
||||
|
||||
assert_int(_rows().size()).is_equal(2)
|
||||
|
||||
|
||||
func test_clicking_a_row_tells_which_song() -> void:
|
||||
_panel.refresh()
|
||||
await _runner.simulate_frames(2)
|
||||
var signals: GdUnitSignalAssert = assert_signal(monitor_signals(_panel))
|
||||
var row: Control = _rows()[1]
|
||||
# The left end of the row is the song text, not one of the player icons
|
||||
var target: Vector2 = row.get_global_rect().position + Vector2(20, row.size.y / 2)
|
||||
|
||||
_runner.set_mouse_position(_panel.get_viewport().get_final_transform() * target)
|
||||
await _runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT)
|
||||
await _runner.await_input_processed()
|
||||
|
||||
await signals.is_emitted("song_clicked", [1])
|
||||
|
||||
|
||||
func test_right_click_does_nothing() -> void:
|
||||
_panel.refresh()
|
||||
await _runner.simulate_frames(2)
|
||||
var signals: GdUnitSignalAssert = assert_signal(monitor_signals(_panel))
|
||||
var row: Control = _rows()[0]
|
||||
|
||||
_runner.set_mouse_position(_panel.get_viewport().get_final_transform()
|
||||
* (row.get_global_rect().position + Vector2(20, row.size.y / 2)))
|
||||
await _runner.simulate_mouse_button_pressed(MOUSE_BUTTON_RIGHT)
|
||||
await _runner.await_input_processed()
|
||||
|
||||
await signals.wait_until(200).is_not_emitted("song_clicked")
|
||||
Reference in new issue
Block a user