FrameTests.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using NStack;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Xml.Linq;
  5. using Terminal.Gui.Graphs;
  6. using Xunit;
  7. using Xunit.Abstractions;
  8. //using GraphViewTests = Terminal.Gui.Views.GraphViewTests;
  9. // Alias Console to MockConsole so we don't accidentally use Console
  10. using Console = Terminal.Gui.FakeConsole;
  11. namespace Terminal.Gui.CoreTests {
  12. public class FrameTests {
  13. readonly ITestOutputHelper output;
  14. public FrameTests (ITestOutputHelper output)
  15. {
  16. this.output = output;
  17. }
  18. [Theory, AutoInitShutdown]
  19. [InlineData (0)]
  20. [InlineData (1)]
  21. [InlineData (2)]
  22. [InlineData (3)]
  23. public void BorderFrame_With_Title_Size_Height (int height)
  24. {
  25. var win = new Window ("1234") {
  26. Width = Dim.Fill (),
  27. Height = Dim.Fill ()
  28. };
  29. var rs = Application.Begin (win);
  30. bool firstIteration = false;
  31. ((FakeDriver)Application.Driver).SetBufferSize (20, height);
  32. Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
  33. var expected = string.Empty;
  34. switch (height) {
  35. case 0:
  36. //Assert.Equal (new Rect (0, 0, 17, 0), subview.Frame);
  37. expected = @"
  38. ";
  39. break;
  40. case 1:
  41. //Assert.Equal (new Rect (0, 0, 17, 0), subview.Frame);
  42. expected = @"
  43. ────────────────────";
  44. break;
  45. case 2:
  46. //Assert.Equal (new Rect (0, 0, 17, 1), subview.Frame);
  47. expected = @"
  48. ┌┤1234├────────────┐
  49. └──────────────────┘
  50. ";
  51. break;
  52. case 3:
  53. //Assert.Equal (new Rect (0, 0, 17, 2), subview.Frame);
  54. expected = @"
  55. ┌┤1234├────────────┐
  56. │ │
  57. └──────────────────┘
  58. ";
  59. break;
  60. }
  61. _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  62. }
  63. [Theory, AutoInitShutdown]
  64. [InlineData (0)]
  65. [InlineData (1)]
  66. [InlineData (2)]
  67. [InlineData (3)]
  68. [InlineData (4)]
  69. [InlineData (5)]
  70. [InlineData (6)]
  71. [InlineData (7)]
  72. [InlineData (8)]
  73. [InlineData (9)]
  74. [InlineData (10)]
  75. public void BorderFrame_With_Title_Size_Width (int width)
  76. {
  77. var win = new Window ("1234") {
  78. Width = Dim.Fill (),
  79. Height = Dim.Fill ()
  80. };
  81. var rs = Application.Begin (win);
  82. bool firstIteration = false;
  83. ((FakeDriver)Application.Driver).SetBufferSize (width, 3);
  84. Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
  85. var expected = string.Empty;
  86. switch (width) {
  87. case 1:
  88. //Assert.Equal (new Rect (0, 0, 17, 0), subview.Frame);
  89. expected = @"
  90. │";
  91. break;
  92. case 2:
  93. //Assert.Equal (new Rect (0, 0, 17, 1), subview.Frame);
  94. expected = @"
  95. ┌┐
  96. ││
  97. └┘";
  98. break;
  99. case 3:
  100. //Assert.Equal (new Rect (0, 0, 17, 2), subview.Frame);
  101. expected = @"
  102. ┌─┐
  103. │ │
  104. └─┘
  105. ";
  106. break;
  107. case 4:
  108. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  109. expected = @"
  110. ┌┤├┐
  111. │ │
  112. └──┘";
  113. break;
  114. case 5:
  115. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  116. expected = @"
  117. ┌┤1├┐
  118. │ │
  119. └───┘";
  120. break;
  121. case 6:
  122. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  123. expected = @"
  124. ┌┤12├┐
  125. │ │
  126. └────┘";
  127. break;
  128. case 7:
  129. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  130. expected = @"
  131. ┌┤123├┐
  132. │ │
  133. └─────┘";
  134. break;
  135. case 8:
  136. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  137. expected = @"
  138. ┌┤1234├┐
  139. │ │
  140. └──────┘";
  141. break;
  142. case 9:
  143. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  144. expected = @"
  145. ┌┤1234├─┐
  146. │ │
  147. └───────┘";
  148. break;
  149. case 10:
  150. //Assert.Equal (new Rect (0, 0, 17, 3), subview.Frame);
  151. expected = @"
  152. ┌┤1234├──┐
  153. │ │
  154. └────────┘";
  155. break;
  156. }
  157. _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  158. }
  159. }
  160. }