DrawTests.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. #nullable enable
  2. using System.Text;
  3. using Xunit.Abstractions;
  4. namespace Terminal.Gui.ViewTests;
  5. [Trait ("Category", "Output")]
  6. public class DrawTests (ITestOutputHelper output)
  7. {
  8. [Fact]
  9. [SetupFakeDriver]
  10. public void Move_Is_Constrained_To_Viewport ()
  11. {
  12. var view = new View
  13. {
  14. X = 1,
  15. Y = 1,
  16. Width = 3, Height = 3
  17. };
  18. view.Margin.Thickness = new Thickness (1);
  19. // Only valid location w/in Viewport is 0, 0 (view) - 2, 2 (screen)
  20. view.Move (0, 0);
  21. Assert.Equal(new Point(2, 2), new Point (Application.Driver.Col, Application.Driver.Row));
  22. view.Move (-1, -1);
  23. Assert.Equal (new Point (2, 2), new Point (Application.Driver.Col, Application.Driver.Row));
  24. view.Move (1, 1);
  25. Assert.Equal (new Point (2, 2), new Point (Application.Driver.Col, Application.Driver.Row));
  26. }
  27. [Fact]
  28. [SetupFakeDriver]
  29. public void AddRune_Is_Constrained_To_Viewport ()
  30. {
  31. var view = new View
  32. {
  33. X = 1,
  34. Y = 1,
  35. Width = 3, Height = 3
  36. };
  37. view.Margin.Thickness = new Thickness (1);
  38. View.Diagnostics = ViewDiagnosticFlags.Padding;
  39. view.BeginInit();
  40. view.EndInit();
  41. view.Draw();
  42. // Only valid location w/in Viewport is 0, 0 (view) - 2, 2 (screen)
  43. Assert.Equal ((Rune)' ', Application.Driver.Contents [2, 2].Rune);
  44. view.AddRune(0, 0, Rune.ReplacementChar);
  45. Assert.Equal (Rune.ReplacementChar, Application.Driver.Contents [2, 2].Rune);
  46. view.AddRune (-1, -1, Rune.ReplacementChar);
  47. Assert.Equal ((Rune)'M', Application.Driver.Contents [1, 1].Rune);
  48. view.AddRune (1, 1, Rune.ReplacementChar);
  49. Assert.Equal ((Rune)'M', Application.Driver.Contents [3, 3].Rune);
  50. View.Diagnostics = ViewDiagnosticFlags.Off;
  51. }
  52. [Theory]
  53. [InlineData (0, 0, 1, 1)]
  54. [InlineData (0, 0, 2, 2)]
  55. [InlineData (-1, -1, 2, 2)]
  56. [SetupFakeDriver]
  57. public void Clear_Clears_Only_Viewport (int x, int y, int width, int height)
  58. {
  59. var superView = new View { Width = Dim.Fill (), Height = Dim.Fill () };
  60. var view = new View
  61. {
  62. Text = "X",
  63. X = 1, Y = 1,
  64. Width = 3, Height = 3,
  65. BorderStyle = LineStyle.Single
  66. };
  67. superView.Add (view);
  68. superView.BeginInit ();
  69. superView.EndInit ();
  70. superView.LayoutSubviews ();
  71. superView.Draw ();
  72. TestHelpers.AssertDriverContentsWithFrameAre (
  73. @"
  74. ┌─┐
  75. │X│
  76. └─┘",
  77. output);
  78. Rectangle toClear = new (x, y, width, height);
  79. view.Clear (toClear);
  80. TestHelpers.AssertDriverContentsWithFrameAre (
  81. @"
  82. ┌─┐
  83. │ │
  84. └─┘",
  85. output);
  86. // Now try to clear beyond Viewport (invalid)
  87. superView.SetNeedsDisplay ();
  88. superView.Draw ();
  89. TestHelpers.AssertDriverContentsWithFrameAre (
  90. @"
  91. ┌─┐
  92. │X│
  93. └─┘",
  94. output);
  95. toClear = new (-width, -height, width, height);
  96. view.Clear (toClear);
  97. TestHelpers.AssertDriverContentsWithFrameAre (
  98. @"
  99. ┌─┐
  100. │X│
  101. └─┘",
  102. output);
  103. // Now try to clear beyond Viewport (valid)
  104. superView.SetNeedsDisplay ();
  105. superView.Draw ();
  106. TestHelpers.AssertDriverContentsWithFrameAre (
  107. @"
  108. ┌─┐
  109. │X│
  110. └─┘",
  111. output);
  112. toClear = new (-1, -1, width + 1, height + 1);
  113. view.Clear (toClear);
  114. TestHelpers.AssertDriverContentsWithFrameAre (
  115. @"
  116. ┌─┐
  117. │ │
  118. └─┘",
  119. output);
  120. // Now clear too much size
  121. superView.SetNeedsDisplay ();
  122. superView.Draw ();
  123. TestHelpers.AssertDriverContentsWithFrameAre (
  124. @"
  125. ┌─┐
  126. │X│
  127. └─┘",
  128. output);
  129. toClear = new (0, 0, width * 2, height * 2);
  130. view.Clear (toClear);
  131. TestHelpers.AssertDriverContentsWithFrameAre (
  132. @"
  133. ┌─┐
  134. │ │
  135. └─┘",
  136. output);
  137. }
  138. [Fact]
  139. [AutoInitShutdown]
  140. [Trait ("Category", "Unicode")]
  141. public void CJK_Compatibility_Ideographs_ConsoleWidth_ColumnWidth_Equal_Two ()
  142. {
  143. const string us = "\U0000f900";
  144. var r = (Rune)0xf900;
  145. Assert.Equal ("豈", us);
  146. Assert.Equal ("豈", r.ToString ());
  147. Assert.Equal (us, r.ToString ());
  148. Assert.Equal (2, us.GetColumns ());
  149. Assert.Equal (2, r.GetColumns ());
  150. var win = new Window { Title = us };
  151. var view = new View { Text = r.ToString (), Height = Dim.Fill (), Width = Dim.Fill () };
  152. var tf = new TextField { Text = us, Y = 1, Width = 3 };
  153. win.Add (view, tf);
  154. Toplevel top = Application.Top;
  155. top.Add (win);
  156. Application.Begin (top);
  157. ((FakeDriver)Application.Driver).SetBufferSize (10, 4);
  158. const string expectedOutput = """
  159. ┌┤豈├────┐
  160. │豈 │
  161. │豈 │
  162. └────────┘
  163. """;
  164. TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, output);
  165. TestHelpers.AssertDriverContentsAre (expectedOutput, output);
  166. Attribute [] expectedColors =
  167. {
  168. // 0
  169. Colors.ColorSchemes ["Base"].Normal,
  170. // 1
  171. Colors.ColorSchemes ["Base"].Focus,
  172. // 2
  173. Colors.ColorSchemes ["Base"].HotNormal
  174. };
  175. TestHelpers.AssertDriverAttributesAre (
  176. """
  177. 0011000000
  178. 0000000000
  179. 0111000000
  180. 0000000000
  181. """,
  182. Application.Driver,
  183. expectedColors
  184. );
  185. }
  186. // TODO: Refactor this test to not depend on TextView etc... Make it as primitive as possible
  187. [Fact]
  188. [AutoInitShutdown]
  189. [Trait ("Category", "Unicode")]
  190. public void Clipping_AddRune_Left_Or_Right_Replace_Previous_Or_Next_Wide_Rune_With_Space ()
  191. {
  192. var tv = new TextView
  193. {
  194. Width = Dim.Fill (),
  195. Height = Dim.Fill (),
  196. Text = """
  197. これは広いルーンラインです。
  198. これは広いルーンラインです。
  199. これは広いルーンラインです。
  200. これは広いルーンラインです。
  201. これは広いルーンラインです。
  202. これは広いルーンラインです。
  203. これは広いルーンラインです。
  204. これは広いルーンラインです。
  205. """
  206. };
  207. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
  208. win.Add (tv);
  209. Application.Top.Add (win);
  210. // Don't use Label. It sets AutoSize = true which is not what we're testing here.
  211. var view = new View { Text = "ワイドルーン。", Height = Dim.Fill (), Width = Dim.Fill () };
  212. // Don't have unit tests use things that aren't absolutely critical for the test, like Dialog
  213. var dg = new Window { X = 2, Y = 2, Width = 14, Height = 3 };
  214. dg.Add (view);
  215. Application.Begin (Application.Top);
  216. Application.Begin (dg);
  217. ((FakeDriver)Application.Driver).SetBufferSize (30, 10);
  218. const string expectedOutput = """
  219. ┌────────────────────────────┐
  220. │これは広いルーンラインです。│
  221. │�┌────────────┐�ラインです。│
  222. │�│ワイドルーン│�ラインです。│
  223. │�└────────────┘�ラインです。│
  224. │これは広いルーンラインです。│
  225. │これは広いルーンラインです。│
  226. │これは広いルーンラインです。│
  227. │これは広いルーンラインです。│
  228. └────────────────────────────┘
  229. """;
  230. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, output);
  231. Assert.Equal (new Rectangle (0, 0, 30, 10), pos);
  232. }
  233. [Fact]
  234. [AutoInitShutdown]
  235. [Trait ("Category", "Output")]
  236. public void Colors_On_TextAlignment_Right_And_Bottom ()
  237. {
  238. var viewRight = new View
  239. {
  240. Text = "Test",
  241. Width = 6,
  242. Height = 1,
  243. TextAlignment = TextAlignment.Right,
  244. ColorScheme = Colors.ColorSchemes ["Base"]
  245. };
  246. var viewBottom = new View
  247. {
  248. Text = "Test",
  249. TextDirection = TextDirection.TopBottom_LeftRight,
  250. Y = 1,
  251. Width = 1,
  252. Height = 6,
  253. VerticalTextAlignment = VerticalTextAlignment.Bottom,
  254. ColorScheme = Colors.ColorSchemes ["Base"]
  255. };
  256. Toplevel top = Application.Top;
  257. top.Add (viewRight, viewBottom);
  258. Application.Begin (top);
  259. ((FakeDriver)Application.Driver).SetBufferSize (7, 7);
  260. TestHelpers.AssertDriverContentsWithFrameAre (
  261. """
  262. Test
  263. T
  264. e
  265. s
  266. t
  267. """,
  268. output
  269. );
  270. TestHelpers.AssertDriverAttributesAre (
  271. """
  272. 000000
  273. 0
  274. 0
  275. 0
  276. 0
  277. 0
  278. 0
  279. """,
  280. Application.Driver,
  281. Colors.ColorSchemes ["Base"].Normal
  282. );
  283. }
  284. [Fact]
  285. [SetupFakeDriver]
  286. public void Draw_Minimum_Full_Border_With_Empty_Viewport ()
  287. {
  288. var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
  289. view.BeginInit ();
  290. view.EndInit ();
  291. view.SetRelativeLayout (Application.Driver.Viewport);
  292. Assert.Equal (new (0, 0, 2, 2), view.Frame);
  293. Assert.Equal (Rectangle.Empty, view.Viewport);
  294. view.Draw ();
  295. TestHelpers.AssertDriverContentsWithFrameAre (
  296. """
  297. ┌┐
  298. └┘
  299. """,
  300. output
  301. );
  302. }
  303. [Fact]
  304. [SetupFakeDriver]
  305. public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Bottom ()
  306. {
  307. var view = new View { Width = 2, Height = 1, BorderStyle = LineStyle.Single };
  308. view.Border.Thickness = new Thickness (1, 1, 1, 0);
  309. view.BeginInit ();
  310. view.EndInit ();
  311. view.SetRelativeLayout (Application.Driver.Viewport);
  312. Assert.Equal (new (0, 0, 2, 1), view.Frame);
  313. Assert.Equal (Rectangle.Empty, view.Viewport);
  314. view.Draw ();
  315. TestHelpers.AssertDriverContentsWithFrameAre (string.Empty, output);
  316. }
  317. [Fact]
  318. [SetupFakeDriver]
  319. public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Left ()
  320. {
  321. var view = new View { Width = 1, Height = 2, BorderStyle = LineStyle.Single };
  322. view.Border.Thickness = new Thickness (0, 1, 1, 1);
  323. view.BeginInit ();
  324. view.EndInit ();
  325. view.SetRelativeLayout (Application.Driver.Viewport);
  326. Assert.Equal (new (0, 0, 1, 2), view.Frame);
  327. Assert.Equal (Rectangle.Empty, view.Viewport);
  328. view.Draw ();
  329. TestHelpers.AssertDriverContentsWithFrameAre (
  330. """
  331. """,
  332. output
  333. );
  334. }
  335. [Fact]
  336. [SetupFakeDriver]
  337. public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Right ()
  338. {
  339. var view = new View { Width = 1, Height = 2, BorderStyle = LineStyle.Single };
  340. view.Border.Thickness = new Thickness (1, 1, 0, 1);
  341. view.BeginInit ();
  342. view.EndInit ();
  343. view.SetRelativeLayout (Application.Driver.Viewport);
  344. Assert.Equal (new (0, 0, 1, 2), view.Frame);
  345. Assert.Equal (Rectangle.Empty, view.Viewport);
  346. view.Draw ();
  347. TestHelpers.AssertDriverContentsWithFrameAre (
  348. """
  349. """,
  350. output
  351. );
  352. }
  353. [Fact]
  354. [SetupFakeDriver]
  355. public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Top ()
  356. {
  357. var view = new View { Width = 2, Height = 1, BorderStyle = LineStyle.Single };
  358. view.Border.Thickness = new Thickness (1, 0, 1, 1);
  359. view.BeginInit ();
  360. view.EndInit ();
  361. view.SetRelativeLayout (Application.Driver.Viewport);
  362. Assert.Equal (new (0, 0, 2, 1), view.Frame);
  363. Assert.Equal (Rectangle.Empty, view.Viewport);
  364. view.Draw ();
  365. // BUGBUG: Wha? Is this right? Shouldn't it be "└┘"???
  366. TestHelpers.AssertDriverContentsWithFrameAre (
  367. """
  368. ┌┐
  369. """,
  370. output
  371. );
  372. }
  373. [Fact]
  374. [AutoInitShutdown]
  375. public void Draw_Negative_Viewport_Horizontal_With_New_Lines ()
  376. {
  377. var subView = new View
  378. {
  379. Id = "subView",
  380. X = 1,
  381. Width = 1,
  382. Height = 7,
  383. Text = """
  384. s
  385. u
  386. b
  387. V
  388. i
  389. e
  390. w
  391. """
  392. };
  393. var view = new View
  394. {
  395. Id = "view", Width = 2, Height = 20, Text = """
  396. 0
  397. 1
  398. 2
  399. 3
  400. 4
  401. 5
  402. 6
  403. 7
  404. 8
  405. 9
  406. 0
  407. 1
  408. 2
  409. 3
  410. 4
  411. 5
  412. 6
  413. 7
  414. 8
  415. 9
  416. """
  417. };
  418. view.Add (subView);
  419. var content = new View { Id = "content", Width = 20, Height = 20 };
  420. content.Add (view);
  421. var container = new View
  422. {
  423. Id = "container",
  424. X = 1,
  425. Y = 1,
  426. Width = 5,
  427. Height = 5
  428. };
  429. container.Add (content);
  430. Toplevel top = Application.Top;
  431. top.Add (container);
  432. Application.Driver.Clip = container.Frame;
  433. Application.Begin (top);
  434. TestHelpers.AssertDriverContentsWithFrameAre (
  435. """
  436. 0s
  437. 1u
  438. 2b
  439. 3V
  440. 4i
  441. """,
  442. output
  443. );
  444. content.X = -1;
  445. Application.Refresh ();
  446. TestHelpers.AssertDriverContentsWithFrameAre (
  447. """
  448. s
  449. u
  450. b
  451. V
  452. i
  453. """,
  454. output
  455. );
  456. content.X = -2;
  457. Application.Refresh ();
  458. TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
  459. content.X = 0;
  460. content.Y = -1;
  461. Application.Refresh ();
  462. TestHelpers.AssertDriverContentsWithFrameAre (
  463. """
  464. 1u
  465. 2b
  466. 3V
  467. 4i
  468. 5e
  469. """,
  470. output
  471. );
  472. content.Y = -6;
  473. Application.Refresh ();
  474. TestHelpers.AssertDriverContentsWithFrameAre (
  475. """
  476. 6w
  477. 7
  478. 8
  479. 9
  480. 0
  481. """,
  482. output
  483. );
  484. content.Y = -19;
  485. Application.Refresh ();
  486. TestHelpers.AssertDriverContentsWithFrameAre (
  487. """
  488. 9
  489. """,
  490. output
  491. );
  492. content.Y = -20;
  493. Application.Refresh ();
  494. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  495. content.X = -2;
  496. content.Y = 0;
  497. Application.Refresh ();
  498. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  499. }
  500. [Fact]
  501. [AutoInitShutdown]
  502. public void Draw_Negative_Viewport_Horizontal_Without_New_Lines ()
  503. {
  504. // BUGBUG: This previously assumed the default height of a View was 1.
  505. var subView = new View
  506. {
  507. Id = "subView",
  508. Y = 1,
  509. Width = 7,
  510. Height = 1,
  511. Text = "subView"
  512. };
  513. var view = new View { Id = "view", Width = 20, Height = 2, Text = "01234567890123456789" };
  514. view.Add (subView);
  515. var content = new View { Id = "content", Width = 20, Height = 20 };
  516. content.Add (view);
  517. var container = new View
  518. {
  519. Id = "container",
  520. X = 1,
  521. Y = 1,
  522. Width = 5,
  523. Height = 5
  524. };
  525. container.Add (content);
  526. Toplevel top = Application.Top;
  527. top.Add (container);
  528. // BUGBUG: v2 - it's bogus to reference .Frame before BeginInit. And why is the clip being set anyway???
  529. void Top_LayoutComplete (object sender, LayoutEventArgs e) { Application.Driver.Clip = container.Frame; }
  530. top.LayoutComplete += Top_LayoutComplete;
  531. Application.Begin (top);
  532. TestHelpers.AssertDriverContentsWithFrameAre (
  533. """
  534. 01234
  535. subVi
  536. """,
  537. output
  538. );
  539. content.X = -1;
  540. Application.Refresh ();
  541. TestHelpers.AssertDriverContentsWithFrameAre (
  542. """
  543. 12345
  544. ubVie
  545. """,
  546. output
  547. );
  548. content.Y = -1;
  549. Application.Refresh ();
  550. TestHelpers.AssertDriverContentsWithFrameAre (
  551. """
  552. ubVie
  553. """,
  554. output
  555. );
  556. content.Y = -2;
  557. Application.Refresh ();
  558. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  559. content.X = -20;
  560. content.Y = 0;
  561. Application.Refresh ();
  562. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  563. }
  564. [Fact]
  565. [AutoInitShutdown]
  566. public void Draw_Negative_Viewport_Vertical ()
  567. {
  568. var subView = new View
  569. {
  570. Id = "subView",
  571. X = 1,
  572. Width = 1,
  573. Height = 7,
  574. Text = "subView",
  575. TextDirection = TextDirection.TopBottom_LeftRight
  576. };
  577. var view = new View
  578. {
  579. Id = "view",
  580. Width = 2,
  581. Height = 20,
  582. Text = "01234567890123456789",
  583. TextDirection = TextDirection.TopBottom_LeftRight
  584. };
  585. view.Add (subView);
  586. var content = new View { Id = "content", Width = 20, Height = 20 };
  587. content.Add (view);
  588. var container = new View
  589. {
  590. Id = "container",
  591. X = 1,
  592. Y = 1,
  593. Width = 5,
  594. Height = 5
  595. };
  596. container.Add (content);
  597. Toplevel top = Application.Top;
  598. top.Add (container);
  599. Application.Driver.Clip = container.Frame;
  600. Application.Begin (top);
  601. TestHelpers.AssertDriverContentsWithFrameAre (
  602. """
  603. 0s
  604. 1u
  605. 2b
  606. 3V
  607. 4i
  608. """,
  609. output
  610. );
  611. content.X = -1;
  612. Application.Refresh ();
  613. TestHelpers.AssertDriverContentsWithFrameAre (
  614. """
  615. s
  616. u
  617. b
  618. V
  619. i
  620. """,
  621. output
  622. );
  623. content.X = -2;
  624. Application.Refresh ();
  625. TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
  626. content.X = 0;
  627. content.Y = -1;
  628. Application.Refresh ();
  629. TestHelpers.AssertDriverContentsWithFrameAre (
  630. """
  631. 1u
  632. 2b
  633. 3V
  634. 4i
  635. 5e
  636. """,
  637. output
  638. );
  639. content.Y = -6;
  640. Application.Refresh ();
  641. TestHelpers.AssertDriverContentsWithFrameAre (
  642. """
  643. 6w
  644. 7
  645. 8
  646. 9
  647. 0
  648. """,
  649. output
  650. );
  651. content.Y = -19;
  652. Application.Refresh ();
  653. TestHelpers.AssertDriverContentsWithFrameAre (
  654. """
  655. 9
  656. """,
  657. output
  658. );
  659. content.Y = -20;
  660. Application.Refresh ();
  661. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  662. content.X = -2;
  663. content.Y = 0;
  664. Application.Refresh ();
  665. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  666. }
  667. [Theory]
  668. [SetupFakeDriver]
  669. [InlineData ("𝔽𝕆𝕆𝔹𝔸R")]
  670. [InlineData ("a𐐀b")]
  671. public void DrawHotString_NonBmp (string expected)
  672. {
  673. var view = new View { Width = 10, Height = 1 };
  674. view.DrawHotString (expected, Attribute.Default, Attribute.Default);
  675. TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  676. }
  677. // TODO: The tests below that use Label should use View instead.
  678. [Fact]
  679. [AutoInitShutdown]
  680. public void Non_Bmp_ConsoleWidth_ColumnWidth_Equal_Two ()
  681. {
  682. var us = "\U0001d539";
  683. var r = (Rune)0x1d539;
  684. Assert.Equal ("𝔹", us);
  685. Assert.Equal ("𝔹", r.ToString ());
  686. Assert.Equal (us, r.ToString ());
  687. Assert.Equal (1, us.GetColumns ());
  688. Assert.Equal (1, r.GetColumns ());
  689. var win = new Window { Title = us };
  690. var view = new Label { Text = r.ToString () };
  691. var tf = new TextField { Text = us, Y = 1, Width = 3 };
  692. win.Add (view, tf);
  693. Toplevel top = Application.Top;
  694. top.Add (win);
  695. Application.Begin (top);
  696. ((FakeDriver)Application.Driver).SetBufferSize (10, 4);
  697. var expected = """
  698. ┌┤𝔹├─────┐
  699. │𝔹 │
  700. │𝔹 │
  701. └────────┘
  702. """;
  703. TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
  704. TestHelpers.AssertDriverContentsAre (expected, output);
  705. Attribute [] expectedColors =
  706. {
  707. // 0
  708. Colors.ColorSchemes ["Base"].Normal,
  709. // 1
  710. Colors.ColorSchemes ["Base"].Focus,
  711. // 2
  712. Colors.ColorSchemes ["Base"].HotNormal
  713. };
  714. TestHelpers.AssertDriverAttributesAre (
  715. """
  716. 0010000000
  717. 0000000000
  718. 0111000000
  719. 0000000000
  720. """,
  721. Application.Driver,
  722. expectedColors
  723. );
  724. }
  725. }