|
|
@@ -0,0 +1,471 @@
|
|
|
+ // Round 190sj (issue #327, 0.1.32). Included in the app class of Main.cpp; --keysheet190sjtest <report> and --selftest
|
|
|
+ // "keysheet190sj". Every key of the F1 shortcut sheet (keys::sheet::rows) is pressed in the main window
|
|
|
+ // (MainComponent::keyPressed, as a key the system delivers) with the panel it belongs to focused, the typing keyboard off
|
|
|
+ // and on: the action the key map gives it there must be the one that runs (seen by MainComponent::actionFilterForCheck,
|
|
|
+ // which keeps file choosers and dialogs from opening). A General key is pressed with every panel focused; where a panel
|
|
|
+ // has its own action on it (FL's Ctrl+T in the Playlist and the Piano roll: Add auto marker) that one must run. Then the
|
|
|
+ // keys the issue named do what they say, a remapped key moves with its action, and the sheet shows the remapped key.
|
|
|
+ juce::String keySheet190sjCheck (juce::String& log)
|
|
|
+ {
|
|
|
+ using namespace lynx;
|
|
|
+ using Panel = 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 (! ok && result == "OK")
|
|
|
+ result = "ERROR " + what + " " + detail;
|
|
|
+ };
|
|
|
+ struct Keep
|
|
|
+ {
|
|
|
+ layoutstyle::Style was = layoutstyle::current();
|
|
|
+ ~Keep()
|
|
|
+ {
|
|
|
+ layoutstyle::setCurrent (was);
|
|
|
+ MainComponent::actionFilterForCheck = nullptr;
|
|
|
+ }
|
|
|
+ } keep;
|
|
|
+
|
|
|
+ AudioEngine offline (false);
|
|
|
+ MainComponent ui (offline, false);
|
|
|
+ ui.setSize (1600, 900);
|
|
|
+ ui.setLayoutStyle (layoutstyle::Style::pattern);
|
|
|
+ const auto settle = [&] {
|
|
|
+ for (int k = 0; k < 3; ++k)
|
|
|
+ offline.dispatchPendingMessages();
|
|
|
+ };
|
|
|
+ settle();
|
|
|
+ ui.showPanelsForSnapshot ({ Panel::playlist, Panel::channelRack, Panel::pianoRoll, Panel::mixer, Panel::browser });
|
|
|
+ settle();
|
|
|
+ const auto focus = [&] (Panel p) {
|
|
|
+ ui.workspaceForTest().activate (p);
|
|
|
+ settle();
|
|
|
+ };
|
|
|
+ // a key as JUCE hands it over: letters by their upper-case code, the others by JUCE's key codes
|
|
|
+ const auto keyPressOf = [] (const keys::Chord& c) {
|
|
|
+ int code = c.key;
|
|
|
+ struct Pair { int key, juce; };
|
|
|
+ static const Pair specials[] = {
|
|
|
+ { keys::space, juce::KeyPress::spaceKey }, { keys::enter, juce::KeyPress::returnKey }, { keys::escape, juce::KeyPress::escapeKey },
|
|
|
+ { keys::tab, juce::KeyPress::tabKey }, { keys::backspace, juce::KeyPress::backspaceKey }, { keys::del, juce::KeyPress::deleteKey },
|
|
|
+ { keys::insert, juce::KeyPress::insertKey }, { keys::up, juce::KeyPress::upKey }, { keys::down, juce::KeyPress::downKey },
|
|
|
+ { keys::left, juce::KeyPress::leftKey }, { keys::right, juce::KeyPress::rightKey }, { keys::pageUp, juce::KeyPress::pageUpKey },
|
|
|
+ { keys::pageDown, juce::KeyPress::pageDownKey }, { keys::home, juce::KeyPress::homeKey }, { keys::end, juce::KeyPress::endKey },
|
|
|
+ { keys::numpadPlus, juce::KeyPress::numberPadAdd }, { keys::numpadMinus, juce::KeyPress::numberPadSubtract },
|
|
|
+ { keys::numpadMultiply, juce::KeyPress::numberPadMultiply }, { keys::numpadDivide, juce::KeyPress::numberPadDivide },
|
|
|
+ };
|
|
|
+ for (const auto& p : specials)
|
|
|
+ if (p.key == c.key)
|
|
|
+ code = p.juce;
|
|
|
+ if (c.key >= keys::f1 && c.key <= keys::f12)
|
|
|
+ code = juce::KeyPress::F1Key + (c.key - keys::f1);
|
|
|
+ const auto mods = ((c.mods & keys::ctrl) ? juce::ModifierKeys::commandModifier : 0) | ((c.mods & keys::shift) ? juce::ModifierKeys::shiftModifier : 0)
|
|
|
+ | ((c.mods & keys::alt) ? juce::ModifierKeys::altModifier : 0);
|
|
|
+ const auto character = c.key > ' ' && c.key < 0x7f && (c.mods & (keys::ctrl | keys::alt)) == 0 ? (juce::juce_wchar) c.key : (juce::juce_wchar) 0;
|
|
|
+ return juce::KeyPress (code, juce::ModifierKeys (mods), character);
|
|
|
+ };
|
|
|
+ const auto contextOf = [] (Panel p) {
|
|
|
+ return p == Panel::playlist ? keys::Context::playlist : p == Panel::channelRack ? keys::Context::channelRack
|
|
|
+ : p == Panel::pianoRoll ? keys::Context::pianoRoll : p == Panel::mixer ? keys::Context::mixer : keys::Context::browser;
|
|
|
+ };
|
|
|
+ const auto panelName = [] (Panel p) {
|
|
|
+ return juce::String (p == Panel::playlist ? "Playlist" : p == Panel::channelRack ? "Channel rack" : p == Panel::pianoRoll ? "Piano roll"
|
|
|
+ : p == Panel::mixer ? "Mixer" : "Browser");
|
|
|
+ };
|
|
|
+ const auto& map = ui.getKeyMapForSnapshot();
|
|
|
+
|
|
|
+ // 1. every key of the sheet, dry (the action is seen, not run)
|
|
|
+ std::vector<std::string> ran;
|
|
|
+ MainComponent::actionFilterForCheck = [&ran] (const std::string& id) {
|
|
|
+ ran.push_back (id);
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ int pressed = 0, rowsWithKeys = 0;
|
|
|
+ std::set<std::string> panelOwn; // a General key that a focused panel uses for its own action
|
|
|
+ for (const auto piano : { false, true })
|
|
|
+ {
|
|
|
+ ui.setTypingPianoForTest (piano);
|
|
|
+ for (const auto& row : keys::sheet::rows())
|
|
|
+ {
|
|
|
+ if (row.actions.empty())
|
|
|
+ {
|
|
|
+ check (juce::String ("a row without keys is a mouse row: ") + row.gesture, juce::String (row.gesture).isNotEmpty());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ++rowsWithKeys;
|
|
|
+ const auto ctx = keys::sheet::sectionContext (row.section);
|
|
|
+ for (const auto& id : keys::sheet::shownActions (row, map))
|
|
|
+ {
|
|
|
+ const auto* action = keys::findAction (id);
|
|
|
+ check (juce::String ("the sheet's action exists: ") + id, action != nullptr);
|
|
|
+ if (action == nullptr)
|
|
|
+ continue;
|
|
|
+ check (juce::String (id) + " has a key", ! map.chordsFor (id).empty());
|
|
|
+ check (juce::String (id) + " belongs to its section's panel", action->context == ctx || action->context == keys::Context::global);
|
|
|
+ const auto panels = action->context == keys::Context::global
|
|
|
+ ? std::vector<Panel> { Panel::channelRack, Panel::mixer, Panel::browser, Panel::playlist, Panel::pianoRoll }
|
|
|
+ : std::vector<Panel> { action->context == keys::Context::pianoRoll ? Panel::pianoRoll
|
|
|
+ : action->context == keys::Context::playlist ? Panel::playlist : Panel::channelRack };
|
|
|
+ for (const auto& chord : map.chordsFor (id))
|
|
|
+ {
|
|
|
+ // the typing keyboard on: a plain letter / digit is its (a note, or nothing), unless the action works then
|
|
|
+ const auto plain = (chord.mods & (keys::ctrl | keys::alt | keys::shift)) == 0 && chord.isPrintable();
|
|
|
+ if (piano && plain && (! action->whilePiano || keys::typingPianoKey (chord.key, keys::typingpiano::defaultOctave, 0, keys::typingpiano::pianoLayout()).taken))
|
|
|
+ continue;
|
|
|
+ for (const auto p : panels)
|
|
|
+ {
|
|
|
+ focus (p);
|
|
|
+ const auto expected = map.find (chord, contextOf (p), piano);
|
|
|
+ ran.clear();
|
|
|
+ ui.keyPressed (keyPressOf (chord));
|
|
|
+ settle();
|
|
|
+ ++pressed;
|
|
|
+ const auto got = ran.empty() ? std::string ("(nothing)") : ran.front();
|
|
|
+ const auto what = juce::String (keys::toString (chord)) + " (" + id + "), " + panelName (p) + " focused, typing keyboard "
|
|
|
+ + (piano ? "on" : "off");
|
|
|
+ check (what + " runs " + expected, got == expected, got);
|
|
|
+ if (expected != id)
|
|
|
+ {
|
|
|
+ log << " (that panel's own key: " << expected << ")\n";
|
|
|
+ panelOwn.insert (id + " @ " + panelName (p).toStdString() + " = " + expected);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MainComponent::actionFilterForCheck = nullptr;
|
|
|
+ log << " " << pressed << " key presses, " << rowsWithKeys << " rows with keys\n";
|
|
|
+ // the General keys a panel keeps for itself, all FL's: Ctrl+T in the Playlist / Piano roll (Add auto marker, REA 168t2),
|
|
|
+ // Ctrl+Shift+S in the Mixer (Save the mixer track state), Enter in the Browser (load the selected file)
|
|
|
+ {
|
|
|
+ const std::set<std::string> known { "view.typingPiano @ Playlist = playlist.markerAuto", "view.typingPiano @ Piano roll = pianoRoll.markerAuto",
|
|
|
+ "file.saveAs @ Mixer = mixer.saveTrackState", "panel.maximisePlaylist @ Browser = browser.load" };
|
|
|
+ juce::String got;
|
|
|
+ for (const auto& k : panelOwn)
|
|
|
+ got << k << "; ";
|
|
|
+ check ("the General keys a panel takes for itself are FL's (and only those)", panelOwn == known, got);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. what the issue named, run for real
|
|
|
+ ui.setTypingPianoForTest (false);
|
|
|
+ for (const auto p : { Panel::channelRack, Panel::mixer, Panel::browser })
|
|
|
+ {
|
|
|
+ focus (p);
|
|
|
+ ui.keyPressed (juce::KeyPress ('T', juce::ModifierKeys::commandModifier, 0));
|
|
|
+ settle();
|
|
|
+ check ("Ctrl+T switches the typing keyboard on, " + panelName (p) + " focused", ui.typingPianoForCheck());
|
|
|
+ ui.keyPressed (juce::KeyPress ('T', juce::ModifierKeys::commandModifier, 0));
|
|
|
+ settle();
|
|
|
+ check ("Ctrl+T switches it off again, " + panelName (p) + " focused", ! ui.typingPianoForCheck());
|
|
|
+ }
|
|
|
+ {
|
|
|
+ focus (Panel::playlist);
|
|
|
+ const auto markers = offline.getSong().markers().size();
|
|
|
+ ui.keyPressed (juce::KeyPress ('T', juce::ModifierKeys::commandModifier, 0));
|
|
|
+ settle();
|
|
|
+ check ("Ctrl+T with the Playlist focused adds an Auto time marker, as FL (REA 168t2)",
|
|
|
+ offline.getSong().markers().size() == markers + 1 && ! ui.typingPianoForCheck());
|
|
|
+ }
|
|
|
+ const auto channel = offline.getSelectedChannel();
|
|
|
+ offline.editSong ([channel] (Song& s) {
|
|
|
+ auto& pat = s.patterns[(std::size_t) s.currentPattern];
|
|
|
+ pat.notes.clear();
|
|
|
+ for (int i = 0; i < 3; ++i)
|
|
|
+ {
|
|
|
+ Note n;
|
|
|
+ n.channel = channel;
|
|
|
+ n.key = 60 + 2 * i;
|
|
|
+ n.start = i * ppq;
|
|
|
+ n.length = ppq / 2;
|
|
|
+ pat.notes.push_back (n);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ settle();
|
|
|
+ focus (Panel::pianoRoll);
|
|
|
+ auto& roll = ui.getPianoRollForSnapshot();
|
|
|
+ const auto firstKey = [&] { return offline.getSong().patterns[(std::size_t) offline.getSong().currentPattern].notes.front().key; };
|
|
|
+ const auto firstStart = [&] { return offline.getSong().patterns[(std::size_t) offline.getSong().currentPattern].notes.front().start; };
|
|
|
+ ui.keyPressed (juce::KeyPress ('A', juce::ModifierKeys::commandModifier, 0));
|
|
|
+ settle();
|
|
|
+ check ("Piano roll: Ctrl+A selects every note", roll.selectionForTests().size() == 3, juce::String ((int) roll.selectionForTests().size()));
|
|
|
+ struct Move
|
|
|
+ {
|
|
|
+ const char* name;
|
|
|
+ int code, mods, keys, steps;
|
|
|
+ };
|
|
|
+ const auto cmd = juce::ModifierKeys::commandModifier, shift = juce::ModifierKeys::shiftModifier;
|
|
|
+ for (const auto& m : { Move { "Shift+Up", juce::KeyPress::upKey, shift, 1, 0 }, Move { "Shift+Down", juce::KeyPress::downKey, shift, -1, 0 },
|
|
|
+ Move { "Ctrl+Up", juce::KeyPress::upKey, cmd, 12, 0 }, Move { "Ctrl+Down", juce::KeyPress::downKey, cmd, -12, 0 },
|
|
|
+ Move { "Shift+Right", juce::KeyPress::rightKey, shift, 0, 1 }, Move { "Shift+Left", juce::KeyPress::leftKey, shift, 0, -1 } })
|
|
|
+ {
|
|
|
+ const auto key = firstKey();
|
|
|
+ const auto start = firstStart();
|
|
|
+ ui.keyPressed (juce::KeyPress (m.code, juce::ModifierKeys (m.mods), 0));
|
|
|
+ settle();
|
|
|
+ check (juce::String ("Piano roll: ") + m.name + " moves the selected notes", firstKey() == key + m.keys
|
|
|
+ && firstStart() == start + m.steps * roll.gridTicksForSnapshot(),
|
|
|
+ juce::String (key) + " -> " + juce::String (firstKey()));
|
|
|
+ }
|
|
|
+ ui.keyPressed (juce::KeyPress ('D', juce::ModifierKeys::commandModifier, 0));
|
|
|
+ settle();
|
|
|
+ check ("Piano roll: Ctrl+D deselects", roll.selectionForTests().empty());
|
|
|
+ {
|
|
|
+ const auto key = firstKey();
|
|
|
+ ui.keyPressed (juce::KeyPress (juce::KeyPress::upKey, juce::ModifierKeys (shift), 0));
|
|
|
+ settle();
|
|
|
+ check ("Piano roll: Shift+Up with nothing selected moves nothing", firstKey() == key);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. remapped: the octave on Alt+Shift+Up, in Manage shortcuts' map; Ctrl+Up no longer moves; the sheet says so
|
|
|
+ ui.keyMapForCheck().setChords ("pianoRoll.octaveUp", { keys::Chord { keys::up, (std::uint8_t) (keys::alt | keys::shift) } });
|
|
|
+ roll.setSelectionForSnapshot ({ 0, 1, 2 });
|
|
|
+ {
|
|
|
+ const auto key = firstKey();
|
|
|
+ ui.keyPressed (juce::KeyPress (juce::KeyPress::upKey, juce::ModifierKeys (cmd), 0));
|
|
|
+ settle();
|
|
|
+ check ("remapped: Ctrl+Up no longer transposes", firstKey() == key);
|
|
|
+ ui.keyPressed (juce::KeyPress (juce::KeyPress::upKey, juce::ModifierKeys (juce::ModifierKeys::altModifier | shift), 0));
|
|
|
+ settle();
|
|
|
+ check ("remapped: Alt+Shift+Up transposes an octave", firstKey() == key + 12);
|
|
|
+ const auto& rows = keys::sheet::rows();
|
|
|
+ const auto octave = std::find_if (rows.begin(), rows.end(), [] (const keys::sheet::Row& r) {
|
|
|
+ return ! r.actions.empty() && r.actions.front() == "pianoRoll.octaveUp";
|
|
|
+ });
|
|
|
+ const auto text = octave == rows.end() ? std::string() : keys::sheet::keysText (*octave, ui.getKeyMapForSnapshot(), modmap::Os::windows);
|
|
|
+ check ("the sheet shows the remapped key", text == "Shift+Alt+Up / Ctrl+Down", text);
|
|
|
+ }
|
|
|
+ ui.keyMapForCheck().resetToDefaults();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ // --keyroute190sjtest report.txt (round 190sj, issue #327): the same keys as the user presses them, in a window. Each step
|
|
|
+ // clicks as the system would (through the native window under the point) and presses the key where the system sends it
|
|
|
+ // (Windows: posted to the window with the system's focus, the modifiers in the thread's keyboard state; elsewhere the
|
|
|
+ // focused component's native window). Shows a window (Windows: GUI lock).
|
|
|
+ void runKeyRoute190sj (const juce::String& reportPath)
|
|
|
+ {
|
|
|
+ juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
|
|
|
+
|
|
|
+ struct RouteTest final : juce::Timer
|
|
|
+ {
|
|
|
+ juce::String reportPath, report;
|
|
|
+ bool ok = true;
|
|
|
+ int stepIndex = 0;
|
|
|
+ std::unique_ptr<lynx::AudioEngine> engine;
|
|
|
+ lynx::MainComponent* ui = nullptr;
|
|
|
+ std::unique_ptr<juce::DocumentWindow> main;
|
|
|
+ std::function<void()> done;
|
|
|
+
|
|
|
+ void line (const juce::String& text)
|
|
|
+ {
|
|
|
+ report << text << "\n";
|
|
|
+ juce::File (reportPath).replaceWithText (report);
|
|
|
+ }
|
|
|
+ void check (const juce::String& what, bool passed, const juce::String& detail = {})
|
|
|
+ {
|
|
|
+ line ((passed ? "ok " : "FAIL ") + what + (detail.isNotEmpty() ? " [" + detail + "]" : juce::String()));
|
|
|
+ ok = ok && passed;
|
|
|
+ }
|
|
|
+ static juce::String describe (juce::Component* c)
|
|
|
+ {
|
|
|
+ if (c == nullptr)
|
|
|
+ return "nothing";
|
|
|
+ juce::String path;
|
|
|
+ for (auto* p = c; p != nullptr && path.length() < 160; p = p->getParentComponent())
|
|
|
+ {
|
|
|
+ auto name = p->getComponentID().isNotEmpty() ? p->getComponentID() : p->getName();
|
|
|
+ if (name.isEmpty())
|
|
|
+ name = juce::String (typeid (*p).name()).fromLastOccurrenceOf ("::", false, false).substring (0, 28);
|
|
|
+ path << (path.isEmpty() ? "" : " < ") << name;
|
|
|
+ }
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+ void click (juce::Component& c, juce::Point<int> local, juce::ModifierKeys mods = {})
|
|
|
+ {
|
|
|
+ auto* peer = c.getPeer();
|
|
|
+ if (peer == nullptr)
|
|
|
+ {
|
|
|
+ line (" (no native window for the click)");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const auto at = peer->getComponent().getLocalPoint (&c, local.toFloat());
|
|
|
+ line (" click at " + local.toString() + " -> " + describe (peer->getComponent().getComponentAt (at.roundToInt())));
|
|
|
+ const auto now = juce::Time::currentTimeMillis();
|
|
|
+ peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, mods.withFlags (juce::ModifierKeys::leftButtonModifier), 1.0f, 0.0f, now);
|
|
|
+ peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, mods, 1.0f, 0.0f, now + 40);
|
|
|
+ }
|
|
|
+ // a key where the system sends it
|
|
|
+ void press (int code, int mods, juce::juce_wchar character = 0)
|
|
|
+ {
|
|
|
+ const juce::ModifierKeys m (mods);
|
|
|
+ #if JUCE_WINDOWS
|
|
|
+ int vk = code;
|
|
|
+ if (code == juce::KeyPress::upKey) vk = 0x26; // (VK_UP)
|
|
|
+ else if (code == juce::KeyPress::downKey) vk = 0x28; // (VK_DOWN)
|
|
|
+ else if (code == juce::KeyPress::leftKey) vk = 0x25; // (VK_LEFT)
|
|
|
+ else if (code == juce::KeyPress::rightKey) vk = 0x27; // (VK_RIGHT)
|
|
|
+ else if (code >= 'a' && code <= 'z') vk = code - 'a' + 'A';
|
|
|
+ if (lynx::nativechild::pressKeyForTest (main->getWindowHandle(), vk, m.isCtrlDown(), m.isShiftDown(), m.isAltDown()))
|
|
|
+ return;
|
|
|
+ #endif
|
|
|
+ auto* focused = juce::Component::getCurrentlyFocusedComponent();
|
|
|
+ auto* peer = focused != nullptr && focused->getPeer() != nullptr ? focused->getPeer() : main->getPeer();
|
|
|
+ juce::ModifierKeys::currentModifiers = m;
|
|
|
+ if (peer != nullptr)
|
|
|
+ peer->handleKeyPress (juce::KeyPress (code, m, character));
|
|
|
+ juce::ModifierKeys::currentModifiers = {};
|
|
|
+ }
|
|
|
+ juce::String keysNow() const
|
|
|
+ {
|
|
|
+ juce::String k;
|
|
|
+ const auto& s = engine->getSong();
|
|
|
+ for (const auto& n : s.patterns[(std::size_t) s.currentPattern].notes)
|
|
|
+ k << n.key << " ";
|
|
|
+ return k.trim();
|
|
|
+ }
|
|
|
+ void transposeCase (const juce::String& after)
|
|
|
+ {
|
|
|
+ auto& roll = ui->getPianoRollForSnapshot();
|
|
|
+ line (" keys at: " + describe (juce::Component::getCurrentlyFocusedComponent()) + ", panel focus "
|
|
|
+ + juce::String ((int) ui->workspaceForTest().getFocused()));
|
|
|
+ press ('A', juce::ModifierKeys::commandModifier, 'a');
|
|
|
+ check ("Ctrl+A selects the notes (" + after + ")", roll.selectionForTests().size() == 3, juce::String ((int) roll.selectionForTests().size()));
|
|
|
+ struct Step
|
|
|
+ {
|
|
|
+ const char* name;
|
|
|
+ int code, mods, delta;
|
|
|
+ };
|
|
|
+ for (const auto& s : { Step { "Shift+Up", juce::KeyPress::upKey, juce::ModifierKeys::shiftModifier, 1 },
|
|
|
+ Step { "Shift+Down", juce::KeyPress::downKey, juce::ModifierKeys::shiftModifier, -1 },
|
|
|
+ Step { "Ctrl+Up", juce::KeyPress::upKey, juce::ModifierKeys::commandModifier, 12 },
|
|
|
+ Step { "Ctrl+Down", juce::KeyPress::downKey, juce::ModifierKeys::commandModifier, -12 } })
|
|
|
+ {
|
|
|
+ const auto before = engine->getSong().patterns[(std::size_t) engine->getSong().currentPattern].notes.front().key;
|
|
|
+ const auto text = keysNow();
|
|
|
+ press (s.code, s.mods);
|
|
|
+ const auto now = engine->getSong().patterns[(std::size_t) engine->getSong().currentPattern].notes.front().key;
|
|
|
+ check (juce::String (s.name) + " moves the selected notes (" + after + ")", now == before + s.delta, text + " -> " + keysNow());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void timerCallback() override
|
|
|
+ {
|
|
|
+ auto& roll = ui->getPianoRollForSnapshot();
|
|
|
+ switch (stepIndex++)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ ui->setLayoutStyle (lynx::layoutstyle::Style::pattern);
|
|
|
+ const auto channel = engine->getSelectedChannel();
|
|
|
+ engine->editSong ([channel] (lynx::Song& s) {
|
|
|
+ auto& pat = s.patterns[(std::size_t) s.currentPattern];
|
|
|
+ pat.notes.clear();
|
|
|
+ for (int i = 0; i < 3; ++i)
|
|
|
+ {
|
|
|
+ lynx::Note n;
|
|
|
+ n.channel = channel;
|
|
|
+ n.key = 60 + 2 * i;
|
|
|
+ n.start = i * lynx::ppq;
|
|
|
+ n.length = lynx::ppq / 2;
|
|
|
+ pat.notes.push_back (n);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ui->setTypingPianoForTest (false);
|
|
|
+ ui->grabKeyboardFocus();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 1:
|
|
|
+ if (! ui->workspaceForTest().isPanelVisible (lynx::workspace::Panel::pianoRoll))
|
|
|
+ ui->runActionForSnapshot ("panel.pianoRoll");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+ check ("the Piano roll shows", roll.isShowing());
|
|
|
+ const auto grid = roll.gridAreaForSnapshot();
|
|
|
+ click (roll, { grid.getRight() - 30, grid.getBottom() - 30 }); // (an empty spot: no note made, Draw tool)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 3:
|
|
|
+ engine->editSong ([] (lynx::Song& s) { // (the click may have drawn a note: the three are kept)
|
|
|
+ auto& notes = s.patterns[(std::size_t) s.currentPattern].notes;
|
|
|
+ if (notes.size() > 3)
|
|
|
+ notes.resize (3);
|
|
|
+ });
|
|
|
+ transposeCase ("after a click in the Piano roll");
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ {
|
|
|
+ // the Browser's search box clicked, then the Piano roll again
|
|
|
+ juce::TextEditor* field = nullptr;
|
|
|
+ std::function<void (juce::Component&)> look = [&] (juce::Component& c) {
|
|
|
+ if (auto* t = dynamic_cast<juce::TextEditor*> (&c); t != nullptr && t->isShowing() && field == nullptr)
|
|
|
+ field = t;
|
|
|
+ for (auto* child : c.getChildren())
|
|
|
+ look (*child);
|
|
|
+ };
|
|
|
+ look (ui->getBrowserForSnapshot());
|
|
|
+ line (" Browser search box found=" + juce::String ((int) (field != nullptr)));
|
|
|
+ if (field != nullptr)
|
|
|
+ click (*field, field->getLocalBounds().getCentre());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 5:
|
|
|
+ {
|
|
|
+ const auto grid = roll.gridAreaForSnapshot();
|
|
|
+ click (roll, { grid.getRight() - 30, grid.getBottom() - 30 });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 6:
|
|
|
+ engine->editSong ([] (lynx::Song& s) {
|
|
|
+ auto& notes = s.patterns[(std::size_t) s.currentPattern].notes;
|
|
|
+ if (notes.size() > 3)
|
|
|
+ notes.resize (3);
|
|
|
+ });
|
|
|
+ transposeCase ("after a click in the Browser's search box, then the Piano roll");
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ {
|
|
|
+ // Ctrl+T after a click in each panel
|
|
|
+ using Panel = lynx::workspace::Panel;
|
|
|
+ for (const auto p : { Panel::channelRack, Panel::playlist, Panel::pianoRoll })
|
|
|
+ {
|
|
|
+ juce::Component* c = p == Panel::pianoRoll ? (juce::Component*) &roll
|
|
|
+ : p == Panel::playlist ? (juce::Component*) &ui->getPlaylistForSnapshot()
|
|
|
+ : nullptr;
|
|
|
+ if (p == Panel::channelRack)
|
|
|
+ ui->workspaceForTest().activate (p);
|
|
|
+ else if (c != nullptr && c->isShowing())
|
|
|
+ click (*c, { c->getWidth() - 40, c->getHeight() - 40 });
|
|
|
+ const auto before = ui->typingPianoForCheck();
|
|
|
+ const auto markers = engine->getSong().markers().size();
|
|
|
+ press ('T', juce::ModifierKeys::commandModifier, 't');
|
|
|
+ line (" Ctrl+T, panel " + juce::String ((int) p) + " focused (" + juce::String ((int) ui->workspaceForTest().getFocused())
|
|
|
+ + "): typing keyboard " + juce::String ((int) before) + " -> " + juce::String ((int) ui->typingPianoForCheck())
|
|
|
+ + ", song markers " + juce::String ((int) markers) + " -> " + juce::String ((int) engine->getSong().markers().size()));
|
|
|
+ if (ui->typingPianoForCheck() != before)
|
|
|
+ ui->setTypingPianoForTest (before);
|
|
|
+ }
|
|
|
+ finish();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void finish()
|
|
|
+ {
|
|
|
+ line (ok ? "result=OK" : "result=FAILED");
|
|
|
+ stopTimer();
|
|
|
+ done();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ auto* test = new RouteTest();
|
|
|
+ test->reportPath = reportPath;
|
|
|
+ startFocusTestWindow (*test);
|
|
|
+ #if JUCE_WINDOWS
|
|
|
+ test->main->setAlwaysOnTop (true);
|
|
|
+ #endif
|
|
|
+ test->startTimer (700);
|
|
|
+ }
|