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.
51 lines
1.6 KiB
GDScript
51 lines
1.6 KiB
GDScript
extends GdUnitTestSuite
|
|
## The music player scene: the player bar and the auto repeat switch under it.
|
|
|
|
var _snapshot: AutoloadSnapshot
|
|
var _runner: GdUnitSceneRunner
|
|
var _player: MusicPlayer
|
|
|
|
|
|
func before_test() -> void:
|
|
_snapshot = AutoloadSnapshot.take([Settings])
|
|
Settings.auto_repeat_song = true
|
|
_runner = scene_runner("res://MusicPlayer.tscn")
|
|
_player = _runner.scene()
|
|
|
|
|
|
func after_test() -> void:
|
|
_snapshot.restore()
|
|
|
|
|
|
func _click(control: Control) -> void:
|
|
_runner.set_mouse_position(_player.get_viewport().get_final_transform()
|
|
* control.get_global_rect().get_center())
|
|
await _runner.simulate_mouse_button_pressed(MOUSE_BUTTON_LEFT)
|
|
await _runner.await_input_processed()
|
|
|
|
|
|
func test_auto_repeat_starts_on() -> void:
|
|
assert_bool(_player.auto_repeat_button.button_pressed).is_true()
|
|
|
|
|
|
func test_clicking_auto_repeat_turns_it_off_and_on() -> void:
|
|
await _click(_player.auto_repeat_button)
|
|
assert_bool(Settings.auto_repeat_song).is_false()
|
|
assert_bool(_player.auto_repeat_button.button_pressed).is_false()
|
|
|
|
await _click(_player.auto_repeat_button)
|
|
assert_bool(Settings.auto_repeat_song).is_true()
|
|
|
|
|
|
func test_auto_repeat_is_under_the_player_bar() -> void:
|
|
await _runner.simulate_frames(1)
|
|
var bar: Rect2 = (_player.get_node("PlayerBar") as Control).get_global_rect()
|
|
var repeat: Rect2 = _player.auto_repeat_button.get_global_rect()
|
|
|
|
assert_float(repeat.position.y).is_greater_equal(bar.end.y)
|
|
assert_bool(_player.get_global_rect().encloses(repeat)).is_true()
|
|
|
|
|
|
func test_empty_space_lets_clicks_through() -> void:
|
|
assert_int(_player.mouse_filter).is_equal(Control.MOUSE_FILTER_IGNORE)
|