ScrollBarViewTests.cs 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Reflection;
  5. using Xunit;
  6. using Xunit.Abstractions;
  7. namespace Terminal.Gui.ViewsTests {
  8. public class ScrollBarViewTests {
  9. readonly ITestOutputHelper output;
  10. public ScrollBarViewTests (ITestOutputHelper output)
  11. {
  12. this.output = output;
  13. }
  14. [Fact, AutoInitShutdown]
  15. public void Horizontal_Default_Draws_Correctly ()
  16. {
  17. var width = 40;
  18. var height = 3;
  19. var super = new Window () { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
  20. Application.Top.Add (super);
  21. var sbv = new ScrollBarView () {
  22. Id = "sbv",
  23. Size = width * 2,
  24. // BUGBUG: ScrollBarView should work if Host is null
  25. Host = super,
  26. ShowScrollIndicator = true,
  27. };
  28. super.Add (sbv);
  29. Application.Begin (Application.Top);
  30. ((FakeDriver)Application.Driver).SetBufferSize (width, height);
  31. var expected = @"
  32. ┌──────────────────────────────────────┐
  33. │◄├────────────────┤░░░░░░░░░░░░░░░░░░►│
  34. └──────────────────────────────────────┘";
  35. _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  36. }
  37. [Fact, AutoInitShutdown]
  38. public void Vertical_Default_Draws_Correctly ()
  39. {
  40. var width = 3;
  41. var height = 40;
  42. var super = new Window () { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
  43. Application.Top.Add (super);
  44. var sbv = new ScrollBarView () {
  45. Id = "sbv",
  46. Size = height * 2,
  47. // BUGBUG: ScrollBarView should work if Host is null
  48. Host = super,
  49. ShowScrollIndicator = true,
  50. IsVertical = true
  51. };
  52. super.Add (sbv);
  53. Application.Begin (Application.Top);
  54. ((FakeDriver)Application.Driver).SetBufferSize (width, height);
  55. var expected = @"
  56. ┌─┐
  57. │▲│
  58. │┬│
  59. │││
  60. │││
  61. │││
  62. │││
  63. │││
  64. │││
  65. │││
  66. │││
  67. │││
  68. │││
  69. │││
  70. │││
  71. │││
  72. │││
  73. │││
  74. │││
  75. │┴│
  76. │░│
  77. │░│
  78. │░│
  79. │░│
  80. │░│
  81. │░│
  82. │░│
  83. │░│
  84. │░│
  85. │░│
  86. │░│
  87. │░│
  88. │░│
  89. │░│
  90. │░│
  91. │░│
  92. │░│
  93. │░│
  94. │▼│
  95. └─┘";
  96. _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  97. }
  98. [Fact, AutoInitShutdown]
  99. public void Both_Default_Draws_Correctly ()
  100. {
  101. var width = 3;
  102. var height = 40;
  103. var super = new Window () { Id = "super", Width = Dim.Fill (), Height = Dim.Fill () };
  104. Application.Top.Add (super);
  105. var horiz = new ScrollBarView () {
  106. Id = "horiz",
  107. Size = width * 2,
  108. // BUGBUG: ScrollBarView should work if Host is null
  109. Host = super,
  110. ShowScrollIndicator = true,
  111. IsVertical = true
  112. };
  113. super.Add (horiz);
  114. var vert = new ScrollBarView () {
  115. Id = "vert",
  116. Size = height * 2,
  117. // BUGBUG: ScrollBarView should work if Host is null
  118. Host = super,
  119. ShowScrollIndicator = true,
  120. IsVertical = true
  121. };
  122. super.Add (vert);
  123. Application.Begin (Application.Top);
  124. ((FakeDriver)Application.Driver).SetBufferSize (width, height);
  125. var expected = @"
  126. ┌─┐
  127. │▲│
  128. │┬│
  129. │││
  130. │││
  131. │││
  132. │││
  133. │││
  134. │││
  135. │││
  136. │││
  137. │││
  138. │││
  139. │││
  140. │││
  141. │││
  142. │││
  143. │││
  144. │││
  145. │┴│
  146. │░│
  147. │░│
  148. │░│
  149. │░│
  150. │░│
  151. │░│
  152. │░│
  153. │░│
  154. │░│
  155. │░│
  156. │░│
  157. │░│
  158. │░│
  159. │░│
  160. │░│
  161. │░│
  162. │░│
  163. │░│
  164. │▼│
  165. └─┘";
  166. _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  167. }
  168. // This class enables test functions annotated with the [InitShutdown] attribute
  169. // to have a function called before the test function is called and after.
  170. //
  171. // This is necessary because a) Application is a singleton and Init/Shutdown must be called
  172. // as a pair, and b) all unit test functions should be atomic.
  173. [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
  174. public class ScrollBarAutoInitShutdownAttribute : AutoInitShutdownAttribute {
  175. public override void Before (MethodInfo methodUnderTest)
  176. {
  177. base.Before (methodUnderTest);
  178. ScrollBarViewTests._hostView = new HostView () {
  179. Width = Dim.Fill (),
  180. Height = Dim.Fill (),
  181. Top = 0,
  182. Lines = 30,
  183. Left = 0,
  184. Cols = 100
  185. };
  186. Application.Top.Add (ScrollBarViewTests._hostView);
  187. }
  188. public override void After (MethodInfo methodUnderTest)
  189. {
  190. ScrollBarViewTests._hostView = null;
  191. base.After (methodUnderTest);
  192. }
  193. }
  194. public class HostView : View {
  195. public int Top { get; set; }
  196. public int Lines { get; set; }
  197. public int Left { get; set; }
  198. public int Cols { get; set; }
  199. }
  200. private static HostView _hostView;
  201. private ScrollBarView _scrollBar;
  202. private bool _added;
  203. private void AddHandlers ()
  204. {
  205. if (!_added) {
  206. _hostView.DrawContent += _hostView_DrawContent;
  207. _scrollBar.ChangedPosition += _scrollBar_ChangedPosition;
  208. _scrollBar.OtherScrollBarView.ChangedPosition += _scrollBar_OtherScrollBarView_ChangedPosition;
  209. }
  210. _added = true;
  211. }
  212. private void RemoveHandlers ()
  213. {
  214. if (_added) {
  215. _hostView.DrawContent -= _hostView_DrawContent;
  216. _scrollBar.ChangedPosition -= _scrollBar_ChangedPosition;
  217. _scrollBar.OtherScrollBarView.ChangedPosition -= _scrollBar_OtherScrollBarView_ChangedPosition;
  218. }
  219. _added = false;
  220. }
  221. private void _hostView_DrawContent (object sender, DrawEventArgs e)
  222. {
  223. _scrollBar.Size = _hostView.Lines;
  224. _scrollBar.Position = _hostView.Top;
  225. _scrollBar.OtherScrollBarView.Size = _hostView.Cols;
  226. _scrollBar.OtherScrollBarView.Position = _hostView.Left;
  227. _scrollBar.Refresh ();
  228. }
  229. private void _scrollBar_ChangedPosition (object sender, EventArgs e)
  230. {
  231. _hostView.Top = _scrollBar.Position;
  232. if (_hostView.Top != _scrollBar.Position) {
  233. _scrollBar.Position = _hostView.Top;
  234. }
  235. _hostView.SetNeedsDisplay ();
  236. }
  237. private void _scrollBar_OtherScrollBarView_ChangedPosition (object sender, EventArgs e)
  238. {
  239. _hostView.Left = _scrollBar.OtherScrollBarView.Position;
  240. if (_hostView.Left != _scrollBar.OtherScrollBarView.Position) {
  241. _scrollBar.OtherScrollBarView.Position = _hostView.Left;
  242. }
  243. _hostView.SetNeedsDisplay ();
  244. }
  245. [Fact]
  246. [ScrollBarAutoInitShutdown]
  247. public void Hosting_A_Null_View_To_A_ScrollBarView_Throws_ArgumentNullException ()
  248. {
  249. Assert.Throws<ArgumentNullException> ("The host parameter can't be null.",
  250. () => new ScrollBarView (null, true));
  251. Assert.Throws<ArgumentNullException> ("The host parameter can't be null.",
  252. () => new ScrollBarView (null, false));
  253. }
  254. [Fact]
  255. [ScrollBarAutoInitShutdown]
  256. public void Hosting_A_Null_SuperView_View_To_A_ScrollBarView_Throws_ArgumentNullException ()
  257. {
  258. Assert.Throws<ArgumentNullException> ("The host SuperView parameter can't be null.",
  259. () => new ScrollBarView (new View (), true));
  260. Assert.Throws<ArgumentNullException> ("The host SuperView parameter can't be null.",
  261. () => new ScrollBarView (new View (), false));
  262. }
  263. [Fact]
  264. [ScrollBarAutoInitShutdown]
  265. public void Hosting_Two_Vertical_ScrollBarView_Throws_ArgumentException ()
  266. {
  267. var top = new Toplevel ();
  268. var host = new View ();
  269. top.Add (host);
  270. var v = new ScrollBarView (host, true);
  271. var h = new ScrollBarView (host, true);
  272. Assert.Throws<ArgumentException> (() => v.OtherScrollBarView = h);
  273. Assert.Throws<ArgumentException> (() => h.OtherScrollBarView = v);
  274. }
  275. [Fact]
  276. [ScrollBarAutoInitShutdown]
  277. public void Hosting_Two_Horizontal_ScrollBarView_Throws_ArgumentException ()
  278. {
  279. var top = new Toplevel ();
  280. var host = new View ();
  281. top.Add (host);
  282. var v = new ScrollBarView (host, false);
  283. var h = new ScrollBarView (host, false);
  284. Assert.Throws<ArgumentException> (() => v.OtherScrollBarView = h);
  285. Assert.Throws<ArgumentException> (() => h.OtherScrollBarView = v);
  286. }
  287. [Fact]
  288. [ScrollBarAutoInitShutdown]
  289. public void Scrolling_With_Default_Constructor_Do_Not_Scroll ()
  290. {
  291. var sbv = new ScrollBarView {
  292. Position = 1
  293. };
  294. // BUGBUG: v2 - this test makes no sense to me. Why would we un-set Positon?
  295. //Assert.NotEqual (1, sbv.Position);
  296. //Assert.Equal (0, sbv.Position);
  297. }
  298. [Fact]
  299. [ScrollBarAutoInitShutdown]
  300. public void Hosting_A_View_To_A_ScrollBarView ()
  301. {
  302. RemoveHandlers ();
  303. _scrollBar = new ScrollBarView (_hostView, true);
  304. Application.Begin (Application.Top);
  305. Assert.True (_scrollBar.IsVertical);
  306. Assert.False (_scrollBar.OtherScrollBarView.IsVertical);
  307. Assert.Equal (_scrollBar.Position, _hostView.Top);
  308. Assert.NotEqual (_scrollBar.Size, _hostView.Lines);
  309. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  310. Assert.NotEqual (_scrollBar.OtherScrollBarView.Size, _hostView.Cols);
  311. AddHandlers ();
  312. _hostView.SuperView.LayoutSubviews ();
  313. _hostView.Redraw (_hostView.Bounds);
  314. Assert.Equal (_scrollBar.Position, _hostView.Top);
  315. Assert.Equal (_scrollBar.Size, _hostView.Lines);
  316. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  317. Assert.Equal (_scrollBar.OtherScrollBarView.Size, _hostView.Cols);
  318. }
  319. [Fact]
  320. [ScrollBarAutoInitShutdown]
  321. public void ChangedPosition_Update_The_Hosted_View ()
  322. {
  323. Hosting_A_View_To_A_ScrollBarView ();
  324. AddHandlers ();
  325. _scrollBar.Position = 2;
  326. Assert.Equal (_scrollBar.Position, _hostView.Top);
  327. _scrollBar.OtherScrollBarView.Position = 5;
  328. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  329. }
  330. [Fact]
  331. [ScrollBarAutoInitShutdown]
  332. public void ChangedPosition_Scrolling ()
  333. {
  334. Hosting_A_View_To_A_ScrollBarView ();
  335. AddHandlers ();
  336. for (int i = 0; i < _scrollBar.Size; i++) {
  337. _scrollBar.Position += 1;
  338. Assert.Equal (_scrollBar.Position, _hostView.Top);
  339. }
  340. for (int i = _scrollBar.Size - 1; i >= 0; i--) {
  341. _scrollBar.Position -= 1;
  342. Assert.Equal (_scrollBar.Position, _hostView.Top);
  343. }
  344. for (int i = 0; i < _scrollBar.OtherScrollBarView.Size; i++) {
  345. _scrollBar.OtherScrollBarView.Position += i;
  346. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  347. }
  348. for (int i = _scrollBar.OtherScrollBarView.Size - 1; i >= 0; i--) {
  349. _scrollBar.OtherScrollBarView.Position -= 1;
  350. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  351. }
  352. }
  353. [Fact]
  354. [ScrollBarAutoInitShutdown]
  355. public void ChangedPosition_Negative_Value ()
  356. {
  357. Hosting_A_View_To_A_ScrollBarView ();
  358. AddHandlers ();
  359. _scrollBar.Position = -20;
  360. Assert.Equal (0, _scrollBar.Position);
  361. Assert.Equal (_scrollBar.Position, _hostView.Top);
  362. _scrollBar.OtherScrollBarView.Position = -50;
  363. Assert.Equal (0, _scrollBar.OtherScrollBarView.Position);
  364. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  365. }
  366. [Fact]
  367. [ScrollBarAutoInitShutdown]
  368. public void DrawContent_Update_The_ScrollBarView_Position ()
  369. {
  370. Hosting_A_View_To_A_ScrollBarView ();
  371. AddHandlers ();
  372. _hostView.Top = 3;
  373. _hostView.Redraw (_hostView.Bounds);
  374. Assert.Equal (_scrollBar.Position, _hostView.Top);
  375. _hostView.Left = 6;
  376. _hostView.Redraw (_hostView.Bounds);
  377. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  378. }
  379. [Fact]
  380. [ScrollBarAutoInitShutdown]
  381. public void OtherScrollBarView_Not_Null ()
  382. {
  383. Hosting_A_View_To_A_ScrollBarView ();
  384. AddHandlers ();
  385. Assert.NotNull (_scrollBar.OtherScrollBarView);
  386. Assert.NotEqual (_scrollBar, _scrollBar.OtherScrollBarView);
  387. Assert.Equal (_scrollBar.OtherScrollBarView.OtherScrollBarView, _scrollBar);
  388. }
  389. [Fact]
  390. [ScrollBarAutoInitShutdown]
  391. public void ShowScrollIndicator_Check ()
  392. {
  393. Hosting_A_View_To_A_ScrollBarView ();
  394. AddHandlers ();
  395. Assert.True (_scrollBar.ShowScrollIndicator);
  396. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  397. }
  398. [Fact]
  399. [ScrollBarAutoInitShutdown]
  400. public void KeepContentAlwaysInViewport_True ()
  401. {
  402. Hosting_A_View_To_A_ScrollBarView ();
  403. AddHandlers ();
  404. Assert.Equal (80, _hostView.Bounds.Width);
  405. Assert.Equal (25, _hostView.Bounds.Height);
  406. Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width);
  407. Assert.Equal (24, _scrollBar.Bounds.Height);
  408. Assert.Equal (30, _scrollBar.Size);
  409. Assert.Equal (100, _scrollBar.OtherScrollBarView.Size);
  410. Assert.True (_scrollBar.ShowScrollIndicator);
  411. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  412. Assert.True (_scrollBar.Visible);
  413. Assert.True (_scrollBar.OtherScrollBarView.Visible);
  414. _scrollBar.Position = 50;
  415. Assert.Equal (_scrollBar.Position, _scrollBar.Size - _scrollBar.Bounds.Height);
  416. Assert.Equal (_scrollBar.Position, _hostView.Top);
  417. Assert.Equal (6, _scrollBar.Position);
  418. Assert.Equal (6, _hostView.Top);
  419. Assert.True (_scrollBar.ShowScrollIndicator);
  420. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  421. Assert.True (_scrollBar.Visible);
  422. Assert.True (_scrollBar.OtherScrollBarView.Visible);
  423. _scrollBar.OtherScrollBarView.Position = 150;
  424. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _scrollBar.OtherScrollBarView.Size - _scrollBar.OtherScrollBarView.Bounds.Width);
  425. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  426. Assert.Equal (21, _scrollBar.OtherScrollBarView.Position);
  427. Assert.Equal (21, _hostView.Left);
  428. Assert.True (_scrollBar.ShowScrollIndicator);
  429. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  430. Assert.True (_scrollBar.Visible);
  431. Assert.True (_scrollBar.OtherScrollBarView.Visible);
  432. }
  433. [Fact]
  434. [ScrollBarAutoInitShutdown]
  435. public void KeepContentAlwaysInViewport_False ()
  436. {
  437. Hosting_A_View_To_A_ScrollBarView ();
  438. AddHandlers ();
  439. _scrollBar.KeepContentAlwaysInViewport = false;
  440. _scrollBar.Position = 50;
  441. Assert.Equal (_scrollBar.Position, _scrollBar.Size - 1);
  442. Assert.Equal (_scrollBar.Position, _hostView.Top);
  443. Assert.Equal (29, _scrollBar.Position);
  444. Assert.Equal (29, _hostView.Top);
  445. _scrollBar.OtherScrollBarView.Position = 150;
  446. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _scrollBar.OtherScrollBarView.Size - 1);
  447. Assert.Equal (_scrollBar.OtherScrollBarView.Position, _hostView.Left);
  448. Assert.Equal (99, _scrollBar.OtherScrollBarView.Position);
  449. Assert.Equal (99, _hostView.Left);
  450. }
  451. [Fact]
  452. [ScrollBarAutoInitShutdown]
  453. public void AutoHideScrollBars_Check ()
  454. {
  455. Hosting_A_View_To_A_ScrollBarView ();
  456. AddHandlers ();
  457. _hostView.Redraw (_hostView.Bounds);
  458. Assert.True (_scrollBar.ShowScrollIndicator);
  459. Assert.True (_scrollBar.Visible);
  460. Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
  461. Assert.Equal (1, _scrollBar.Bounds.Width);
  462. Assert.Equal ("Combine(View(Height,HostView()((0,0,80,25)))-Absolute(1))",
  463. _scrollBar.Height.ToString ());
  464. Assert.Equal (24, _scrollBar.Bounds.Height);
  465. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  466. Assert.True (_scrollBar.OtherScrollBarView.Visible);
  467. Assert.Equal ("Combine(View(Width,HostView()((0,0,80,25)))-Absolute(1))",
  468. _scrollBar.OtherScrollBarView.Width.ToString ());
  469. Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width);
  470. Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
  471. Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
  472. _hostView.Lines = 10;
  473. _hostView.Redraw (_hostView.Bounds);
  474. Assert.False (_scrollBar.ShowScrollIndicator);
  475. Assert.False (_scrollBar.Visible);
  476. Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
  477. Assert.Equal (1, _scrollBar.Bounds.Width);
  478. Assert.Equal ("Combine(View(Height,HostView()((0,0,80,25)))-Absolute(1))",
  479. _scrollBar.Height.ToString ());
  480. Assert.Equal (24, _scrollBar.Bounds.Height);
  481. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  482. Assert.True (_scrollBar.OtherScrollBarView.Visible);
  483. Assert.Equal ("View(Width,HostView()((0,0,80,25)))",
  484. _scrollBar.OtherScrollBarView.Width.ToString ());
  485. Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
  486. Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
  487. Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
  488. _hostView.Cols = 60;
  489. _hostView.Redraw (_hostView.Bounds);
  490. Assert.False (_scrollBar.ShowScrollIndicator);
  491. Assert.False (_scrollBar.Visible);
  492. Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
  493. Assert.Equal (1, _scrollBar.Bounds.Width);
  494. Assert.Equal ("Combine(View(Height,HostView()((0,0,80,25)))-Absolute(1))",
  495. _scrollBar.Height.ToString ());
  496. Assert.Equal (24, _scrollBar.Bounds.Height);
  497. Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  498. Assert.False (_scrollBar.OtherScrollBarView.Visible);
  499. Assert.Equal ("View(Width,HostView()((0,0,80,25)))",
  500. _scrollBar.OtherScrollBarView.Width.ToString ());
  501. Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
  502. Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
  503. Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
  504. _hostView.Lines = 40;
  505. _hostView.Redraw (_hostView.Bounds);
  506. Assert.True (_scrollBar.ShowScrollIndicator);
  507. Assert.True (_scrollBar.Visible);
  508. Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
  509. Assert.Equal (1, _scrollBar.Bounds.Width);
  510. Assert.Equal ("View(Height,HostView()((0,0,80,25)))",
  511. _scrollBar.Height.ToString ());
  512. Assert.Equal (25, _scrollBar.Bounds.Height);
  513. Assert.False (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  514. Assert.False (_scrollBar.OtherScrollBarView.Visible);
  515. Assert.Equal ("View(Width,HostView()((0,0,80,25)))",
  516. _scrollBar.OtherScrollBarView.Width.ToString ());
  517. Assert.Equal (80, _scrollBar.OtherScrollBarView.Bounds.Width);
  518. Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
  519. Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
  520. _hostView.Cols = 120;
  521. _hostView.Redraw (_hostView.Bounds);
  522. Assert.True (_scrollBar.ShowScrollIndicator);
  523. Assert.True (_scrollBar.Visible);
  524. Assert.Equal ("Absolute(1)", _scrollBar.Width.ToString ());
  525. Assert.Equal (1, _scrollBar.Bounds.Width);
  526. Assert.Equal ("Combine(View(Height,HostView()((0,0,80,25)))-Absolute(1))",
  527. _scrollBar.Height.ToString ());
  528. Assert.Equal (24, _scrollBar.Bounds.Height);
  529. Assert.True (_scrollBar.OtherScrollBarView.ShowScrollIndicator);
  530. Assert.True (_scrollBar.OtherScrollBarView.Visible);
  531. Assert.Equal ("Combine(View(Width,HostView()((0,0,80,25)))-Absolute(1))",
  532. _scrollBar.OtherScrollBarView.Width.ToString ());
  533. Assert.Equal (79, _scrollBar.OtherScrollBarView.Bounds.Width);
  534. Assert.Equal ("Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ());
  535. Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height);
  536. }
  537. // BUGBUG: v2 - Tig broke these tests; @bdisp help?
  538. //[Fact]
  539. //public void Constructor_ShowBothScrollIndicator_False_And_IsVertical_True_Refresh_Does_Not_Throws_An_Object_Null_Exception ()
  540. //{
  541. // var exception = Record.Exception (() => {
  542. // Application.Init (new FakeDriver ());
  543. // var top = Application.Top;
  544. // var win = new Window () {
  545. // X = 0,
  546. // Y = 0,
  547. // Width = Dim.Fill (),
  548. // Height = Dim.Fill ()
  549. // };
  550. // List<string> source = new List<string> ();
  551. // for (int i = 0; i < 50; i++) {
  552. // source.Add ($"item {i}");
  553. // }
  554. // var listView = new ListView (source) {
  555. // X = 0,
  556. // Y = 0,
  557. // Width = Dim.Fill (),
  558. // Height = Dim.Fill ()
  559. // };
  560. // win.Add (listView);
  561. // var newScrollBarView = new ScrollBarView (listView, true, false) {
  562. // KeepContentAlwaysInViewport = true
  563. // };
  564. // win.Add (newScrollBarView);
  565. // newScrollBarView.ChangedPosition += (s,e) => {
  566. // listView.TopItem = newScrollBarView.Position;
  567. // if (listView.TopItem != newScrollBarView.Position) {
  568. // newScrollBarView.Position = listView.TopItem;
  569. // }
  570. // Assert.Equal (newScrollBarView.Position, listView.TopItem);
  571. // listView.SetNeedsDisplay ();
  572. // };
  573. // listView.DrawContent += (s,e) => {
  574. // newScrollBarView.Size = listView.Source.Count;
  575. // Assert.Equal (newScrollBarView.Size, listView.Source.Count);
  576. // newScrollBarView.Position = listView.TopItem;
  577. // Assert.Equal (newScrollBarView.Position, listView.TopItem);
  578. // newScrollBarView.Refresh ();
  579. // };
  580. // top.Ready += (s, e) => {
  581. // newScrollBarView.Position = 45;
  582. // Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.TopItem + (listView.TopItem - listView.Bounds.Height));
  583. // Assert.Equal (newScrollBarView.Position, listView.TopItem);
  584. // Assert.Equal (27, newScrollBarView.Position);
  585. // Assert.Equal (27, listView.TopItem);
  586. // Application.RequestStop ();
  587. // };
  588. // top.Add (win);
  589. // Application.Run ();
  590. // Application.Shutdown ();
  591. // });
  592. // Assert.Null (exception);
  593. //}
  594. [Fact]
  595. public void Constructor_ShowBothScrollIndicator_False_And_IsVertical_False_Refresh_Does_Not_Throws_An_Object_Null_Exception ()
  596. {
  597. // BUGBUG: v2 - Tig broke these tests; @bdisp help?
  598. //var exception = Record.Exception (() => {
  599. Application.Init (new FakeDriver ());
  600. var top = Application.Top;
  601. var win = new Window () {
  602. X = 0,
  603. Y = 0,
  604. Width = Dim.Fill (),
  605. Height = Dim.Fill ()
  606. };
  607. List<string> source = new List<string> ();
  608. for (int i = 0; i < 50; i++) {
  609. var text = $"item {i} - ";
  610. for (int j = 0; j < 160; j++) {
  611. var col = j.ToString ();
  612. text += col.Length == 1 ? col [0] : col [1];
  613. }
  614. source.Add (text);
  615. }
  616. var listView = new ListView (source) {
  617. X = 0,
  618. Y = 0,
  619. Width = Dim.Fill (),
  620. Height = Dim.Fill ()
  621. };
  622. win.Add (listView);
  623. var newScrollBarView = new ScrollBarView (listView, false, false) {
  624. KeepContentAlwaysInViewport = true
  625. };
  626. win.Add (newScrollBarView);
  627. newScrollBarView.ChangedPosition += (s, e) => {
  628. listView.LeftItem = newScrollBarView.Position;
  629. if (listView.LeftItem != newScrollBarView.Position) {
  630. newScrollBarView.Position = listView.LeftItem;
  631. }
  632. Assert.Equal (newScrollBarView.Position, listView.LeftItem);
  633. listView.SetNeedsDisplay ();
  634. };
  635. listView.DrawContent += (s, e) => {
  636. newScrollBarView.Size = listView.Maxlength;
  637. Assert.Equal (newScrollBarView.Size, listView.Maxlength);
  638. newScrollBarView.Position = listView.LeftItem;
  639. Assert.Equal (newScrollBarView.Position, listView.LeftItem);
  640. newScrollBarView.Refresh ();
  641. };
  642. top.Ready += (s, e) => {
  643. newScrollBarView.Position = 100;
  644. //Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.LeftItem + (listView.LeftItem - listView.Bounds.Width));
  645. Assert.Equal (newScrollBarView.Position, listView.LeftItem);
  646. //Assert.Equal (92, newScrollBarView.Position);
  647. //Assert.Equal (92, listView.LeftItem);
  648. Application.RequestStop ();
  649. };
  650. top.Add (win);
  651. Application.Run ();
  652. Application.Shutdown ();
  653. //});
  654. //Assert.Null (exception);
  655. }
  656. [Fact]
  657. [AutoInitShutdown]
  658. public void Internal_Tests ()
  659. {
  660. var top = Application.Top;
  661. Assert.Equal (new Rect (0, 0, 80, 25), top.Bounds);
  662. var view = new View () { Width = Dim.Fill (), Height = Dim.Fill () };
  663. top.Add (view);
  664. var sbv = new ScrollBarView (view, true);
  665. top.Add (sbv);
  666. Assert.Equal (view, sbv.Host);
  667. sbv.Size = 40;
  668. sbv.Position = 0;
  669. sbv.OtherScrollBarView.Size = 100;
  670. sbv.OtherScrollBarView.Position = 0;
  671. // Host bounds is empty.
  672. Assert.False (sbv.CanScroll (10, out int max, sbv.IsVertical));
  673. Assert.Equal (0, max);
  674. Assert.False (sbv.OtherScrollBarView.CanScroll (10, out max, sbv.OtherScrollBarView.IsVertical));
  675. Assert.Equal (0, max);
  676. Application.Begin (top);
  677. // They aren't visible so they aren't drawn.
  678. Assert.False (sbv.Visible);
  679. Assert.False (sbv.OtherScrollBarView.Visible);
  680. top.LayoutSubviews ();
  681. // Now the host bounds is not empty.
  682. Assert.True (sbv.CanScroll (10, out max, sbv.IsVertical));
  683. Assert.Equal (10, max);
  684. Assert.True (sbv.OtherScrollBarView.CanScroll (10, out max, sbv.OtherScrollBarView.IsVertical));
  685. Assert.Equal (10, max);
  686. Assert.True (sbv.CanScroll (50, out max, sbv.IsVertical));
  687. Assert.Equal (40, sbv.Size);
  688. Assert.Equal (15, max); // 15+25=40
  689. Assert.True (sbv.OtherScrollBarView.CanScroll (150, out max, sbv.OtherScrollBarView.IsVertical));
  690. Assert.Equal (100, sbv.OtherScrollBarView.Size);
  691. Assert.Equal (20, max); // 20+80=100
  692. Assert.False (sbv.Visible);
  693. Assert.False (sbv.OtherScrollBarView.Visible);
  694. sbv.KeepContentAlwaysInViewport = false;
  695. sbv.OtherScrollBarView.KeepContentAlwaysInViewport = false;
  696. Assert.True (sbv.CanScroll (50, out max, sbv.IsVertical));
  697. Assert.Equal (39, max);
  698. Assert.True (sbv.OtherScrollBarView.CanScroll (150, out max, sbv.OtherScrollBarView.IsVertical));
  699. Assert.Equal (99, max);
  700. Assert.True (sbv.Visible);
  701. Assert.True (sbv.OtherScrollBarView.Visible);
  702. }
  703. [Fact, AutoInitShutdown]
  704. public void Hosting_ShowBothScrollIndicator_Invisible ()
  705. {
  706. var textView = new TextView () {
  707. Width = Dim.Fill (),
  708. Height = Dim.Fill (),
  709. Text = "This is the help text for the Second Step.\n\nPress the button to see a message box.\n\nEnter name too."
  710. };
  711. var win = new Window () {
  712. Width = Dim.Fill (),
  713. Height = Dim.Fill ()
  714. };
  715. win.Add (textView);
  716. var scrollBar = new ScrollBarView (textView, true);
  717. scrollBar.ChangedPosition += (s, e) => {
  718. textView.TopRow = scrollBar.Position;
  719. if (textView.TopRow != scrollBar.Position) {
  720. scrollBar.Position = textView.TopRow;
  721. }
  722. textView.SetNeedsDisplay ();
  723. };
  724. scrollBar.OtherScrollBarView.ChangedPosition += (s, e) => {
  725. textView.LeftColumn = scrollBar.OtherScrollBarView.Position;
  726. if (textView.LeftColumn != scrollBar.OtherScrollBarView.Position) {
  727. scrollBar.OtherScrollBarView.Position = textView.LeftColumn;
  728. }
  729. textView.SetNeedsDisplay ();
  730. };
  731. scrollBar.VisibleChanged += (s, e) => {
  732. if (scrollBar.Visible && textView.RightOffset == 0) {
  733. textView.RightOffset = 1;
  734. } else if (!scrollBar.Visible && textView.RightOffset == 1) {
  735. textView.RightOffset = 0;
  736. }
  737. };
  738. scrollBar.OtherScrollBarView.VisibleChanged += (s, e) => {
  739. if (scrollBar.OtherScrollBarView.Visible && textView.BottomOffset == 0) {
  740. textView.BottomOffset = 1;
  741. } else if (!scrollBar.OtherScrollBarView.Visible && textView.BottomOffset == 1) {
  742. textView.BottomOffset = 0;
  743. }
  744. };
  745. textView.LayoutComplete += (s, e) => {
  746. scrollBar.Size = textView.Lines;
  747. scrollBar.Position = textView.TopRow;
  748. if (scrollBar.OtherScrollBarView != null) {
  749. scrollBar.OtherScrollBarView.Size = textView.Maxlength;
  750. scrollBar.OtherScrollBarView.Position = textView.LeftColumn;
  751. }
  752. scrollBar.LayoutSubviews ();
  753. scrollBar.Refresh ();
  754. };
  755. Application.Top.Add (win);
  756. Application.Begin (Application.Top);
  757. ((FakeDriver)Application.Driver).SetBufferSize (45, 20);
  758. Assert.True (scrollBar.AutoHideScrollBars);
  759. Assert.False (scrollBar.ShowScrollIndicator);
  760. Assert.False (scrollBar.OtherScrollBarView.ShowScrollIndicator);
  761. Assert.Equal (5, textView.Lines);
  762. Assert.Equal (42, textView.Maxlength);
  763. Assert.Equal (0, textView.LeftColumn);
  764. Assert.Equal (0, scrollBar.Position);
  765. Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
  766. var expected = @"
  767. ┌───────────────────────────────────────────┐
  768. │This is the help text for the Second Step. │
  769. │ │
  770. │Press the button to see a message box. │
  771. │ │
  772. │Enter name too. │
  773. │ │
  774. │ │
  775. │ │
  776. │ │
  777. │ │
  778. │ │
  779. │ │
  780. │ │
  781. │ │
  782. │ │
  783. │ │
  784. │ │
  785. │ │
  786. └───────────────────────────────────────────┘
  787. ";
  788. var pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  789. Assert.Equal (new Rect (0, 0, 45, 20), pos);
  790. textView.WordWrap = true;
  791. ((FakeDriver)Application.Driver).SetBufferSize (26, 20);
  792. Application.Refresh ();
  793. Assert.True (textView.WordWrap);
  794. Assert.True (scrollBar.AutoHideScrollBars);
  795. Assert.Equal (7, textView.Lines);
  796. Assert.Equal (22, textView.Maxlength);
  797. Assert.Equal (0, textView.LeftColumn);
  798. Assert.Equal (0, scrollBar.Position);
  799. Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
  800. expected = @"
  801. ┌────────────────────────┐
  802. │This is the help text │
  803. │for the Second Step. │
  804. │ │
  805. │Press the button to │
  806. │see a message box. │
  807. │ │
  808. │Enter name too. │
  809. │ │
  810. │ │
  811. │ │
  812. │ │
  813. │ │
  814. │ │
  815. │ │
  816. │ │
  817. │ │
  818. │ │
  819. │ │
  820. └────────────────────────┘
  821. ";
  822. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  823. Assert.Equal (new Rect (0, 0, 26, 20), pos);
  824. ((FakeDriver)Application.Driver).SetBufferSize (10, 10);
  825. Application.Refresh ();
  826. Assert.True (textView.WordWrap);
  827. Assert.True (scrollBar.AutoHideScrollBars);
  828. Assert.Equal (20, textView.Lines);
  829. Assert.Equal (7, textView.Maxlength);
  830. Assert.Equal (0, textView.LeftColumn);
  831. Assert.Equal (0, scrollBar.Position);
  832. Assert.Equal (0, scrollBar.OtherScrollBarView.Position);
  833. expected = @"
  834. ┌────────┐
  835. │This ▲│
  836. │is the ┬│
  837. │help ││
  838. │text ┴│
  839. │for ░│
  840. │the ░│
  841. │Second ░│
  842. │Step. ▼│
  843. └────────┘
  844. ";
  845. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  846. Assert.Equal (new Rect (0, 0, 10, 10), pos);
  847. }
  848. [Fact, AutoInitShutdown]
  849. public void ContentBottomRightCorner_Not_Redraw_If_Both_Size_Equal_To_Zero ()
  850. {
  851. var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
  852. var label = new Label (text);
  853. Application.Top.Add (label);
  854. var sbv = new ScrollBarView (label, true, true) {
  855. Size = 100,
  856. };
  857. sbv.OtherScrollBarView.Size = 100;
  858. Application.Begin (Application.Top);
  859. Assert.Equal (100, sbv.Size);
  860. Assert.Equal (100, sbv.OtherScrollBarView.Size);
  861. Assert.True (sbv.ShowScrollIndicator);
  862. Assert.True (sbv.OtherScrollBarView.ShowScrollIndicator);
  863. Assert.True (sbv.Visible);
  864. Assert.True (sbv.OtherScrollBarView.Visible);
  865. TestHelpers.AssertDriverContentsWithFrameAre (@"
  866. This is a tes▲
  867. This is a tes┬
  868. This is a tes┴
  869. This is a tes░
  870. This is a tes▼
  871. ◄├─┤░░░░░░░░►
  872. ", output);
  873. sbv.Size = 0;
  874. sbv.OtherScrollBarView.Size = 0;
  875. Assert.Equal (0, sbv.Size);
  876. Assert.Equal (0, sbv.OtherScrollBarView.Size);
  877. Assert.False (sbv.ShowScrollIndicator);
  878. Assert.False (sbv.OtherScrollBarView.ShowScrollIndicator);
  879. Assert.False (sbv.Visible);
  880. Assert.False (sbv.OtherScrollBarView.Visible);
  881. Application.Top.Redraw (Application.Top.Bounds);
  882. TestHelpers.AssertDriverContentsWithFrameAre (@"
  883. This is a test
  884. This is a test
  885. This is a test
  886. This is a test
  887. This is a test
  888. This is a test
  889. ", output);
  890. sbv.Size = 50;
  891. sbv.OtherScrollBarView.Size = 50;
  892. Assert.Equal (50, sbv.Size);
  893. Assert.Equal (50, sbv.OtherScrollBarView.Size);
  894. Assert.True (sbv.ShowScrollIndicator);
  895. Assert.True (sbv.OtherScrollBarView.ShowScrollIndicator);
  896. Assert.True (sbv.Visible);
  897. Assert.True (sbv.OtherScrollBarView.Visible);
  898. Application.Top.Redraw (Application.Top.Bounds);
  899. TestHelpers.AssertDriverContentsWithFrameAre (@"
  900. This is a tes▲
  901. This is a tes┬
  902. This is a tes┴
  903. This is a tes░
  904. This is a tes▼
  905. ◄├──┤░░░░░░░►
  906. ", output);
  907. }
  908. [Fact, AutoInitShutdown]
  909. public void ContentBottomRightCorner_Not_Redraw_If_One_Size_Equal_To_Zero ()
  910. {
  911. var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
  912. var label = new Label (text);
  913. Application.Top.Add (label);
  914. var sbv = new ScrollBarView (label, true, false) {
  915. Size = 100,
  916. };
  917. Application.Begin (Application.Top);
  918. Assert.Equal (100, sbv.Size);
  919. Assert.Null (sbv.OtherScrollBarView);
  920. Assert.True (sbv.ShowScrollIndicator);
  921. Assert.True (sbv.Visible);
  922. TestHelpers.AssertDriverContentsWithFrameAre (@"
  923. This is a tes▲
  924. This is a tes┬
  925. This is a tes┴
  926. This is a tes░
  927. This is a tes░
  928. This is a tes▼
  929. ", output);
  930. sbv.Size = 0;
  931. Assert.Equal (0, sbv.Size);
  932. Assert.False (sbv.ShowScrollIndicator);
  933. Assert.False (sbv.Visible);
  934. Application.Top.Redraw (Application.Top.Bounds);
  935. TestHelpers.AssertDriverContentsWithFrameAre (@"
  936. This is a test
  937. This is a test
  938. This is a test
  939. This is a test
  940. This is a test
  941. This is a test
  942. ", output);
  943. }
  944. [Fact, AutoInitShutdown]
  945. public void ShowScrollIndicator_False_Must_Also_Set_Visible_To_False_To_Not_Respond_To_Events ()
  946. {
  947. var clicked = false;
  948. var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
  949. var label = new Label (text) { Width = 14, Height = 5 };
  950. var btn = new Button (14, 0, "Click Me!");
  951. btn.Clicked += (s, e) => clicked = true;
  952. Application.Top.Add (label, btn);
  953. var sbv = new ScrollBarView (label, true, false) {
  954. Size = 5,
  955. };
  956. Application.Begin (Application.Top);
  957. Assert.Equal (5, sbv.Size);
  958. Assert.Null (sbv.OtherScrollBarView);
  959. Assert.False (sbv.ShowScrollIndicator);
  960. Assert.False (sbv.Visible);
  961. TestHelpers.AssertDriverContentsWithFrameAre (@"
  962. This is a test[ Click Me! ]
  963. This is a test
  964. This is a test
  965. This is a test
  966. This is a test
  967. ", output);
  968. ReflectionTools.InvokePrivate (
  969. typeof (Application),
  970. "ProcessMouseEvent",
  971. new MouseEvent () {
  972. X = 15,
  973. Y = 0,
  974. Flags = MouseFlags.Button1Clicked
  975. });
  976. Assert.Null (Application.MouseGrabView);
  977. Assert.True (clicked);
  978. clicked = false;
  979. sbv.Visible = true;
  980. Assert.Equal (5, sbv.Size);
  981. Assert.False (sbv.ShowScrollIndicator);
  982. Assert.True (sbv.Visible);
  983. Application.Top.Redraw (Application.Top.Bounds);
  984. TestHelpers.AssertDriverContentsWithFrameAre (@"
  985. This is a test[ Click Me! ]
  986. This is a test
  987. This is a test
  988. This is a test
  989. This is a test
  990. ", output);
  991. ReflectionTools.InvokePrivate (
  992. typeof (Application),
  993. "ProcessMouseEvent",
  994. new MouseEvent () {
  995. X = 15,
  996. Y = 0,
  997. Flags = MouseFlags.Button1Clicked
  998. });
  999. Assert.Null (Application.MouseGrabView);
  1000. Assert.True (clicked);
  1001. Assert.Equal (5, sbv.Size);
  1002. Assert.False (sbv.ShowScrollIndicator);
  1003. Assert.False (sbv.Visible);
  1004. }
  1005. [Fact, AutoInitShutdown]
  1006. public void ClearOnVisibleFalse_Gets_Sets ()
  1007. {
  1008. var text = "This is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test\nThis is a test";
  1009. var label = new Label (text);
  1010. Application.Top.Add (label);
  1011. var sbv = new ScrollBarView (label, true, false) {
  1012. Size = 100,
  1013. ClearOnVisibleFalse = false
  1014. };
  1015. Application.Begin (Application.Top);
  1016. Assert.True (sbv.Visible);
  1017. TestHelpers.AssertDriverContentsWithFrameAre (@"
  1018. This is a tes▲
  1019. This is a tes┬
  1020. This is a tes┴
  1021. This is a tes░
  1022. This is a tes░
  1023. This is a tes▼
  1024. ", output);
  1025. sbv.Visible = false;
  1026. Assert.False (sbv.Visible);
  1027. Application.Top.Redraw (Application.Top.Bounds);
  1028. TestHelpers.AssertDriverContentsWithFrameAre (@"
  1029. This is a test
  1030. This is a test
  1031. This is a test
  1032. This is a test
  1033. This is a test
  1034. This is a test
  1035. ", output);
  1036. sbv.Visible = true;
  1037. Assert.True (sbv.Visible);
  1038. Application.Top.Redraw (Application.Top.Bounds);
  1039. TestHelpers.AssertDriverContentsWithFrameAre (@"
  1040. This is a tes▲
  1041. This is a tes┬
  1042. This is a tes┴
  1043. This is a tes░
  1044. This is a tes░
  1045. This is a tes▼
  1046. ", output);
  1047. sbv.ClearOnVisibleFalse = true;
  1048. sbv.Visible = false;
  1049. Assert.False (sbv.Visible);
  1050. TestHelpers.AssertDriverContentsWithFrameAre (@"
  1051. This is a tes
  1052. This is a tes
  1053. This is a tes
  1054. This is a tes
  1055. This is a tes
  1056. This is a tes
  1057. ", output);
  1058. }
  1059. }
  1060. }