FirstRun167vTests.inc 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Round 167v: the first-run window layout (a fresh LYNX SHARE opened with the Channel Rack covering the Playlist on
  2. // small/scaled screens, and the Browser over the Playlist after a restart). Included at the end of tests.cpp.
  3. TEST (firstrun167v_default_rack_leaves_the_track_names_visible)
  4. {
  5. using namespace lynx::workspace;
  6. // desktops of a maximized/88 % window at 1366x768 and 1920x1080 with 100/125/150 % Windows scaling
  7. for (const auto& [w, h] : std::vector<std::pair<int, int>> { { 945, 440 }, { 1093, 520 }, { 1186, 540 }, { 1280, 600 }, { 1350, 600 },
  8. { 1690, 820 }, { 1920, 960 }, { 2560, 1340 } })
  9. {
  10. const auto l = Layout::makeDefault (w, h);
  11. const auto browser = l[Panel::browser].bounds, playlist = l[Panel::playlist].bounds, rack = l[Panel::channelRack].bounds;
  12. CHECK (browser.x == 0 && playlist.x == browser.right() && playlist.right() == w); // the Playlist fills the rest
  13. CHECK (rack.right() <= w - 16 && rack.bottom() <= h && rack.w >= rackMinWidth && rack.w <= rackMaxWidth);
  14. CHECK (rack.x >= browser.right() + playlistHeaderWidth); // the pattern picker and track names stay in view
  15. CHECK (l.focused == Panel::channelRack && l[Panel::channelRack].visible && ! l[Panel::mixer].visible && ! l[Panel::pianoRoll].visible);
  16. if (w >= 1690)
  17. CHECK (rack.w == rackMaxWidth); // a big desktop: the usual width
  18. }
  19. // a desktop too small for that: the rack keeps a usable width and stays on the desktop
  20. const auto tiny = Layout::makeDefault (780, 400);
  21. CHECK (tiny[Panel::channelRack].bounds.w >= rackMinWidth - 64 && tiny[Panel::channelRack].bounds.right() <= 780);
  22. }
  23. TEST (firstrun167v_browser_and_playlist_stay_side_by_side)
  24. {
  25. using namespace lynx::workspace;
  26. // a layout moved by hand (not the pristine default) scaled down past the Browser's minimum width and back up:
  27. // the Browser used to keep 220 px while the Playlist's left edge scaled, covering its pattern picker
  28. auto l = Layout::makeDefault (1690, 820);
  29. l[Panel::channelRack].bounds.x += 30;
  30. for (const auto& [w, h] : std::vector<std::pair<int, int>> { { 1180, 560 }, { 900, 420 }, { 1690, 820 }, { 2560, 1340 } })
  31. {
  32. l.resize (w, h);
  33. CHECK (l[Panel::playlist].bounds.x == l[Panel::browser].bounds.right() && l[Panel::playlist].bounds.right() == w);
  34. }
  35. // a Playlist undocked by hand stays where the user put it
  36. auto u = Layout::makeDefault (1690, 820);
  37. u[Panel::playlist].bounds = { 600, 100, 800, 500 };
  38. u.resize (1180, 560);
  39. CHECK (u[Panel::playlist].bounds.x != u[Panel::browser].bounds.right());
  40. }
  41. TEST (firstrun167v_saved_layout_with_the_browser_over_the_playlist_is_repaired)
  42. {
  43. using namespace lynx::workspace;
  44. // workspace.txt as 0.1.21 saved it on a first run (Windows, 1705x947 window): Browser 0.1865 wide, Playlist at 0.1545
  45. const std::string saved = "lynx-layout 1\n"
  46. "panel playlist 1 0 0 0.15453 0.00000 0.84547 1.00000 0 0 0 0\n"
  47. "panel channelRack 1 0 0 0.30787 0.04621 0.39372 0.26185 0 0 0 0\n"
  48. "panel pianoRoll 0 0 0 0.17288 0.03791 0.80876 0.46919 0 0 0 0\n"
  49. "panel mixer 0 0 0 0.15867 0.51777 0.83600 0.47393 0 0 0 0\n"
  50. "panel browser 1 0 0 0.00000 0.00000 0.18650 1.00000 0 0 0 0\n"
  51. "order playlist browser mixer pianoRoll channelRack\n"
  52. "focus channelRack\n";
  53. for (const auto& [w, h] : std::vector<std::pair<int, int>> { { 1180, 560 }, { 1690, 820 } })
  54. {
  55. const auto l = Layout::parse (saved, w, h);
  56. CHECK (l.has_value());
  57. if (! l)
  58. continue;
  59. CHECK ((*l)[Panel::playlist].bounds.x == (*l)[Panel::browser].bounds.right() && (*l)[Panel::playlist].bounds.right() == w);
  60. CHECK ((*l)[Panel::channelRack].visible && l->focused == Panel::channelRack);
  61. }
  62. // a sound layout reads back unchanged at the size it was saved at
  63. const auto fresh = Layout::makeDefault (1690, 820);
  64. const auto again = Layout::parse (fresh.serialise(), 1690, 820);
  65. CHECK (again.has_value() && (*again)[Panel::playlist].bounds == fresh[Panel::playlist].bounds
  66. && (*again)[Panel::browser].bounds == fresh[Panel::browser].bounds);
  67. }