FrameTests.cs 3.9 KB

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