ScrollSliderTests.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. using UnitTests;
  2. using Xunit.Abstractions;
  3. namespace Terminal.Gui.ViewsTests;
  4. public class ScrollSliderTests (ITestOutputHelper output)
  5. {
  6. [Theory]
  7. [SetupFakeDriver]
  8. [InlineData (
  9. 3,
  10. 10,
  11. 1,
  12. 0,
  13. Orientation.Vertical,
  14. @"
  15. ┌───┐
  16. │███│
  17. │ │
  18. │ │
  19. │ │
  20. │ │
  21. │ │
  22. │ │
  23. │ │
  24. │ │
  25. │ │
  26. └───┘")]
  27. [InlineData (
  28. 10,
  29. 1,
  30. 3,
  31. 0,
  32. Orientation.Horizontal,
  33. @"
  34. ┌──────────┐
  35. │███ │
  36. └──────────┘")]
  37. [InlineData (
  38. 3,
  39. 10,
  40. 3,
  41. 0,
  42. Orientation.Vertical,
  43. @"
  44. ┌───┐
  45. │███│
  46. │███│
  47. │███│
  48. │ │
  49. │ │
  50. │ │
  51. │ │
  52. │ │
  53. │ │
  54. │ │
  55. └───┘")]
  56. [InlineData (
  57. 3,
  58. 10,
  59. 5,
  60. 0,
  61. Orientation.Vertical,
  62. @"
  63. ┌───┐
  64. │███│
  65. │███│
  66. │███│
  67. │███│
  68. │███│
  69. │ │
  70. │ │
  71. │ │
  72. │ │
  73. │ │
  74. └───┘")]
  75. [InlineData (
  76. 3,
  77. 10,
  78. 5,
  79. 1,
  80. Orientation.Vertical,
  81. @"
  82. ┌───┐
  83. │ │
  84. │███│
  85. │███│
  86. │███│
  87. │███│
  88. │███│
  89. │ │
  90. │ │
  91. │ │
  92. │ │
  93. └───┘")]
  94. [InlineData (
  95. 3,
  96. 10,
  97. 5,
  98. 4,
  99. Orientation.Vertical,
  100. @"
  101. ┌───┐
  102. │ │
  103. │ │
  104. │ │
  105. │ │
  106. │███│
  107. │███│
  108. │███│
  109. │███│
  110. │███│
  111. │ │
  112. └───┘")]
  113. [InlineData (
  114. 3,
  115. 10,
  116. 5,
  117. 5,
  118. Orientation.Vertical,
  119. @"
  120. ┌───┐
  121. │ │
  122. │ │
  123. │ │
  124. │ │
  125. │ │
  126. │███│
  127. │███│
  128. │███│
  129. │███│
  130. │███│
  131. └───┘")]
  132. [InlineData (
  133. 3,
  134. 10,
  135. 5,
  136. 6,
  137. Orientation.Vertical,
  138. @"
  139. ┌───┐
  140. │ │
  141. │ │
  142. │ │
  143. │ │
  144. │ │
  145. │███│
  146. │███│
  147. │███│
  148. │███│
  149. │███│
  150. └───┘")]
  151. [InlineData (
  152. 3,
  153. 10,
  154. 10,
  155. 0,
  156. Orientation.Vertical,
  157. @"
  158. ┌───┐
  159. │███│
  160. │███│
  161. │███│
  162. │███│
  163. │███│
  164. │███│
  165. │███│
  166. │███│
  167. │███│
  168. │███│
  169. └───┘")]
  170. [InlineData (
  171. 3,
  172. 10,
  173. 10,
  174. 5,
  175. Orientation.Vertical,
  176. @"
  177. ┌───┐
  178. │███│
  179. │███│
  180. │███│
  181. │███│
  182. │███│
  183. │███│
  184. │███│
  185. │███│
  186. │███│
  187. │███│
  188. └───┘")]
  189. [InlineData (
  190. 3,
  191. 10,
  192. 11,
  193. 0,
  194. Orientation.Vertical,
  195. @"
  196. ┌───┐
  197. │███│
  198. │███│
  199. │███│
  200. │███│
  201. │███│
  202. │███│
  203. │███│
  204. │███│
  205. │███│
  206. │███│
  207. └───┘")]
  208. [InlineData (
  209. 10,
  210. 3,
  211. 5,
  212. 0,
  213. Orientation.Horizontal,
  214. @"
  215. ┌──────────┐
  216. │█████ │
  217. │█████ │
  218. │█████ │
  219. └──────────┘")]
  220. [InlineData (
  221. 10,
  222. 3,
  223. 5,
  224. 1,
  225. Orientation.Horizontal,
  226. @"
  227. ┌──────────┐
  228. │ █████ │
  229. │ █████ │
  230. │ █████ │
  231. └──────────┘")]
  232. [InlineData (
  233. 10,
  234. 3,
  235. 5,
  236. 4,
  237. Orientation.Horizontal,
  238. @"
  239. ┌──────────┐
  240. │ █████ │
  241. │ █████ │
  242. │ █████ │
  243. └──────────┘")]
  244. [InlineData (
  245. 10,
  246. 3,
  247. 5,
  248. 5,
  249. Orientation.Horizontal,
  250. @"
  251. ┌──────────┐
  252. │ █████│
  253. │ █████│
  254. │ █████│
  255. └──────────┘")]
  256. [InlineData (
  257. 10,
  258. 3,
  259. 5,
  260. 6,
  261. Orientation.Horizontal,
  262. @"
  263. ┌──────────┐
  264. │ █████│
  265. │ █████│
  266. │ █████│
  267. └──────────┘")]
  268. [InlineData (
  269. 10,
  270. 3,
  271. 10,
  272. 0,
  273. Orientation.Horizontal,
  274. @"
  275. ┌──────────┐
  276. │██████████│
  277. │██████████│
  278. │██████████│
  279. └──────────┘")]
  280. [InlineData (
  281. 10,
  282. 3,
  283. 10,
  284. 5,
  285. Orientation.Horizontal,
  286. @"
  287. ┌──────────┐
  288. │██████████│
  289. │██████████│
  290. │██████████│
  291. └──────────┘")]
  292. [InlineData (
  293. 10,
  294. 3,
  295. 11,
  296. 0,
  297. Orientation.Horizontal,
  298. @"
  299. ┌──────────┐
  300. │██████████│
  301. │██████████│
  302. │██████████│
  303. └──────────┘")]
  304. public void Draws_Correctly (int superViewportWidth, int superViewportHeight, int sliderSize, int position, Orientation orientation, string expected)
  305. {
  306. var super = new Window
  307. {
  308. Id = "super",
  309. Width = superViewportWidth + 2,
  310. Height = superViewportHeight + 2
  311. };
  312. var scrollSlider = new ScrollSlider
  313. {
  314. Orientation = orientation,
  315. Size = sliderSize,
  316. //Position = position,
  317. };
  318. Assert.Equal (sliderSize, scrollSlider.Size);
  319. super.Add (scrollSlider);
  320. scrollSlider.Position = position;
  321. super.Layout ();
  322. super.Draw ();
  323. _ = DriverAssert.AssertDriverContentsWithFrameAre (expected, output);
  324. }
  325. }