TileViewTests.cs 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306
  1. using System;
  2. using System.ComponentModel;
  3. using System.Linq;
  4. using Xunit;
  5. using Xunit.Abstractions;
  6. // BUGBUG: v2 - These tests are all broken for now
  7. //namespace Terminal.Gui.ViewsTests {
  8. // public class TileViewTests {
  9. // readonly ITestOutputHelper output;
  10. // public TileViewTests (ITestOutputHelper output)
  11. // {
  12. // this.output = output;
  13. // }
  14. // [Fact, AutoInitShutdown]
  15. // public void TestTileView_Vertical ()
  16. // {
  17. // var tileView = Get11By3TileView (out var line);
  18. // tileView.Redraw (tileView.Bounds);
  19. // string looksLike =
  20. //@"
  21. //11111│22222
  22. //11111│22222
  23. // │ ";
  24. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  25. // // Keyboard movement on splitter should have no effect if it is not focused
  26. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  27. // tileView.SetNeedsDisplay ();
  28. // tileView.Redraw (tileView.Bounds);
  29. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  30. // }
  31. // [Fact, AutoInitShutdown]
  32. // public void TestTileView_Vertical_WithBorder ()
  33. // {
  34. // var tileView = Get11By3TileView (out var line, true);
  35. // tileView.Redraw (tileView.Bounds);
  36. // string looksLike =
  37. //@"
  38. //┌────┬────┐
  39. //│1111│2222│
  40. //└────┴────┘";
  41. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  42. // // Keyboard movement on splitter should have no effect if it is not focused
  43. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  44. // tileView.SetNeedsDisplay ();
  45. // tileView.Redraw (tileView.Bounds);
  46. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  47. // }
  48. // [Fact, AutoInitShutdown]
  49. // public void TestTileView_Vertical_Focused ()
  50. // {
  51. // var tileView = Get11By3TileView (out var line);
  52. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  53. // tileView.Redraw (tileView.Bounds);
  54. // string looksLike =
  55. //@"
  56. //11111│22222
  57. //11111◊22222
  58. // │ ";
  59. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  60. // // Now while focused move the splitter 1 unit right
  61. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  62. // tileView.Redraw (tileView.Bounds);
  63. // looksLike =
  64. //@"
  65. //111111│2222
  66. //111111◊2222
  67. // │ ";
  68. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  69. // // and 2 to the left
  70. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  71. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  72. // tileView.Redraw (tileView.Bounds);
  73. // looksLike =
  74. //@"
  75. //1111│222222
  76. //1111◊222222
  77. // │ ";
  78. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  79. // }
  80. // [Fact, AutoInitShutdown]
  81. // public void TestTileView_Vertical_Focused_WithBorder ()
  82. // {
  83. // var tileView = Get11By3TileView (out var line, true);
  84. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  85. // tileView.Redraw (tileView.Bounds);
  86. // string looksLike =
  87. //@"
  88. //┌────┬────┐
  89. //│1111◊2222│
  90. //└────┴────┘";
  91. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  92. // // Now while focused move the splitter 1 unit right
  93. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  94. // tileView.Redraw (tileView.Bounds);
  95. // looksLike =
  96. //@"
  97. //┌─────┬───┐
  98. //│11111◊222│
  99. //└─────┴───┘";
  100. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  101. // // and 2 to the left
  102. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  103. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  104. // tileView.Redraw (tileView.Bounds);
  105. // looksLike =
  106. //@"
  107. //┌───┬─────┐
  108. //│111◊22222│
  109. //└───┴─────┘";
  110. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  111. // }
  112. // [Fact, AutoInitShutdown]
  113. // public void TestTileView_Vertical_Focused_50PercentSplit ()
  114. // {
  115. // var tileView = Get11By3TileView (out var line);
  116. // tileView.SetSplitterPos (0, Pos.Percent (50));
  117. // Assert.IsType<Pos.PosFactor> (tileView.SplitterDistances.ElementAt (0));
  118. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  119. // tileView.Redraw (tileView.Bounds);
  120. // string looksLike =
  121. //@"
  122. //11111│22222
  123. //11111◊22222
  124. // │ ";
  125. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  126. // // Now while focused move the splitter 1 unit right
  127. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  128. // tileView.Redraw (tileView.Bounds);
  129. // looksLike =
  130. //@"
  131. //111111│2222
  132. //111111◊2222
  133. // │ ";
  134. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  135. // // Even when moving the splitter location it should stay a Percentage based one
  136. // Assert.IsType<Pos.PosFactor> (tileView.SplitterDistances.ElementAt (0));
  137. // // and 2 to the left
  138. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  139. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  140. // tileView.Redraw (tileView.Bounds);
  141. // looksLike =
  142. //@"
  143. //1111│222222
  144. //1111◊222222
  145. // │ ";
  146. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  147. // // Even when moving the splitter location it should stay a Percentage based one
  148. // Assert.IsType<Pos.PosFactor> (tileView.SplitterDistances.ElementAt (0));
  149. // }
  150. // [Fact, AutoInitShutdown]
  151. // public void TestTileView_Horizontal ()
  152. // {
  153. // var tileView = Get11By3TileView (out var line);
  154. // tileView.Orientation = Orientation.Horizontal;
  155. // tileView.Redraw (tileView.Bounds);
  156. // string looksLike =
  157. //@"
  158. //11111111111
  159. //───────────
  160. //22222222222";
  161. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  162. // // Keyboard movement on splitter should have no effect if it is not focused
  163. // line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
  164. // tileView.SetNeedsDisplay ();
  165. // tileView.Redraw (tileView.Bounds);
  166. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  167. // }
  168. // [Fact, AutoInitShutdown]
  169. // public void TestTileView_Vertical_View1MinSize_Absolute ()
  170. // {
  171. // var tileView = Get11By3TileView (out var line);
  172. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  173. // tileView.Tiles.ElementAt (0).MinSize = 6;
  174. // // distance is too small (below 6)
  175. // Assert.False (tileView.SetSplitterPos (0, 2));
  176. // // Should stay where it was originally at (50%)
  177. // Assert.Equal (Pos.Percent (50), tileView.SplitterDistances.ElementAt (0));
  178. // tileView.Redraw (tileView.Bounds);
  179. // // so should ignore the 2 distance and stick to 6
  180. // string looksLike =
  181. //@"
  182. //11111│22222
  183. //11111◊22222
  184. // │ ";
  185. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  186. // // Keyboard movement on splitter should have no effect because it
  187. // // would take us below the minimum splitter size
  188. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  189. // tileView.SetNeedsDisplay ();
  190. // tileView.Redraw (tileView.Bounds);
  191. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  192. // // but we can continue to move the splitter right if we want
  193. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  194. // tileView.SetNeedsDisplay ();
  195. // tileView.Redraw (tileView.Bounds);
  196. // looksLike =
  197. //@"
  198. //111111│2222
  199. //111111◊2222
  200. // │ ";
  201. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  202. // }
  203. // [Fact, AutoInitShutdown]
  204. // public void TestTileView_Vertical_View1MinSize_Absolute_WithBorder ()
  205. // {
  206. // var tileView = Get11By3TileView (out var line, true);
  207. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  208. // tileView.Tiles.ElementAt (0).MinSize = 5;
  209. // // distance is too small (below 5)
  210. // Assert.False (tileView.SetSplitterPos (0, 2));
  211. // // Should stay where it was originally at (50%)
  212. // Assert.Equal (Pos.Percent (50), tileView.SplitterDistances.ElementAt (0));
  213. // tileView.Redraw (tileView.Bounds);
  214. // // so should ignore the 2 distance and stick to 5
  215. // string looksLike =
  216. //@"
  217. //┌────┬────┐
  218. //│1111◊2222│
  219. //└────┴────┘";
  220. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  221. // // Keyboard movement on splitter should have no effect because it
  222. // // would take us below the minimum splitter size
  223. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  224. // tileView.SetNeedsDisplay ();
  225. // tileView.Redraw (tileView.Bounds);
  226. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  227. // // but we can continue to move the splitter right if we want
  228. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  229. // tileView.SetNeedsDisplay ();
  230. // tileView.Redraw (tileView.Bounds);
  231. // looksLike =
  232. //@"
  233. //┌─────┬───┐
  234. //│11111◊222│
  235. //└─────┴───┘";
  236. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  237. // }
  238. // [Fact, AutoInitShutdown]
  239. // public void TestTileView_Vertical_View2MinSize_Absolute ()
  240. // {
  241. // var tileView = Get11By3TileView (out var line);
  242. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  243. // tileView.Tiles.ElementAt (1).MinSize = 6;
  244. // // distance leaves too little space for view2 (less than 6 would remain)
  245. // Assert.False (tileView.SetSplitterPos (0, 8));
  246. // // Should stay where it was originally at (50%)
  247. // Assert.Equal (Pos.Percent (50), tileView.SplitterDistances.ElementAt (0));
  248. // tileView.Redraw (tileView.Bounds);
  249. // // so should ignore the 2 distance and stick to 6
  250. // string looksLike =
  251. //@"
  252. //11111│22222
  253. //11111◊22222
  254. // │ ";
  255. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  256. // // Keyboard movement on splitter should have no effect because it
  257. // // would take us below the minimum splitter size
  258. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  259. // tileView.SetNeedsDisplay ();
  260. // tileView.Redraw (tileView.Bounds);
  261. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  262. // // but we can continue to move the splitter left if we want
  263. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  264. // tileView.SetNeedsDisplay ();
  265. // tileView.Redraw (tileView.Bounds);
  266. // looksLike =
  267. //@"
  268. //1111│222222
  269. //1111◊222222
  270. // │ ";
  271. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  272. // }
  273. // [Fact, AutoInitShutdown]
  274. // public void TestTileView_Vertical_View2MinSize_Absolute_WithBorder ()
  275. // {
  276. // var tileView = Get11By3TileView (out var line, true);
  277. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  278. // tileView.Tiles.ElementAt (1).MinSize = 5;
  279. // // distance leaves too little space for view2 (less than 5 would remain)
  280. // Assert.False (tileView.SetSplitterPos (0, 8));
  281. // // Should stay where it was originally at (50%)
  282. // Assert.Equal (Pos.Percent (50), tileView.SplitterDistances.ElementAt (0));
  283. // tileView.Redraw (tileView.Bounds);
  284. // // so should ignore the 2 distance and stick to 6
  285. // string looksLike =
  286. //@"
  287. //┌────┬────┐
  288. //│1111◊2222│
  289. //└────┴────┘";
  290. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  291. // // Keyboard movement on splitter should have no effect because it
  292. // // would take us below the minimum splitter size
  293. // line.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ()));
  294. // tileView.SetNeedsDisplay ();
  295. // tileView.Redraw (tileView.Bounds);
  296. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  297. // // but we can continue to move the splitter left if we want
  298. // line.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ()));
  299. // tileView.SetNeedsDisplay ();
  300. // tileView.Redraw (tileView.Bounds);
  301. // looksLike =
  302. //@"
  303. //┌───┬─────┐
  304. //│111◊22222│
  305. //└───┴─────┘";
  306. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  307. // }
  308. // [Fact, AutoInitShutdown]
  309. // public void TestTileView_InsertPanelAtStart ()
  310. // {
  311. // var tileView = Get11By3TileView (out var line, true);
  312. // tileView.InsertTile (0);
  313. // tileView.Redraw (tileView.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 TestTileView_InsertPanelMiddle ()
  324. // {
  325. // var tileView = Get11By3TileView (out var line, true);
  326. // tileView.InsertTile (1);
  327. // tileView.Redraw (tileView.Bounds);
  328. // // so should ignore the 2 distance and stick to 6
  329. // string looksLike =
  330. //@"
  331. //┌──┬───┬──┐
  332. //│11│ │22│
  333. //└──┴───┴──┘";
  334. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  335. // }
  336. // [Fact, AutoInitShutdown]
  337. // public void TestTileView_InsertPanelAtEnd ()
  338. // {
  339. // var tileView = Get11By3TileView (out var line, true);
  340. // tileView.InsertTile (2);
  341. // tileView.Redraw (tileView.Bounds);
  342. // // so should ignore the 2 distance and stick to 6
  343. // string looksLike =
  344. //@"
  345. //┌──┬───┬──┐
  346. //│11│222│ │
  347. //└──┴───┴──┘";
  348. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  349. // }
  350. // [Fact, AutoInitShutdown]
  351. // public void TestTileView_Horizontal_Focused ()
  352. // {
  353. // var tileView = Get11By3TileView (out var line);
  354. // tileView.Orientation = Orientation.Horizontal;
  355. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  356. // Assert.True (line.HasFocus);
  357. // tileView.Redraw (tileView.Bounds);
  358. // string looksLike =
  359. //@"
  360. //11111111111
  361. //─────◊─────
  362. //22222222222";
  363. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  364. // // Now move splitter line down
  365. // line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
  366. // tileView.Redraw (tileView.Bounds);
  367. // looksLike =
  368. //@"
  369. //11111111111
  370. //11111111111
  371. //─────◊─────";
  372. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  373. // // And 2 up
  374. // line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  375. // line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  376. // tileView.SetNeedsDisplay ();
  377. // tileView.Redraw (tileView.Bounds);
  378. // looksLike =
  379. //@"
  380. //─────◊─────
  381. //22222222222
  382. //22222222222";
  383. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  384. // }
  385. // [Fact, AutoInitShutdown]
  386. // public void TestTileView_Horizontal_View1MinSize_Absolute ()
  387. // {
  388. // var tileView = Get11By3TileView (out var line);
  389. // tileView.ProcessHotKey (new KeyEvent (tileView.ToggleResizable, new KeyModifiers ()));
  390. // tileView.Orientation = Orientation.Horizontal;
  391. // tileView.Tiles.ElementAt (0).MinSize = 1;
  392. // // 0 should not be allowed because it brings us below minimum size of View1
  393. // Assert.False (tileView.SetSplitterPos (0, 0));
  394. // // position should remain where it was, at 50%
  395. // Assert.Equal (Pos.Percent (50f), tileView.SplitterDistances.ElementAt (0));
  396. // tileView.Redraw (tileView.Bounds);
  397. // string looksLike =
  398. //@"
  399. //11111111111
  400. //─────◊─────
  401. //22222222222";
  402. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  403. // // Now move splitter line down (allowed
  404. // line.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ()));
  405. // tileView.Redraw (tileView.Bounds);
  406. // looksLike =
  407. //@"
  408. //11111111111
  409. //11111111111
  410. //─────◊─────";
  411. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  412. // // And up 2 (only 1 is allowed because of minimum size of 1 on view1)
  413. // line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  414. // line.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ()));
  415. // tileView.SetNeedsDisplay ();
  416. // tileView.Redraw (tileView.Bounds);
  417. // looksLike =
  418. //@"
  419. //11111111111
  420. //─────◊─────
  421. //22222222222";
  422. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  423. // }
  424. // [Fact, AutoInitShutdown]
  425. // public void TestTileView_CannotSetSplitterPosToFuncEtc ()
  426. // {
  427. // var tileView = Get11By3TileView ();
  428. // var ex = Assert.Throws<ArgumentException> (() => tileView.SetSplitterPos (0, Pos.Right (tileView)));
  429. // Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosCombine", ex.Message);
  430. // ex = Assert.Throws<ArgumentException> (() => tileView.SetSplitterPos (0, Pos.Function (() => 1)));
  431. // Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosFunc", ex.Message);
  432. // // Also not allowed because this results in a PosCombine
  433. // ex = Assert.Throws<ArgumentException> (() => tileView.SetSplitterPos (0, Pos.Percent (50) - 1));
  434. // Assert.Equal ("Only Percent and Absolute values are supported. Passed value was PosCombine", ex.Message);
  435. // }
  436. // [Fact, AutoInitShutdown]
  437. // public void TestNestedContainer2LeftAnd1Right_RendersNicely ()
  438. // {
  439. // var tileView = GetNestedContainer2Left1Right (false);
  440. // Assert.Equal (20, tileView.Frame.Width);
  441. // Assert.Equal (10, tileView.Tiles.ElementAt (0).ContentView.Frame.Width);
  442. // Assert.Equal (9, tileView.Tiles.ElementAt (1).ContentView.Frame.Width);
  443. // Assert.IsType<TileView> (tileView.Tiles.ElementAt (0).ContentView);
  444. // var left = (TileView)tileView.Tiles.ElementAt (0).ContentView;
  445. // Assert.Same (left.SuperView, tileView);
  446. // Assert.Equal (2, left.Tiles.ElementAt (0).ContentView.Subviews.Count);
  447. // Assert.IsType<Label> (left.Tiles.ElementAt (0).ContentView.Subviews [0]);
  448. // Assert.IsType<Label> (left.Tiles.ElementAt (0).ContentView.Subviews [1]);
  449. // var onesTop = (Label)left.Tiles.ElementAt (0).ContentView.Subviews [0];
  450. // var onesBottom = (Label)left.Tiles.ElementAt (0).ContentView.Subviews [1];
  451. // Assert.Same (left.Tiles.ElementAt (0).ContentView, onesTop.SuperView);
  452. // Assert.Same (left.Tiles.ElementAt (0).ContentView, onesBottom.SuperView);
  453. // Assert.Equal (10, onesTop.Frame.Width);
  454. // Assert.Equal (10, onesBottom.Frame.Width);
  455. // tileView.Redraw (tileView.Bounds);
  456. // string looksLike =
  457. //@"
  458. //1111111111│222222222
  459. //1111111111│222222222
  460. // │
  461. // │
  462. // │
  463. //──────────┤
  464. // │
  465. // │
  466. // │
  467. // │";
  468. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  469. // }
  470. // [Fact, AutoInitShutdown]
  471. // public void TestNestedContainer3RightAnd1Down_RendersNicely ()
  472. // {
  473. // var tileView = GetNestedContainer3Right1Down (false);
  474. // tileView.Redraw (tileView.Bounds);
  475. // string looksLike =
  476. //@"
  477. //111111│222222│333333
  478. //111111│222222│333333
  479. //111111│222222│333333
  480. //111111│222222│333333
  481. //111111│222222│333333
  482. //111111│222222├──────
  483. //111111│222222│444444
  484. //111111│222222│444444
  485. //111111│222222│444444
  486. //111111│222222│444444
  487. //";
  488. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  489. // // It looks good but lets double check the measurements incase
  490. // // anything is sticking out but drawn over
  491. // // 3 panels + 2 splitters
  492. // Assert.Equal (5, tileView.Subviews.Count);
  493. // // Check X and Widths of Tiles
  494. // Assert.Equal (0, tileView.Tiles.ElementAt (0).ContentView.Frame.X);
  495. // Assert.Equal (6, tileView.Tiles.ElementAt (0).ContentView.Frame.Width);
  496. // Assert.Equal (7, tileView.Tiles.ElementAt (1).ContentView.Frame.X);
  497. // Assert.Equal (6, tileView.Tiles.ElementAt (1).ContentView.Frame.Width);
  498. // Assert.Equal (14, tileView.Tiles.ElementAt (2).ContentView.Frame.X);
  499. // Assert.Equal (6, tileView.Tiles.ElementAt (2).ContentView.Frame.Width);
  500. // // Check Y and Heights of Tiles
  501. // Assert.Equal (0, tileView.Tiles.ElementAt (0).ContentView.Frame.Y);
  502. // Assert.Equal (10, tileView.Tiles.ElementAt (0).ContentView.Frame.Height);
  503. // Assert.Equal (0, tileView.Tiles.ElementAt (1).ContentView.Frame.Y);
  504. // Assert.Equal (10, tileView.Tiles.ElementAt (1).ContentView.Frame.Height);
  505. // Assert.Equal (0, tileView.Tiles.ElementAt (2).ContentView.Frame.Y);
  506. // Assert.Equal (10, tileView.Tiles.ElementAt (2).ContentView.Frame.Height);
  507. // // Check Sub containers in last panel
  508. // var subSplit = (TileView)tileView.Tiles.ElementAt (2).ContentView;
  509. // Assert.Equal (0, subSplit.Tiles.ElementAt (0).ContentView.Frame.X);
  510. // Assert.Equal (6, subSplit.Tiles.ElementAt (0).ContentView.Frame.Width);
  511. // Assert.Equal (0, subSplit.Tiles.ElementAt (0).ContentView.Frame.Y);
  512. // Assert.Equal (5, subSplit.Tiles.ElementAt (0).ContentView.Frame.Height);
  513. // Assert.IsType<TextView> (subSplit.Tiles.ElementAt (0).ContentView.Subviews.Single ());
  514. // Assert.Equal (0, subSplit.Tiles.ElementAt (1).ContentView.Frame.X);
  515. // Assert.Equal (6, subSplit.Tiles.ElementAt (1).ContentView.Frame.Width);
  516. // Assert.Equal (6, subSplit.Tiles.ElementAt (1).ContentView.Frame.Y);
  517. // Assert.Equal (4, subSplit.Tiles.ElementAt (1).ContentView.Frame.Height);
  518. // Assert.IsType<TextView> (subSplit.Tiles.ElementAt (1).ContentView.Subviews.Single ());
  519. // }
  520. // [Fact, AutoInitShutdown]
  521. // public void TestNestedContainer3RightAnd1Down_WithBorder_RendersNicely ()
  522. // {
  523. // var tileView = GetNestedContainer3Right1Down (true);
  524. // tileView.Redraw (tileView.Bounds);
  525. // string looksLike =
  526. //@"
  527. //┌─────┬──────┬─────┐
  528. //│11111│222222│33333│
  529. //│11111│222222│33333│
  530. //│11111│222222│33333│
  531. //│11111│222222│33333│
  532. //│11111│222222├─────┤
  533. //│11111│222222│44444│
  534. //│11111│222222│44444│
  535. //│11111│222222│44444│
  536. //└─────┴──────┴─────┘";
  537. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  538. // // It looks good but lets double check the measurements incase
  539. // // anything is sticking out but drawn over
  540. // // 3 panels + 2 splitters
  541. // Assert.Equal (5, tileView.Subviews.Count);
  542. // // Check X and Widths of Tiles
  543. // Assert.Equal (1, tileView.Tiles.ElementAt (0).ContentView.Frame.X);
  544. // Assert.Equal (5, tileView.Tiles.ElementAt (0).ContentView.Frame.Width);
  545. // Assert.Equal (7, tileView.Tiles.ElementAt (1).ContentView.Frame.X);
  546. // Assert.Equal (6, tileView.Tiles.ElementAt (1).ContentView.Frame.Width);
  547. // Assert.Equal (14, tileView.Tiles.ElementAt (2).ContentView.Frame.X);
  548. // Assert.Equal (5, tileView.Tiles.ElementAt (2).ContentView.Frame.Width);
  549. // // Check Y and Heights of Tiles
  550. // Assert.Equal (1, tileView.Tiles.ElementAt (0).ContentView.Frame.Y);
  551. // Assert.Equal (8, tileView.Tiles.ElementAt (0).ContentView.Frame.Height);
  552. // Assert.Equal (1, tileView.Tiles.ElementAt (1).ContentView.Frame.Y);
  553. // Assert.Equal (8, tileView.Tiles.ElementAt (1).ContentView.Frame.Height);
  554. // Assert.Equal (1, tileView.Tiles.ElementAt (2).ContentView.Frame.Y);
  555. // Assert.Equal (8, tileView.Tiles.ElementAt (2).ContentView.Frame.Height);
  556. // // Check Sub containers in last panel
  557. // var subSplit = (TileView)tileView.Tiles.ElementAt (2).ContentView;
  558. // Assert.Equal (0, subSplit.Tiles.ElementAt (0).ContentView.Frame.X);
  559. // Assert.Equal (5, subSplit.Tiles.ElementAt (0).ContentView.Frame.Width);
  560. // Assert.Equal (0, subSplit.Tiles.ElementAt (0).ContentView.Frame.Y);
  561. // Assert.Equal (4, subSplit.Tiles.ElementAt (0).ContentView.Frame.Height);
  562. // Assert.IsType<TextView> (subSplit.Tiles.ElementAt (0).ContentView.Subviews.Single ());
  563. // Assert.Equal (0, subSplit.Tiles.ElementAt (1).ContentView.Frame.X);
  564. // Assert.Equal (5, subSplit.Tiles.ElementAt (1).ContentView.Frame.Width);
  565. // Assert.Equal (5, subSplit.Tiles.ElementAt (1).ContentView.Frame.Y);
  566. // Assert.Equal (3, subSplit.Tiles.ElementAt (1).ContentView.Frame.Height);
  567. // Assert.IsType<TextView> (subSplit.Tiles.ElementAt (1).ContentView.Subviews.Single ());
  568. // }
  569. // [Fact, AutoInitShutdown]
  570. // public void TestNestedContainer3RightAnd1Down_WithTitledBorder_RendersNicely ()
  571. // {
  572. // var tileView = GetNestedContainer3Right1Down (true, true);
  573. // tileView.Redraw (tileView.Bounds);
  574. // string looksLike =
  575. //@"
  576. //┌ T1 ─┬ T2 ──┬ T3 ─┐
  577. //│11111│222222│33333│
  578. //│11111│222222│33333│
  579. //│11111│222222│33333│
  580. //│11111│222222│33333│
  581. //│11111│222222├ T4 ─┤
  582. //│11111│222222│44444│
  583. //│11111│222222│44444│
  584. //│11111│222222│44444│
  585. //└─────┴──────┴─────┘";
  586. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  587. // }
  588. // [Fact, AutoInitShutdown]
  589. // public void TestNestedContainer3RightAnd1Down_WithBorder_RemovingTiles ()
  590. // {
  591. // var tileView = GetNestedContainer3Right1Down (true);
  592. // tileView.Redraw (tileView.Bounds);
  593. // string looksLike =
  594. //@"
  595. //┌─────┬──────┬─────┐
  596. //│11111│222222│33333│
  597. //│11111│222222│33333│
  598. //│11111│222222│33333│
  599. //│11111│222222│33333│
  600. //│11111│222222├─────┤
  601. //│11111│222222│44444│
  602. //│11111│222222│44444│
  603. //│11111│222222│44444│
  604. //└─────┴──────┴─────┘";
  605. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  606. // var toRemove = tileView.Tiles.ElementAt (1);
  607. // var removed = tileView.RemoveTile (1);
  608. // Assert.Same (toRemove, removed);
  609. // Assert.DoesNotContain (removed, tileView.Tiles);
  610. // tileView.Redraw (tileView.Bounds);
  611. // looksLike =
  612. //@"
  613. //┌─────────┬────────┐
  614. //│111111111│33333333│
  615. //│111111111│33333333│
  616. //│111111111│33333333│
  617. //│111111111│33333333│
  618. //│111111111├────────┤
  619. //│111111111│44444444│
  620. //│111111111│44444444│
  621. //│111111111│44444444│
  622. //└─────────┴────────┘";
  623. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  624. // // cannot remove at this index because there is only one horizontal tile left
  625. // Assert.Null (tileView.RemoveTile (2));
  626. // tileView.RemoveTile (0);
  627. // tileView.Redraw (tileView.Bounds);
  628. // looksLike =
  629. //@"
  630. //┌──────────────────┐
  631. //│333333333333333333│
  632. //│333333333333333333│
  633. //│333333333333333333│
  634. //│333333333333333333│
  635. //├──────────────────┤
  636. //│444444444444444444│
  637. //│444444444444444444│
  638. //│444444444444444444│
  639. //└──────────────────┘";
  640. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  641. // Assert.NotNull (tileView.RemoveTile (0));
  642. // tileView.Redraw (tileView.Bounds);
  643. // looksLike =
  644. //@"
  645. //┌──────────────────┐
  646. //│ │
  647. //│ │
  648. //│ │
  649. //│ │
  650. //│ │
  651. //│ │
  652. //│ │
  653. //│ │
  654. //└──────────────────┘";
  655. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  656. // // cannot remove
  657. // Assert.Null (tileView.RemoveTile (0));
  658. // }
  659. // [Theory, AutoInitShutdown]
  660. // [InlineData (true)]
  661. // [InlineData (false)]
  662. // public void TestTileView_IndexOf (bool recursive)
  663. // {
  664. // var tv = new TileView ();
  665. // var lbl1 = new Label ();
  666. // var lbl2 = new Label ();
  667. // var frame = new FrameView ();
  668. // var sub = new Label ();
  669. // frame.Add (sub);
  670. // // IndexOf returns -1 when view not found
  671. // Assert.Equal (-1, tv.IndexOf (lbl1, recursive));
  672. // Assert.Equal (-1, tv.IndexOf (lbl2, recursive));
  673. // // IndexOf supports looking for Tile.View
  674. // Assert.Equal (0, tv.IndexOf (tv.Tiles.ElementAt (0).ContentView, recursive));
  675. // Assert.Equal (1, tv.IndexOf (tv.Tiles.ElementAt (1).ContentView, recursive));
  676. // // IndexOf supports looking for Tile.View.Subviews
  677. // tv.Tiles.ElementAt (0).ContentView.Add (lbl1);
  678. // Assert.Equal (0, tv.IndexOf (lbl1, recursive));
  679. // tv.Tiles.ElementAt (1).ContentView.Add (lbl2);
  680. // Assert.Equal (1, tv.IndexOf (lbl2, recursive));
  681. // // IndexOf supports looking deep into subviews only when
  682. // // the recursive true value is passed
  683. // tv.Tiles.ElementAt (1).ContentView.Add (frame);
  684. // if (recursive) {
  685. // Assert.Equal (1, tv.IndexOf (sub, recursive));
  686. // } else {
  687. // Assert.Equal (-1, tv.IndexOf (sub, recursive));
  688. // }
  689. // }
  690. // [Fact, AutoInitShutdown]
  691. // public void TestNestedRoots_BothRoots_BothCanHaveBorders ()
  692. // {
  693. // var tv = new TileView {
  694. // Width = 10,
  695. // Height = 5,
  696. // ColorScheme = new ColorScheme (),
  697. // Border = new Border () { BorderStyle = BorderStyle.Single }
  698. // };
  699. // var tv2 = new TileView {
  700. // Width = Dim.Fill (),
  701. // Height = Dim.Fill (),
  702. // ColorScheme = new ColorScheme (),
  703. // Border = new Border () { BorderStyle = BorderStyle.Single },
  704. // Orientation = Orientation.Horizontal
  705. // };
  706. // Assert.True (tv.IsRootTileView ());
  707. // tv.Tiles.ElementAt (1).ContentView.Add (tv2);
  708. // Application.Top.Add (tv);
  709. // tv.BeginInit ();
  710. // tv.EndInit ();
  711. // tv.LayoutSubviews ();
  712. // tv.LayoutSubviews ();
  713. // tv.Tiles.ElementAt (1).ContentView.LayoutSubviews ();
  714. // tv2.LayoutSubviews ();
  715. // // tv2 is still considered a root because
  716. // // it was manually created by API user. That
  717. // // means it will not have its lines joined to
  718. // // parents and it is permitted to have a border
  719. // Assert.True (tv2.IsRootTileView ());
  720. // tv.Redraw (tv.Bounds);
  721. // var looksLike =
  722. //@"
  723. //┌────┬───┐
  724. //│ │┌─┐│
  725. //│ │├─┤│
  726. //│ │└─┘│
  727. //└────┴───┘
  728. //";
  729. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  730. // }
  731. // [Fact, AutoInitShutdown]
  732. // public void Test5Panel_MinSizes_VerticalSplitters_ResizeSplitter1 ()
  733. // {
  734. // var tv = Get5x1TilesView ();
  735. // tv.Tiles.ElementAt (0).MinSize = int.MaxValue;
  736. // tv.Redraw (tv.Bounds);
  737. // var looksLike =
  738. //@"
  739. //┌────┬────┬────┬────┬───┐
  740. //│1111│2222│3333│4444│555│
  741. //│ │ │ │ │ │
  742. //└────┴────┴────┴────┴───┘
  743. //";
  744. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  745. // for (int x = 0; x <= 5; x++) {
  746. // // All these values would result in tile 0 getting smaller
  747. // // so are not allowed (tile[0] has a min size of Int.Max)
  748. // Assert.False (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  749. // }
  750. // for (int x = 6; x < 10; x++) {
  751. // // All these values would result in tile 0 getting bigger
  752. // // so are allowed
  753. // Assert.True (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  754. // }
  755. // for (int x = 10; x < 100; x++) {
  756. // // These values would result in the first splitter moving past
  757. // // the second splitter so are not allowed
  758. // Assert.False (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  759. // }
  760. // tv.SetNeedsDisplay ();
  761. // tv.Redraw (tv.Bounds);
  762. // looksLike =
  763. //@"
  764. //┌────────┬┬────┬────┬───┐
  765. //│11111111││3333│4444│555│
  766. //│ ││ │ │ │
  767. //└────────┴┴────┴────┴───┘
  768. //";
  769. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  770. // }
  771. // [Fact, AutoInitShutdown]
  772. // public void Test5Panel_MinSizes_VerticalSplitters_ResizeSplitter1_NoBorder ()
  773. // {
  774. // var tv = Get5x1TilesView (false);
  775. // tv.Tiles.ElementAt (0).MinSize = int.MaxValue;
  776. // tv.Redraw (tv.Bounds);
  777. // var looksLike =
  778. //@"
  779. //11111│2222│3333│4444│5555
  780. // │ │ │ │
  781. // │ │ │ │
  782. // │ │ │ │
  783. //";
  784. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  785. // for (int x = 0; x <= 5; x++) {
  786. // // All these values would result in tile 0 getting smaller
  787. // // so are not allowed (tile[0] has a min size of Int.Max)
  788. // Assert.False (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  789. // }
  790. // for (int x = 6; x < 10; x++) {
  791. // // All these values would result in tile 0 getting bigger
  792. // // so are allowed
  793. // Assert.True (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  794. // }
  795. // for (int x = 10; x < 100; x++) {
  796. // // These values would result in the first splitter moving past
  797. // // the second splitter so are not allowed
  798. // Assert.False (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  799. // }
  800. // tv.SetNeedsDisplay ();
  801. // tv.Redraw (tv.Bounds);
  802. // looksLike =
  803. //@"
  804. //111111111││3333│4444│5555
  805. // ││ │ │
  806. // ││ │ │
  807. // ││ │ │
  808. //";
  809. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  810. // }
  811. // [Fact, AutoInitShutdown]
  812. // public void Test5Panel_NoMinSizes_VerticalSplitters_ResizeSplitter1_CannotCrossBorder ()
  813. // {
  814. // var tv = Get5x1TilesView ();
  815. // tv.Redraw (tv.Bounds);
  816. // var looksLike =
  817. //@"
  818. //┌────┬────┬────┬────┬───┐
  819. //│1111│2222│3333│4444│555│
  820. //│ │ │ │ │ │
  821. //└────┴────┴────┴────┴───┘
  822. //";
  823. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  824. // for (int x = 5; x > 0; x--) {
  825. // Assert.True (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  826. // }
  827. // Assert.False (tv.SetSplitterPos (0, 0));
  828. // tv.SetNeedsDisplay ();
  829. // tv.Redraw (tv.Bounds);
  830. // looksLike =
  831. //@"
  832. //┌┬────────┬────┬────┬───┐
  833. //││22222222│3333│4444│555│
  834. //││ │ │ │ │
  835. //└┴────────┴────┴────┴───┘
  836. //";
  837. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  838. // for (int x = 6; x < 10; x++) {
  839. // Assert.True (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  840. // }
  841. // for (int x = 10; x < 100; x++) {
  842. // // These values would result in the first splitter moving past
  843. // // the second splitter so are not allowed
  844. // Assert.False (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  845. // }
  846. // tv.SetNeedsDisplay ();
  847. // tv.Redraw (tv.Bounds);
  848. // looksLike =
  849. //@"
  850. //┌────────┬┬────┬────┬───┐
  851. //│11111111││3333│4444│555│
  852. //│ ││ │ │ │
  853. //└────────┴┴────┴────┴───┘
  854. //";
  855. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  856. // }
  857. // [Fact, AutoInitShutdown]
  858. // public void Test5Panel_NoMinSizes_VerticalSplitters_ResizeSplitter1_CannotCrossBorder_NoBorder ()
  859. // {
  860. // var tv = Get5x1TilesView (false);
  861. // tv.Redraw (tv.Bounds);
  862. // var looksLike =
  863. //@"
  864. //11111│2222│3333│4444│5555
  865. // │ │ │ │
  866. // │ │ │ │
  867. // │ │ │ │
  868. //";
  869. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  870. // for (int x = 5; x >= 0; x--) {
  871. // Assert.True (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  872. // }
  873. // tv.SetNeedsDisplay ();
  874. // tv.Redraw (tv.Bounds);
  875. // looksLike =
  876. //@"
  877. //│222222222│3333│4444│5555
  878. //│ │ │ │
  879. //│ │ │ │
  880. //│ │ │ │
  881. //";
  882. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  883. // for (int x = 6; x < 10; x++) {
  884. // Assert.True (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  885. // }
  886. // for (int x = 10; x < 100; x++) {
  887. // // These values would result in the first splitter moving past
  888. // // the second splitter so are not allowed
  889. // Assert.False (tv.SetSplitterPos (0, x), $"Assert failed for x={x}");
  890. // }
  891. // tv.SetNeedsDisplay ();
  892. // tv.Redraw (tv.Bounds);
  893. // looksLike =
  894. //@"
  895. //111111111││3333│4444│5555
  896. // ││ │ │
  897. // ││ │ │
  898. // ││ │ │
  899. //";
  900. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  901. // }
  902. // [Fact, AutoInitShutdown]
  903. // public void Test5Panel_NoMinSizes_VerticalSplitters_ResizeSplitter2_CannotMoveOverNeighbours ()
  904. // {
  905. // var tv = Get5x1TilesView ();
  906. // tv.Redraw (tv.Bounds);
  907. // var looksLike =
  908. //@"
  909. //┌────┬────┬────┬────┬───┐
  910. //│1111│2222│3333│4444│555│
  911. //│ │ │ │ │ │
  912. //└────┴────┴────┴────┴───┘
  913. //";
  914. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  915. // for (int x = 10; x > 5; x--) {
  916. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  917. // }
  918. // for (int x = 5; x > 0; x--) {
  919. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  920. // }
  921. // tv.SetNeedsDisplay ();
  922. // tv.Redraw (tv.Bounds);
  923. // looksLike =
  924. //@"
  925. //┌────┬┬────────┬────┬───┐
  926. //│1111││33333333│4444│555│
  927. //│ ││ │ │ │
  928. //└────┴┴────────┴────┴───┘
  929. //";
  930. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  931. // for (int x = 10; x < 15; x++) {
  932. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  933. // }
  934. // for (int x = 15; x < 25; x++) {
  935. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  936. // }
  937. // tv.SetNeedsDisplay ();
  938. // tv.Redraw (tv.Bounds);
  939. // looksLike =
  940. //@"
  941. //┌────┬────────┬┬────┬───┐
  942. //│1111│22222222││4444│555│
  943. //│ │ ││ │ │
  944. //└────┴────────┴┴────┴───┘
  945. //";
  946. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  947. // }
  948. // [Fact, AutoInitShutdown]
  949. // public void Test5Panel_NoMinSizes_VerticalSplitters_ResizeSplitter2_CannotMoveOverNeighbours_NoBorder ()
  950. // {
  951. // var tv = Get5x1TilesView (false);
  952. // tv.Redraw (tv.Bounds);
  953. // var looksLike =
  954. //@"
  955. //11111│2222│3333│4444│5555
  956. // │ │ │ │
  957. // │ │ │ │
  958. // │ │ │ │
  959. //";
  960. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  961. // for (int x = 10; x > 5; x--) {
  962. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  963. // }
  964. // for (int x = 5; x > 0; x--) {
  965. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  966. // }
  967. // tv.SetNeedsDisplay ();
  968. // tv.Redraw (tv.Bounds);
  969. // looksLike =
  970. //@"
  971. //11111││33333333│4444│5555
  972. // ││ │ │
  973. // ││ │ │
  974. // ││ │ │
  975. //";
  976. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  977. // for (int x = 10; x < 15; x++) {
  978. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  979. // }
  980. // for (int x = 15; x < 25; x++) {
  981. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  982. // }
  983. // tv.SetNeedsDisplay ();
  984. // tv.Redraw (tv.Bounds);
  985. // looksLike =
  986. //@"
  987. //11111│22222222││4444│5555
  988. // │ ││ │
  989. // │ ││ │
  990. // │ ││ │
  991. //";
  992. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  993. // }
  994. // [Fact, AutoInitShutdown]
  995. // public void Test5Panel_MinSizes_VerticalSplitters_ResizeSplitter2 ()
  996. // {
  997. // var tv = Get5x1TilesView ();
  998. // tv.Tiles.ElementAt (1).MinSize = 2;
  999. // tv.Tiles.ElementAt (2).MinSize = 3;
  1000. // tv.Redraw (tv.Bounds);
  1001. // var looksLike =
  1002. //@"
  1003. //┌────┬────┬────┬────┬───┐
  1004. //│1111│2222│3333│4444│555│
  1005. //│ │ │ │ │ │
  1006. //└────┴────┴────┴────┴───┘
  1007. //";
  1008. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1009. // for (int x = 10; x > 7; x--) {
  1010. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1011. // }
  1012. // for (int x = 7; x > 0; x--) {
  1013. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1014. // }
  1015. // tv.SetNeedsDisplay ();
  1016. // tv.Redraw (tv.Bounds);
  1017. // looksLike =
  1018. //@"
  1019. //┌────┬──┬──────┬────┬───┐
  1020. //│1111│22│333333│4444│555│
  1021. //│ │ │ │ │ │
  1022. //└────┴──┴──────┴────┴───┘
  1023. //";
  1024. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1025. // for (int x = 10; x < 12; x++) {
  1026. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1027. // }
  1028. // for (int x = 12; x < 25; x++) {
  1029. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1030. // }
  1031. // tv.SetNeedsDisplay ();
  1032. // tv.Redraw (tv.Bounds);
  1033. // looksLike =
  1034. //@"
  1035. //┌────┬─────┬───┬────┬───┐
  1036. //│1111│22222│333│4444│555│
  1037. //│ │ │ │ │ │
  1038. //└────┴─────┴───┴────┴───┘
  1039. //";
  1040. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1041. // }
  1042. // [Fact, AutoInitShutdown]
  1043. // public void Test5Panel_MinSizes_VerticalSplitters_ResizeSplitter2_NoBorder ()
  1044. // {
  1045. // var tv = Get5x1TilesView (false);
  1046. // tv.Tiles.ElementAt (1).MinSize = 2;
  1047. // tv.Tiles.ElementAt (2).MinSize = 3;
  1048. // tv.Redraw (tv.Bounds);
  1049. // var looksLike =
  1050. //@"
  1051. //11111│2222│3333│4444│5555
  1052. // │ │ │ │
  1053. // │ │ │ │
  1054. // │ │ │ │
  1055. //";
  1056. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1057. // for (int x = 10; x > 7; x--) {
  1058. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1059. // }
  1060. // for (int x = 7; x > 0; x--) {
  1061. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1062. // }
  1063. // tv.SetNeedsDisplay ();
  1064. // tv.Redraw (tv.Bounds);
  1065. // looksLike =
  1066. //@"
  1067. //11111│22│333333│4444│5555
  1068. // │ │ │ │
  1069. // │ │ │ │
  1070. // │ │ │ │
  1071. //";
  1072. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1073. // for (int x = 10; x < 12; x++) {
  1074. // Assert.True (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1075. // }
  1076. // for (int x = 12; x < 25; x++) {
  1077. // Assert.False (tv.SetSplitterPos (1, x), $"Assert failed for x={x}");
  1078. // }
  1079. // tv.SetNeedsDisplay ();
  1080. // tv.Redraw (tv.Bounds);
  1081. // looksLike =
  1082. //@"
  1083. //11111│22222│333│4444│5555
  1084. // │ │ │ │
  1085. // │ │ │ │
  1086. // │ │ │ │
  1087. //";
  1088. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1089. // }
  1090. // [Fact, AutoInitShutdown]
  1091. // public void Test5Panel_NoMinSizes_VerticalSplitters_ResizeSplitter4_CannotMoveOverNeighbours ()
  1092. // {
  1093. // var tv = Get5x1TilesView ();
  1094. // tv.Redraw (tv.Bounds);
  1095. // var looksLike =
  1096. //@"
  1097. //┌────┬────┬────┬────┬───┐
  1098. //│1111│2222│3333│4444│555│
  1099. //│ │ │ │ │ │
  1100. //└────┴────┴────┴────┴───┘
  1101. //";
  1102. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1103. // for (int x = 20; x > 15; x--) {
  1104. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1105. // }
  1106. // for (int x = 15; x > 0; x--) {
  1107. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1108. // }
  1109. // tv.SetNeedsDisplay ();
  1110. // tv.Redraw (tv.Bounds);
  1111. // looksLike =
  1112. //@"
  1113. //┌────┬────┬────┬┬───────┐
  1114. //│1111│2222│3333││5555555│
  1115. //│ │ │ ││ │
  1116. //└────┴────┴────┴┴───────┘
  1117. //";
  1118. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1119. // for (int x = 20; x < 24; x++) {
  1120. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1121. // }
  1122. // for (int x = 24; x < 100; x++) {
  1123. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1124. // }
  1125. // tv.SetNeedsDisplay ();
  1126. // tv.Redraw (tv.Bounds);
  1127. // looksLike =
  1128. //@"
  1129. //┌────┬────┬────┬───────┬┐
  1130. //│1111│2222│3333│4444444││
  1131. //│ │ │ │ ││
  1132. //└────┴────┴────┴───────┴┘
  1133. //";
  1134. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1135. // }
  1136. // [Fact, AutoInitShutdown]
  1137. // public void Test5Panel_NoMinSizes_VerticalSplitters_ResizeSplitter4_CannotMoveOverNeighbours_NoBorder ()
  1138. // {
  1139. // var tv = Get5x1TilesView (false);
  1140. // tv.Redraw (tv.Bounds);
  1141. // var looksLike =
  1142. //@"
  1143. //11111│2222│3333│4444│5555
  1144. // │ │ │ │
  1145. // │ │ │ │
  1146. // │ │ │ │
  1147. //";
  1148. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1149. // for (int x = 20; x > 15; x--) {
  1150. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1151. // }
  1152. // for (int x = 15; x > 0; x--) {
  1153. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1154. // }
  1155. // tv.SetNeedsDisplay ();
  1156. // tv.Redraw (tv.Bounds);
  1157. // looksLike =
  1158. //@"
  1159. //11111│2222│3333││55555555
  1160. // │ │ ││
  1161. // │ │ ││
  1162. // │ │ ││
  1163. //";
  1164. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1165. // for (int x = 20; x < 25; x++) {
  1166. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1167. // }
  1168. // for (int x = 25; x < 100; x++) {
  1169. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1170. // }
  1171. // tv.SetNeedsDisplay ();
  1172. // tv.Redraw (tv.Bounds);
  1173. // looksLike =
  1174. //@"
  1175. //11111│2222│3333│44444444│
  1176. // │ │ │ │
  1177. // │ │ │ │
  1178. // │ │ │ │
  1179. //";
  1180. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1181. // }
  1182. // [Fact, AutoInitShutdown]
  1183. // public void Test5Panel_MinSizes_VerticalSplitters_ResizeSplitter4 ()
  1184. // {
  1185. // var tv = Get5x1TilesView ();
  1186. // tv.Tiles.ElementAt (3).MinSize = 2;
  1187. // tv.Tiles.ElementAt (4).MinSize = 1;
  1188. // tv.Redraw (tv.Bounds);
  1189. // var looksLike =
  1190. //@"
  1191. //┌────┬────┬────┬────┬───┐
  1192. //│1111│2222│3333│4444│555│
  1193. //│ │ │ │ │ │
  1194. //└────┴────┴────┴────┴───┘
  1195. //";
  1196. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1197. // for (int x = 20; x > 17; x--) {
  1198. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1199. // }
  1200. // for (int x = 17; x > 0; x--) {
  1201. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1202. // }
  1203. // tv.SetNeedsDisplay ();
  1204. // tv.Redraw (tv.Bounds);
  1205. // looksLike =
  1206. //@"
  1207. //┌────┬────┬────┬──┬─────┐
  1208. //│1111│2222│3333│44│55555│
  1209. //│ │ │ │ │ │
  1210. //└────┴────┴────┴──┴─────┘
  1211. //";
  1212. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1213. // for (int x = 20; x < 23; x++) {
  1214. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1215. // }
  1216. // for (int x = 23; x < 100; x++) {
  1217. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1218. // }
  1219. // tv.SetNeedsDisplay ();
  1220. // tv.Redraw (tv.Bounds);
  1221. // looksLike =
  1222. //@"
  1223. //┌────┬────┬────┬──────┬─┐
  1224. //│1111│2222│3333│444444│5│
  1225. //│ │ │ │ │ │
  1226. //└────┴────┴────┴──────┴─┘
  1227. //";
  1228. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1229. // }
  1230. // [Fact, AutoInitShutdown]
  1231. // public void Test5Panel_MinSizes_VerticalSplitters_ResizeSplitter4_NoBorder ()
  1232. // {
  1233. // var tv = Get5x1TilesView (false);
  1234. // tv.Tiles.ElementAt (3).MinSize = 2;
  1235. // tv.Tiles.ElementAt (4).MinSize = 1;
  1236. // tv.Redraw (tv.Bounds);
  1237. // var looksLike =
  1238. //@"
  1239. //11111│2222│3333│4444│5555
  1240. // │ │ │ │
  1241. // │ │ │ │
  1242. // │ │ │ │
  1243. //";
  1244. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1245. // for (int x = 20; x > 17; x--) {
  1246. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1247. // }
  1248. // for (int x = 17; x > 0; x--) {
  1249. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1250. // }
  1251. // tv.SetNeedsDisplay ();
  1252. // tv.Redraw (tv.Bounds);
  1253. // looksLike =
  1254. //@"
  1255. //11111│2222│3333│44│555555
  1256. // │ │ │ │
  1257. // │ │ │ │
  1258. // │ │ │ │
  1259. //";
  1260. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1261. // for (int x = 20; x < 24; x++) {
  1262. // Assert.True (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1263. // }
  1264. // for (int x = 24; x < 100; x++) {
  1265. // Assert.False (tv.SetSplitterPos (3, x), $"Assert failed for x={x}");
  1266. // }
  1267. // tv.SetNeedsDisplay ();
  1268. // tv.Redraw (tv.Bounds);
  1269. // looksLike =
  1270. //@"
  1271. //11111│2222│3333│4444444│5
  1272. // │ │ │ │
  1273. // │ │ │ │
  1274. // │ │ │ │
  1275. //";
  1276. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1277. // }
  1278. // [Fact, AutoInitShutdown]
  1279. // public void TestNestedNonRoots_OnlyOneRoot_OnlyRootCanHaveBorders ()
  1280. // {
  1281. // var tv = new TileView {
  1282. // Width = 10,
  1283. // Height = 5,
  1284. // ColorScheme = new ColorScheme (),
  1285. // Border = new Border () { BorderStyle = BorderStyle.Single }
  1286. // };
  1287. // tv.TrySplitTile (1, 2, out var tv2);
  1288. // tv2.ColorScheme = new ColorScheme ();
  1289. // tv2.Border.BorderStyle = BorderStyle.Single;
  1290. // tv2.Orientation = Orientation.Horizontal;
  1291. // Assert.True (tv.IsRootTileView ());
  1292. // Application.Top.Add (tv);
  1293. // tv.BeginInit ();
  1294. // tv.EndInit ();
  1295. // tv.LayoutSubviews ();
  1296. // tv.LayoutSubviews ();
  1297. // tv.Tiles.ElementAt (1).ContentView.LayoutSubviews ();
  1298. // tv2.LayoutSubviews ();
  1299. // // tv2 is not considered a root because
  1300. // // it was created via TrySplitTile so it
  1301. // // will have its lines joined to
  1302. // // parent and cannot have its own border
  1303. // Assert.False (tv2.IsRootTileView ());
  1304. // tv.Redraw (tv.Bounds);
  1305. // var looksLike =
  1306. //@"
  1307. //┌────┬───┐
  1308. //│ │ │
  1309. //│ ├───┤
  1310. //│ │ │
  1311. //└────┴───┘
  1312. //";
  1313. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1314. // }
  1315. // [Fact, AutoInitShutdown]
  1316. // public void TestTrySplit_ShouldRetainTitle ()
  1317. // {
  1318. // var tv = new TileView ();
  1319. // tv.Tiles.ElementAt (0).Title = "flibble";
  1320. // tv.TrySplitTile (0, 2, out var subTileView);
  1321. // // We moved the content so the title should also have been moved
  1322. // Assert.Equal ("flibble", subTileView.Tiles.ElementAt (0).Title);
  1323. // // Secondly we should have cleared the old title (it should have been moved not copied)
  1324. // Assert.Empty (tv.Tiles.ElementAt (0).Title);
  1325. // }
  1326. // [Fact, AutoInitShutdown]
  1327. // public void TestNestedContainer3RightAnd1Down_TileVisibility_WithBorder ()
  1328. // {
  1329. // var tileView = GetNestedContainer3Right1Down (true);
  1330. // tileView.Redraw (tileView.Bounds);
  1331. // string looksLike =
  1332. //@"
  1333. //┌─────┬──────┬─────┐
  1334. //│11111│222222│33333│
  1335. //│11111│222222│33333│
  1336. //│11111│222222│33333│
  1337. //│11111│222222│33333│
  1338. //│11111│222222├─────┤
  1339. //│11111│222222│44444│
  1340. //│11111│222222│44444│
  1341. //│11111│222222│44444│
  1342. //└─────┴──────┴─────┘";
  1343. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1344. // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1345. // tileView.Tiles.ElementAt (1).ContentView.Visible = true;
  1346. // tileView.Tiles.ElementAt (2).ContentView.Visible = true;
  1347. // tileView.LayoutSubviews ();
  1348. // tileView.Redraw (tileView.Bounds);
  1349. // looksLike =
  1350. //@"
  1351. //┌────────────┬─────┐
  1352. //│222222222222│33333│
  1353. //│222222222222│33333│
  1354. //│222222222222│33333│
  1355. //│222222222222│33333│
  1356. //│222222222222├─────┤
  1357. //│222222222222│44444│
  1358. //│222222222222│44444│
  1359. //│222222222222│44444│
  1360. //└────────────┴─────┘";
  1361. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1362. // // BUGBUG: v2 - Something broke and I can't figure it out. Disabling for now.
  1363. // // tileView.Tiles.ElementAt (0).ContentView.Visible = true;
  1364. // // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1365. // // tileView.Tiles.ElementAt (2).ContentView.Visible = true;
  1366. // // tileView.LayoutSubviews ();
  1367. // // tileView.Redraw (tileView.Bounds);
  1368. // // looksLike =
  1369. // //@"
  1370. // //┌────────────┬─────┐
  1371. // //│111111111111│33333│
  1372. // //│111111111111│33333│
  1373. // //│111111111111│33333│
  1374. // //│111111111111│33333│
  1375. // //│111111111111├─────┤
  1376. // //│111111111111│44444│
  1377. // //│111111111111│44444│
  1378. // //│111111111111│44444│
  1379. // //└────────────┴─────┘";
  1380. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1381. // // tileView.Tiles.ElementAt (0).ContentView.Visible = true;
  1382. // // tileView.Tiles.ElementAt (1).ContentView.Visible = true;
  1383. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1384. // // tileView.LayoutSubviews ();
  1385. // // tileView.Redraw (tileView.Bounds);
  1386. // // looksLike =
  1387. // //@"
  1388. // //┌─────┬────────────┐
  1389. // //│11111│222222222222│
  1390. // //│11111│222222222222│
  1391. // //│11111│222222222222│
  1392. // //│11111│222222222222│
  1393. // //│11111│222222222222│
  1394. // //│11111│222222222222│
  1395. // //│11111│222222222222│
  1396. // //│11111│222222222222│
  1397. // //└─────┴────────────┘";
  1398. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1399. // // tileView.Tiles.ElementAt (0).ContentView.Visible = true;
  1400. // // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1401. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1402. // // tileView.LayoutSubviews ();
  1403. // // tileView.Redraw (tileView.Bounds);
  1404. // // looksLike =
  1405. // //@"
  1406. // //┌──────────────────┐
  1407. // //│111111111111111111│
  1408. // //│111111111111111111│
  1409. // //│111111111111111111│
  1410. // //│111111111111111111│
  1411. // //│111111111111111111│
  1412. // //│111111111111111111│
  1413. // //│111111111111111111│
  1414. // //│111111111111111111│
  1415. // //└──────────────────┘";
  1416. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1417. // // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1418. // // tileView.Tiles.ElementAt (1).ContentView.Visible = true;
  1419. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1420. // // tileView.LayoutSubviews ();
  1421. // // tileView.Redraw (tileView.Bounds);
  1422. // // looksLike =
  1423. // //@"
  1424. // //┌──────────────────┐
  1425. // //│222222222222222222│
  1426. // //│222222222222222222│
  1427. // //│222222222222222222│
  1428. // //│222222222222222222│
  1429. // //│222222222222222222│
  1430. // //│222222222222222222│
  1431. // //│222222222222222222│
  1432. // //│222222222222222222│
  1433. // //└──────────────────┘";
  1434. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1435. // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1436. // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1437. // tileView.Tiles.ElementAt (2).ContentView.Visible = true;
  1438. // tileView.LayoutSubviews ();
  1439. // tileView.Redraw (tileView.Bounds);
  1440. // looksLike =
  1441. //@"
  1442. //┌──────────────────┐
  1443. //│333333333333333333│
  1444. //│333333333333333333│
  1445. //│333333333333333333│
  1446. //│333333333333333333│
  1447. //├──────────────────┤
  1448. //│444444444444444444│
  1449. //│444444444444444444│
  1450. //│444444444444444444│
  1451. //└──────────────────┘";
  1452. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1453. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1454. // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1455. // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1456. // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1457. // tileView.LayoutSubviews ();
  1458. // tileView.Redraw (tileView.Bounds);
  1459. // looksLike =
  1460. //@"
  1461. //┌──────────────────┐
  1462. //│ │
  1463. //│ │
  1464. //│ │
  1465. //│ │
  1466. //│ │
  1467. //│ │
  1468. //│ │
  1469. //│ │
  1470. //└──────────────────┘";
  1471. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1472. // }
  1473. // [Fact, AutoInitShutdown]
  1474. // public void TestNestedContainer3RightAnd1Down_TileVisibility_WithoutBorder ()
  1475. // {
  1476. // var tileView = GetNestedContainer3Right1Down (false);
  1477. // tileView.Redraw (tileView.Bounds);
  1478. // string looksLike =
  1479. //@"
  1480. //111111│222222│333333
  1481. //111111│222222│333333
  1482. //111111│222222│333333
  1483. //111111│222222│333333
  1484. //111111│222222│333333
  1485. //111111│222222├──────
  1486. //111111│222222│444444
  1487. //111111│222222│444444
  1488. //111111│222222│444444
  1489. //111111│222222│444444";
  1490. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1491. // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1492. // tileView.Tiles.ElementAt (1).ContentView.Visible = true;
  1493. // tileView.Tiles.ElementAt (2).ContentView.Visible = true;
  1494. // tileView.LayoutSubviews ();
  1495. // tileView.Redraw (tileView.Bounds);
  1496. // looksLike =
  1497. //@"
  1498. //2222222222222│333333
  1499. //2222222222222│333333
  1500. //2222222222222│333333
  1501. //2222222222222│333333
  1502. //2222222222222│333333
  1503. //2222222222222├──────
  1504. //2222222222222│444444
  1505. //2222222222222│444444
  1506. //2222222222222│444444
  1507. //2222222222222│444444";
  1508. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1509. // // BUGBUG: v2 - Something broke and I can't figure it out. Disabling for now.
  1510. // // tileView.Tiles.ElementAt (0).ContentView.Visible = true;
  1511. // // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1512. // // tileView.Tiles.ElementAt (2).ContentView.Visible = true;
  1513. // // tileView.LayoutSubviews ();
  1514. // // tileView.Redraw (tileView.Bounds);
  1515. // // looksLike =
  1516. // //@"
  1517. // //1111111111111│333333
  1518. // //1111111111111│333333
  1519. // //1111111111111│333333
  1520. // //1111111111111│333333
  1521. // //1111111111111│333333
  1522. // //1111111111111├──────
  1523. // //1111111111111│444444
  1524. // //1111111111111│444444
  1525. // //1111111111111│444444
  1526. // //1111111111111│444444";
  1527. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1528. // // tileView.Tiles.ElementAt (0).ContentView.Visible = true;
  1529. // // tileView.Tiles.ElementAt (1).ContentView.Visible = true;
  1530. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1531. // // tileView.LayoutSubviews ();
  1532. // // tileView.Redraw (tileView.Bounds);
  1533. // // looksLike =
  1534. // //@"
  1535. // //111111│2222222222222
  1536. // //111111│2222222222222
  1537. // //111111│2222222222222
  1538. // //111111│2222222222222
  1539. // //111111│2222222222222
  1540. // //111111│2222222222222
  1541. // //111111│2222222222222
  1542. // //111111│2222222222222
  1543. // //111111│2222222222222
  1544. // //111111│2222222222222";
  1545. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1546. // // tileView.Tiles.ElementAt (0).ContentView.Visible = true;
  1547. // // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1548. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1549. // // tileView.LayoutSubviews ();
  1550. // // tileView.Redraw (tileView.Bounds);
  1551. // // looksLike =
  1552. // //@"
  1553. // //11111111111111111111
  1554. // //11111111111111111111
  1555. // //11111111111111111111
  1556. // //11111111111111111111
  1557. // //11111111111111111111
  1558. // //11111111111111111111
  1559. // //11111111111111111111
  1560. // //11111111111111111111
  1561. // //11111111111111111111
  1562. // //11111111111111111111";
  1563. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1564. // // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1565. // // tileView.Tiles.ElementAt (1).ContentView.Visible = true;
  1566. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1567. // // tileView.LayoutSubviews ();
  1568. // // tileView.Redraw (tileView.Bounds);
  1569. // // looksLike =
  1570. // //@"
  1571. // //22222222222222222222
  1572. // //22222222222222222222
  1573. // //22222222222222222222
  1574. // //22222222222222222222
  1575. // //22222222222222222222
  1576. // //22222222222222222222
  1577. // //22222222222222222222
  1578. // //22222222222222222222
  1579. // //22222222222222222222
  1580. // //22222222222222222222";
  1581. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1582. // // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1583. // // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1584. // // tileView.Tiles.ElementAt (2).ContentView.Visible = true;
  1585. // // tileView.LayoutSubviews ();
  1586. // // tileView.Redraw (tileView.Bounds);
  1587. // // looksLike =
  1588. // //@"
  1589. // //33333333333333333333
  1590. // //33333333333333333333
  1591. // //33333333333333333333
  1592. // //33333333333333333333
  1593. // //33333333333333333333
  1594. // //────────────────────
  1595. // //44444444444444444444
  1596. // //44444444444444444444
  1597. // //44444444444444444444
  1598. // //44444444444444444444";
  1599. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1600. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1601. // // tileView.Tiles.ElementAt (0).ContentView.Visible = false;
  1602. // // tileView.Tiles.ElementAt (1).ContentView.Visible = false;
  1603. // // tileView.Tiles.ElementAt (2).ContentView.Visible = false;
  1604. // // tileView.LayoutSubviews ();
  1605. // // tileView.Redraw (tileView.Bounds);
  1606. // // looksLike =
  1607. // //@"
  1608. // // ";
  1609. // // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1610. // }
  1611. // [Fact, AutoInitShutdown]
  1612. // public void Test_SplitTop_WholeBottom ()
  1613. // {
  1614. // var tileView = new TileView (2) {
  1615. // Width = 20,
  1616. // Height = 10,
  1617. // Orientation = Orientation.Horizontal,
  1618. // };
  1619. // tileView.BorderStyle = BorderStyle.Single;
  1620. // Assert.True (tileView.TrySplitTile (0, 2, out TileView top));
  1621. // top.Tiles.ElementAt (0).ContentView.Add (new Label ("bleh"));
  1622. // top.Tiles.ElementAt (1).ContentView.Add (new Label ("blah"));
  1623. // top.BeginInit ();
  1624. // top.EndInit ();
  1625. // tileView.Tiles.ElementAt (1).ContentView.Add (new Label ("Hello"));
  1626. // tileView.ColorScheme = new ColorScheme ();
  1627. // top.ColorScheme = new ColorScheme ();
  1628. // tileView.LayoutSubviews ();
  1629. // tileView.Redraw (tileView.Bounds);
  1630. // string looksLike =
  1631. //@"
  1632. //┌─────────┬────────┐
  1633. //│bleh │blah │
  1634. //│ │ │
  1635. //│ │ │
  1636. //│ │ │
  1637. //├─────────┴────────┤
  1638. //│Hello │
  1639. //│ │
  1640. //│ │
  1641. //└──────────────────┘";
  1642. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1643. // }
  1644. // [Fact, AutoInitShutdown]
  1645. // public void TestNestedContainer3RightAnd1Down_TitleDoesNotOverspill ()
  1646. // {
  1647. // var tileView = GetNestedContainer3Right1Down (true, true, 1);
  1648. // tileView.Redraw (tileView.Bounds);
  1649. // string looksLike =
  1650. //@"
  1651. //┌ T1 ─┬ T3 ──┬ T2 ─┐
  1652. //│11111│333333│22222│
  1653. //│11111│333333│22222│
  1654. //│11111│333333│22222│
  1655. //│11111│333333│22222│
  1656. //│11111├ T4 ──┤22222│
  1657. //│11111│444444│22222│
  1658. //│11111│444444│22222│
  1659. //│11111│444444│22222│
  1660. //└─────┴──────┴─────┘";
  1661. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1662. // }
  1663. // [Fact, AutoInitShutdown]
  1664. // public void TestNestedContainer3RightAnd1Down_TitleTriesToOverspill ()
  1665. // {
  1666. // var tileView = GetNestedContainer3Right1Down (true, true, 1);
  1667. // tileView.Tiles.ElementAt (0).Title = new string ('x', 100);
  1668. // ((TileView)tileView.Tiles.ElementAt (1).ContentView)
  1669. // .Tiles.ElementAt (1).Title = new string ('y', 100);
  1670. // tileView.Redraw (tileView.Bounds);
  1671. // string looksLike =
  1672. //@"
  1673. //┌ xxxx┬ T3 ──┬ T2 ─┐
  1674. //│11111│333333│22222│
  1675. //│11111│333333│22222│
  1676. //│11111│333333│22222│
  1677. //│11111│333333│22222│
  1678. //│11111├ yyyyy┤22222│
  1679. //│11111│444444│22222│
  1680. //│11111│444444│22222│
  1681. //│11111│444444│22222│
  1682. //└─────┴──────┴─────┘";
  1683. // TestHelpers.AssertDriverContentsAre (looksLike, output);
  1684. // }
  1685. // [Fact, AutoInitShutdown]
  1686. // public void TestDisposal_NoEarlyDisposalsOfUsersViews_DuringRebuildForTileCount ()
  1687. // {
  1688. // var tv = GetTileView (20, 10);
  1689. // var myReusableView = new DisposeCounter ();
  1690. // // I want my view in the first tile
  1691. // tv.Tiles.ElementAt (0).ContentView.Add (myReusableView);
  1692. // Assert.Equal (0, myReusableView.DisposalCount);
  1693. // // I've changed my mind, I want 3 tiles now
  1694. // tv.RebuildForTileCount (3);
  1695. // // but I still want my view in the first tile
  1696. // tv.Tiles.ElementAt (0).ContentView.Add (myReusableView);
  1697. // Assert.Multiple (
  1698. // () => Assert.Equal (0, myReusableView.DisposalCount)
  1699. // , () => {
  1700. // tv.Dispose ();
  1701. // Assert.Equal (1, myReusableView.DisposalCount);
  1702. // });
  1703. // }
  1704. // [Fact, AutoInitShutdown]
  1705. // public void TestDisposal_NoEarlyDisposalsOfUsersViews_DuringInsertTile ()
  1706. // {
  1707. // var tv = GetTileView (20, 10);
  1708. // var myReusableView = new DisposeCounter ();
  1709. // // I want my view in the first tile
  1710. // tv.Tiles.ElementAt (0).ContentView.Add (myReusableView);
  1711. // Assert.Equal (0, myReusableView.DisposalCount);
  1712. // // I've changed my mind, I want 3 tiles now
  1713. // tv.InsertTile (0);
  1714. // tv.InsertTile (2);
  1715. // // but I still want my view in the first tile
  1716. // tv.Tiles.ElementAt (0).ContentView.Add (myReusableView);
  1717. // Assert.Multiple (
  1718. // () => Assert.Equal (0, myReusableView.DisposalCount)
  1719. // , () => {
  1720. // tv.Dispose ();
  1721. // Assert.True (myReusableView.DisposalCount >= 1);
  1722. // });
  1723. // }
  1724. // [Theory, AutoInitShutdown]
  1725. // [InlineData (0)]
  1726. // [InlineData (1)]
  1727. // public void TestDisposal_NoEarlyDisposalsOfUsersViews_DuringRemoveTile (int idx)
  1728. // {
  1729. // var tv = GetTileView (20, 10);
  1730. // var myReusableView = new DisposeCounter ();
  1731. // // I want my view in the first tile
  1732. // tv.Tiles.ElementAt (0).ContentView.Add (myReusableView);
  1733. // Assert.Equal (0, myReusableView.DisposalCount);
  1734. // tv.RemoveTile (idx);
  1735. // // but I still want my view in the first tile
  1736. // tv.Tiles.ElementAt (0).ContentView.Add (myReusableView);
  1737. // Assert.Multiple (
  1738. // () => Assert.Equal (0, myReusableView.DisposalCount)
  1739. // , () => {
  1740. // tv.Dispose ();
  1741. // Assert.True (myReusableView.DisposalCount >= 1);
  1742. // });
  1743. // }
  1744. // private class DisposeCounter : View {
  1745. // public int DisposalCount;
  1746. // protected override void Dispose (bool disposing)
  1747. // {
  1748. // DisposalCount++;
  1749. // base.Dispose (disposing);
  1750. // }
  1751. // }
  1752. // /// <summary>
  1753. // /// Creates a vertical orientation root container with left pane split into
  1754. // /// two (with horizontal splitter line).
  1755. // /// </summary>
  1756. // /// <param name="withBorder"></param>
  1757. // /// <returns></returns>
  1758. // private TileView GetNestedContainer2Left1Right (bool withBorder)
  1759. // {
  1760. // var container = GetTileView (20, 10, withBorder);
  1761. // Assert.True (container.TrySplitTile (0, 2, out var newContainer));
  1762. // newContainer.Orientation = Orientation.Horizontal;
  1763. // newContainer.ColorScheme = new ColorScheme ();
  1764. // container.ColorScheme = new ColorScheme ();
  1765. // container.LayoutSubviews ();
  1766. // return container;
  1767. // }
  1768. // /// <summary>
  1769. // /// Creates a vertical orientation root container with 3 tiles.
  1770. // /// The rightmost is split horizontally
  1771. // /// </summary>
  1772. // /// <param name="withBorder"></param>
  1773. // /// <returns></returns>
  1774. // private TileView GetNestedContainer3Right1Down (bool withBorder, bool withTitles = false, int split = 2)
  1775. // {
  1776. // var container = new TileView (3) {
  1777. // Width = 20,
  1778. // Height = 10
  1779. // };
  1780. // container.Border.BorderStyle = withBorder ? BorderStyle.Single : BorderStyle.None;
  1781. // Assert.True (container.TrySplitTile (split, 2, out var newContainer));
  1782. // newContainer.Orientation = Orientation.Horizontal;
  1783. // int i = 0;
  1784. // foreach (var tile in container.Tiles.Union (newContainer.Tiles)) {
  1785. // if (tile.ContentView is TileView) {
  1786. // continue;
  1787. // }
  1788. // i++;
  1789. // if (withTitles) {
  1790. // tile.Title = "T" + i;
  1791. // }
  1792. // tile.ContentView.Add (new TextView {
  1793. // Width = Dim.Fill (),
  1794. // Height = Dim.Fill (),
  1795. // Text =
  1796. // string.Join ('\n',
  1797. // Enumerable.Repeat (
  1798. // new string (i.ToString () [0], 100)
  1799. // , 10).ToArray ()),
  1800. // WordWrap = false
  1801. // });
  1802. // }
  1803. // newContainer.ColorScheme = new ColorScheme ();
  1804. // container.ColorScheme = new ColorScheme ();
  1805. // container.LayoutSubviews ();
  1806. // return container;
  1807. // }
  1808. // private LineView GetLine (TileView tileView)
  1809. // {
  1810. // return tileView.Subviews.OfType<LineView> ().Single ();
  1811. // }
  1812. // private TileView Get5x1TilesView (bool border = true)
  1813. // {
  1814. // var tv = new TileView (5) {
  1815. // Width = 25,
  1816. // Height = 4,
  1817. // ColorScheme = new ColorScheme (),
  1818. // Border = new Border () { BorderStyle = BorderStyle.Single }
  1819. // };
  1820. // if (!border) {
  1821. // tv.Border.BorderStyle = BorderStyle.None;
  1822. // }
  1823. // tv.Tiles.ElementAt (0).ContentView.Add (new Label (new string ('1', 100)) { AutoSize = false, Width = Dim.Fill (), Height = 1 });
  1824. // tv.Tiles.ElementAt (1).ContentView.Add (new Label (new string ('2', 100)) { AutoSize = false, Width = Dim.Fill (), Height = 1 });
  1825. // tv.Tiles.ElementAt (2).ContentView.Add (new Label (new string ('3', 100)) { AutoSize = false, Width = Dim.Fill (), Height = 1 });
  1826. // tv.Tiles.ElementAt (3).ContentView.Add (new Label (new string ('4', 100)) { AutoSize = false, Width = Dim.Fill (), Height = 1 });
  1827. // tv.Tiles.ElementAt (4).ContentView.Add (new Label (new string ('5', 100)) { AutoSize = false, Width = Dim.Fill (), Height = 1 });
  1828. // Application.Top.Add (tv);
  1829. // tv.BeginInit ();
  1830. // tv.EndInit ();
  1831. // tv.LayoutSubviews ();
  1832. // return tv;
  1833. // }
  1834. // private TileView Get11By3TileView (out LineView line, bool withBorder = false)
  1835. // {
  1836. // var split = Get11By3TileView (withBorder);
  1837. // line = GetLine (split);
  1838. // return split;
  1839. // }
  1840. // private TileView Get11By3TileView (bool withBorder = false)
  1841. // {
  1842. // return GetTileView (11, 3, withBorder);
  1843. // }
  1844. // private TileView GetTileView (int width, int height, bool withBorder = false)
  1845. // {
  1846. // var container = new TileView () {
  1847. // Width = width,
  1848. // Height = height,
  1849. // };
  1850. // container.Border.BorderStyle = withBorder ? BorderStyle.Single : BorderStyle.None;
  1851. // container.Tiles.ElementAt (0).ContentView.Add (new Label (new string ('1', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false });
  1852. // container.Tiles.ElementAt (0).ContentView.Add (new Label (new string ('1', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false, Y = 1 });
  1853. // container.Tiles.ElementAt (1).ContentView.Add (new Label (new string ('2', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false });
  1854. // container.Tiles.ElementAt (1).ContentView.Add (new Label (new string ('2', 100)) { Width = Dim.Fill (), Height = 1, AutoSize = false, Y = 1 });
  1855. // container.Tiles.ElementAt (0).MinSize = 0;
  1856. // container.Tiles.ElementAt (1).MinSize = 0;
  1857. // Application.Top.Add (container);
  1858. // container.ColorScheme = new ColorScheme ();
  1859. // container.LayoutSubviews ();
  1860. // container.BeginInit ();
  1861. // container.EndInit ();
  1862. // return container;
  1863. // }
  1864. // }
  1865. //}