ScrollTests.cs 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.ViewsTests;
  3. public class ScrollTests
  4. {
  5. public ScrollTests (ITestOutputHelper output) { _output = output; }
  6. private readonly ITestOutputHelper _output;
  7. [Theory]
  8. [AutoInitShutdown]
  9. [InlineData (
  10. 20,
  11. @"
  12. ░",
  13. @"
  14. ░",
  15. @"
  16. █",
  17. @"
  18. ░",
  19. @"
  20. █████░░░░░",
  21. @"
  22. ░░█████░░░",
  23. @"
  24. ░░░░░█████",
  25. @"
  26. ░░███░░░░░")]
  27. [InlineData (
  28. 40,
  29. @"
  30. ░",
  31. @"
  32. ░",
  33. @"
  34. ░",
  35. @"
  36. ░",
  37. @"
  38. ███░░░░░░░",
  39. @"
  40. ░███░░░░░░",
  41. @"
  42. ░░███░░░░░",
  43. @"
  44. ░██░░░░░░░")]
  45. public void Changing_Position_Size_Orientation_Draws_Correctly_KeepContentInAllViewport_True (
  46. int size,
  47. string firstVertExpected,
  48. string middleVertExpected,
  49. string endVertExpected,
  50. string sizeVertExpected,
  51. string firstHoriExpected,
  52. string middleHoriExpected,
  53. string endHoriExpected,
  54. string sizeHoriExpected
  55. )
  56. {
  57. var scroll = new Scroll
  58. {
  59. Orientation = Orientation.Vertical,
  60. Size = size,
  61. Height = 10,
  62. KeepContentInAllViewport = true
  63. };
  64. var top = new Toplevel ();
  65. top.Add (scroll);
  66. Application.Begin (top);
  67. _ = TestHelpers.AssertDriverContentsWithFrameAre (firstVertExpected, _output);
  68. scroll.Position = 4;
  69. Application.Refresh ();
  70. _ = TestHelpers.AssertDriverContentsWithFrameAre (middleVertExpected, _output);
  71. scroll.Position = 10;
  72. Application.Refresh ();
  73. _ = TestHelpers.AssertDriverContentsWithFrameAre (endVertExpected, _output);
  74. scroll.Size = size * 2;
  75. Application.Refresh ();
  76. _ = TestHelpers.AssertDriverContentsWithFrameAre (sizeVertExpected, _output);
  77. scroll.Orientation = Orientation.Horizontal;
  78. scroll.Width = 10;
  79. scroll.Height = 1;
  80. scroll.Position = 0;
  81. scroll.Size = size;
  82. Application.Refresh ();
  83. _ = TestHelpers.AssertDriverContentsWithFrameAre (firstHoriExpected, _output);
  84. scroll.Position = 4;
  85. Application.Refresh ();
  86. _ = TestHelpers.AssertDriverContentsWithFrameAre (middleHoriExpected, _output);
  87. scroll.Position = 10;
  88. Application.Refresh ();
  89. _ = TestHelpers.AssertDriverContentsWithFrameAre (endHoriExpected, _output);
  90. scroll.Size = size * 2;
  91. Application.Refresh ();
  92. _ = TestHelpers.AssertDriverContentsWithFrameAre (sizeHoriExpected, _output);
  93. }
  94. [Fact]
  95. public void Constructor_Defaults ()
  96. {
  97. var scroll = new Scroll ();
  98. Assert.True (scroll.WantContinuousButtonPressed);
  99. Assert.False (scroll.CanFocus);
  100. Assert.Equal (Orientation.Vertical, scroll.Orientation);
  101. Assert.Equal (0, scroll.Size);
  102. Assert.Equal (0, scroll.Position);
  103. Assert.False (scroll.KeepContentInAllViewport);
  104. }
  105. [Fact]
  106. [AutoInitShutdown]
  107. public void KeepContentInAllViewport_True_False_KeepContentInAllViewport_True ()
  108. {
  109. var view = new View { Width = Dim.Fill (), Height = Dim.Fill () };
  110. view.Padding.Thickness = new (0, 0, 2, 0);
  111. view.SetContentSize (new (view.Viewport.Width, 30));
  112. var scroll = new Scroll { Width = 2, Height = Dim.Fill (), Size = view.GetContentSize ().Height, KeepContentInAllViewport = true };
  113. scroll.PositionChanged += (_, e) => view.Viewport = view.Viewport with { Y = e.CurrentValue };
  114. view.Padding.Add (scroll);
  115. var top = new Toplevel ();
  116. top.Add (view);
  117. Application.Begin (top);
  118. Assert.True (scroll.KeepContentInAllViewport);
  119. Assert.Equal (80, view.Padding.Viewport.Width);
  120. Assert.Equal (25, view.Padding.Viewport.Height);
  121. Assert.Equal (2, scroll.Viewport.Width);
  122. Assert.Equal (25, scroll.Viewport.Height);
  123. Assert.Equal (30, scroll.Size);
  124. scroll.KeepContentInAllViewport = false;
  125. scroll.Position = 50;
  126. Assert.Equal (scroll.Position, scroll.Size - 1);
  127. Assert.Equal (scroll.Position, view.Viewport.Y);
  128. Assert.Equal (29, scroll.Position);
  129. Assert.Equal (29, view.Viewport.Y);
  130. top.Dispose ();
  131. }
  132. [Theory]
  133. [AutoInitShutdown]
  134. [InlineData (
  135. Orientation.Vertical,
  136. 20,
  137. 10,
  138. 4,
  139. @"
  140. █",
  141. 0,
  142. @"
  143. ░")]
  144. [InlineData (
  145. Orientation.Vertical,
  146. 40,
  147. 10,
  148. 5,
  149. @"
  150. ░",
  151. 20,
  152. @"
  153. ░")]
  154. [InlineData (
  155. Orientation.Horizontal,
  156. 20,
  157. 10,
  158. 4,
  159. @"
  160. ░░░░░█████",
  161. 0,
  162. @"
  163. █████░░░░░")]
  164. [InlineData (
  165. Orientation.Horizontal,
  166. 40,
  167. 10,
  168. 5,
  169. @"
  170. ░░███░░░░░",
  171. 20,
  172. @"
  173. ░░░░░███░░")]
  174. public void Mouse_On_The_Container_KeepContentInAllViewport_True (Orientation orientation, int size, int position, int location, string output, int expectedPos, string expectedOut)
  175. {
  176. var scroll = new Scroll
  177. {
  178. Width = orientation == Orientation.Vertical ? 1 : 10,
  179. Height = orientation == Orientation.Vertical ? 10 : 1,
  180. Orientation = orientation, Size = size,
  181. Position = position,
  182. KeepContentInAllViewport = true
  183. };
  184. var top = new Toplevel ();
  185. top.Add (scroll);
  186. Application.Begin (top);
  187. _ = TestHelpers.AssertDriverContentsWithFrameAre (output, _output);
  188. Application.OnMouseEvent (
  189. new ()
  190. {
  191. Position = orientation == Orientation.Vertical ? new (0, location) : new Point (location, 0),
  192. Flags = MouseFlags.Button1Pressed
  193. });
  194. Assert.Equal (expectedPos, scroll.Position);
  195. Application.Refresh ();
  196. _ = TestHelpers.AssertDriverContentsWithFrameAre (expectedOut, _output);
  197. }
  198. [Theory]
  199. [AutoInitShutdown]
  200. [InlineData (
  201. Orientation.Vertical,
  202. 20,
  203. 10,
  204. 5,
  205. 5,
  206. @"
  207. █",
  208. MouseFlags.Button1Pressed,
  209. 10,
  210. @"
  211. █")]
  212. [InlineData (
  213. Orientation.Vertical,
  214. 40,
  215. 10,
  216. 3,
  217. 3,
  218. @"
  219. ░",
  220. MouseFlags.Button1Pressed,
  221. 10,
  222. @"
  223. ░")]
  224. [InlineData (
  225. Orientation.Horizontal,
  226. 20,
  227. 10,
  228. 5,
  229. 5,
  230. @"
  231. ░░░░░█████",
  232. MouseFlags.Button1Pressed,
  233. 10,
  234. @"
  235. ░░░░░█████")]
  236. [InlineData (
  237. Orientation.Horizontal,
  238. 40,
  239. 10,
  240. 3,
  241. 3,
  242. @"
  243. ░░███░░░░░",
  244. MouseFlags.Button1Pressed,
  245. 10,
  246. @"
  247. ░░███░░░░░")]
  248. [InlineData (
  249. Orientation.Vertical,
  250. 20,
  251. 10,
  252. 5,
  253. 4,
  254. @"
  255. █",
  256. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  257. 8,
  258. @"
  259. ░")]
  260. [InlineData (
  261. Orientation.Horizontal,
  262. 20,
  263. 10,
  264. 5,
  265. 4,
  266. @"
  267. ░░░░░█████",
  268. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  269. 8,
  270. @"
  271. ░░░░█████░")]
  272. [InlineData (
  273. Orientation.Vertical,
  274. 20,
  275. 10,
  276. 5,
  277. 6,
  278. @"
  279. █",
  280. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  281. 10,
  282. @"
  283. █")]
  284. [InlineData (
  285. Orientation.Horizontal,
  286. 20,
  287. 10,
  288. 5,
  289. 6,
  290. @"
  291. ░░░░░█████",
  292. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  293. 10,
  294. @"
  295. ░░░░░█████")]
  296. [InlineData (
  297. Orientation.Vertical,
  298. 40,
  299. 10,
  300. 2,
  301. 1,
  302. @"
  303. ░",
  304. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  305. 4,
  306. @"
  307. ░")]
  308. [InlineData (
  309. Orientation.Horizontal,
  310. 40,
  311. 10,
  312. 2,
  313. 1,
  314. @"
  315. ░░███░░░░░",
  316. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  317. 4,
  318. @"
  319. ░███░░░░░░")]
  320. [InlineData (
  321. Orientation.Vertical,
  322. 40,
  323. 10,
  324. 3,
  325. 4,
  326. @"
  327. ░",
  328. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  329. 12,
  330. @"
  331. ░")]
  332. [InlineData (
  333. Orientation.Horizontal,
  334. 40,
  335. 10,
  336. 3,
  337. 4,
  338. @"
  339. ░░███░░░░░",
  340. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  341. 12,
  342. @"
  343. ░░░███░░░░")]
  344. [InlineData (
  345. Orientation.Vertical,
  346. 40,
  347. 10,
  348. 2,
  349. 3,
  350. @"
  351. ░",
  352. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  353. 12,
  354. @"
  355. ░")]
  356. [InlineData (
  357. Orientation.Horizontal,
  358. 40,
  359. 10,
  360. 2,
  361. 3,
  362. @"
  363. ░░███░░░░░",
  364. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  365. 12,
  366. @"
  367. ░░░███░░░░")]
  368. [InlineData (
  369. Orientation.Vertical,
  370. 40,
  371. 10,
  372. 2,
  373. 4,
  374. @"
  375. ░",
  376. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  377. 16,
  378. @"
  379. ░")]
  380. [InlineData (
  381. Orientation.Horizontal,
  382. 40,
  383. 10,
  384. 2,
  385. 4,
  386. @"
  387. ░░███░░░░░",
  388. MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition,
  389. 16,
  390. @"
  391. ░░░░███░░░")]
  392. public void Mouse_On_The_Slider_KeepContentInAllViewport_True (
  393. Orientation orientation,
  394. int size,
  395. int position,
  396. int startLocation,
  397. int endLocation,
  398. string output,
  399. MouseFlags mouseFlags,
  400. int expectedPos,
  401. string expectedOut
  402. )
  403. {
  404. var scroll = new Scroll
  405. {
  406. Width = orientation == Orientation.Vertical ? 1 : 10,
  407. Height = orientation == Orientation.Vertical ? 10 : 1,
  408. Orientation = orientation,
  409. Size = size, Position = position,
  410. KeepContentInAllViewport = true
  411. };
  412. var top = new Toplevel ();
  413. top.Add (scroll);
  414. Application.Begin (top);
  415. _ = TestHelpers.AssertDriverContentsWithFrameAre (output, _output);
  416. Assert.Null (Application.MouseGrabView);
  417. if (mouseFlags.HasFlag (MouseFlags.ReportMousePosition))
  418. {
  419. MouseFlags mf = mouseFlags & ~MouseFlags.ReportMousePosition;
  420. Application.OnMouseEvent (
  421. new ()
  422. {
  423. Position = orientation == Orientation.Vertical ? new (0, startLocation) : new (startLocation, 0),
  424. Flags = mf
  425. });
  426. Application.OnMouseEvent (
  427. new ()
  428. {
  429. Position = orientation == Orientation.Vertical ? new (0, endLocation) : new (endLocation, 0),
  430. Flags = mouseFlags
  431. });
  432. }
  433. else
  434. {
  435. Assert.Equal (startLocation, endLocation);
  436. Application.OnMouseEvent (
  437. new ()
  438. {
  439. Position = orientation == Orientation.Vertical ? new (0, startLocation) : new (startLocation, 0),
  440. Flags = mouseFlags
  441. });
  442. }
  443. Assert.Equal ("scrollSlider", Application.MouseGrabView?.Id);
  444. Assert.Equal (expectedPos, scroll.Position);
  445. Application.Refresh ();
  446. _ = TestHelpers.AssertDriverContentsWithFrameAre (expectedOut, _output);
  447. Application.OnMouseEvent (
  448. new ()
  449. {
  450. Position = orientation == Orientation.Vertical ? new (0, startLocation) : new (startLocation, 0),
  451. Flags = MouseFlags.Button1Released
  452. });
  453. Assert.Null (Application.MouseGrabView);
  454. }
  455. [Theory]
  456. [AutoInitShutdown]
  457. [InlineData (Orientation.Vertical)]
  458. [InlineData (Orientation.Horizontal)]
  459. public void Moving_Mouse_Outside_Host_Ensures_Correct_Location_KeepContentInAllViewport_True (Orientation orientation)
  460. {
  461. var scroll = new Scroll
  462. {
  463. X = 10, Y = 10, Width = orientation == Orientation.Vertical ? 1 : 10, Height = orientation == Orientation.Vertical ? 10 : 1, Size = 20,
  464. Position = 5, Orientation = orientation, KeepContentInAllViewport = true
  465. };
  466. var top = new Toplevel ();
  467. top.Add (scroll);
  468. Application.Begin (top);
  469. Rectangle scrollSliderFrame = scroll.Subviews.FirstOrDefault (x => x.Id == "scrollSlider")!.Frame;
  470. Assert.Equal (scrollSliderFrame, orientation == Orientation.Vertical ? new (0, 2, 1, 5) : new (2, 0, 5, 1));
  471. Application.OnMouseEvent (new () { Position = orientation == Orientation.Vertical ? new (10, 12) : new (12, 10), Flags = MouseFlags.Button1Pressed });
  472. Application.OnMouseEvent (
  473. new ()
  474. {
  475. Position = orientation == Orientation.Vertical ? new (10, 0) : new (0, 10),
  476. Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
  477. });
  478. Assert.Equal (new (0, 0), scroll.Subviews.FirstOrDefault (x => x.Id == "scrollSlider")!.Frame.Location);
  479. Application.OnMouseEvent (
  480. new ()
  481. {
  482. Position = orientation == Orientation.Vertical ? new (0, 25) : new (80, 0),
  483. Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
  484. });
  485. Assert.Equal (
  486. orientation == Orientation.Vertical ? new (0, 5) : new (5, 0),
  487. scroll.Subviews.FirstOrDefault (x => x.Id == "scrollSlider")!.Frame.Location);
  488. }
  489. [Theory]
  490. [InlineData (Orientation.Vertical, 20, 10)]
  491. [InlineData (Orientation.Vertical, 40, 30)]
  492. public void Position_Cannot_Be_Negative_Nor_Greater_Than_Size_Minus_Frame_Length_KeepContentInAllViewport_True (Orientation orientation, int size, int expectedPos)
  493. {
  494. var scroll = new Scroll { Orientation = orientation, Height = 10, Size = size, KeepContentInAllViewport = true };
  495. Assert.Equal (0, scroll.Position);
  496. scroll.Position = -1;
  497. Assert.Equal (0, scroll.Position);
  498. scroll.Position = size;
  499. Assert.Equal (expectedPos, scroll.Position);
  500. scroll.Position = expectedPos;
  501. Assert.Equal (expectedPos, scroll.Position);
  502. }
  503. [Fact]
  504. public void PositionChanging_Cancelable_And_PositionChanged_Events ()
  505. {
  506. var changingCount = 0;
  507. var changedCount = 0;
  508. var scroll = new Scroll { Size = 10 };
  509. scroll.PositionChanging += (s, e) =>
  510. {
  511. if (changingCount == 0)
  512. {
  513. e.Cancel = true;
  514. }
  515. changingCount++;
  516. };
  517. scroll.PositionChanged += (s, e) => changedCount++;
  518. scroll.Position = 1;
  519. Assert.Equal (0, scroll.Position);
  520. Assert.Equal (1, changingCount);
  521. Assert.Equal (0, changedCount);
  522. scroll.Position = 1;
  523. Assert.Equal (1, scroll.Position);
  524. Assert.Equal (2, changingCount);
  525. Assert.Equal (1, changedCount);
  526. }
  527. [Fact]
  528. public void PositionChanging_PositionChanged_Events_Only_Raises_Once_If_Position_Was_Really_Changed_KeepContentInAllViewport_True ()
  529. {
  530. var changing = 0;
  531. var cancel = false;
  532. var changed = 0;
  533. var scroll = new Scroll { Height = 10, Size = 20, KeepContentInAllViewport = true };
  534. scroll.PositionChanging += Scroll_PositionChanging;
  535. scroll.PositionChanged += Scroll_PositionChanged;
  536. Assert.Equal (Orientation.Vertical, scroll.Orientation);
  537. Assert.Equal (new (0, 0, 1, 10), scroll.Viewport);
  538. Assert.Equal (0, scroll.Position);
  539. Assert.Equal (0, changing);
  540. Assert.Equal (0, changed);
  541. scroll.Position = 0;
  542. Assert.Equal (0, scroll.Position);
  543. Assert.Equal (0, changing);
  544. Assert.Equal (0, changed);
  545. scroll.Position = 1;
  546. Assert.Equal (1, scroll.Position);
  547. Assert.Equal (1, changing);
  548. Assert.Equal (1, changed);
  549. Reset ();
  550. cancel = true;
  551. scroll.Position = 2;
  552. Assert.Equal (1, scroll.Position);
  553. Assert.Equal (1, changing);
  554. Assert.Equal (0, changed);
  555. Reset ();
  556. scroll.Position = 10;
  557. Assert.Equal (10, scroll.Position);
  558. Assert.Equal (1, changing);
  559. Assert.Equal (1, changed);
  560. Reset ();
  561. scroll.Position = 11;
  562. Assert.Equal (10, scroll.Position);
  563. Assert.Equal (0, changing);
  564. Assert.Equal (0, changed);
  565. Reset ();
  566. scroll.Position = 0;
  567. Assert.Equal (0, scroll.Position);
  568. Assert.Equal (1, changing);
  569. Assert.Equal (1, changed);
  570. scroll.PositionChanging -= Scroll_PositionChanging;
  571. scroll.PositionChanged -= Scroll_PositionChanged;
  572. void Scroll_PositionChanging (object sender, CancelEventArgs<int> e)
  573. {
  574. changing++;
  575. e.Cancel = cancel;
  576. }
  577. void Scroll_PositionChanged (object sender, EventArgs<int> e) { changed++; }
  578. void Reset ()
  579. {
  580. changing = 0;
  581. cancel = false;
  582. changed = 0;
  583. }
  584. }
  585. [Fact]
  586. public void Size_Cannot_Be_Negative ()
  587. {
  588. var scroll = new Scroll { Height = 10, Size = -1 };
  589. Assert.Equal (0, scroll.Size);
  590. scroll.Size = -10;
  591. Assert.Equal (0, scroll.Size);
  592. }
  593. [Fact]
  594. public void SizeChanged_Event ()
  595. {
  596. var count = 0;
  597. var scroll = new Scroll ();
  598. scroll.SizeChanged += (s, e) => count++;
  599. scroll.Size = 10;
  600. Assert.Equal (10, scroll.Size);
  601. Assert.Equal (1, count);
  602. }
  603. [Theory]
  604. [AutoInitShutdown]
  605. [InlineData (
  606. 3,
  607. 10,
  608. 1,
  609. Orientation.Vertical,
  610. @"
  611. ┌─┐
  612. │█│
  613. │█│
  614. │█│
  615. │█│
  616. │░│
  617. │░│
  618. │░│
  619. │░│
  620. └─┘")]
  621. [InlineData (
  622. 10,
  623. 3,
  624. 1,
  625. Orientation.Horizontal,
  626. @"
  627. ┌────────┐
  628. │████░░░░│
  629. └────────┘")]
  630. [InlineData (
  631. 3,
  632. 10,
  633. 3,
  634. Orientation.Vertical,
  635. @"
  636. ┌───┐
  637. │███│
  638. │███│
  639. │███│
  640. │███│
  641. │░░░│
  642. │░░░│
  643. │░░░│
  644. │░░░│
  645. └───┘")]
  646. [InlineData (
  647. 10,
  648. 3,
  649. 3,
  650. Orientation.Horizontal,
  651. @"
  652. ┌────────┐
  653. │████░░░░│
  654. │████░░░░│
  655. │████░░░░│
  656. └────────┘")]
  657. public void Vertical_Horizontal_Draws_Correctly_KeepContentInAllViewport_True (int sizeWidth, int sizeHeight, int widthHeight, Orientation orientation, string expected)
  658. {
  659. var super = new Window { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
  660. var top = new Toplevel ();
  661. top.Add (super);
  662. var scroll = new Scroll
  663. {
  664. Orientation = orientation,
  665. Size = orientation == Orientation.Vertical ? sizeHeight * 2 : sizeWidth * 2,
  666. Width = orientation == Orientation.Vertical ? widthHeight : Dim.Fill (),
  667. Height = orientation == Orientation.Vertical ? Dim.Fill () : widthHeight,
  668. KeepContentInAllViewport = true
  669. };
  670. super.Add (scroll);
  671. Application.Begin (top);
  672. ((FakeDriver)Application.Driver)!.SetBufferSize (
  673. sizeWidth + (orientation == Orientation.Vertical ? widthHeight - 1 : 0),
  674. sizeHeight + (orientation == Orientation.Vertical ? 0 : widthHeight - 1));
  675. _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  676. }
  677. }