Normalise file:// URLs for drag-and-drop loading

This commit is contained in:
Armin 2026-11-12 21:52:35 +01:00
commit 6a8d2aa84d
2 changed files with 51 additions and 11 deletions

View file

@ -164,6 +164,10 @@ MonoslicerProcessor processor;
std::cout << "\n\033[1mAcceptance\033[0m\n";
check (editor.isInterestedInFileDrag ({ path }), "accepts a .wav file");
check (editor.isInterestedInFileDrag ({ juce::String ("file://") + path }),
"accepts a .wav file via a file:// URL");
check (editor.isInterestedInFileDrag ({ "file:///tmp/foo%20bar.wav" }),
"accepts a percent-encoded file:// URL");
check (editor.isInterestedInFileDrag ({ "/tmp/notes.txt" }) == false, "rejects a .txt file");
// The old hardcoded list only accepted ".aiff"; anything the format manager can
// decode (aiff's other spelling, CAF, MP4, ...) is now accepted too.
@ -219,6 +223,16 @@ MonoslicerProcessor processor;
// Note: dropping does not auto-slice - that is a separate explicit action,
// and matches the behaviour of the "Load" button.
std::cout << "\n\033[1mFile drop via file:// URL\033[0m\n";
processor.clearSample();
check (processor.getSampleBuffer().getNumSamples() == 0, "the sample was cleared");
editor.filesDropped ({ juce::String ("file://") + path }, info.position.x, info.position.y);
check (processor.getSampleBuffer().getNumSamples() == 4096,
"a file:// URL dropped as a file loads the sample");
check (processor.getCurrentFile() == wavFile,
"the file:// dropped file is recorded as the current file");
std::cout << "\n\033[1mText drop\033[0m\n";
editor.textDropped (path, info.position.x, info.position.y);
check (processor.getSampleBuffer().getNumSamples() == 4096,