TabViewTests.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Terminal.Gui;
  7. using Xunit;
  8. using System.Globalization;
  9. using Xunit.Abstractions;
  10. namespace Terminal.Gui.Views {
  11. public class TabViewTests {
  12. readonly ITestOutputHelper output;
  13. public TabViewTests (ITestOutputHelper output)
  14. {
  15. this.output = output;
  16. }
  17. private TabView GetTabView ()
  18. {
  19. return GetTabView (out _, out _);
  20. }
  21. private TabView GetTabView (out TabView.Tab tab1, out TabView.Tab tab2, bool initFakeDriver = true)
  22. {
  23. if (initFakeDriver)
  24. InitFakeDriver ();
  25. var tv = new TabView ();
  26. tv.ColorScheme = new ColorScheme ();
  27. tv.AddTab (tab1 = new TabView.Tab ("Tab1", new TextField ("hi")), false);
  28. tv.AddTab (tab2 = new TabView.Tab ("Tab2", new Label ("hi2")), false);
  29. return tv;
  30. }
  31. [Fact]
  32. public void AddTwoTabs_SecondIsSelected ()
  33. {
  34. InitFakeDriver ();
  35. var tv = new TabView ();
  36. TabView.Tab tab1;
  37. TabView.Tab tab2;
  38. tv.AddTab (tab1 = new TabView.Tab ("Tab1", new TextField ("hi")), false);
  39. tv.AddTab (tab2 = new TabView.Tab ("Tab1", new Label ("hi2")), true);
  40. Assert.Equal (2, tv.Tabs.Count);
  41. Assert.Equal (tab2, tv.SelectedTab);
  42. Application.Shutdown ();
  43. }
  44. [Fact]
  45. public void EnsureSelectedTabVisible_NullSelect ()
  46. {
  47. var tv = GetTabView ();
  48. tv.SelectedTab = null;
  49. Assert.Null (tv.SelectedTab);
  50. Assert.Equal (0, tv.TabScrollOffset);
  51. tv.EnsureSelectedTabIsVisible ();
  52. Assert.Null (tv.SelectedTab);
  53. Assert.Equal (0, tv.TabScrollOffset);
  54. Application.Shutdown ();
  55. }
  56. [Fact]
  57. public void EnsureSelectedTabVisible_MustScroll ()
  58. {
  59. var tv = GetTabView (out var tab1, out var tab2);
  60. // Make tab width small to force only one tab visible at once
  61. tv.Width = 4;
  62. tv.SelectedTab = tab1;
  63. Assert.Equal (0, tv.TabScrollOffset);
  64. tv.EnsureSelectedTabIsVisible ();
  65. Assert.Equal (0, tv.TabScrollOffset);
  66. // Asking to show tab2 should automatically move scroll offset accordingly
  67. tv.SelectedTab = tab2;
  68. Assert.Equal (1, tv.TabScrollOffset);
  69. // Shutdown must be called to safely clean up Application if Init has been called
  70. Application.Shutdown ();
  71. }
  72. [Fact]
  73. public void SelectedTabChanged_Called ()
  74. {
  75. var tv = GetTabView (out var tab1, out var tab2);
  76. tv.SelectedTab = tab1;
  77. TabView.Tab oldTab = null;
  78. TabView.Tab newTab = null;
  79. int called = 0;
  80. tv.SelectedTabChanged += (s, e) => {
  81. oldTab = e.OldTab;
  82. newTab = e.NewTab;
  83. called++;
  84. };
  85. tv.SelectedTab = tab2;
  86. Assert.Equal (1, called);
  87. Assert.Equal (tab1, oldTab);
  88. Assert.Equal (tab2, newTab);
  89. // Shutdown must be called to safely clean up Application if Init has been called
  90. Application.Shutdown ();
  91. }
  92. [Fact]
  93. public void RemoveTab_ChangesSelection ()
  94. {
  95. var tv = GetTabView (out var tab1, out var tab2);
  96. tv.SelectedTab = tab1;
  97. tv.RemoveTab (tab1);
  98. Assert.Equal (tab2, tv.SelectedTab);
  99. // Shutdown must be called to safely clean up Application if Init has been called
  100. Application.Shutdown ();
  101. }
  102. [Fact]
  103. public void RemoveTab_MultipleCalls_NotAnError ()
  104. {
  105. var tv = GetTabView (out var tab1, out var tab2);
  106. tv.SelectedTab = tab1;
  107. // Repeated calls to remove a tab that is not part of
  108. // the collection should be ignored
  109. tv.RemoveTab (tab1);
  110. tv.RemoveTab (tab1);
  111. tv.RemoveTab (tab1);
  112. tv.RemoveTab (tab1);
  113. Assert.Equal (tab2, tv.SelectedTab);
  114. // Shutdown must be called to safely clean up Application if Init has been called
  115. Application.Shutdown ();
  116. }
  117. [Fact]
  118. public void RemoveAllTabs_ClearsSelection ()
  119. {
  120. var tv = GetTabView (out var tab1, out var tab2);
  121. tv.SelectedTab = tab1;
  122. tv.RemoveTab (tab1);
  123. tv.RemoveTab (tab2);
  124. Assert.Null (tv.SelectedTab);
  125. // Shutdown must be called to safely clean up Application if Init has been called
  126. Application.Shutdown ();
  127. }
  128. [Fact]
  129. public void SwitchTabBy_NormalUsage ()
  130. {
  131. var tv = GetTabView (out var tab1, out var tab2);
  132. TabView.Tab tab3;
  133. TabView.Tab tab4;
  134. TabView.Tab tab5;
  135. tv.AddTab (tab3 = new TabView.Tab (), false);
  136. tv.AddTab (tab4 = new TabView.Tab (), false);
  137. tv.AddTab (tab5 = new TabView.Tab (), false);
  138. tv.SelectedTab = tab1;
  139. int called = 0;
  140. tv.SelectedTabChanged += (s, e) => { called++; };
  141. tv.SwitchTabBy (1);
  142. Assert.Equal (1, called);
  143. Assert.Equal (tab2, tv.SelectedTab);
  144. //reset called counter
  145. called = 0;
  146. // go right 2
  147. tv.SwitchTabBy (2);
  148. // even though we go right 2 indexes the event should only be called once
  149. Assert.Equal (1, called);
  150. Assert.Equal (tab4, tv.SelectedTab);
  151. // Shutdown must be called to safely clean up Application if Init has been called
  152. Application.Shutdown ();
  153. }
  154. [Fact]
  155. public void AddTab_SameTabMoreThanOnce ()
  156. {
  157. var tv = GetTabView (out var tab1, out var tab2);
  158. Assert.Equal (2, tv.Tabs.Count);
  159. // Tab is already part of the control so shouldn't result in duplication
  160. tv.AddTab (tab1, false);
  161. tv.AddTab (tab1, false);
  162. tv.AddTab (tab1, false);
  163. tv.AddTab (tab1, false);
  164. Assert.Equal (2, tv.Tabs.Count);
  165. // Shutdown must be called to safely clean up Application if Init has been called
  166. Application.Shutdown ();
  167. }
  168. [Fact]
  169. public void SwitchTabBy_OutOfTabsRange ()
  170. {
  171. var tv = GetTabView (out var tab1, out var tab2);
  172. tv.SelectedTab = tab1;
  173. tv.SwitchTabBy (500);
  174. Assert.Equal (tab2, tv.SelectedTab);
  175. tv.SwitchTabBy (-500);
  176. Assert.Equal (tab1, tv.SelectedTab);
  177. // Shutdown must be called to safely clean up Application if Init has been called
  178. Application.Shutdown ();
  179. }
  180. [Fact, AutoInitShutdown]
  181. public void ShowTopLine_True_TabsOnBottom_False_TestThinTabView_WithLongNames ()
  182. {
  183. var tv = GetTabView (out var tab1, out var tab2, false);
  184. tv.Width = 10;
  185. tv.Height = 5;
  186. // Ensures that the tab bar subview gets the bounds of the parent TabView
  187. tv.LayoutSubviews ();
  188. // Test two tab names that fit
  189. tab1.Text = "12";
  190. tab2.Text = "13";
  191. tv.Redraw (tv.Bounds);
  192. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  193. ┌──┐
  194. │12│13
  195. │ └─────┐
  196. │hi │
  197. └────────┘", output);
  198. tv.SelectedTab = tab2;
  199. tv.Redraw (tv.Bounds);
  200. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  201. ┌──┐
  202. 12│13│
  203. ┌──┘ └──┐
  204. │hi2 │
  205. └────────┘", output);
  206. tv.SelectedTab = tab1;
  207. // Test first tab name too long
  208. tab1.Text = "12345678910";
  209. tab2.Text = "13";
  210. tv.Redraw (tv.Bounds);
  211. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  212. ┌───────┐
  213. │1234567│
  214. │ └►
  215. │hi │
  216. └────────┘", output);
  217. //switch to tab2
  218. tv.SelectedTab = tab2;
  219. tv.Redraw (tv.Bounds);
  220. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  221. ┌──┐
  222. │13│
  223. ◄ └─────┐
  224. │hi2 │
  225. └────────┘", output);
  226. // now make both tabs too long
  227. tab1.Text = "12345678910";
  228. tab2.Text = "abcdefghijklmnopq";
  229. tv.Redraw (tv.Bounds);
  230. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  231. ┌───────┐
  232. │abcdefg│
  233. ◄ └┐
  234. │hi2 │
  235. └────────┘", output);
  236. }
  237. [Fact, AutoInitShutdown]
  238. public void ShowTopLine_False_TabsOnBottom_False_TestThinTabView_WithLongNames ()
  239. {
  240. var tv = GetTabView (out var tab1, out var tab2, false);
  241. tv.Width = 10;
  242. tv.Height = 5;
  243. tv.Style = new TabView.TabStyle { ShowTopLine = false };
  244. tv.ApplyStyleChanges ();
  245. // Ensures that the tab bar subview gets the bounds of the parent TabView
  246. tv.LayoutSubviews ();
  247. // Test two tab names that fit
  248. tab1.Text = "12";
  249. tab2.Text = "13";
  250. tv.Redraw (tv.Bounds);
  251. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  252. │12│13
  253. │ └─────┐
  254. │hi │
  255. │ │
  256. └────────┘", output);
  257. tv.SelectedTab = tab2;
  258. tv.Redraw (tv.Bounds);
  259. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  260. 12│13│
  261. ┌──┘ └──┐
  262. │hi2 │
  263. │ │
  264. └────────┘", output);
  265. tv.SelectedTab = tab1;
  266. // Test first tab name too long
  267. tab1.Text = "12345678910";
  268. tab2.Text = "13";
  269. tv.Redraw (tv.Bounds);
  270. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  271. │1234567│
  272. │ └►
  273. │hi │
  274. │ │
  275. └────────┘", output);
  276. //switch to tab2
  277. tv.SelectedTab = tab2;
  278. tv.Redraw (tv.Bounds);
  279. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  280. │13│
  281. ◄ └─────┐
  282. │hi2 │
  283. │ │
  284. └────────┘", output);
  285. // now make both tabs too long
  286. tab1.Text = "12345678910";
  287. tab2.Text = "abcdefghijklmnopq";
  288. tv.Redraw (tv.Bounds);
  289. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  290. │abcdefg│
  291. ◄ └┐
  292. │hi2 │
  293. │ │
  294. └────────┘", output);
  295. }
  296. [Fact, AutoInitShutdown]
  297. public void ShowTopLine_True_TabsOnBottom_False_TestTabView_Width4 ()
  298. {
  299. var tv = GetTabView (out _, out _, false);
  300. tv.Width = 4;
  301. tv.Height = 5;
  302. tv.LayoutSubviews ();
  303. tv.Redraw (tv.Bounds);
  304. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  305. ┌─┐
  306. │T│
  307. │ └►
  308. │hi│
  309. └──┘", output);
  310. }
  311. [Fact, AutoInitShutdown]
  312. public void ShowTopLine_False_TabsOnBottom_False_TestTabView_Width4 ()
  313. {
  314. var tv = GetTabView (out _, out _, false);
  315. tv.Width = 4;
  316. tv.Height = 5;
  317. tv.Style = new TabView.TabStyle { ShowTopLine = false };
  318. tv.ApplyStyleChanges ();
  319. tv.LayoutSubviews ();
  320. tv.Redraw (tv.Bounds);
  321. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  322. │T│
  323. │ └►
  324. │hi│
  325. │ │
  326. └──┘", output);
  327. }
  328. [Fact, AutoInitShutdown]
  329. public void ShowTopLine_True_TabsOnBottom_False_TestTabView_Width3 ()
  330. {
  331. var tv = GetTabView (out _, out _, false);
  332. tv.Width = 3;
  333. tv.Height = 5;
  334. tv.LayoutSubviews ();
  335. tv.Redraw (tv.Bounds);
  336. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  337. ┌┐
  338. ││
  339. │└►
  340. │h│
  341. └─┘", output);
  342. }
  343. [Fact, AutoInitShutdown]
  344. public void ShowTopLine_False_TabsOnBottom_False_TestTabView_Width3 ()
  345. {
  346. var tv = GetTabView (out _, out _, false);
  347. tv.Width = 3;
  348. tv.Height = 5;
  349. tv.Style = new TabView.TabStyle { ShowTopLine = false };
  350. tv.ApplyStyleChanges ();
  351. tv.LayoutSubviews ();
  352. tv.Redraw (tv.Bounds);
  353. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  354. ││
  355. │└►
  356. │h│
  357. │ │
  358. └─┘", output);
  359. }
  360. [Fact, AutoInitShutdown]
  361. public void ShowTopLine_True_TabsOnBottom_True_TestThinTabView_WithLongNames ()
  362. {
  363. var tv = GetTabView (out var tab1, out var tab2, false);
  364. tv.Width = 10;
  365. tv.Height = 5;
  366. tv.Style = new TabView.TabStyle { TabsOnBottom = true };
  367. tv.ApplyStyleChanges ();
  368. // Ensures that the tab bar subview gets the bounds of the parent TabView
  369. tv.LayoutSubviews ();
  370. // Test two tab names that fit
  371. tab1.Text = "12";
  372. tab2.Text = "13";
  373. tv.Redraw (tv.Bounds);
  374. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  375. ┌────────┐
  376. │hi │
  377. │ ┌─────┘
  378. │12│13
  379. └──┘ ", output);
  380. // Test first tab name too long
  381. tab1.Text = "12345678910";
  382. tab2.Text = "13";
  383. tv.Redraw (tv.Bounds);
  384. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  385. ┌────────┐
  386. │hi │
  387. │ ┌►
  388. │1234567│
  389. └───────┘ ", output);
  390. //switch to tab2
  391. tv.SelectedTab = tab2;
  392. tv.Redraw (tv.Bounds);
  393. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  394. ┌────────┐
  395. │hi2 │
  396. ◄ ┌─────┘
  397. │13│
  398. └──┘ ", output);
  399. // now make both tabs too long
  400. tab1.Text = "12345678910";
  401. tab2.Text = "abcdefghijklmnopq";
  402. tv.Redraw (tv.Bounds);
  403. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  404. ┌────────┐
  405. │hi2 │
  406. ◄ ┌┘
  407. │abcdefg│
  408. └───────┘ ", output);
  409. }
  410. [Fact, AutoInitShutdown]
  411. public void ShowTopLine_False_TabsOnBottom_True_TestThinTabView_WithLongNames ()
  412. {
  413. var tv = GetTabView (out var tab1, out var tab2, false);
  414. tv.Width = 10;
  415. tv.Height = 5;
  416. tv.Style = new TabView.TabStyle { ShowTopLine = false, TabsOnBottom = true };
  417. tv.ApplyStyleChanges ();
  418. // Ensures that the tab bar subview gets the bounds of the parent TabView
  419. tv.LayoutSubviews ();
  420. // Test two tab names that fit
  421. tab1.Text = "12";
  422. tab2.Text = "13";
  423. tv.Redraw (tv.Bounds);
  424. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  425. ┌────────┐
  426. │hi │
  427. │ │
  428. │ ┌─────┘
  429. │12│13 ", output);
  430. tv.SelectedTab = tab2;
  431. tv.Redraw (tv.Bounds);
  432. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  433. ┌────────┐
  434. │hi2 │
  435. │ │
  436. └──┐ ┌──┘
  437. 12│13│ ", output);
  438. tv.SelectedTab = tab1;
  439. // Test first tab name too long
  440. tab1.Text = "12345678910";
  441. tab2.Text = "13";
  442. tv.Redraw (tv.Bounds);
  443. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  444. ┌────────┐
  445. │hi │
  446. │ │
  447. │ ┌►
  448. │1234567│ ", output);
  449. //switch to tab2
  450. tv.SelectedTab = tab2;
  451. tv.Redraw (tv.Bounds);
  452. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  453. ┌────────┐
  454. │hi2 │
  455. │ │
  456. ◄ ┌─────┘
  457. │13│ ", output);
  458. // now make both tabs too long
  459. tab1.Text = "12345678910";
  460. tab2.Text = "abcdefghijklmnopq";
  461. tv.Redraw (tv.Bounds);
  462. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  463. ┌────────┐
  464. │hi2 │
  465. │ │
  466. ◄ ┌┘
  467. │abcdefg│ ", output);
  468. }
  469. [Fact, AutoInitShutdown]
  470. public void ShowTopLine_True_TabsOnBottom_True_TestTabView_Width4 ()
  471. {
  472. var tv = GetTabView (out _, out _, false);
  473. tv.Width = 4;
  474. tv.Height = 5;
  475. tv.Style = new TabView.TabStyle { TabsOnBottom = true };
  476. tv.ApplyStyleChanges ();
  477. tv.LayoutSubviews ();
  478. tv.Redraw (tv.Bounds);
  479. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  480. ┌──┐
  481. │hi│
  482. │ ┌►
  483. │T│
  484. └─┘ ", output);
  485. }
  486. [Fact, AutoInitShutdown]
  487. public void ShowTopLine_False_TabsOnBottom_True_TestTabView_Width4 ()
  488. {
  489. var tv = GetTabView (out _, out _, false);
  490. tv.Width = 4;
  491. tv.Height = 5;
  492. tv.Style = new TabView.TabStyle { ShowTopLine = false, TabsOnBottom = true };
  493. tv.ApplyStyleChanges ();
  494. tv.LayoutSubviews ();
  495. tv.Redraw (tv.Bounds);
  496. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  497. ┌──┐
  498. │hi│
  499. │ │
  500. │ ┌►
  501. │T│ ", output);
  502. }
  503. [Fact, AutoInitShutdown]
  504. public void ShowTopLine_True_TabsOnBottom_True_TestTabView_Width3 ()
  505. {
  506. var tv = GetTabView (out _, out _, false);
  507. tv.Width = 3;
  508. tv.Height = 5;
  509. tv.Style = new TabView.TabStyle { TabsOnBottom = true };
  510. tv.ApplyStyleChanges ();
  511. tv.LayoutSubviews ();
  512. tv.Redraw (tv.Bounds);
  513. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  514. ┌─┐
  515. │h│
  516. │┌►
  517. ││
  518. └┘ ", output);
  519. }
  520. [Fact, AutoInitShutdown]
  521. public void ShowTopLine_False_TabsOnBottom_True_TestTabView_Width3 ()
  522. {
  523. var tv = GetTabView (out _, out _, false);
  524. tv.Width = 3;
  525. tv.Height = 5;
  526. tv.Style = new TabView.TabStyle { ShowTopLine = false, TabsOnBottom = true };
  527. tv.ApplyStyleChanges ();
  528. tv.LayoutSubviews ();
  529. tv.Redraw (tv.Bounds);
  530. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  531. ┌─┐
  532. │h│
  533. │ │
  534. │┌►
  535. ││ ", output);
  536. }
  537. [Fact, AutoInitShutdown]
  538. public void ShowTopLine_True_TabsOnBottom_False_With_Unicode ()
  539. {
  540. var tv = GetTabView (out var tab1, out var tab2, false);
  541. tv.Width = 20;
  542. tv.Height = 5;
  543. tv.LayoutSubviews ();
  544. tab1.Text = "Tab0";
  545. tab2.Text = "Les Mise" + Char.ConvertFromUtf32 (Int32.Parse ("0301", NumberStyles.HexNumber)) + "rables";
  546. tv.Redraw (tv.Bounds);
  547. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  548. ┌────┐
  549. │Tab0│
  550. │ └─────────────►
  551. │hi │
  552. └──────────────────┘", output);
  553. tv.SelectedTab = tab2;
  554. tv.Redraw (tv.Bounds);
  555. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  556. ┌──────────────┐
  557. │Les Misérables│
  558. ◄ └───┐
  559. │hi2 │
  560. └──────────────────┘", output);
  561. }
  562. [Fact, AutoInitShutdown]
  563. public void ShowTopLine_True_TabsOnBottom_True_With_Unicode ()
  564. {
  565. var tv = GetTabView (out var tab1, out var tab2, false);
  566. tv.Width = 20;
  567. tv.Height = 5;
  568. tv.Style = new TabView.TabStyle { TabsOnBottom = true };
  569. tv.ApplyStyleChanges ();
  570. tv.LayoutSubviews ();
  571. tab1.Text = "Tab0";
  572. tab2.Text = "Les Mise" + Char.ConvertFromUtf32 (Int32.Parse ("0301", NumberStyles.HexNumber)) + "rables";
  573. tv.Redraw (tv.Bounds);
  574. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  575. ┌──────────────────┐
  576. │hi │
  577. │ ┌─────────────►
  578. │Tab0│
  579. └────┘ ", output);
  580. tv.SelectedTab = tab2;
  581. tv.Redraw (tv.Bounds);
  582. GraphViewTests.AssertDriverContentsWithFrameAre (@"
  583. ┌──────────────────┐
  584. │hi2 │
  585. ◄ ┌───┘
  586. │Les Misérables│
  587. └──────────────┘ ", output);
  588. }
  589. private void InitFakeDriver ()
  590. {
  591. var driver = new FakeDriver ();
  592. Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
  593. driver.Init (() => { });
  594. }
  595. }
  596. }