ScrollBarViewTests.cs 36 KB

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