Skip to content

Commit ea12a08

Browse files
committed
Merge pull request #100022 from DeeJayLSP/wav-load-test
`TestAudioStreamWAV`: use runtime load instead of importer
2 parents 06cce0e + eaa0418 commit ea12a08

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

tests/scene/test_audio_stream_wav.h

+2-25
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737

3838
#include "tests/test_macros.h"
3939

40-
#ifdef TOOLS_ENABLED
41-
#include "core/io/resource_loader.h"
42-
#include "editor/import/resource_importer_wav.h"
43-
#endif
44-
4540
namespace TestAudioStreamWAV {
4641

4742
// Default wav rate for test cases.
@@ -148,25 +143,8 @@ void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo,
148143
Ref<FileAccess> wav_file = FileAccess::open(save_path, FileAccess::READ, &error);
149144
REQUIRE(error == OK);
150145

151-
#ifdef TOOLS_ENABLED
152-
// The WAV importer can be used if enabled to check that the saved file is valid.
153-
Ref<ResourceImporterWAV> wav_importer = memnew(ResourceImporterWAV);
154-
155-
List<ResourceImporter::ImportOption> options_list;
156-
wav_importer->get_import_options("", &options_list);
157-
158-
HashMap<StringName, Variant> options_map;
159-
for (const ResourceImporter::ImportOption &E : options_list) {
160-
options_map[E.option.name] = E.default_value;
161-
}
162-
// Compressed streams can't be saved, disable compression.
163-
options_map["compress/mode"] = 0;
164-
165-
REQUIRE(wav_importer->import(0, save_path, save_path, options_map, nullptr) == OK);
166-
167-
String load_path = save_path + "." + wav_importer->get_save_extension();
168-
Ref<AudioStreamWAV> loaded_stream = ResourceLoader::load(load_path, "AudioStreamWAV", ResourceFormatImporter::CACHE_MODE_IGNORE, &error);
169-
REQUIRE(error == OK);
146+
Dictionary options;
147+
Ref<AudioStreamWAV> loaded_stream = AudioStreamWAV::load_from_file(save_path, options);
170148

171149
CHECK(loaded_stream->get_format() == stream->get_format());
172150
CHECK(loaded_stream->get_loop_mode() == stream->get_loop_mode());
@@ -177,7 +155,6 @@ void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo,
177155
CHECK(loaded_stream->get_length() == stream->get_length());
178156
CHECK(loaded_stream->is_monophonic() == stream->is_monophonic());
179157
CHECK(loaded_stream->get_data() == stream->get_data());
180-
#endif
181158
}
182159
}
183160

0 commit comments

Comments
 (0)