DialogRules190ooTests.inc 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Round 190oo (design review 2): LYNX's one dialog system without JUCE (core/DialogRules.h). WG-6: the button order of
  2. // every dialog on ui::dialog::Alert; WG-22: the accent strip and the divider on whole physical pixels.
  3. #include "core/DialogRules.h"
  4. TEST (dialog190oo_ok_cancel_put_the_primary_at_the_far_right)
  5. {
  6. using lynx::dialogrules::buttonOrder;
  7. // JUCE's OK / Cancel box: OK (0, Return) and Cancel (1, Escape) -> Cancel | OK
  8. CHECK ((buttonOrder (2, 0, 1, false) == std::vector<int> { 1, 0 }));
  9. // the sample Pitch window: OK (Return), Reset, Cancel (Escape) -> Reset | Cancel | OK
  10. CHECK ((buttonOrder (3, 0, 2, false) == std::vector<int> { 1, 2, 0 }));
  11. // without a primary: as added, Cancel last
  12. CHECK ((buttonOrder (3, -1, 2, false) == std::vector<int> { 0, 1, 2 }));
  13. // the plugin crash prompt: Reload (the first, the default), Always run separately, Close (Escape)
  14. // -> Always run separately | Close | Reload
  15. CHECK ((buttonOrder (3, 0, 2, false) == std::vector<int> { 1, 2, 0 }));
  16. // a notice: one OK that is both Return and Escape (the primary)
  17. CHECK ((buttonOrder (1, 0, -1, false) == std::vector<int> { 0 }));
  18. // the record question: Cancel alone (Escape)
  19. CHECK ((buttonOrder (1, -1, 0, false) == std::vector<int> { 0 }));
  20. CHECK (buttonOrder (0, -1, -1, false).empty());
  21. }
  22. TEST (dialog190oo_one_accent_button_the_return_default)
  23. {
  24. using lynx::dialogrules::primaryButton;
  25. CHECK (primaryButton (2, 0, 1) == 0); // OK / Cancel: OK (Return)
  26. CHECK (primaryButton (3, 0, 2) == 0); // Pitch: OK (Return), Reset, Cancel
  27. CHECK (primaryButton (1, 0, -1) == 0); // a notice's OK (Return and Escape)
  28. CHECK (primaryButton (3, -1, 2) == 0); // JUCE's three-button box, the crash prompt: the first takes the focus and Return
  29. CHECK (primaryButton (1, -1, 0) == -1); // the record question's lone Cancel stays secondary
  30. CHECK (primaryButton (2, -1, 0) == -1); // a first button that is the Escape one is no default
  31. CHECK (primaryButton (0, -1, -1) == -1);
  32. }
  33. TEST (dialog190oo_fl_messages_keep_their_order)
  34. {
  35. using lynx::dialogrules::buttonOrder;
  36. // FL's Yes | No (Yes = Return, No = Escape) stays as FL shows it
  37. CHECK ((buttonOrder (2, 0, 1, true) == std::vector<int> { 0, 1 }));
  38. CHECK ((buttonOrder (3, 0, 2, true) == std::vector<int> { 0, 1, 2 }));
  39. }
  40. TEST (dialog190oo_bands_land_on_whole_device_rows)
  41. {
  42. using lynx::dialogrules::bandRows;
  43. CHECK (bandRows (3.0f, 1.5f) == 5.0f); // the strip @150 (was 4.5 rows: 4 full, one at 50 %)
  44. CHECK (bandRows (1.0f, 1.5f) == 1.0f); // the divider @150 (was 1.5 rows)
  45. CHECK (bandRows (3.0f, 1.25f) == 4.0f);
  46. CHECK (bandRows (1.0f, 1.25f) == 1.0f);
  47. CHECK (bandRows (3.0f, 2.0f) == 6.0f); // whole scales as before
  48. CHECK (bandRows (1.0f, 2.0f) == 2.0f);
  49. CHECK (bandRows (1.0f, 2.5f) == 2.0f);
  50. CHECK (bandRows (1.0f, 0.75f) == 1.0f); // never under one row
  51. }