SplitViewTests.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. using System;
  2. using System.Linq;
  3. using Terminal.Gui;
  4. using Xunit;
  5. using Xunit.Abstractions;
  6. namespace UnitTests {
  7. public class SplitViewTests {
  8. readonly ITestOutputHelper output;
  9. public SplitViewTests (ITestOutputHelper output)
  10. {
  11. this.output = output;
  12. }
  13. [Fact, AutoInitShutdown]
  14. public void TestSplitView_Vertical ()
  15. {
  16. var splitContainer = Get11By3SplitView (out var line);
  17. splitContainer.Redraw (splitContainer.Bounds);
  18. string looksLike =
  19. @"
  20. 11111│22222
  21. 11111│22222
  22. │ ";
  23. TestHelpers.AssertDriverContentsAre (looksLike, output);
  24. // Keyboard movement on splitter should have no effect if it is not focused
  25. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  26. splitContainer.SetNeedsDisplay ();
  27. splitContainer.Redraw (splitContainer.Bounds);
  28. TestHelpers.AssertDriverContentsAre (looksLike, output);
  29. }
  30. [Fact, AutoInitShutdown]
  31. public void TestSplitView_Vertical_WithBorder ()
  32. {
  33. var splitContainer = Get11By3SplitView (out var line, true);
  34. splitContainer.Redraw (splitContainer.Bounds);
  35. string looksLike =
  36. @"
  37. ┌────┬────┐
  38. │1111│2222│
  39. └────┴────┘";
  40. TestHelpers.AssertDriverContentsAre (looksLike, output);
  41. // Keyboard movement on splitter should have no effect if it is not focused
  42. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  43. splitContainer.SetNeedsDisplay ();
  44. splitContainer.Redraw (splitContainer.Bounds);
  45. TestHelpers.AssertDriverContentsAre (looksLike, output);
  46. }
  47. [Fact, AutoInitShutdown]
  48. public void TestSplitView_Vertical_Focused ()
  49. {
  50. var splitContainer = Get11By3SplitView (out var line);
  51. SetInputFocusLine (splitContainer);
  52. splitContainer.Redraw (splitContainer.Bounds);
  53. string looksLike =
  54. @"
  55. 11111│22222
  56. 11111◊22222
  57. │ ";
  58. TestHelpers.AssertDriverContentsAre (looksLike, output);
  59. // Now while focused move the splitter 1 unit right
  60. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  61. splitContainer.Redraw (splitContainer.Bounds);
  62. looksLike =
  63. @"
  64. 111111│2222
  65. 111111◊2222
  66. │ ";
  67. TestHelpers.AssertDriverContentsAre (looksLike, output);
  68. // and 2 to the left
  69. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  70. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  71. splitContainer.Redraw (splitContainer.Bounds);
  72. looksLike =
  73. @"
  74. 1111│222222
  75. 1111◊222222
  76. │ ";
  77. TestHelpers.AssertDriverContentsAre (looksLike, output);
  78. }
  79. [Fact, AutoInitShutdown]
  80. public void TestSplitView_Vertical_Focused_WithBorder ()
  81. {
  82. var splitContainer = Get11By3SplitView (out var line, true);
  83. SetInputFocusLine (splitContainer);
  84. splitContainer.Redraw (splitContainer.Bounds);
  85. string looksLike =
  86. @"
  87. ┌────┬────┐
  88. │1111◊2222│
  89. └────┴────┘";
  90. TestHelpers.AssertDriverContentsAre (looksLike, output);
  91. // Now while focused move the splitter 1 unit right
  92. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  93. splitContainer.Redraw (splitContainer.Bounds);
  94. looksLike =
  95. @"
  96. ┌─────┬───┐
  97. │11111◊222│
  98. └─────┴───┘";
  99. TestHelpers.AssertDriverContentsAre (looksLike, output);
  100. // and 2 to the left
  101. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  102. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  103. splitContainer.Redraw (splitContainer.Bounds);
  104. looksLike =
  105. @"
  106. ┌───┬─────┐
  107. │111◊22222│
  108. └───┴─────┘";
  109. TestHelpers.AssertDriverContentsAre (looksLike, output);
  110. }
  111. [Fact, AutoInitShutdown]
  112. public void TestSplitView_Vertical_Focused_50PercentSplit ()
  113. {
  114. var splitContainer = Get11By3SplitView (out var line);
  115. SetInputFocusLine (splitContainer);
  116. splitContainer.SetSplitterPos(0,Pos.Percent (50));
  117. Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistances.ElementAt(0));
  118. splitContainer.Redraw (splitContainer.Bounds);
  119. string looksLike =
  120. @"
  121. 11111│22222
  122. 11111◊22222
  123. │ ";
  124. TestHelpers.AssertDriverContentsAre (looksLike, output);
  125. // Now while focused move the splitter 1 unit right
  126. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  127. splitContainer.Redraw (splitContainer.Bounds);
  128. looksLike =
  129. @"
  130. 111111│2222
  131. 111111◊2222
  132. │ ";
  133. TestHelpers.AssertDriverContentsAre (looksLike, output);
  134. // Even when moving the splitter location it should stay a Percentage based one
  135. Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistances.ElementAt(0));
  136. // and 2 to the left
  137. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  138. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  139. splitContainer.Redraw (splitContainer.Bounds);
  140. looksLike =
  141. @"
  142. 1111│222222
  143. 1111◊222222
  144. │ ";
  145. TestHelpers.AssertDriverContentsAre (looksLike, output);
  146. // Even when moving the splitter location it should stay a Percentage based one
  147. Assert.IsType<Pos.PosFactor> (splitContainer.SplitterDistances.ElementAt (0));
  148. }
  149. [Fact, AutoInitShutdown]
  150. public void TestSplitView_Horizontal ()
  151. {
  152. var splitContainer = Get11By3SplitView (out var line);
  153. splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
  154. splitContainer.Redraw (splitContainer.Bounds);
  155. string looksLike =
  156. @"
  157. 11111111111
  158. ───────────
  159. 22222222222";
  160. TestHelpers.AssertDriverContentsAre (looksLike, output);
  161. // Keyboard movement on splitter should have no effect if it is not focused
  162. line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
  163. splitContainer.SetNeedsDisplay ();
  164. splitContainer.Redraw (splitContainer.Bounds);
  165. TestHelpers.AssertDriverContentsAre (looksLike, output);
  166. }
  167. [Fact, AutoInitShutdown]
  168. public void TestSplitView_Vertical_View1MinSize_Absolute ()
  169. {
  170. var splitContainer = Get11By3SplitView (out var line);
  171. SetInputFocusLine (splitContainer);
  172. splitContainer.Tiles.ElementAt(0).MinSize = 6;
  173. // distance is too small (below 6)
  174. splitContainer.SetSplitterPos(0, 2);
  175. // Should bound the value to the minimum distance
  176. Assert.Equal (6, splitContainer.SplitterDistances.ElementAt (0));
  177. splitContainer.Redraw (splitContainer.Bounds);
  178. // so should ignore the 2 distance and stick to 6
  179. string looksLike =
  180. @"
  181. 111111│2222
  182. 111111◊2222
  183. │ ";
  184. TestHelpers.AssertDriverContentsAre (looksLike, output);
  185. // Keyboard movement on splitter should have no effect because it
  186. // would take us below the minimum splitter size
  187. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  188. splitContainer.SetNeedsDisplay ();
  189. splitContainer.Redraw (splitContainer.Bounds);
  190. TestHelpers.AssertDriverContentsAre (looksLike, output);
  191. // but we can continue to move the splitter right if we want
  192. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  193. splitContainer.SetNeedsDisplay ();
  194. splitContainer.Redraw (splitContainer.Bounds);
  195. looksLike =
  196. @"
  197. 1111111│222
  198. 1111111◊222
  199. │ ";
  200. TestHelpers.AssertDriverContentsAre (looksLike, output);
  201. }
  202. [Fact, AutoInitShutdown]
  203. public void TestSplitView_Vertical_View1MinSize_Absolute_WithBorder ()
  204. {
  205. var splitContainer = Get11By3SplitView (out var line,true);
  206. SetInputFocusLine (splitContainer);
  207. splitContainer.Tiles.ElementAt(0).MinSize = 5;
  208. // distance is too small (below 5)
  209. splitContainer.SetSplitterPos(0,2);
  210. // Should bound the value to the minimum distance
  211. Assert.Equal (6, splitContainer.SplitterDistances.ElementAt(0));
  212. splitContainer.Redraw (splitContainer.Bounds);
  213. // so should ignore the 2 distance and stick to 5
  214. string looksLike =
  215. @"
  216. ┌─────┬───┐
  217. │11111◊222│
  218. └─────┴───┘";
  219. TestHelpers.AssertDriverContentsAre (looksLike, output);
  220. // Keyboard movement on splitter should have no effect because it
  221. // would take us below the minimum splitter size
  222. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  223. splitContainer.SetNeedsDisplay ();
  224. splitContainer.Redraw (splitContainer.Bounds);
  225. TestHelpers.AssertDriverContentsAre (looksLike, output);
  226. // but we can continue to move the splitter right if we want
  227. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  228. splitContainer.SetNeedsDisplay ();
  229. splitContainer.Redraw (splitContainer.Bounds);
  230. looksLike =
  231. @"
  232. ┌──────┬──┐
  233. │111111◊22│
  234. └──────┴──┘";
  235. TestHelpers.AssertDriverContentsAre (looksLike, output);
  236. }
  237. [Fact, AutoInitShutdown]
  238. public void TestSplitView_Vertical_View2MinSize_Absolute ()
  239. {
  240. var splitContainer = Get11By3SplitView (out var line);
  241. SetInputFocusLine (splitContainer);
  242. splitContainer.Tiles.ElementAt(1).MinSize = 6;
  243. // distance leaves too little space for view2 (less than 6 would remain)
  244. splitContainer.SetSplitterPos(0,8);
  245. // Should bound the value to the minimum distance
  246. Assert.Equal (4, splitContainer.SplitterDistances.ElementAt(0));
  247. splitContainer.Redraw (splitContainer.Bounds);
  248. // so should ignore the 2 distance and stick to 6
  249. string looksLike =
  250. @"
  251. 1111│222222
  252. 1111◊222222
  253. │ ";
  254. TestHelpers.AssertDriverContentsAre (looksLike, output);
  255. // Keyboard movement on splitter should have no effect because it
  256. // would take us below the minimum splitter size
  257. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  258. splitContainer.SetNeedsDisplay ();
  259. splitContainer.Redraw (splitContainer.Bounds);
  260. TestHelpers.AssertDriverContentsAre (looksLike, output);
  261. // but we can continue to move the splitter left if we want
  262. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  263. splitContainer.SetNeedsDisplay ();
  264. splitContainer.Redraw (splitContainer.Bounds);
  265. looksLike =
  266. @"
  267. 111│2222222
  268. 111◊2222222
  269. │ ";
  270. TestHelpers.AssertDriverContentsAre (looksLike, output);
  271. }
  272. [Fact, AutoInitShutdown]
  273. public void TestSplitView_Vertical_View2MinSize_Absolute_WithBorder ()
  274. {
  275. var splitContainer = Get11By3SplitView (out var line, true);
  276. SetInputFocusLine (splitContainer);
  277. splitContainer.Tiles.ElementAt(1).MinSize = 5;
  278. // distance leaves too little space for view2 (less than 5 would remain)
  279. splitContainer.SetSplitterPos(0,8);
  280. // Should bound the value to the minimum distance
  281. Assert.Equal (4, splitContainer.SplitterDistances.ElementAt(0));
  282. splitContainer.Redraw (splitContainer.Bounds);
  283. // so should ignore the 2 distance and stick to 6
  284. string looksLike =
  285. @"
  286. ┌───┬─────┐
  287. │111◊22222│
  288. └───┴─────┘";
  289. TestHelpers.AssertDriverContentsAre (looksLike, output);
  290. // Keyboard movement on splitter should have no effect because it
  291. // would take us below the minimum splitter size
  292. line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  293. splitContainer.SetNeedsDisplay ();
  294. splitContainer.Redraw (splitContainer.Bounds);
  295. TestHelpers.AssertDriverContentsAre (looksLike, output);
  296. // but we can continue to move the splitter left if we want
  297. line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  298. splitContainer.SetNeedsDisplay ();
  299. splitContainer.Redraw (splitContainer.Bounds);
  300. looksLike =
  301. @"
  302. ┌──┬──────┐
  303. │11◊222222│
  304. └──┴──────┘";
  305. TestHelpers.AssertDriverContentsAre (looksLike, output);
  306. }
  307. [Fact, AutoInitShutdown]
  308. public void TestSplitView_InsertPanelAtStart ()
  309. {
  310. var splitContainer = Get11By3SplitView (out var line, true);
  311. SetInputFocusLine (splitContainer);
  312. splitContainer.InsertTile (0);
  313. splitContainer.Redraw (splitContainer.Bounds);
  314. // so should ignore the 2 distance and stick to 6
  315. string looksLike =
  316. @"
  317. ┌──┬───┬──┐
  318. │ │111│22│
  319. └──┴───┴──┘";
  320. TestHelpers.AssertDriverContentsAre (looksLike, output);
  321. }
  322. [Fact, AutoInitShutdown]
  323. public void TestSplitView_InsertPanelMiddle()
  324. {
  325. var splitContainer = Get11By3SplitView (out var line, true);
  326. SetInputFocusLine (splitContainer);
  327. splitContainer.InsertTile (1);
  328. splitContainer.Redraw (splitContainer.Bounds);
  329. // so should ignore the 2 distance and stick to 6
  330. string looksLike =
  331. @"
  332. ┌──┬───┬──┐
  333. │11│ │22│
  334. └──┴───┴──┘";
  335. TestHelpers.AssertDriverContentsAre (looksLike, output);
  336. }
  337. [Fact, AutoInitShutdown]
  338. public void TestSplitView_InsertPanelAtEnd ()
  339. {
  340. var splitContainer = Get11By3SplitView (out var line, true);
  341. SetInputFocusLine (splitContainer);
  342. splitContainer.InsertTile (2);
  343. splitContainer.Redraw (splitContainer.Bounds);
  344. // so should ignore the 2 distance and stick to 6
  345. string looksLike =
  346. @"
  347. ┌──┬───┬──┐
  348. │11│222│ │
  349. └──┴───┴──┘";
  350. TestHelpers.AssertDriverContentsAre (looksLike, output);
  351. }
  352. [Fact, AutoInitShutdown]
  353. public void TestSplitView_Horizontal_Focused ()
  354. {
  355. var splitContainer = Get11By3SplitView (out var line);
  356. splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
  357. SetInputFocusLine (splitContainer);
  358. splitContainer.Redraw (splitContainer.Bounds);
  359. string looksLike =
  360. @"
  361. 11111111111
  362. ─────◊─────
  363. 22222222222";
  364. TestHelpers.AssertDriverContentsAre (looksLike, output);
  365. // Now move splitter line down
  366. line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
  367. splitContainer.Redraw (splitContainer.Bounds);
  368. looksLike =
  369. @"
  370. 11111111111
  371. 11111111111
  372. ─────◊─────";
  373. TestHelpers.AssertDriverContentsAre (looksLike, output);
  374. // And 2 up
  375. line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  376. line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  377. splitContainer.Redraw (splitContainer.Bounds);
  378. looksLike =
  379. @"
  380. ─────◊─────
  381. 22222222222
  382. 22222222222";
  383. TestHelpers.AssertDriverContentsAre (looksLike, output);
  384. }
  385. [Fact, AutoInitShutdown]
  386. public void TestSplitView_Horizontal_View1MinSize_Absolute ()
  387. {
  388. var splitContainer = Get11By3SplitView (out var line);
  389. splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
  390. SetInputFocusLine (splitContainer);
  391. splitContainer.Tiles.ElementAt(0).MinSize = 1;
  392. // 0 should not be allowed because it brings us below minimum size of View1
  393. splitContainer.SetSplitterPos(0,0);
  394. Assert.Equal ((Pos)1, splitContainer.SplitterDistances.ElementAt(0));
  395. splitContainer.Redraw (splitContainer.Bounds);
  396. string looksLike =
  397. @"
  398. 11111111111
  399. ─────◊─────
  400. 22222222222";
  401. TestHelpers.AssertDriverContentsAre (looksLike, output);
  402. // Now move splitter line down (allowed
  403. line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
  404. splitContainer.Redraw (splitContainer.Bounds);
  405. looksLike =
  406. @"
  407. 11111111111
  408. 11111111111
  409. ─────◊─────";
  410. TestHelpers.AssertDriverContentsAre (looksLike, output);
  411. // And up 2 (only 1 is allowed because of minimum size of 1 on view1)
  412. line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  413. line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  414. splitContainer.Redraw (splitContainer.Bounds);
  415. looksLike =
  416. @"
  417. 11111111111
  418. ─────◊─────
  419. 22222222222";
  420. TestHelpers.AssertDriverContentsAre (looksLike, output);
  421. }
  422. [Fact, AutoInitShutdown]
  423. public void TestSplitView_CannotSetSplitterPosToFuncEtc ()
  424. {
  425. var splitContainer = Get11By3SplitView ();
  426. var ex = Assert.Throws<ArgumentException> (() => splitContainer.SetSplitterPos(0,Pos.Right (splitContainer)));
  427. Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosCombine", ex.Message);
  428. ex = Assert.Throws<ArgumentException> (() => splitContainer.SetSplitterPos(0,Pos.Function (() => 1)));
  429. Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosFunc", ex.Message);
  430. // Also not allowed because this results in a PosCombine
  431. ex = Assert.Throws<ArgumentException> (() => splitContainer.SetSplitterPos(0, Pos.Percent (50) - 1));
  432. Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosCombine", ex.Message);
  433. }
  434. [Fact,AutoInitShutdown]
  435. public void TestNestedContainer2LeftAnd1Right_RendersNicely()
  436. {
  437. var splitContainer = GetNestedContainer2Left1Right (false);
  438. Assert.Equal (20,splitContainer.Frame.Width);
  439. Assert.Equal (10, splitContainer.Tiles.ElementAt(0).View.Frame.Width);
  440. Assert.Equal (9, splitContainer.Tiles.ElementAt (1).View.Frame.Width);
  441. Assert.IsType<SplitView> (splitContainer.Tiles.ElementAt (0).View);
  442. var left = (SplitView)splitContainer.Tiles.ElementAt (0).View;
  443. Assert.Same (left.SuperView, splitContainer);
  444. Assert.Equal(2, left.Tiles.ElementAt (0).View.Subviews.Count);
  445. Assert.IsType<Label> (left.Tiles.ElementAt (0).View.Subviews [0]);
  446. Assert.IsType<Label> (left.Tiles.ElementAt (0).View.Subviews [1]);
  447. var onesTop = (Label)left.Tiles.ElementAt (0).View.Subviews [0];
  448. var onesBottom = (Label)left.Tiles.ElementAt (0).View.Subviews [1];
  449. Assert.Same (left.Tiles.ElementAt (0).View, onesTop.SuperView);
  450. Assert.Same (left.Tiles.ElementAt (0).View, onesBottom.SuperView);
  451. Assert.Equal (10, onesTop.Frame.Width);
  452. Assert.Equal (10, onesBottom.Frame.Width);
  453. splitContainer.Redraw (splitContainer.Bounds);
  454. string looksLike =
  455. @"
  456. 1111111111│222222222
  457. 1111111111│222222222
  458. ──────────┤
  459. │";
  460. TestHelpers.AssertDriverContentsAre (looksLike, output);
  461. }
  462. /// <summary>
  463. /// Creates a vertical orientation root container with left pane split into
  464. /// two (with horizontal splitter line).
  465. /// </summary>
  466. /// <param name="withBorder"></param>
  467. /// <returns></returns>
  468. private SplitView GetNestedContainer2Left1Right(bool withBorder)
  469. {
  470. var container = GetSplitView (20, 10,withBorder);
  471. Assert.True (container.TrySplitView (0,2, out var newContainer));
  472. newContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
  473. newContainer.ColorScheme = new ColorScheme ();
  474. container.ColorScheme = new ColorScheme ();
  475. container.LayoutSubviews ();
  476. return container;
  477. }
  478. private LineView GetLine (SplitView splitContainer)
  479. {
  480. return splitContainer.Subviews.OfType<LineView> ().Single ();
  481. }
  482. private void SetInputFocusLine (SplitView splitContainer)
  483. {
  484. var line = GetLine (splitContainer);
  485. line.SetFocus ();
  486. Assert.True (line.HasFocus);
  487. }
  488. private SplitView Get11By3SplitView(out LineView line, bool withBorder = false)
  489. {
  490. var split = Get11By3SplitView (withBorder);
  491. line = GetLine (split);
  492. return split;
  493. }
  494. private SplitView Get11By3SplitView (bool withBorder = false)
  495. {
  496. return GetSplitView (11, 3, withBorder);
  497. }
  498. private SplitView GetSplitView (int width, int height, bool withBorder = false)
  499. {
  500. var container = new SplitView () {
  501. Width = width,
  502. Height = height,
  503. };
  504. container.IntegratedBorder = withBorder ? BorderStyle.Single : BorderStyle.None;
  505. container.Tiles.ElementAt(0).View.Add (new Label (new string ('1', 100)) { Width = Dim.Fill(), Height = 1, AutoSize = false});
  506. container.Tiles.ElementAt (0).View.Add (new Label (new string ('1', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false,Y = 1});
  507. container.Tiles.ElementAt (1).View.Add (new Label (new string ('2', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false });
  508. container.Tiles.ElementAt (1).View.Add (new Label (new string ('2', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false,Y = 1});
  509. container.Tiles.ElementAt (0).MinSize = 0;
  510. container.Tiles.ElementAt (1).MinSize = 0;
  511. Application.Top.Add (container);
  512. container.ColorScheme = new ColorScheme ();
  513. container.LayoutSubviews ();
  514. container.BeginInit ();
  515. container.EndInit ();
  516. return container;
  517. }
  518. }
  519. }