ソースを参照

Round 190tp checks: --round190tptest (and --selftest "round190tp"), tests for the header drag rule, the paste rules, URI lists and keys

src/Round190tpCheck.inc drives the real Playlist, Channel rack, Browser and File menu off screen
(Pattern and Clip-launch layouts) and reads the X11 clipboard for real: another X connection owns
CLIPBOARD as a file manager does (text/uri-list, x-special/gnome-copied-files, an owner without a
list), skipped on a desktop's display (WSLg's :0) or when the clipboard already has an owner.
Windows: a CF_HDROP block built in memory decoded as the clipboard's is. tests/UxTracks190tpTests.inc
(5 tests); Extras190am count 93, KeySheet190sj rows 24.

(cherry picked from commit 28fef4530249266ce13149e2640f7de1e9646844)
Ka1-S 5 日 前
親
コミット
fcd422b201

+ 24 - 1
src/Main.cpp

@@ -369,6 +369,9 @@ namespace juce::detail { bool dispatchNextMessageOnSystemQueue (bool returnIfNoP
 #include "core/Timecode.h" // round 190ta (src/Rea190taCheck.inc)
 #include "core/SlicexInstrument.h" // round 190ti (src/Round190tiCheck.inc)
 #include "core/NativeSlots.h" // round 190tn (src/Round190tnCheck.inc)
+#include "core/OsPaste.h"             // round 190tp (src/Round190tpCheck.inc)
+#include "core/TrackMoveDrag.h"       // round 190tp
+#include "platform/OsClipboardFiles.h" // round 190tp
 #include "ui/ProjectPickerView.h" // (round 190my)
 #include "ui/WindowPlaces.h" // (round 190oa)
 #include "ui/HintBar.h" // (round 190oa)
@@ -2480,6 +2483,21 @@ public:
             quit();
             return;
         }
+        if (args.contains ("--round190tptest"))
+        {
+            // LYNX --round190tptest report.txt [shot prefix] (round 190tp, issues #365 / #366: a plain drag on a Playlist track
+            // header moves the track, Alt+Up / Down, Ctrl+V of files copied in the file manager, File › Import › Audio file...;
+            // also in --selftest): src/Round190tpCheck.inc
+            juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
+            juce::String log;
+            const auto i = args.indexOf ("--round190tptest");
+            const auto shots = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
+            const auto result = round190tpCheck (log, shots);
+            juce::File (args[i + 1].unquoted()).replaceWithText (log + "round190tp=" + result + "\n");
+            setApplicationReturnValue (result == "OK" ? 0 : 1);
+            quit();
+            return;
+        }
         if (args.contains ("--round190tntest"))
         {
             // LYNX --round190tntest report.txt [shot prefix] (round 190tn, issue #363: the native effects' preset box and LYNX's own
@@ -11214,6 +11232,9 @@ private:
         // round 190tn: the native effects' preset box and LYNX's own banks (issue #363, src/Round190tnCheck.inc)
         juce::String round190tnLog;
         const auto round190tnResult = round190tnCheck (round190tnLog);
+        // round 190tp: track header drag / keys, Ctrl+V of the file manager's files, File › Import › Audio file... (src/Round190tpCheck.inc)
+        juce::String round190tpLog;
+        const auto round190tpResult = round190tpCheck (round190tpLog);
         // round 190tk: FL's automation timing for imported FL projects (src/Round190tkCheck.inc)
         juce::String round190tkLog;
         const auto round190tkResult = round190tkCheck (round190tkLog);
@@ -12692,7 +12713,7 @@ private:
                         && sidechainResult == "OK" && lanesResult == "OK" && arrange190cgResult == "OK" && livescr190drResult == "OK" && livewf190efResult == "OK" && livewf190emResult == "OK" && trackclips190neResult == "OK" && tracker190nwResult == "OK" && tracker190obResult == "OK" && rackauto190ooResult == "OK" && tracker190omResult == "OK" && rackauto190owResult == "OK" && versionsResult == "OK" && pluginsOffResult == "OK" && missingFilesResult == "OK"
                         && midigen190fmResult == "OK" && clipenv190giResult == "OK" && beatslaw190gxResult == "OK" && warplaw190ikResult == "OK" && editorScale190heResult == "OK" && sfModBase190heResult == "OK" && trackauto190gzResult == "OK" && community190hqResult == "OK" && rollup030Result == "OK" && rollup031Result == "OK" && rollup031s2Result == "OK"
                         && keys190nuResult == "OK" && rollup031s3Result == "OK"
-                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && backlog190rcResult == "OK" && community190riResult == "OK" && flParity190tcResult == "OK" && q1a190rwResult == "OK" && iox190rmResult == "OK" && issues190rtResult == "OK" && perf190rnResult == "OK" && perf190sbResult == "OK" && cachecheck190tgResult == "OK" && undo190spResult == "OK" && menuwindows190skResult == "OK" && issues330skResult == "OK" && audioedit190stResult == "OK" && drumsynth190syResult == "OK" && smallbugs190srResult == "OK" && quickwins190srResult == "OK" && batch292_190swResult == "OK" && round190teResult == "OK" && yannik190sqResult == "OK" && rea190taResult == "OK" && round190tiResult == "OK" && round190tnResult == "OK" && round190tkResult == "OK" && round190tmResult == "OK" && round190toResult == "OK" && batch334svResult == "OK" && details190tdResult == "OK" && qa190rbResult == "OK" && bugs190rvResult == "OK" && q6190saResult == "OK" && issue325Result == "OK" && keysheet190sjResult == "OK" && details190tbResult == "OK" && notes190tjResult == "OK" && children190thResult == "OK" && stab190rpResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && extras190roResult == "OK" && playlistview190soResult == "OK" && custom190ssResult == "OK" && discord190quResult == "OK" && trialmark190qtResult == "OK" && optionsux190qxResult == "OK" && chordlane190pfResult == "OK" && nofl190rhResult == "OK" && downgrade0132Result == "OK" && autolinks190ovResult == "OK"
+                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && backlog190rcResult == "OK" && community190riResult == "OK" && flParity190tcResult == "OK" && q1a190rwResult == "OK" && iox190rmResult == "OK" && issues190rtResult == "OK" && perf190rnResult == "OK" && perf190sbResult == "OK" && cachecheck190tgResult == "OK" && undo190spResult == "OK" && menuwindows190skResult == "OK" && issues330skResult == "OK" && audioedit190stResult == "OK" && drumsynth190syResult == "OK" && smallbugs190srResult == "OK" && quickwins190srResult == "OK" && batch292_190swResult == "OK" && round190teResult == "OK" && yannik190sqResult == "OK" && rea190taResult == "OK" && round190tiResult == "OK" && round190tnResult == "OK" && round190tpResult == "OK" && round190tkResult == "OK" && round190tmResult == "OK" && round190toResult == "OK" && batch334svResult == "OK" && details190tdResult == "OK" && qa190rbResult == "OK" && bugs190rvResult == "OK" && q6190saResult == "OK" && issue325Result == "OK" && keysheet190sjResult == "OK" && details190tbResult == "OK" && notes190tjResult == "OK" && children190thResult == "OK" && stab190rpResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && extras190roResult == "OK" && playlistview190soResult == "OK" && custom190ssResult == "OK" && discord190quResult == "OK" && trialmark190qtResult == "OK" && optionsux190qxResult == "OK" && chordlane190pfResult == "OK" && nofl190rhResult == "OK" && downgrade0132Result == "OK" && autolinks190ovResult == "OK"
                         && trackstates190opResult == "OK" && rollup031s6Result == "OK" // (round 190op's item, reported but not counted in its branch: rollup 0.1.31 step 6)
                         && rollup031s7Result == "OK" && rollup031s8Result == "OK" && rollup032Result == "OK" && headerGearResult == "OK" && perTab259Result == "OK" && slots260Result == "OK" && hotfixPlacesResult == "OK" && startPageScrollResult.startsWith ("OK") // (round 190qf: slots260) (rollup 0.1.31 step 7, round 190pw; and the three rounds' items its branches reported but did not count:)
                         && slides190piResult == "OK" && automodes190paResult == "OK" && heldSteps190ozResult == "OK"
@@ -12835,6 +12856,7 @@ private:
                << "details190td=" << details190tdResult << (details190tdResult == "OK" ? juce::String() : " | " + details190tdLog.replace ("\n", "; ")) << "\n"
                << "round190ti=" << round190tiResult << (round190tiResult == "OK" ? juce::String() : " | " + round190tiLog.replace ("\n", "; ")) << "\n"
                << "round190tn=" << round190tnResult << (round190tnResult == "OK" ? juce::String() : " | " + round190tnLog.replace ("\n", "; ")) << "\n"
+               << "round190tp=" << round190tpResult << (round190tpResult == "OK" ? juce::String() : " | " + round190tpLog.replace ("\n", "; ")) << "\n"
                << "round190tk=" << round190tkResult << (round190tkResult == "OK" ? juce::String() : " | " + round190tkLog.replace ("\n", "; ")) << "\n"
                << "round190tm=" << round190tmResult << (round190tmResult == "OK" ? juce::String() : " | " + round190tmLog.replace ("\n", "; ")) << "\n"
                << "round190to=" << round190toResult << (round190toResult == "OK" ? juce::String() : " | " + round190toLog.replace ("\n", "; ")) << "\n"
@@ -23303,6 +23325,7 @@ private:
 #include "Details190tdCheck.inc" // round 190td: undo names per layout (D2), Esc clears the selection first (D1), items 73-78
 #include "Round190tiCheck.inc" // round 190ti: Slicex's pitch automation paths, the Playlist's Add key marker
 #include "Round190tnCheck.inc" // round 190tn: the native effects' preset box and LYNX's own banks (issue #363)
+#include "Round190tpCheck.inc" // round 190tp: issues #365 / #366 (track header drag and keys, Ctrl+V of copied files)
 #include "Round190tkCheck.inc" // round 190tk: FL's automation timing for imported FL projects
 #include "Round190tmCheck.inc" // round 190tm: Reload re-reads the file, the Playlist ▾ Time markers, Song mode key markers, muted clips
 #include "Round190toCheck.inc" // round 190to: FL's per-insert effects switch, the Master's / Current column's icons, Extra large

+ 403 - 0
src/Round190tpCheck.inc

@@ -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;
+    }

ファイルの差分が大きいため隠しています
+ 0 - 0
tests/Extras190amTests.inc


+ 1 - 1
tests/KeySheet190sjTests.inc

@@ -30,7 +30,7 @@ TEST (keysheet190sj_every_sheet_key_is_a_key_map_action)
                 CHECK (map.find (c, a->context == Context::global ? Context::channelRack : a->context, false) == id);
         }
     }
-    CHECK (keyRows == 23);
+    CHECK (keyRows == 24); // (round 190tp: "Drag a track header" with Alt+Up / Alt+Down)
 }
 
 TEST (keysheet190sj_fl_keys_and_the_sheet_text)

+ 92 - 0
tests/UxTracks190tpTests.inc

@@ -0,0 +1,92 @@
+// Round 190tp (issues #365 and #366): a plain drag on a Playlist track header moves the track (LYNX extra), Alt+Up / Down
+// move the selected tracks, and Ctrl+V takes files copied in the file manager (core/OsPaste.h).
+
+#include "core/OsPaste.h"
+#include "core/TrackMoveDrag.h"
+#include "core/ExtrasDefaults.h"
+#include "core/KeyMap.h"
+
+TEST (uxtracks190tp_header_drag_rules)
+{
+    using namespace lynx;
+    // a plain press moves only with the extra on; Alt always (round 190jf); Ctrl / Shift keep FL's selections; Simple: never
+    CHECK (trackmovedrag::startsMove (false, false, false, true, false));
+    CHECK (! trackmovedrag::startsMove (false, false, false, false, false));
+    CHECK (trackmovedrag::startsMove (true, false, false, false, false));
+    CHECK (trackmovedrag::startsMove (true, false, false, true, false));
+    CHECK (! trackmovedrag::startsMove (false, true, false, true, false));
+    CHECK (! trackmovedrag::startsMove (false, false, true, true, false));
+    CHECK (! trackmovedrag::startsMove (true, true, false, true, false));
+    CHECK (! trackmovedrag::startsMove (false, false, false, true, true));
+    CHECK (! trackmovedrag::startsMove (true, false, false, true, true));
+}
+
+TEST (uxtracks190tp_extras_listed_and_on)
+{
+    using namespace lynx;
+    for (const auto* id : { "playlist.dragMovesTracks", "editing.pasteOsFiles" })
+    {
+        CHECK (std::any_of (std::begin (extras::items), std::end (extras::items), [id] (const extras::Item& i) { return i.id == id; }));
+        CHECK (extras::defaultOn (id) && ! extras::flExactOn (id) && ! extras::isVisual (id));
+    }
+    CHECK (trackmovedrag::plainDragMoves == extras::defaultOn ("playlist.dragMovesTracks"));
+    CHECK (ospaste::enabled == extras::defaultOn ("editing.pasteOsFiles"));
+}
+
+TEST (uxtracks190tp_paste_source)
+{
+    using namespace lynx::ospaste;
+    // files copied after LYNX's copy win; before it, LYNX's own clipboard; an empty LYNX clipboard takes the files
+    CHECK (choose (true, true, true, true) == Source::systemFiles);
+    CHECK (choose (true, true, true, false) == Source::lynx);
+    CHECK (choose (true, true, false, false) == Source::systemFiles);
+    CHECK (choose (true, false, false, true) == Source::lynx);
+    CHECK (choose (false, true, false, true) == Source::lynx); // (the switch off: FL's Ctrl+V)
+}
+
+TEST (uxtracks190tp_uri_lists)
+{
+    using namespace lynx::ospaste;
+    CHECK (pathOfFileUri ("file:///home/me/My%20loop.wav") == "/home/me/My loop.wav");
+    CHECK (pathOfFileUri ("file://localhost/tmp/a.wav") == "/tmp/a.wav");
+    CHECK (pathOfFileUri ("FILE:///tmp/b.wav") == "/tmp/b.wav");
+    CHECK (pathOfFileUri ("file:///C:/Samples/Kick%2001.wav") == "C:/Samples/Kick 01.wav");
+    CHECK (pathOfFileUri ("file:///tmp/%C3%A1gua.wav") == "/tmp/\xC3\xA1gua.wav"); // (UTF-8 bytes)
+    CHECK (pathOfFileUri ("http://example.com/a.wav").empty());
+    CHECK (pathOfFileUri ("file:///tmp/50%") == "/tmp/50%"); // (a lone % stays)
+
+    // text/uri-list: CRLF lines, comments
+    auto a = pathsOfText ("# copied\r\nfile:///tmp/a.wav\r\nfile:///tmp/b%20c.wav\r\n");
+    CHECK (a.size() == 2 && a[0] == "/tmp/a.wav" && a[1] == "/tmp/b c.wav");
+    // GNOME's x-special/gnome-copied-files ("copy" / "cut" first)
+    auto g = pathsOfText ("copy\nfile:///tmp/a.wav\nfile:///tmp/b.wav");
+    CHECK (g.size() == 2 && g[1] == "/tmp/b.wav");
+    CHECK (pathsOfText ("cut\nfile:///tmp/a.wav").size() == 1);
+    // plain paths (KDE's text, the Browser's "Copy the file path")
+    auto p = pathsOfText ("/tmp/a.wav\n/tmp/b.wav\n");
+    CHECK (p.size() == 2);
+    auto w = pathsOfText ("C:\\Samples\\Kick.wav\r\n\\\\server\\share\\x.wav");
+    CHECK (w.size() == 2 && w[0] == "C:\\Samples\\Kick.wav");
+    // text that is not a file list stays text
+    CHECK (pathsOfText ("hello world").empty());
+    CHECK (pathsOfText ("/tmp/a.wav\nsome words").empty());
+    CHECK (pathsOfText ("copy").empty());
+    CHECK (pathsOfText ("").empty());
+    CHECK (pathsOfText ("https://lynx-share.com/x.wav").empty());
+}
+
+TEST (uxtracks190tp_keys)
+{
+    using namespace lynx::keys;
+    const KeyMap map;
+    const auto chord = [] (int key, std::uint8_t mods) { return Chord { key, mods }; };
+    // Alt+Up / Alt+Down move the selected Playlist tracks; FL's keys around them stay
+    CHECK (map.find (chord (up, alt), Context::playlist, false) == "playlist.moveTrackUp");
+    CHECK (map.find (chord (down, alt), Context::playlist, false) == "playlist.moveTrackDown");
+    CHECK (map.find (chord (up, shift), Context::playlist, false) == "playlist.shiftUp");
+    CHECK (map.find (chord (up, alt), Context::channelRack, false) == "rack.moveUp");
+    CHECK (map.find (chord ('V', ctrl), Context::playlist, false) == "playlist.paste");
+    CHECK (map.find (chord ('V', ctrl), Context::browser, false) == "browser.paste");
+    // Import audio file... has no default key (Insert is FL's slice at the mouse in the Playlist)
+    CHECK (findAction ("file.importAudio") != nullptr && findAction ("file.importAudio")->defaults.empty());
+}

+ 1 - 0
tests/tests.cpp

@@ -18254,3 +18254,4 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Notes358_190tjTests.inc" // round 190tj (issue #358): the Notes window's texts (core/ItemNotes.h)
 #include "AutoTime190tkTests.inc" // round 190tk (0.1.33, QUEUE item 92): FL's automation timing for imported FL projects; the NewTick fix
 #include "MixFx190toTests.inc" // round 190to (0.1.33, QUEUE item 96): FL's per-insert effects switch; the Master's arm tap
+#include "UxTracks190tpTests.inc" // round 190tp (issues #365 / #366): the header drag that moves a track, Ctrl+V of copied files

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません