Multilink177bTests.inc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Round 177b-4: FL's "Multilink to controllers" (core/Multilink.h): the controls moved while it is on link to the
  2. // controllers moved next, in the same order; one controller (CC and channel) per target; it ends when all are linked.
  3. TEST (multilink177b_links_in_the_order_moved)
  4. {
  5. lynx::MultilinkSession m;
  6. const lynx::AutomationTarget a { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 };
  7. const lynx::AutomationTarget b { lynx::AutomationTargetKind::mixerPan, 2, 0, 0 };
  8. const lynx::AutomationTarget c { lynx::AutomationTargetKind::tempo, 0, 0, 0 };
  9. CHECK (! m.controller (10, 0).has_value()); // nothing queued: a controller links nothing
  10. CHECK (m.add (a) && m.add (b));
  11. CHECK (! m.add (a)); // moved again: keeps its place
  12. CHECK (m.add (c));
  13. CHECK (! m.add ({})); // (no target)
  14. CHECK (m.targets.size() == 3 && ! m.complete());
  15. const auto first = m.controller (21, 0);
  16. CHECK (first && first->target == a && first->cc == 21 && first->channel == 0);
  17. CHECK (! m.controller (21, 0).has_value()); // the same knob turning on: no new link
  18. const auto second = m.controller (21, 1); // the same CC on another channel is another controller
  19. CHECK (second && second->target == b && second->channel == 1);
  20. CHECK (! m.complete());
  21. const auto third = m.controller (7, 0);
  22. CHECK (third && third->target == c && m.complete());
  23. CHECK (! m.controller (8, 0).has_value()); // all linked
  24. }
  25. TEST (multilink177b_switch_menu_and_toolbar)
  26. {
  27. // the switch's "Link to controller" / "Override global links": no more controls are queued, the controllers link
  28. lynx::MultilinkSession m;
  29. const lynx::AutomationTarget a { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 };
  30. CHECK (m.add (a));
  31. m.collecting = false;
  32. CHECK (! m.add ({ lynx::AutomationTargetKind::mixerPan, 1, 0, 0 }));
  33. const auto link = m.controller (30, 2);
  34. CHECK (link && link->target == a && m.complete());
  35. // FL keeps its MultiLinkBtn off the default toolbar; LYNX's Multilink group is hidden on a new install, after the
  36. // window shortcuts, and a toolbar saved by an older version gets it hidden in that place
  37. using namespace lynx::toolbarlayout;
  38. const auto d = Layout::makeDefault();
  39. CHECK (! d.isShown (Group::multilink) && d.isShown (Group::windows));
  40. CHECK (d.orderToString().find ("windows,-multilink,file") != std::string::npos);
  41. Layout old;
  42. old.orderFromString ("transport,master,record,snap,windows,file,chord,meters,output");
  43. CHECK (! old.isShown (Group::multilink) && old.isDefault());
  44. auto shown = d;
  45. shown.setShown (Group::multilink, true);
  46. Layout back;
  47. back.orderFromString (shown.orderToString());
  48. CHECK (back.isShown (Group::multilink) && ! back.isDefault());
  49. CHECK (matchingPreset (d) == (int) Preset::standard);
  50. // shown on request, the one-button panel outlasts the file buttons and the meters when room is short
  51. std::array<int, groupCount> widths;
  52. widths.fill (100);
  53. int shownCount = 0;
  54. for (const auto& e : shown.entries)
  55. shownCount += e.shown ? 1 : 0;
  56. const auto v = fit (shown, widths, 10, (shownCount - 1) * 110 + 300, 300);
  57. CHECK (v[(std::size_t) Group::multilink] && ! v[(std::size_t) Group::chord]);
  58. }