Files
MusicPlayer/tests/integration/test_music_player_scene.gd
T
Sansan d77b72159d Sort the scripts and scenes into folders
main/ holds the main window and top bar, quiz/ the quiz and its parts,
player/ the music player, popups/ every popup and what they share, data/ the
songs, players, playlist and settings, server/ the MusicServer client,
common/ the list row and GameLog, and themes/ the themes and style boxes.
2026-10-06 11:57:29 +02:00

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://player/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)