SchemeTests.GetAttributeForRoleAlgorithmTests.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using Xunit;
  2. namespace Terminal.Gui.DrawingTests;
  3. public class SchemeGetAttributeForRoleAlgorithmTests
  4. {
  5. [Fact]
  6. public void Normal_Is_Always_Explicit ()
  7. {
  8. Attribute normal = new ("Red", "Blue");
  9. Scheme scheme = new (normal);
  10. Assert.NotNull (scheme.Normal);
  11. Assert.Equal (normal, scheme.GetAttributeForRole (VisualRole.Normal));
  12. }
  13. [Fact]
  14. public void Focus_Derived_From_Normal_Swaps_FgBg ()
  15. {
  16. Attribute normal = new ("Red", "Blue");
  17. Scheme scheme = new (normal);
  18. Attribute focus = scheme.GetAttributeForRole (VisualRole.Focus);
  19. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Focus, out _));
  20. Assert.Equal (normal.Background, focus.Foreground);
  21. Assert.Equal (normal.Foreground, focus.Background);
  22. }
  23. //[Fact]
  24. //public void Highlight_Derived_From_Normal_HighlightColor ()
  25. //{
  26. // Attribute normal = new ("Red", "Blue");
  27. // Scheme scheme = new (normal);
  28. // Attribute highlight = scheme.GetAttributeForRole (VisualRole.Highlight);
  29. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Highlight, out _));
  30. // Assert.Equal (normal.Background.GetHighlightColor (), highlight.Background);
  31. //}
  32. //[Fact]
  33. //public void Editable_Derived_From_Normal_LightYellow_Fg ()
  34. //{
  35. // Attribute normal = new ("Red", "Blue");
  36. // Scheme scheme = new (normal);
  37. // Attribute editable = scheme.GetAttributeForRole (VisualRole.Editable);
  38. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Editable, out _));
  39. // Assert.Equal (new Color ("LightYellow"), editable.Foreground);
  40. //}
  41. //[Fact]
  42. //public void ReadOnly_Derived_From_Editable_Italic ()
  43. //{
  44. // Attribute normal = new ("Red", "Blue");
  45. // Scheme scheme = new (normal);
  46. // Attribute readOnly = scheme.GetAttributeForRole (VisualRole.ReadOnly);
  47. // Attribute editable = scheme.GetAttributeForRole (VisualRole.Editable);
  48. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.ReadOnly, out _));
  49. // Assert.Equal (editable.Foreground, readOnly.Foreground);
  50. // Assert.True (readOnly.Style.HasFlag (TextStyle.Italic));
  51. //}
  52. //[Fact]
  53. //public void Disabled_Derived_From_Normal_Faint ()
  54. //{
  55. // Attribute normal = new ("Red", "Blue");
  56. // Scheme scheme = new (normal);
  57. // Attribute disabled = scheme.GetAttributeForRole (VisualRole.Disabled);
  58. // Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Disabled, out _));
  59. // Assert.True (disabled.Style.HasFlag (TextStyle.Faint));
  60. //}
  61. [Fact]
  62. public void Active_Derived_Correctly ()
  63. {
  64. Attribute normal = new ("Red", "Blue");
  65. Scheme scheme = new (normal);
  66. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.Active, out _));
  67. Attribute active = scheme.GetAttributeForRole (VisualRole.Active);
  68. Attribute focus = scheme.GetAttributeForRole (VisualRole.Focus);
  69. Assert.True (active.Style.HasFlag (TextStyle.Bold));
  70. //Assert.Equal (active.Foreground, focus.Foreground);
  71. //Assert.Equal (active.Background, active.Background);
  72. }
  73. [Fact]
  74. public void HotNormal_Derived_From_Normal_Underline ()
  75. {
  76. Attribute normal = new ("Red", "Blue");
  77. Scheme scheme = new (normal);
  78. Attribute hotNormal = scheme.GetAttributeForRole (VisualRole.HotNormal);
  79. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.HotNormal, out _));
  80. Assert.True (hotNormal.Style.HasFlag (TextStyle.Underline));
  81. }
  82. [Fact]
  83. public void HotFocus_Derived_From_Focus_Underline ()
  84. {
  85. Attribute normal = new ("Red", "Blue");
  86. Scheme scheme = new (normal);
  87. Attribute hotFocus = scheme.GetAttributeForRole (VisualRole.HotFocus);
  88. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.HotFocus, out _));
  89. Attribute focus = scheme.GetAttributeForRole (VisualRole.Focus);
  90. Assert.True (hotFocus.Style.HasFlag (TextStyle.Underline));
  91. Assert.Equal (focus.Foreground, hotFocus.Foreground);
  92. Assert.Equal (focus.Background, hotFocus.Background);
  93. }
  94. [Fact]
  95. public void HotActive_Derived_From_Active_Underline ()
  96. {
  97. Attribute normal = new ("Red", "Blue");
  98. Scheme scheme = new (normal);
  99. Attribute hotActive = scheme.GetAttributeForRole (VisualRole.HotActive);
  100. Assert.False (scheme.TryGetExplicitlySetAttributeForRole (VisualRole.HotActive, out _));
  101. Attribute active = scheme.GetAttributeForRole (VisualRole.Active);
  102. Assert.True (hotActive.Style.HasFlag (TextStyle.Underline));
  103. Assert.Equal (active.Foreground, hotActive.Foreground);
  104. Assert.Equal (active.Background, hotActive.Background);
  105. }
  106. }