fix: harden S4 audio verification
This commit is contained in:
@@ -25,6 +25,24 @@ func test_unknown_requests_are_silent() -> void:
|
||||
assert_eq(library.get_last_ambience_path(), "")
|
||||
assert_eq(library.get_last_sfx_path(), "")
|
||||
|
||||
func test_invalid_wav_is_not_selected_or_played_and_does_not_block_requests() -> void:
|
||||
var root := ProjectSettings.globalize_path("user://s4-invalid-audio-library")
|
||||
var invalid_path := root.path_join("audio/exploration/not-a-wave.wav")
|
||||
DirAccess.make_dir_recursive_absolute(invalid_path.get_base_dir())
|
||||
var invalid_file := FileAccess.open(invalid_path, FileAccess.WRITE)
|
||||
invalid_file.store_string("this is not a WAV file")
|
||||
invalid_file.close()
|
||||
var library := AudioLibrary.new(root)
|
||||
add_child_autofree(library)
|
||||
|
||||
library.set_ambience_context("exploration")
|
||||
library.play_sfx("attack_given")
|
||||
|
||||
assert_eq(library.get_last_ambience_path(), "")
|
||||
assert_eq(library.get_last_sfx_path(), "")
|
||||
assert_false(library._ambience_player.playing)
|
||||
assert_false(library._sfx_player.playing)
|
||||
|
||||
func test_admitted_wav_file_is_discovered() -> void:
|
||||
var root := ProjectSettings.globalize_path("user://s4-audio-library")
|
||||
var sample_path := root.path_join("audio/exploration/silence.wav")
|
||||
|
||||
Reference in New Issue
Block a user