|
|
@@ -0,0 +1,403 @@
|
|
|
+ // Round 190tp (issues #365 and #366, yannikthegenius; FL 2026 live check in docs/analise/REA_rodada190tp.md):
|
|
|
+ // #365: a plain drag on a Playlist track header moves the track (LYNX extra "playlist.dragMovesTracks", on; FL does
|
|
|
+ // nothing on that drag), Alt+drag as before, Alt+Up / Alt+Down move the selected tracks (LYNX keys; FL has none),
|
|
|
+ // the header hint and the track menu name them.
|
|
|
+ // #366: Ctrl+V takes files copied in the file manager when they are newer than LYNX's own copy (LYNX extra
|
|
|
+ // "editing.pasteOsFiles", on): the Playlist (at the playhead on the selected track), the Channel rack (new
|
|
|
+ // channels), the Browser (into the selected folder), through the drop's own code; the platform layer read for
|
|
|
+ // real on X11 (another X connection owns CLIPBOARD as a file manager does) and Windows' CF_HDROP decoding; File ›
|
|
|
+ // Import › Audio file... after FL's MIDI file...
|
|
|
+ // Included in the app class of Main.cpp; --round190tptest <report> [<shot prefix>] and --selftest "round190tp".
|
|
|
+ juce::String round190tpCheck (juce::String& log, const juce::String& shots = {})
|
|
|
+ {
|
|
|
+ using namespace lynx;
|
|
|
+ using workspace::Panel;
|
|
|
+ juce::String result = "OK";
|
|
|
+ const auto check = [&] (const juce::String& what, bool ok, const juce::String& detail = {}) {
|
|
|
+ log << (ok ? "ok " : "FAIL ") << what << (detail.isNotEmpty() ? " [" + detail + "]" : juce::String()) << "\n";
|
|
|
+ if (shots.isNotEmpty()) // (--round190tptest: each line as it comes, on stderr)
|
|
|
+ std::fprintf (stderr, "190tp %s %s\n", ok ? "ok " : "FAIL", what.toRawUTF8());
|
|
|
+ if (! ok && result == "OK")
|
|
|
+ result = "ERROR " + what + " " + detail;
|
|
|
+ };
|
|
|
+ const auto note = [&] (const juce::String& what) { log << " " << what << "\n"; };
|
|
|
+ struct Restore
|
|
|
+ {
|
|
|
+ layoutstyle::Style style = layoutstyle::current();
|
|
|
+ bool drag = trackmovedrag::plainDragMoves, paste = ospaste::enabled;
|
|
|
+ ~Restore()
|
|
|
+ {
|
|
|
+ layoutstyle::setCurrent (style);
|
|
|
+ trackmovedrag::plainDragMoves = drag;
|
|
|
+ ospaste::enabled = paste;
|
|
|
+ osclip::setProviderForChecks ({});
|
|
|
+ osclip::allowInTestRun (false);
|
|
|
+ osclip::stopFakeOwnerForChecks();
|
|
|
+ }
|
|
|
+ } restore;
|
|
|
+ trackmovedrag::plainDragMoves = true;
|
|
|
+ ospaste::enabled = true;
|
|
|
+
|
|
|
+ // test samples: "Loop A" 2 s, "Hit B c" 1 s (a space in the name: the URI's %20)
|
|
|
+ const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190tp-" + juce::String (juce::Time::currentTimeMillis()));
|
|
|
+ dir.createDirectory();
|
|
|
+ const struct Cleanup
|
|
|
+ {
|
|
|
+ juce::File d;
|
|
|
+ ~Cleanup() { d.deleteRecursively(); }
|
|
|
+ } cleanup { dir };
|
|
|
+ const auto writeWav = [] (const juce::File& f, double seconds, float hz) {
|
|
|
+ const int rate = 44100, n = (int) (seconds * rate);
|
|
|
+ juce::AudioBuffer<float> b (1, n);
|
|
|
+ for (int i = 0; i < n; ++i)
|
|
|
+ b.setSample (0, i, 0.3f * std::sin (juce::MathConstants<float>::twoPi * hz * (float) i / (float) rate));
|
|
|
+ juce::WavAudioFormat wav;
|
|
|
+ std::unique_ptr<juce::OutputStream> out (f.createOutputStream().release());
|
|
|
+ if (out == nullptr)
|
|
|
+ return false;
|
|
|
+ std::unique_ptr<juce::AudioFormatWriter> w (wav.createWriterFor (out.get(), rate, 1, 16, {}, 0));
|
|
|
+ if (w == nullptr)
|
|
|
+ return false;
|
|
|
+ out.release();
|
|
|
+ return w->writeFromAudioSampleBuffer (b, 0, n);
|
|
|
+ };
|
|
|
+ const auto fileA = dir.getChildFile ("Loop A.wav"), fileB = dir.getChildFile ("Hit B c.wav");
|
|
|
+ check ("the test samples", writeWav (fileA, 2.0, 110.0f) && writeWav (fileB, 1.0, 220.0f));
|
|
|
+ const juce::StringArray copied { fileA.getFullPathName(), fileB.getFullPathName() };
|
|
|
+
|
|
|
+ const auto makeSong = [] {
|
|
|
+ Song s = Song::makeDefault();
|
|
|
+ s.mode = PlayMode::song;
|
|
|
+ s.playlistTracks.resize (8);
|
|
|
+ for (int t = 0; t < 8; ++t)
|
|
|
+ s.playlistTracks[(std::size_t) t].name = "T" + std::to_string (t + 1);
|
|
|
+ return s;
|
|
|
+ };
|
|
|
+ const auto order = [] (const Song& s, int count) {
|
|
|
+ juce::String o;
|
|
|
+ for (int t = 0; t < count && t < (int) s.playlistTracks.size(); ++t)
|
|
|
+ o << s.playlistTracks[(std::size_t) t].name << (t + 1 < count ? "," : "");
|
|
|
+ return o;
|
|
|
+ };
|
|
|
+ const auto source = juce::Desktop::getInstance().getMainMouseSource();
|
|
|
+
|
|
|
+ for (const auto style : { layoutstyle::Style::pattern, layoutstyle::Style::clipLaunch })
|
|
|
+ {
|
|
|
+ const auto pattern = style == layoutstyle::Style::pattern;
|
|
|
+ const juce::String tag = pattern ? "Pattern: " : "Clip-launch: ";
|
|
|
+ AudioEngine offline (false);
|
|
|
+ MainComponent ui (offline, false);
|
|
|
+ ui.setSize (1600, 900);
|
|
|
+ ui.setLayoutStyle (style);
|
|
|
+ const auto settle = [&] {
|
|
|
+ for (int k = 0; k < 3; ++k)
|
|
|
+ offline.dispatchPendingMessages();
|
|
|
+ };
|
|
|
+ offline.setSong (makeSong());
|
|
|
+ settle();
|
|
|
+ ui.selectTabForSnapshot (2);
|
|
|
+ settle();
|
|
|
+ auto& pl = ui.getPlaylistForSnapshot();
|
|
|
+ auto& mouse = static_cast<juce::Component&> (pl);
|
|
|
+ const auto event = [&source, &pl] (juce::Point<int> p, juce::ModifierKeys mods, juce::Point<int> downAt) {
|
|
|
+ const auto now = juce::Time::getCurrentTime();
|
|
|
+ return juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &pl, &pl, now, downAt.toFloat(), now, 1, false);
|
|
|
+ };
|
|
|
+ const auto row = [&pl] (int t) { return pl.trackRowForSnapshot (t); };
|
|
|
+ const auto left = juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier);
|
|
|
+ const auto hx = 60;
|
|
|
+ const auto drag = [&] (int from, juce::Point<int> to, juce::ModifierKeys held, bool shotIt = false) {
|
|
|
+ const juce::Point<int> a (hx, row (from).getCentreY());
|
|
|
+ mouse.mouseDown (event (a, held, a));
|
|
|
+ mouse.mouseDrag (event (to, held, a));
|
|
|
+ if (shotIt && shots.isNotEmpty())
|
|
|
+ {
|
|
|
+ if (const auto h = ui::postedHint())
|
|
|
+ ui.setHintForSnapshot (*h);
|
|
|
+ savePng (ui.createComponentSnapshot (ui.getLocalBounds()), shots + "-01-plain-drag.png");
|
|
|
+ savePng (ui.createComponentSnapshot (ui.getLocalBounds(), true, 1.5f), shots + "-01-plain-drag@150.png");
|
|
|
+ }
|
|
|
+ mouse.mouseUp (event (to, juce::ModifierKeys (held.getRawFlags() & ~juce::ModifierKeys::allMouseButtonModifiers), a));
|
|
|
+ settle();
|
|
|
+ };
|
|
|
+
|
|
|
+ // ---- #365: a plain drag of T4's header to the upper half of T1's row: T4 goes first, one undo step
|
|
|
+ const auto history = offline.getHistorySize();
|
|
|
+ ui::clearPostedHint();
|
|
|
+ drag (3, { hx, row (0).getY() + 2 }, left, pattern);
|
|
|
+ check (tag + "a plain drag moves the track (T4 above T1)", order (offline.getSong(), 5) == "T4,T1,T2,T3,T5", order (offline.getSong(), 5));
|
|
|
+ check (tag + "one undo step", offline.getHistorySize() == history + 1, juce::String (offline.getHistorySize() - history));
|
|
|
+ check (tag + "the moved track is the selected one", pl.getCurrentTrack() == 0, juce::String (pl.getCurrentTrack()));
|
|
|
+ offline.undo();
|
|
|
+ settle();
|
|
|
+ check (tag + "undo puts it back", order (offline.getSong(), 5) == "T1,T2,T3,T4,T5", order (offline.getSong(), 5));
|
|
|
+
|
|
|
+ // a click (no move) and a drag within its own row move nothing
|
|
|
+ drag (2, { hx, row (2).getCentreY() }, left);
|
|
|
+ drag (2, { hx + 3, row (2).getCentreY() + 2 }, left);
|
|
|
+ check (tag + "a click selects, moves nothing", order (offline.getSong(), 5) == "T1,T2,T3,T4,T5" && pl.getCurrentTrack() == 2,
|
|
|
+ order (offline.getSong(), 5));
|
|
|
+ // Ctrl+drag stays FL's range selection
|
|
|
+ drag (1, { hx, row (3).getCentreY() }, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier | juce::ModifierKeys::ctrlModifier));
|
|
|
+ check (tag + "Ctrl+drag selects the tracks crossed, moves nothing", order (offline.getSong(), 5) == "T1,T2,T3,T4,T5" && pl.getSelectedTracks().size() == 3,
|
|
|
+ juce::String ((int) pl.getSelectedTracks().size()));
|
|
|
+ // dragged downwards: below T5's middle
|
|
|
+ drag (0, { hx, row (4).getBottom() - 2 }, left);
|
|
|
+ check (tag + "dragged down past T5", order (offline.getSong(), 5) == "T2,T3,T4,T5,T1", order (offline.getSong(), 5));
|
|
|
+ offline.undo();
|
|
|
+ settle();
|
|
|
+
|
|
|
+ // the switch off (FL's way): the plain drag moves nothing, Alt+drag still moves
|
|
|
+ trackmovedrag::plainDragMoves = false;
|
|
|
+ drag (3, { hx, row (0).getY() + 2 }, left);
|
|
|
+ check (tag + "switch off: a plain drag moves nothing (FL)", order (offline.getSong(), 5) == "T1,T2,T3,T4,T5", order (offline.getSong(), 5));
|
|
|
+ drag (3, { hx, row (0).getY() + 2 }, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier | juce::ModifierKeys::altModifier));
|
|
|
+ check (tag + "switch off: Alt+drag moves (round 190jf)", order (offline.getSong(), 5) == "T4,T1,T2,T3,T5", order (offline.getSong(), 5));
|
|
|
+ offline.undo();
|
|
|
+ settle();
|
|
|
+ // the header hint names the drag (on) / Alt+drag (off)
|
|
|
+ const auto hintOff = pl.hintAt ({ hx, row (2).getCentreY() }).text;
|
|
|
+ trackmovedrag::plainDragMoves = true;
|
|
|
+ const auto hintOn = pl.hintAt ({ hx, row (2).getCentreY() }).text;
|
|
|
+ check (tag + "the header hint: \"drag: move up / down\" (on), \"[Alt] drag\" (off)",
|
|
|
+ hintOn.contains ("drag: move up / down") && ! hintOn.contains ("[Alt] drag") && hintOff.contains ("[Alt] drag: move"), hintOn);
|
|
|
+
|
|
|
+ // ---- Alt+Up / Alt+Down (the Playlist focused): the selected track moves; the track menu shows the keys
|
|
|
+ auto& ws = ui.getWorkspaceForSnapshot();
|
|
|
+ ws.show (Panel::playlist);
|
|
|
+ ws.activate (Panel::playlist);
|
|
|
+ pl.selectTrack (2);
|
|
|
+ settle();
|
|
|
+ ui.keyPressed (juce::KeyPress (juce::KeyPress::downKey, juce::ModifierKeys::altModifier, 0));
|
|
|
+ settle();
|
|
|
+ check (tag + "Alt+Down moves the selected track down", order (offline.getSong(), 5) == "T1,T2,T4,T3,T5" && pl.getCurrentTrack() == 3,
|
|
|
+ order (offline.getSong(), 5) + " current " + juce::String (pl.getCurrentTrack()));
|
|
|
+ ui.keyPressed (juce::KeyPress (juce::KeyPress::upKey, juce::ModifierKeys::altModifier, 0));
|
|
|
+ ui.keyPressed (juce::KeyPress (juce::KeyPress::upKey, juce::ModifierKeys::altModifier, 0));
|
|
|
+ settle();
|
|
|
+ check (tag + "Alt+Up twice moves it up two", order (offline.getSong(), 5) == "T1,T3,T2,T4,T5" && pl.getCurrentTrack() == 1,
|
|
|
+ order (offline.getSong(), 5) + " current " + juce::String (pl.getCurrentTrack()));
|
|
|
+ pl.selectTracks ({ 1, 2 });
|
|
|
+ ui.runActionForSnapshot ("playlist.moveTrackDown");
|
|
|
+ settle();
|
|
|
+ check (tag + "two selected tracks move together", order (offline.getSong(), 5) == "T1,T4,T3,T2,T5", order (offline.getSong(), 5));
|
|
|
+ pl.selectTrack (0);
|
|
|
+ const auto history2 = offline.getHistorySize();
|
|
|
+ ui.runActionForSnapshot ("playlist.moveTrackUp");
|
|
|
+ settle();
|
|
|
+ check (tag + "the first track does not move up (nothing in the history)", offline.getHistorySize() == history2);
|
|
|
+ {
|
|
|
+ juce::StringArray items;
|
|
|
+ const auto trackMenu = pl.getTrackMenuForSnapshot (2); // (named: the iterator keeps a reference)
|
|
|
+ for (juce::PopupMenu::MenuItemIterator it (trackMenu); it.next();)
|
|
|
+ items.add (it.getItem().text.removeCharacters (juce::String::charToString ((juce::juce_wchar) 1)));
|
|
|
+ juce::String moveUp, moveDown;
|
|
|
+ for (const auto& i : items)
|
|
|
+ {
|
|
|
+ if (i.contains ("Move up"))
|
|
|
+ moveUp = i;
|
|
|
+ if (i.contains ("Move down"))
|
|
|
+ moveDown = i;
|
|
|
+ }
|
|
|
+ check (tag + "the track menu's Move up / down show Alt+Up / Alt+Down", moveUp.contains ("Alt+Up") && moveDown.contains ("Alt+Down"),
|
|
|
+ moveUp + " | " + moveDown);
|
|
|
+ if (pattern && shots.isNotEmpty())
|
|
|
+ saveMenus (juce::StringArray { "Track" }, std::vector<juce::PopupMenu> { pl.getTrackMenuForSnapshot (2) }, shots + "-02-track-menu.png");
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---- #366 in the Playlist: two files copied in the file manager, Ctrl+V at the playhead on the selected track
|
|
|
+ offline.setSong (makeSong());
|
|
|
+ settle();
|
|
|
+ const auto bar = offline.getSong().barTicks();
|
|
|
+ offline.getTransport().positionTicks.store ((double) (2 * bar));
|
|
|
+ juce::String token = "copy 1";
|
|
|
+ osclip::setProviderForChecks ([&copied] { return copied; }, [&token] { return token; });
|
|
|
+ pl.selectTrack (3);
|
|
|
+ const auto clipsBefore = offline.getSong().playlist.size();
|
|
|
+ const auto history3 = offline.getHistorySize();
|
|
|
+ ui::clearPostedHint();
|
|
|
+ ui.keyPressed (juce::KeyPress ('V', juce::ModifierKeys::ctrlModifier, 0));
|
|
|
+ settle();
|
|
|
+ const auto& song = offline.getSong();
|
|
|
+ const auto audioAt = [&song] (int track, std::int64_t start, const juce::String& file) {
|
|
|
+ return std::any_of (song.playlist.begin(), song.playlist.end(), [&] (const Clip& c) {
|
|
|
+ return c.kind == ClipKind::audio && c.track == track && c.start == start && c.channel >= 0 && c.channel < (int) song.channels.size()
|
|
|
+ && juce::File (juce::String::fromUTF8 (song.channels[(std::size_t) c.channel].samplePath.c_str())) == juce::File (file);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ check (tag + "Ctrl+V: the two files at the playhead (bar 3), on the selected track and the one under it",
|
|
|
+ song.playlist.size() == clipsBefore + 2 && audioAt (3, 2 * bar, copied[0]) && audioAt (4, 2 * bar, copied[1]),
|
|
|
+ juce::String ((int) (song.playlist.size() - clipsBefore)) + " clips");
|
|
|
+ check (tag + "one undo step", offline.getHistorySize() == history3 + 1, juce::String (offline.getHistorySize() - history3));
|
|
|
+ const auto pastedHint = ui::postedHint();
|
|
|
+ check (tag + "the hint names the files", pastedHint && pastedHint->text.contains ("Loop A.wav") && pastedHint->text.contains ("Hit B c.wav"),
|
|
|
+ pastedHint ? pastedHint->text : juce::String ("none"));
|
|
|
+ if (pattern && shots.isNotEmpty())
|
|
|
+ {
|
|
|
+ if (pastedHint)
|
|
|
+ ui.setHintForSnapshot (*pastedHint);
|
|
|
+ savePng (ui.createComponentSnapshot (ui.getLocalBounds()), shots + "-03-pasted-files.png");
|
|
|
+ savePng (ui.createComponentSnapshot (ui.getLocalBounds(), true, 1.5f), shots + "-03-pasted-files@150.png");
|
|
|
+ }
|
|
|
+
|
|
|
+ // LYNX's own copy after that: Ctrl+V pastes the LYNX clip, not the files again
|
|
|
+ pl.selectClipsForSnapshot ({ (int) song.playlist.size() - 1 });
|
|
|
+ ui.runActionForSnapshot ("playlist.copy");
|
|
|
+ const auto clips2 = song.playlist.size();
|
|
|
+ ui.runActionForSnapshot ("playlist.paste");
|
|
|
+ settle();
|
|
|
+ check (tag + "after LYNX's copy, Ctrl+V pastes LYNX's clip", song.playlist.size() == clips2 + 1, juce::String ((int) (song.playlist.size() - clips2)));
|
|
|
+ // a new copy in the file manager: the files win again
|
|
|
+ token = "copy 2";
|
|
|
+ const auto clips3 = song.playlist.size();
|
|
|
+ ui.runActionForSnapshot ("playlist.paste");
|
|
|
+ settle();
|
|
|
+ check (tag + "files copied after LYNX's copy win", song.playlist.size() == clips3 + 2, juce::String ((int) (song.playlist.size() - clips3)));
|
|
|
+ // the switch off: FL's Ctrl+V (LYNX's clipboard only)
|
|
|
+ ospaste::enabled = false;
|
|
|
+ token = "copy 3";
|
|
|
+ const auto clips4 = song.playlist.size();
|
|
|
+ ui.runActionForSnapshot ("playlist.paste");
|
|
|
+ settle();
|
|
|
+ check (tag + "switch off: LYNX's clip, never the files", song.playlist.size() == clips4 + 1, juce::String ((int) (song.playlist.size() - clips4)));
|
|
|
+ ospaste::enabled = true;
|
|
|
+ // a file the Playlist can't place (a text file): LYNX's clipboard
|
|
|
+ const auto textFile = dir.getChildFile ("notes.txt");
|
|
|
+ textFile.replaceWithText ("x");
|
|
|
+ osclip::setProviderForChecks ([textFile] { return juce::StringArray { textFile.getFullPathName() }; }, [] { return juce::String ("t"); });
|
|
|
+ const auto clips5 = song.playlist.size();
|
|
|
+ ui.runActionForSnapshot ("playlist.paste");
|
|
|
+ settle();
|
|
|
+ check (tag + "a file it can't place: LYNX's clipboard pastes", song.playlist.size() == clips5 + 1, juce::String ((int) (song.playlist.size() - clips5)));
|
|
|
+ osclip::setProviderForChecks ([&copied] { return copied; }, [&token] { return token; });
|
|
|
+
|
|
|
+ if (! pattern)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ // ---- the Channel rack: new channels; LYNX's steps after a LYNX copy
|
|
|
+ {
|
|
|
+ auto& rack = ui.getRackForSnapshot();
|
|
|
+ token = "rack 1";
|
|
|
+ const auto channels = song.channels.size();
|
|
|
+ ui.runActionForSnapshot ("rack.paste");
|
|
|
+ settle();
|
|
|
+ check ("Channel rack: Ctrl+V's files become two new channels", song.channels.size() == channels + 2
|
|
|
+ && juce::File (juce::String::fromUTF8 (song.channels.back().samplePath.c_str())) == juce::File (copied[1]),
|
|
|
+ juce::String ((int) (song.channels.size() - channels)));
|
|
|
+ offline.setSelectedChannel (0);
|
|
|
+ rack.copySelected();
|
|
|
+ const auto channels2 = song.channels.size();
|
|
|
+ ui.runActionForSnapshot ("rack.paste");
|
|
|
+ settle();
|
|
|
+ check ("Channel rack: after LYNX's copy, Ctrl+V pastes the steps (no new channel)", song.channels.size() == channels2);
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---- the Browser: into the selected folder
|
|
|
+ {
|
|
|
+ auto& browser = ui.getBrowserForSnapshot();
|
|
|
+ const auto folder = dir.getChildFile ("Pasted here");
|
|
|
+ folder.createDirectory();
|
|
|
+ browser.addUserFolders ({ folder.getFullPathName() });
|
|
|
+ settle();
|
|
|
+ browser.selectRowForSnapshot (folder.getFileName());
|
|
|
+ token = "browser 1";
|
|
|
+ const auto took = ui.runActionForSnapshot ("browser.paste");
|
|
|
+ check ("Browser: Ctrl+V copies the files into the selected folder", took && folder.getChildFile ("Loop A.wav").existsAsFile()
|
|
|
+ && folder.getChildFile ("Hit B c.wav").existsAsFile());
|
|
|
+ osclip::setProviderForChecks ([] { return juce::StringArray(); }, [] { return juce::String ("none"); });
|
|
|
+ check ("Browser: nothing on the system clipboard, the key goes on (false)", ! ui.runActionForSnapshot ("browser.paste"));
|
|
|
+ osclip::setProviderForChecks ([&copied] { return copied; }, [&token] { return token; });
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---- File › Import: FL's MIDI file..., then LYNX's Audio file...; it places like a drop
|
|
|
+ {
|
|
|
+ juce::PopupMenu imports;
|
|
|
+ const auto fileMenu = ui.menuForCheck (0, "File");
|
|
|
+ for (juce::PopupMenu::MenuItemIterator it (fileMenu); it.next();)
|
|
|
+ if (it.getItem().text == "Import" && it.getItem().subMenu != nullptr)
|
|
|
+ imports = *it.getItem().subMenu;
|
|
|
+ juce::StringArray items;
|
|
|
+ for (juce::PopupMenu::MenuItemIterator it (imports); it.next();)
|
|
|
+ items.add (it.getItem().text.upToFirstOccurrenceOf ("\t", false, false));
|
|
|
+ check ("File › Import: MIDI file... then Audio file...", items.indexOf ("MIDI file...") == 0 && items.indexOf ("Audio file...") == 1,
|
|
|
+ items.joinIntoString (" | "));
|
|
|
+ if (shots.isNotEmpty())
|
|
|
+ saveMenus (juce::StringArray { "Import" }, std::vector<juce::PopupMenu> { imports }, shots + "-04-file-import.png");
|
|
|
+ offline.setSong (makeSong());
|
|
|
+ settle();
|
|
|
+ offline.getTransport().positionTicks.store ((double) bar);
|
|
|
+ pl.selectTrack (5);
|
|
|
+ pl.placeFilesAtPlayhead ({ copied[0] }); // (the chooser's result goes here)
|
|
|
+ settle();
|
|
|
+ check ("Audio file...: the file at the playhead on the selected track", audioAt (5, bar, copied[0]));
|
|
|
+ const auto* action = keys::findAction ("file.importAudio");
|
|
|
+ check ("Import audio file... is a key-map action with no default key (Insert stays free)", action != nullptr && action->defaults.empty());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---- the platform layer
|
|
|
+#if JUCE_WINDOWS
|
|
|
+ check ("Windows: a CF_HDROP block decodes (wide and ANSI names)", osclip::hdropSelfTestForChecks().isEmpty(), osclip::hdropSelfTestForChecks());
|
|
|
+#endif
|
|
|
+#if JUCE_LINUX || JUCE_BSD
|
|
|
+ {
|
|
|
+ osclip::setProviderForChecks ({});
|
|
|
+ osclip::allowInTestRun (true);
|
|
|
+ const auto uri = [] (const juce::File& f) { return "file://" + juce::URL::addEscapeChars (f.getFullPathName(), false).replace ("%2F", "/"); };
|
|
|
+ const auto list = "# from a file manager\r\n" + uri (fileA) + "\r\n" + uri (fileB) + "\r\n";
|
|
|
+ const auto why = osclip::startFakeOwnerForChecks ("text/uri-list", list);
|
|
|
+ if (why.isNotEmpty())
|
|
|
+ note ("X11 clipboard: " + why);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ const auto got = osclip::readSystemFiles();
|
|
|
+ check ("X11: text/uri-list read from another program's CLIPBOARD", got == copied && osclip::fakeOwnerAnswersForChecks() >= 1,
|
|
|
+ got.joinIntoString (" | "));
|
|
|
+ // Ctrl+V in the Playlist through the platform layer
|
|
|
+ AudioEngine offline (false);
|
|
|
+ MainComponent ui (offline, false);
|
|
|
+ ui.setSize (1600, 900);
|
|
|
+ ui.setLayoutStyle (layoutstyle::Style::pattern);
|
|
|
+ offline.setSong (makeSong());
|
|
|
+ for (int k = 0; k < 3; ++k)
|
|
|
+ offline.dispatchPendingMessages();
|
|
|
+ ui.selectTabForSnapshot (2);
|
|
|
+ auto& ws = ui.getWorkspaceForSnapshot();
|
|
|
+ ws.show (Panel::playlist);
|
|
|
+ ws.activate (Panel::playlist);
|
|
|
+ ui.getPlaylistForSnapshot().selectTrack (2);
|
|
|
+ ui.keyPressed (juce::KeyPress ('V', juce::ModifierKeys::ctrlModifier, 0));
|
|
|
+ for (int k = 0; k < 3; ++k)
|
|
|
+ offline.dispatchPendingMessages();
|
|
|
+ const auto& s = offline.getSong();
|
|
|
+ const auto onTrack = [&s] (int track) {
|
|
|
+ return std::count_if (s.playlist.begin(), s.playlist.end(), [track] (const Clip& c) { return c.kind == ClipKind::audio && c.track == track; });
|
|
|
+ };
|
|
|
+ check ("X11: Ctrl+V in the Playlist places the copied files (tracks 3 and 4)", onTrack (2) == 1 && onTrack (3) == 1,
|
|
|
+ juce::String ((int) s.playlist.size()) + " clips");
|
|
|
+ osclip::stopFakeOwnerForChecks();
|
|
|
+ // GNOME's own form only
|
|
|
+ if (osclip::startFakeOwnerForChecks ("x-special/gnome-copied-files", "copy\n" + uri (fileB)).isEmpty())
|
|
|
+ {
|
|
|
+ const auto gnome = osclip::readSystemFiles();
|
|
|
+ check ("X11: x-special/gnome-copied-files", gnome.size() == 1 && gnome[0] == copied[1], gnome.joinIntoString (" | "));
|
|
|
+ osclip::stopFakeOwnerForChecks();
|
|
|
+ }
|
|
|
+ // an owner with text only: no files
|
|
|
+ if (osclip::startFakeOwnerForChecks ("text/html", "<b>hello</b>").isEmpty())
|
|
|
+ {
|
|
|
+ check ("X11: an owner without a file list gives no files", osclip::readSystemFiles().isEmpty());
|
|
|
+ osclip::stopFakeOwnerForChecks();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // the text fallback (a file:// URI or a path as the clipboard's text)
|
|
|
+ check ("text fallback: file:// URIs and paths", osclip::filesOfText (uri (fileA) + "\n" + fileB.getFullPathName()) == copied);
|
|
|
+ check ("text fallback: words stay text", osclip::filesOfText ("Loop A").isEmpty() && osclip::filesOfText ("/no/such/file.wav").isEmpty());
|
|
|
+ osclip::allowInTestRun (false);
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ // a test run reads no system clipboard unless a check allows it (the clipboard belongs to the person at the computer)
|
|
|
+ osclip::setProviderForChecks ({});
|
|
|
+ check ("test mode: the system clipboard is not read", ! platform::testMode() || osclip::files().isEmpty());
|
|
|
+ return result;
|
|
|
+ }
|