Rea190taCheck.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. // Round 190ta (the 0.1.33 REA gap-hunt of FL Studio 2026 and Live 12; docs/analise/COVERAGE-0.1.33-TECH.md): the small
  2. // FL-exact gaps it fixed, through the real components, off screen. Included in the app class of Main.cpp;
  3. // --rea190tatest <report> and --selftest "rea190ta".
  4. // `shots` (optional, --rea190tatest <report> <prefix>): the changed menus as pictures, <prefix>-<name>.png (@150 with
  5. // LYNX_SHOT_SCALE=1.5 LYNX_SHOT_SUFFIX=@150, as the other shot routes)
  6. juce::String rea190taCheck (juce::String& log, const juce::String& shots = {})
  7. {
  8. using namespace lynx;
  9. juce::String result = "OK";
  10. const auto check = [&] (const juce::String& what, bool ok, const juce::String& detail = {}) {
  11. log << (ok ? "ok " : "FAIL ") << what << (detail.isNotEmpty() ? " (" + detail + ")" : juce::String()) << "\n";
  12. if (! ok && result == "OK")
  13. result = "ERROR " + what;
  14. };
  15. #if JUCE_MAC
  16. // (as 190sk's checks: the selftest has no message pump on macOS)
  17. log << "skipped on macOS (the selftest has no message pump there)\n";
  18. return result;
  19. #else
  20. const auto settle = [] (int ms) {
  21. const auto end = juce::Time::getMillisecondCounter() + (juce::uint32) ms;
  22. while (juce::Time::getMillisecondCounter() < end)
  23. {
  24. for (int i = 0; i < 256 && juce::detail::dispatchNextMessageOnSystemQueue (true); ++i) {}
  25. juce::Thread::sleep (2);
  26. }
  27. };
  28. const auto closeModals = [&settle] {
  29. for (int k = 0; k < 20; ++k)
  30. if (auto* modal = juce::Component::getCurrentlyModalComponent())
  31. modal->exitModalState (0);
  32. settle (50);
  33. };
  34. // (theme::mnemonic marks the accelerator letter with \x01, core/MenuMnemonic.h)
  35. const auto plain = [] (juce::String t) { return t.upToFirstOccurrenceOf ("\t", false, false).removeCharacters ("&").removeCharacters (juce::String::charToString (1)); };
  36. // the menu's rows in order (separators as "-", headers as "#<text>"), one level
  37. const auto rows = [&plain] (const juce::PopupMenu& menu) {
  38. juce::StringArray out;
  39. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  40. {
  41. const auto& item = it.getItem();
  42. out.add (item.isSeparator ? juce::String ("-") : item.isSectionHeader ? "#" + plain (item.text) : plain (item.text));
  43. }
  44. return out;
  45. };
  46. const auto find = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu::Item* {
  47. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  48. if (plain (it.getItem().text) == text)
  49. return &it.getItem();
  50. return nullptr;
  51. };
  52. const auto run = [&find, &settle] (const juce::PopupMenu& menu, const juce::String& text) {
  53. const auto* item = find (menu, text);
  54. if (item == nullptr || item->action == nullptr || ! item->isEnabled)
  55. return false;
  56. item->action();
  57. settle (30);
  58. return true;
  59. };
  60. const auto before = [] (const juce::StringArray& list, const juce::String& a, const juce::String& b) {
  61. const auto i = list.indexOf (a), j = list.indexOf (b);
  62. return i >= 0 && j >= 0 && i < j;
  63. };
  64. const auto shootMenu = [&shots] (const juce::String& name, const juce::PopupMenu& menu) {
  65. if (shots.isNotEmpty()) // (the PNG writer adds LYNX_SHOT_SUFFIX itself, ui/ShotScale.h)
  66. saveMenus (juce::StringArray { name }, std::vector<juce::PopupMenu> { menu }, shots + "-" + name + ".png");
  67. };
  68. const auto layoutBefore = layoutstyle::current();
  69. layoutstyle::setCurrent (layoutstyle::Style::pattern);
  70. const juce::ScopedValueSetter<bool> shown (ui::showingForShots(), true);
  71. AudioEngine offline (false);
  72. {
  73. auto song = Song::makeDefault();
  74. song.patterns.resize (1);
  75. song.currentPattern = 0;
  76. const auto bar = song.barTicks();
  77. auto& p = song.patterns[0];
  78. p.lengthTicks = 8 * bar;
  79. p.notes.clear();
  80. for (int k = 0; k < 4; ++k)
  81. {
  82. Note n;
  83. n.channel = 0;
  84. n.key = 60 + k;
  85. n.start = k * bar;
  86. n.length = bar / 2;
  87. p.notes.push_back (n);
  88. }
  89. offline.setSong (std::move (song));
  90. }
  91. offline.setSelectedChannel (0);
  92. MainComponent mainUi (offline, false);
  93. mainUi.setSize (1600, 900);
  94. closeModals();
  95. const auto bar = offline.getSong().barTicks();
  96. // ---- the Piano roll's Time markers: FL's "Add one every" (after Add auto) and "Delete" (FL's EEMenu order)
  97. {
  98. auto& roll = mainUi.getPianoRollForSnapshot();
  99. roll.setBounds (0, 0, 1200, 700);
  100. settle (30);
  101. const auto marker = roll.getPatternMarkerMenuForSnapshot (-1);
  102. const auto* sub = find (marker, tr ("Time markers"));
  103. check ("PR Time markers submenu is there", sub != nullptr && sub->subMenu != nullptr);
  104. if (sub != nullptr && sub->subMenu != nullptr)
  105. {
  106. const auto& markers = *sub->subMenu;
  107. shootMenu ("pianoroll-time-markers", markers);
  108. const auto list = rows (markers);
  109. log << " Time markers: " << list.joinIntoString (" | ") << "\n";
  110. check ("PR Time markers: Add auto, Add two..., Add one every, then Add time signature change... (FL's EEMenu)",
  111. before (list, tr ("Add auto"), tr ("Add two...")) && before (list, tr ("Add two..."), tr ("Add one every"))
  112. && before (list, tr ("Add one every"), tr ("Add time signature change...")));
  113. const auto* two = find (markers, tr ("Add two..."));
  114. check ("PR Add two... is greyed without a time selection (FL)", two != nullptr && ! two->isEnabled);
  115. check ("PR Time markers: Delete after Add key marker", before (list, tr ("Add key marker"), tr ("Delete")));
  116. check ("PR Time markers: LYNX's key region and Delete all markers after FL's items",
  117. before (list, tr ("Delete"), tr ("Key region for the time selection")) && before (list, tr ("Delete"), tr ("Delete all markers")));
  118. const auto* every = find (markers, tr ("Add one every"));
  119. check ("PR Add one every lists Bar / 2 / 4 / 8 bars",
  120. every != nullptr && every->subMenu != nullptr && rows (*every->subMenu).joinIntoString ("|") == tr ("Bar") + "|" + tr ("2 bars") + "|" + tr ("4 bars") + "|" + tr ("8 bars"));
  121. if (every != nullptr && every->subMenu != nullptr)
  122. {
  123. run (*every->subMenu, tr ("2 bars"));
  124. const auto& m = offline.getSong().patterns[0].markers;
  125. check ("PR Add one every 2 bars on an 8-bar pattern: bars 1, 3, 5, 7",
  126. m.size() == 4u && m[0].tick == 0 && m[3].tick == 6 * bar && m[3].name == "7", juce::String ((int) m.size()));
  127. }
  128. roll.setTimeSelectionForTests (2 * bar, 5 * bar);
  129. const auto again = roll.getPatternMarkerMenuForSnapshot (-1);
  130. if (const auto* s2 = find (again, tr ("Time markers")); s2 != nullptr && s2->subMenu != nullptr)
  131. {
  132. shootMenu ("pianoroll-time-markers-selection", *s2->subMenu);
  133. const auto* two = find (*s2->subMenu, tr ("Add two..."));
  134. check ("PR Add two... is enabled with a time selection (FL)", two != nullptr && two->isEnabled);
  135. }
  136. if (const auto* s2 = find (again, tr ("Time markers")); s2 != nullptr && s2->subMenu != nullptr)
  137. run (*s2->subMenu, tr ("Delete"));
  138. const auto& m = offline.getSong().patterns[0].markers;
  139. check ("PR Delete with a time selection [bar 3, bar 6): only the bar 3 and 5 markers go",
  140. m.size() == 2u && m[0].tick == 0 && m[1].tick == 6 * bar, juce::String ((int) m.size()));
  141. roll.setTimeSelectionForTests (-1, -1);
  142. }
  143. // ---- the Piano roll's Select › Select time around selection / previous time / next time (Ctrl+Enter / Left / Right)
  144. roll.selectAll();
  145. settle (30);
  146. {
  147. shootMenu ("pianoroll-select", roll.selectMenuForSnapshot());
  148. const auto list = rows (roll.selectMenuForSnapshot());
  149. check ("PR Select: Invert selection, then Select time around / previous / next time",
  150. before (list, tr ("Invert selection"), tr ("Select time around selection")) && before (list, tr ("Select time around selection"), tr ("Select previous time"))
  151. && before (list, tr ("Select previous time"), tr ("Select next time")),
  152. list.joinIntoString (" | "));
  153. }
  154. check ("PR Ctrl+Enter is the key map's pianoRoll.selectTimeAround",
  155. keys::findAction ("pianoRoll.selectTimeAround") != nullptr && keys::findAction ("pianoRoll.timeNext") != nullptr);
  156. roll.runAction ("pianoRoll.selectTimeAround");
  157. const auto span = roll.timeSelectionForTests();
  158. check ("PR Select time around selection: the notes' span [0, 3.5 bars)", span.first == 0 && span.second == 3 * bar + bar / 2,
  159. juce::String (span.first) + ".." + juce::String (span.second));
  160. roll.runAction ("pianoRoll.timeNext");
  161. const auto next = roll.timeSelectionForTests();
  162. check ("PR Select next time: moved by its own length", next.first == 3 * bar + bar / 2 && next.second == 7 * bar);
  163. roll.runAction ("pianoRoll.timePrevious");
  164. roll.runAction ("pianoRoll.timePrevious");
  165. check ("PR Select previous time stops at the pattern's start", roll.timeSelectionForTests().first == 0);
  166. roll.runAction ("pianoRoll.selectTimeAround");
  167. check ("PR the same span again clears the time selection", roll.timeSelectionForTests().first < 0);
  168. }
  169. // ---- the chord progression tool: FL's MultiSelMenu on a chord of a selection of several
  170. {
  171. ChordToolState state;
  172. state.strip.blocks.resize (3);
  173. for (auto& b : state.strip.blocks)
  174. b.chord.intervals = { 0, 4, 7 };
  175. state.selected = { 0, 1 };
  176. ChordStripView strip (offline, state, 0);
  177. strip.setBounds (0, 0, 600, 80);
  178. const auto multi = strip.chordMenuForSnapshot (1);
  179. shootMenu ("chord-multiple-selection", multi);
  180. const auto list = rows (multi);
  181. check ("chord tool: a chord of a selection of two opens FL's \"Multiple selection\" menu",
  182. ! list.isEmpty() && list[0] == "#" + tr ("Multiple selection") && list.contains (tr ("Unlock")), list.joinIntoString (" | "));
  183. if (const auto* t = find (multi, tr ("Transpose")); t != nullptr && t->subMenu != nullptr)
  184. run (*t->subMenu, tr ("One semitone up"));
  185. check ("chord tool: Transpose › One semitone up moves both selected chords, not the third",
  186. state.strip.blocks[0].transpose == 1 && state.strip.blocks[1].transpose == 1 && state.strip.blocks[2].transpose == 0);
  187. run (multi, tr ("Lock"));
  188. check ("chord tool: Lock locks both", state.strip.blocks[0].locked && state.strip.blocks[1].locked && ! state.strip.blocks[2].locked);
  189. state.selected = { 2 };
  190. const auto one = rows (strip.chordMenuForSnapshot (2));
  191. check ("chord tool: one selected chord keeps the chord menu", ! one.isEmpty() && one[0] != "#" + tr ("Multiple selection"));
  192. }
  193. // ---- the Channel rack menu (FL's SSMenu): Color selected / Mute / Unmute selected, swing mix, the mixer tracks
  194. {
  195. {
  196. auto s = offline.getSong();
  197. while (s.channels.size() < 3)
  198. s.channels.push_back (s.channels.front());
  199. s.channels[0].mixerTrack = 2;
  200. s.channels[1].mixerTrack = 5;
  201. s.channels[2].mixerTrack = 5;
  202. s.channels[0].group = 0;
  203. if (s.channelGroups.empty())
  204. s.channelGroups.push_back ("Drums");
  205. offline.setSong (std::move (s));
  206. settle (30);
  207. }
  208. offline.setChannelSelection ({ 0, 1 }, 0);
  209. settle (30);
  210. const auto menu = mainUi.rackMenuForSnapshot();
  211. shootMenu ("channel-rack-menu", menu);
  212. const auto list = rows (menu);
  213. check ("rack menu: Group selected..., Color selected, Mute selected, Unmute selected, Transpose selected... (FL's order)",
  214. before (list, tr ("Group selected..."), tr ("Color selected")) && before (list, tr ("Color selected"), tr ("Mute selected"))
  215. && before (list, tr ("Mute selected"), tr ("Unmute selected")) && before (list, tr ("Unmute selected"), tr ("Transpose selected...")),
  216. list.joinIntoString (" | "));
  217. check ("rack menu: Set swing mix for selected, then Select mixer tracks for the selected channels",
  218. before (list, tr ("Transpose selected..."), tr ("Set swing mix for selected"))
  219. && before (list, tr ("Set swing mix for selected"), tr ("Select mixer tracks for the selected channels")));
  220. if (const auto* colours = find (menu, tr ("Color selected")); colours != nullptr && colours->subMenu != nullptr)
  221. check ("rack menu: Color selected › Gradient... / Random / All...", rows (*colours->subMenu).joinIntoString ("|") == tr ("Gradient...") + "|" + tr ("Random") + "|" + tr ("All..."));
  222. run (menu, tr ("Mute selected"));
  223. const auto& c = offline.getSong().channels;
  224. check ("rack menu: Mute selected mutes the two selected channels only", c[0].muted && c[1].muted && ! c[2].muted);
  225. run (mainUi.rackMenuForSnapshot(), tr ("Unmute selected"));
  226. check ("rack menu: Unmute selected", ! offline.getSong().channels[0].muted && ! offline.getSong().channels[1].muted);
  227. const auto swingMenu = mainUi.rackMenuForSnapshot(); // (kept: the items found point into it)
  228. if (const auto* swing = find (swingMenu, tr ("Set swing mix for selected")); swing != nullptr && swing->subMenu != nullptr)
  229. {
  230. run (*swing->subMenu, "25%");
  231. check ("rack menu: Set swing mix for selected › 25%", std::abs (offline.getSong().channels[0].swingMix - 0.25f) < 1.0e-6f
  232. && std::abs (offline.getSong().channels[1].swingMix - 0.25f) < 1.0e-6f
  233. && std::abs (offline.getSong().channels[2].swingMix - 0.25f) > 0.1f);
  234. }
  235. const auto colourMenu = mainUi.rackMenuForSnapshot();
  236. if (const auto* colours = find (colourMenu, tr ("Color selected")); colours != nullptr && colours->subMenu != nullptr)
  237. {
  238. run (*colours->subMenu, tr ("Random"));
  239. check ("rack menu: Color selected › Random colours the selected channels", offline.getSong().channels[0].colour != 0 && offline.getSong().channels[1].colour != 0);
  240. }
  241. run (mainUi.rackMenuForSnapshot(), tr ("Select mixer tracks for the selected channels"));
  242. check ("rack menu: Select mixer tracks for the selected channels selects inserts 2 and 5",
  243. mainUi.getMixerForSnapshot().getStripsForSnapshot().getSelection() == std::vector<int> { 2, 5 });
  244. // (no "Ungroup selected..." in the channel menu: FL 2026 shows none of its group items there, live check
  245. // 11-30 raw/fl-channel-menu-2sel.png; the filter menu's "Move selected channels to" holds it)
  246. shootMenu ("channel-menu", mainUi.getRackForSnapshot().getChannelMenuForSnapshot (0));
  247. check ("channel menu: no Ungroup selected... (FL 2026 shows none)", ! rows (mainUi.getRackForSnapshot().getChannelMenuForSnapshot (0)).contains (tr ("Ungroup selected...")));
  248. }
  249. // ---- the Browser: FL's sample menu "Open in new ... channel" items, the options menu's Search / Navigation history /
  250. // Actions / Structure sections, Ctrl+Up "Collapse structure"
  251. {
  252. auto& browser = mainUi.getBrowserForSnapshot();
  253. const auto root = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-rea190ta-" + juce::String (juce::Random::getSystemRandom().nextInt (1 << 30)));
  254. root.createDirectory();
  255. const auto wav = root.getChildFile ("tone.wav");
  256. {
  257. juce::WavAudioFormat format;
  258. std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
  259. if (out != nullptr)
  260. if (std::unique_ptr<juce::AudioFormatWriter> w (format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0)); w != nullptr)
  261. {
  262. out.release();
  263. juce::AudioBuffer<float> b (1, 4410);
  264. b.clear();
  265. w->writeFromAudioSampleBuffer (b, 0, b.getNumSamples());
  266. }
  267. }
  268. shootMenu ("browser-sample-menu", browser.buildFileMenu (wav));
  269. const auto fileMenu = rows (browser.buildFileMenu (wav));
  270. check ("Browser sample menu: Open in new sampler / Fruity Granulizer / Fruity Slicer / Slicex channel, after the audio editor",
  271. before (fileMenu, tr ("Edit in the audio editor..."), tr ("Open in new sampler channel"))
  272. && before (fileMenu, tr ("Open in new sampler channel"), tr ("Open in new Fruity Granulizer channel"))
  273. && before (fileMenu, tr ("Open in new Fruity Slicer channel"), tr ("Open in new Slicex channel")),
  274. fileMenu.joinIntoString (" | "));
  275. const auto channelsBefore = offline.getSong().channels.size();
  276. run (browser.buildFileMenu (wav), tr ("Open in new Fruity Slicer channel"));
  277. settle (200);
  278. const auto& chs = offline.getSong().channels;
  279. check ("Browser sample menu: Open in new Fruity Slicer channel adds a Fruity Slicer channel",
  280. chs.size() == channelsBefore + 1 && chs.back().instrument == InstrumentKind::fruityslicer);
  281. closeModals();
  282. shootMenu ("browser-options-menu", browser.buildViewMenu());
  283. const auto view = rows (browser.buildViewMenu());
  284. check ("Browser options menu: FL's Search, Navigation history, Actions and Structure sections first",
  285. view.size() > 12 && view[0] == "#" + tr ("Search") && view[1] == tr ("Find previous") && view[2] == tr ("Find next")
  286. && view[3] == "#" + tr ("Navigation history") && view[6] == "#" + tr ("Actions") && view[9] == "#" + tr ("Structure")
  287. && view[10] == tr ("Collapse structure"),
  288. view.joinIntoString (" | "));
  289. {
  290. const auto options = browser.buildViewMenu();
  291. const auto* previous = find (options, tr ("Find previous"));
  292. check ("Browser options menu: Find previous / next greyed without a search (as FL's)", previous != nullptr && ! previous->isEnabled);
  293. }
  294. const auto* collapse = keys::findAction ("browser.collapseAll");
  295. check ("Browser: Ctrl+Up is the key map's browser.collapseAll (FL's \"Ctrl+Up Collapse structure\")",
  296. collapse != nullptr && ! collapse->defaults.empty() && collapse->defaults.front().key == keys::up && collapse->defaults.front().mods == keys::ctrl);
  297. root.deleteRecursively();
  298. }
  299. // ---- the time display's menu and the mixer track menu as pictures (FL 2026 live references raw/fl-time-menu.png,
  300. // raw/fl-mixer-track-menu.png)
  301. {
  302. const auto timeMenu = mainUi.getTimeDisplayForSnapshot().buildMenu();
  303. shootMenu ("time-display-menu", timeMenu);
  304. const auto list = rows (timeMenu);
  305. check ("time display menu: FL's SMPTE 120 fps last of the rates", list.contains ("SMPTE 120 fps") && list.indexOf ("SMPTE 120 fps") == list.indexOf ("SMPTE 72 fps") + 1,
  306. list.joinIntoString (" | "));
  307. shootMenu ("mixer-track-menu", mainUi.getMixerForSnapshot().getStripsForSnapshot().buildMenu (1));
  308. }
  309. // ---- the time display: FL's 13 SMPTE rates with FL's words
  310. check ("time display: FL's SMPTE 120 fps, appended (old indexes stay)", timecode::rateCount == 13 && timecode::menuLabel (12) == "SMPTE 120 fps" && timecode::menuLabel (5) == "SMPTE 30 fps");
  311. check ("time display: FL's \"SMPTE 29.97 fps (drop)\" / \"SMPTE 29.97 (non-drop)\"",
  312. timecode::menuLabel (3) == "SMPTE 29.97 fps (drop)" && timecode::menuLabel (4) == "SMPTE 29.97 (non-drop)" && timecode::menuLabel (9) == "SMPTE 59.94 (non-drop)");
  313. // ---- the tempo tapper's Apply tempo is remembered (FL 25.2.5)
  314. {
  315. const auto was = tempoTapperApplyTempo();
  316. tempoTapperApplyTempo() = false;
  317. auto tapper = makeTempoTapperForSnapshot (offline, 0, 120.0);
  318. juce::ToggleButton* apply = nullptr;
  319. for (auto* child : tapper->getChildren())
  320. if (auto* t = dynamic_cast<juce::ToggleButton*> (child); t != nullptr && t->getButtonText() == tr ("Apply tempo"))
  321. apply = t;
  322. check ("tempo tapper: Apply tempo opens as it was left (off)", apply != nullptr && ! apply->getToggleState());
  323. if (apply != nullptr)
  324. apply->triggerClick();
  325. settle (30);
  326. check ("tempo tapper: ticking it is remembered", tempoTapperApplyTempo());
  327. tempoTapperApplyTempo() = was;
  328. }
  329. // ---- the Clip-launch clip menu: Live's "Select on Launch (Pref)" last
  330. {
  331. const auto was = clipGridSelectOnLaunch();
  332. check ("clip grid: Select on Launch is on by default (as LYNX always selected)", was);
  333. clipGridSelectOnLaunch() = was;
  334. }
  335. mainUi.setVisible (false);
  336. closeModals();
  337. layoutstyle::setCurrent (layoutBefore);
  338. return result;
  339. #endif
  340. }