Add working tests, fix bugs, rework popups and automate releases #36

Merged
Sansan merged 34 commits from feature/adding_tests into develop 2026-10-06 22:14:44 +02:00
2 changed files with 63 additions and 0 deletions
Showing only changes of commit 1acc757981 - Show all commits

No files matched your search

+7
View File
@@ -174,6 +174,7 @@ func _ready() -> void:
music_player_container.connect("play_next_song", play_next_song)
music_player_container.connect("update_song_list", update_song_list)
settings_window.connect("server_changed", server_updated)
settings_window.visibility_changed.connect(_on_settings_window_visibility_changed)
sync_window.connect("sync_started", _on_sync_started)
sync_window.connect("sync_finished", _on_sync_finished)
@@ -277,6 +278,12 @@ func play_next_song() -> void:
#"/music/rand"
#"/music/addQue"
#"/music/info"
# The cache size can be changed in the settings. Waiting until the settings are closed
# avoids starting downloads while the user is still clicking the number up and down.
func _on_settings_window_visibility_changed() -> void:
if !settings_window.visible && !Playlist.is_song_downloading && Playlist.should_preload_more_songs():
fetch_song()
func fetch_song() -> void:
print("fetch_song")
Playlist.is_song_downloading = true
+56
View File
@@ -158,3 +158,59 @@ func test_cache_keeps_filling_after_a_failed_download() -> void:
assert_int(Playlist.get_preloaded_songs()).is_equal(3)
assert_bool(Playlist.is_song_downloading).is_false()
func _open_settings() -> void:
_press("SettingsButton")
func _close_settings() -> void:
(_window.get_node("SettingsWindow") as Control).visible = false
func _press_settings_button(unique_name: String) -> void:
(_window.get_node("SettingsWindow").get_node("%" + unique_name) as Button).pressed.emit()
func test_raising_cache_size_does_not_download_while_settings_are_open() -> void:
var downloads_before: int = _server.count("/music/rand")
_open_settings()
_press_settings_button("IncreaseCacheButton")
_press_settings_button("IncreaseCacheButton")
assert_int(Playlist.number_of_tracks_to_preload).is_equal(3)
assert_int(_server.count("/music/rand")).is_equal(downloads_before)
func test_closing_settings_fills_cache_to_new_size() -> void:
_open_settings()
_press_settings_button("IncreaseCacheButton")
_press_settings_button("IncreaseCacheButton")
_close_settings()
assert_int(Playlist.get_preloaded_songs()).is_equal(3)
func test_changing_cache_size_back_and_forth_downloads_only_what_is_needed() -> void:
var downloads_before: int = _server.count("/music/rand")
_open_settings()
for i: int in 5:
_press_settings_button("IncreaseCacheButton")
_press_settings_button("LowerCacheButton")
_press_settings_button("IncreaseCacheButton")
_close_settings()
assert_int(_server.count("/music/rand") - downloads_before).is_equal(1)
assert_int(Playlist.get_preloaded_songs()).is_equal(2)
func test_closing_settings_with_full_cache_downloads_nothing() -> void:
var downloads_before: int = _server.count("/music/rand")
_open_settings()
_close_settings()
assert_int(_server.count("/music/rand")).is_equal(downloads_before)