37
37
38
38
#include " tests/test_macros.h"
39
39
40
- #ifdef TOOLS_ENABLED
41
- #include " core/io/resource_loader.h"
42
- #include " editor/import/resource_importer_wav.h"
43
- #endif
44
-
45
40
namespace TestAudioStreamWAV {
46
41
47
42
// Default wav rate for test cases.
@@ -148,25 +143,8 @@ void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo,
148
143
Ref<FileAccess> wav_file = FileAccess::open (save_path, FileAccess::READ, &error);
149
144
REQUIRE (error == OK);
150
145
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);
170
148
171
149
CHECK (loaded_stream->get_format () == stream->get_format ());
172
150
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,
177
155
CHECK (loaded_stream->get_length () == stream->get_length ());
178
156
CHECK (loaded_stream->is_monophonic () == stream->is_monophonic ());
179
157
CHECK (loaded_stream->get_data () == stream->get_data ());
180
- #endif
181
158
}
182
159
}
183
160
0 commit comments