Fill the song cache when the settings menu is closed
Raising the cache size used to have no effect until the next song was played. Downloads now start when the settings window closes, so clicking the number up and down while it is open does not start any downloads.
This commit is contained in:
1 parent
16724922ed
commit
1acc757981
2 files changed
+63
No files matched your search
@@ -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)
|
||||
Reference in new issue
Block a user