ScrollTests.cs 24 KB

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