TileViewTests.cs 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  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. //}