Split now playing, the quiz buttons and song loading out of the quiz
NowPlaying, QuizToolbar and SongControls become their own scenes, the auto repeat switch moves into the music player scene, and downloading songs moves into a SongLoader node. The quiz only wires the parts together. 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 new part has its own tests.
This commit is contained in:
1 parent
bad4b3ad8b
commit
e94c75e84d
32 files changed
+822
-300
No files matched your search
@@ -0,0 +1,69 @@
|
||||
extends GdUnitTestSuite
|
||||
## The row of quiz buttons: each button reports its press, and locking disables the
|
||||
## buttons that use the song list.
|
||||
|
||||
const BUTTON_SIGNALS: Dictionary = {
|
||||
"ResetPlaylistButton": "reset_playlist_pressed",
|
||||
"ResetPointsButton": "reset_points_pressed",
|
||||
"SettingsButton": "settings_pressed",
|
||||
"SoundTestButton": "sound_test_pressed",
|
||||
}
|
||||
|
||||
var _runner: GdUnitSceneRunner
|
||||
var _toolbar: QuizToolbar
|
||||
|
||||
|
||||
func before_test() -> void:
|
||||
_runner = scene_runner("res://QuizToolbar.tscn")
|
||||
_toolbar = _runner.scene()
|
||||
|
||||
|
||||
func _button(button_name: String) -> Button:
|
||||
return _toolbar.get_node(button_name)
|
||||
|
||||
|
||||
func _click(button_name: String) -> void:
|
||||
_runner.set_mouse_position(_toolbar.get_viewport().get_final_transform()
|
||||
* _button(button_name).get_global_rect().get_center())
|
||||
await _runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT)
|
||||
await _runner.await_input_processed()
|
||||
|
||||
|
||||
func test_clicking_each_button_reports_it() -> void:
|
||||
for button_name: String in BUTTON_SIGNALS:
|
||||
var signals: GdUnitSignalAssert = assert_signal(monitor_signals(_toolbar))
|
||||
|
||||
await _click(button_name)
|
||||
|
||||
await signals.override_failure_message(button_name + " not reported") \
|
||||
.is_emitted(BUTTON_SIGNALS[button_name])
|
||||
|
||||
|
||||
func test_buttons_are_in_order_left_to_right() -> void:
|
||||
var lefts: Array = ["ResetPlaylistButton", "ResetPointsButton", "SettingsButton",
|
||||
"SoundTestButton"].map(func(n: String) -> float: return _button(n).position.x)
|
||||
|
||||
for i: int in lefts.size() - 1:
|
||||
assert_float(lefts[i]).is_less(lefts[i + 1])
|
||||
|
||||
|
||||
func test_locking_disables_only_buttons_that_use_the_song_list() -> void:
|
||||
_toolbar.set_locked(true)
|
||||
|
||||
assert_bool(_button("ResetPlaylistButton").disabled).is_true()
|
||||
assert_bool(_button("SoundTestButton").disabled).is_true()
|
||||
assert_bool(_button("ResetPointsButton").disabled).is_false()
|
||||
assert_bool(_button("SettingsButton").disabled).is_false()
|
||||
|
||||
|
||||
func test_unlocking_enables_them_again() -> void:
|
||||
_toolbar.set_locked(true)
|
||||
|
||||
_toolbar.set_locked(false)
|
||||
|
||||
assert_bool(_button("ResetPlaylistButton").disabled).is_false()
|
||||
assert_bool(_button("SoundTestButton").disabled).is_false()
|
||||
|
||||
|
||||
func test_clicks_between_buttons_go_through() -> void:
|
||||
assert_int(_toolbar.mouse_filter).is_equal(Control.MOUSE_FILTER_IGNORE)
|
||||
Reference in new issue
Block a user