LayoutStyle184aTests.inc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // --- Round 184a: the three layout styles (core/LayoutStyle.h): Pattern (default), Clip-launch and Simple workflow.
  2. #include "core/LayoutStyle.h"
  3. TEST (simple184a_layout_style_ids_round_trip)
  4. {
  5. using namespace lynx::layoutstyle;
  6. for (auto s : { Style::pattern, Style::clipLaunch, Style::simple })
  7. {
  8. CHECK (fromId (id (s)) == s);
  9. CHECK (fromComboId (comboId (s)) == s);
  10. }
  11. CHECK (std::string (id (Style::pattern)) == "pattern");
  12. CHECK (std::string (id (Style::clipLaunch)) == "clipLaunch");
  13. CHECK (std::string (id (Style::simple)) == "simple");
  14. // unknown or empty: the default, so a settings file from a newer version opens in Pattern workflow
  15. CHECK (fromId ("") == Style::pattern);
  16. CHECK (fromId ("somethingNew") == Style::pattern);
  17. CHECK (fromComboId (0) == Style::pattern);
  18. CHECK (fromComboId (9) == Style::pattern);
  19. CHECK (comboId (Style::pattern) == 1 && comboId (Style::clipLaunch) == 2 && comboId (Style::simple) == 3); // 181a's ids kept
  20. }
  21. TEST (simple184a_layout_style_workspace_files)
  22. {
  23. using namespace lynx::layoutstyle;
  24. // round 181a's two file names are kept, so the users' saved layouts still load
  25. CHECK (std::string (workspaceFile (Style::pattern)) == "workspace-pattern.txt");
  26. CHECK (std::string (workspaceFile (Style::clipLaunch)) == "workspace-cliplaunch.txt");
  27. CHECK (std::string (workspaceFile (Style::simple)) == "workspace-simple.txt");
  28. }
  29. TEST (simple184a_layout_style_settings_keys)
  30. {
  31. using namespace lynx::layoutstyle;
  32. // a 181a settings file: only the old key
  33. {
  34. SettingsReader r;
  35. r.legacyFlag (true);
  36. CHECK (r.style == Style::clipLaunch);
  37. }
  38. {
  39. SettingsReader r;
  40. CHECK (r.style == Style::pattern); // nothing saved: the default
  41. r.legacyFlag (false);
  42. CHECK (r.style == Style::pattern);
  43. }
  44. // both keys, in either order: "layoutStyle" wins
  45. {
  46. SettingsReader r;
  47. r.legacyFlag (false);
  48. r.styleId ("simple");
  49. CHECK (r.style == Style::simple);
  50. }
  51. {
  52. SettingsReader r;
  53. r.styleId ("simple");
  54. r.legacyFlag (false); // written as 0 for Simple, so an older version opens Pattern workflow
  55. CHECK (r.style == Style::simple);
  56. }
  57. {
  58. SettingsReader r;
  59. r.styleId ("clipLaunch");
  60. r.legacyFlag (true);
  61. CHECK (r.style == Style::clipLaunch);
  62. }
  63. // what is written for the old key
  64. CHECK (legacyClipLaunchFlag (Style::clipLaunch));
  65. CHECK (! legacyClipLaunchFlag (Style::simple));
  66. CHECK (! legacyClipLaunchFlag (Style::pattern));
  67. }