TextFormatterDrawTests.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. #nullable enable
  2. using System.Text;
  3. using UICatalog;
  4. using Xunit.Abstractions;
  5. // Alias Console to MockConsole so we don't accidentally use Console
  6. namespace UnitTests.TextTests;
  7. public class TextFormatterDrawTests (ITestOutputHelper output) : FakeDriverBase
  8. {
  9. public static IEnumerable<object []> CMGlyphs =>
  10. new List<object []> { new object [] { $"{Glyphs.LeftBracket} Say Hello 你 {Glyphs.RightBracket}", 16, 15 } };
  11. [Theory]
  12. [InlineData ("A", 1, 0, "")]
  13. [InlineData ("A", 0, 1, "")]
  14. [InlineData ("AB1 2", 2, 1, "2")]
  15. [InlineData ("AB12", 5, 1, "21BA")]
  16. [InlineData ("AB\n12", 5, 2, "21\nBA")]
  17. [InlineData ("ABC 123 456", 7, 2, "CBA \n654 321")]
  18. [InlineData ("こんにちは", 1, 1, "")]
  19. [InlineData ("こんにちは", 2, 1, "は")]
  20. [InlineData ("こんにちは", 5, 1, "はち")]
  21. [InlineData ("こんにちは", 10, 1, "はちにんこ")]
  22. [InlineData ("こんにちは\nAB\n12", 10, 3, "21 \nBA \nはちにんこ")]
  23. public void Draw_Horizontal_RightLeft_BottomTop (string text, int width, int height, string expectedText)
  24. {
  25. IDriver driver = CreateFakeDriver ();
  26. TextFormatter tf = new ()
  27. {
  28. Text = text,
  29. Direction = TextDirection.RightLeft_BottomTop
  30. };
  31. tf.ConstrainToWidth = width;
  32. tf.ConstrainToHeight = height;
  33. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  34. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  35. }
  36. [Theory]
  37. [InlineData ("A", 1, 0, "")]
  38. [InlineData ("A", 0, 1, "")]
  39. [InlineData ("AB1 2", 2, 1, "2")]
  40. [InlineData ("AB12", 5, 1, "21BA")]
  41. [InlineData ("AB\n12", 5, 2, "BA\n21")]
  42. [InlineData ("ABC 123 456", 7, 2, "654 321\nCBA ")]
  43. [InlineData ("こんにちは", 1, 1, "")]
  44. [InlineData ("こんにちは", 2, 1, "は")]
  45. [InlineData ("こんにちは", 5, 1, "はち")]
  46. [InlineData ("こんにちは", 10, 1, "はちにんこ")]
  47. [InlineData ("こんにちは\nAB\n12", 10, 3, "はちにんこ\nBA \n21 ")]
  48. public void Draw_Horizontal_RightLeft_TopBottom (string text, int width, int height, string expectedText)
  49. {
  50. IDriver driver = CreateFakeDriver ();
  51. TextFormatter tf = new ()
  52. {
  53. Text = text,
  54. Direction = TextDirection.RightLeft_TopBottom
  55. };
  56. tf.ConstrainToWidth = width;
  57. tf.ConstrainToHeight = height;
  58. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  59. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  60. }
  61. [Theory]
  62. [InlineData ("A", 0, 1, "", 0)]
  63. [InlineData ("A", 1, 1, "A", 0)]
  64. [InlineData ("A", 2, 2, " A", 1)]
  65. [InlineData ("AB", 1, 1, "B", 0)]
  66. [InlineData ("AB", 2, 2, " A\n B", 0)]
  67. [InlineData ("ABC", 3, 2, " B\n C", 0)]
  68. [InlineData ("ABC", 4, 2, " B\n C", 0)]
  69. [InlineData ("ABC", 6, 2, " B\n C", 0)]
  70. [InlineData ("こんにちは", 0, 1, "", 0)]
  71. [InlineData ("こんにちは", 1, 0, "", 0)]
  72. [InlineData ("こんにちは", 1, 1, "", 0)]
  73. [InlineData ("こんにちは", 2, 1, "は", 0)]
  74. [InlineData ("こんにちは", 2, 2, "ち\nは", 0)]
  75. [InlineData ("こんにちは", 2, 3, "に\nち\nは", 0)]
  76. [InlineData ("こんにちは", 2, 4, "ん\nに\nち\nは", 0)]
  77. [InlineData ("こんにちは", 2, 5, "こ\nん\nに\nち\nは", 0)]
  78. [InlineData ("こんにちは", 2, 6, "こ\nん\nに\nち\nは", 1)]
  79. [InlineData ("ABCD\nこんにちは", 4, 7, " こ\n Aん\n Bに\n Cち\n Dは", 2)]
  80. [InlineData ("こんにちは\nABCD", 3, 7, "こ \nんA\nにB\nちC\nはD", 2)]
  81. public void Draw_Vertical_Bottom_Horizontal_Right (string text, int width, int height, string expectedText, int expectedY)
  82. {
  83. IDriver driver = CreateFakeDriver ();
  84. TextFormatter tf = new ()
  85. {
  86. Text = text,
  87. Alignment = Alignment.End,
  88. Direction = TextDirection.TopBottom_LeftRight,
  89. VerticalAlignment = Alignment.End
  90. };
  91. tf.ConstrainToWidth = width;
  92. tf.ConstrainToHeight = height;
  93. tf.Draw (new (Point.Empty, new (width, height)), Attribute.Default, Attribute.Default, driver: driver);
  94. Rectangle rect = DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  95. Assert.Equal (expectedY, rect.Y);
  96. }
  97. [Theory]
  98. [InlineData ("A", 1, 0, "")]
  99. [InlineData ("A", 0, 1, "")]
  100. [InlineData ("AB1 2", 1, 2, "2")]
  101. [InlineData ("AB12", 1, 5, "2\n1\nB\nA")]
  102. [InlineData ("AB\n12", 2, 5, "B2\nA1")]
  103. [InlineData ("ABC 123 456", 2, 7, "6C\n5B\n4A\n \n3 \n2 \n1 ")]
  104. [InlineData ("こんにちは", 1, 1, "")]
  105. [InlineData ("こんにちは", 2, 1, "は")]
  106. [InlineData ("こんにちは", 2, 5, "は\nち\nに\nん\nこ")]
  107. [InlineData ("こんにちは", 2, 10, "は\nち\nに\nん\nこ")]
  108. [InlineData ("こんにちは\nAB\n12", 4, 10, "はB2\nちA1\nに \nん \nこ ")]
  109. public void Draw_Vertical_BottomTop_LeftRight (string text, int width, int height, string expectedText)
  110. {
  111. IDriver driver = CreateFakeDriver ();
  112. TextFormatter tf = new ()
  113. {
  114. Text = text,
  115. Direction = TextDirection.BottomTop_LeftRight
  116. };
  117. tf.ConstrainToWidth = width;
  118. tf.ConstrainToHeight = height;
  119. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  120. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  121. }
  122. [Theory]
  123. [InlineData ("A", 1, 0, "")]
  124. [InlineData ("A", 0, 1, "")]
  125. [InlineData ("AB1 2", 1, 2, "2")]
  126. [InlineData ("AB12", 1, 5, "2\n1\nB\nA")]
  127. [InlineData ("AB\n12", 2, 5, "2B\n1A")]
  128. [InlineData ("ABC 123 456", 2, 7, "C6\nB5\nA4\n \n 3\n 2\n 1")]
  129. [InlineData ("こんにちは", 1, 1, "")]
  130. [InlineData ("こんにちは", 2, 1, "は")]
  131. [InlineData ("こんにちは", 2, 5, "は\nち\nに\nん\nこ")]
  132. [InlineData ("こんにちは", 2, 10, "は\nち\nに\nん\nこ")]
  133. [InlineData ("こんにちは\nAB\n12", 4, 10, "2Bは\n1Aち\n に\n ん\n こ")]
  134. public void Draw_Vertical_BottomTop_RightLeft (string text, int width, int height, string expectedText)
  135. {
  136. IDriver driver = CreateFakeDriver ();
  137. TextFormatter tf = new ()
  138. {
  139. Text = text,
  140. Direction = TextDirection.BottomTop_RightLeft
  141. };
  142. tf.ConstrainToWidth = width;
  143. tf.ConstrainToHeight = height;
  144. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  145. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  146. }
  147. [Theory]
  148. [InlineData ("A", 5, 5, "A")]
  149. [InlineData (
  150. "AB12",
  151. 5,
  152. 5,
  153. @"
  154. A
  155. B
  156. 1
  157. 2")]
  158. [InlineData (
  159. "AB\n12",
  160. 5,
  161. 5,
  162. @"
  163. A1
  164. B2")]
  165. [InlineData ("", 5, 1, "")]
  166. [InlineData (
  167. "Hello Worlds",
  168. 1,
  169. 12,
  170. @"
  171. H
  172. e
  173. l
  174. l
  175. o
  176. W
  177. o
  178. r
  179. l
  180. d
  181. s")]
  182. [InlineData ("Hello Worlds", 12, 1, @"HelloWorlds")]
  183. public void Draw_Vertical_TopBottom_LeftRight (string text, int width, int height, string expectedText)
  184. {
  185. IDriver driver = CreateFakeDriver ();
  186. TextFormatter tf = new ()
  187. {
  188. Text = text,
  189. Direction = TextDirection.TopBottom_LeftRight
  190. };
  191. tf.ConstrainToWidth = width;
  192. tf.ConstrainToHeight = height;
  193. tf.Draw (new (0, 0, 20, 20), Attribute.Default, Attribute.Default, driver: driver);
  194. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  195. }
  196. [Theory]
  197. // The expectedY param is to probe that the expectedText param start at that Y coordinate
  198. [InlineData ("A", 0, "", 0)]
  199. [InlineData ("A", 1, "A", 0)]
  200. [InlineData ("A", 2, "A", 0)]
  201. [InlineData ("A", 3, "A", 1)]
  202. [InlineData ("AB", 1, "A", 0)]
  203. [InlineData ("AB", 2, "A\nB", 0)]
  204. [InlineData ("ABC", 2, "A\nB", 0)]
  205. [InlineData ("ABC", 3, "A\nB\nC", 0)]
  206. [InlineData ("ABC", 4, "A\nB\nC", 0)]
  207. [InlineData ("ABC", 5, "A\nB\nC", 1)]
  208. [InlineData ("ABC", 6, "A\nB\nC", 1)]
  209. [InlineData ("ABC", 9, "A\nB\nC", 3)]
  210. [InlineData ("ABCD", 2, "B\nC", 0)]
  211. [InlineData ("こんにちは", 0, "", 0)]
  212. [InlineData ("こんにちは", 1, "に", 0)]
  213. [InlineData ("こんにちは", 2, "ん\nに", 0)]
  214. [InlineData ("こんにちは", 3, "ん\nに\nち", 0)]
  215. [InlineData ("こんにちは", 4, "こ\nん\nに\nち", 0)]
  216. [InlineData ("こんにちは", 5, "こ\nん\nに\nち\nは", 0)]
  217. [InlineData ("こんにちは", 6, "こ\nん\nに\nち\nは", 0)]
  218. [InlineData ("ABCD\nこんにちは", 7, "Aこ\nBん\nCに\nDち\n は", 1)]
  219. [InlineData ("こんにちは\nABCD", 7, "こA\nんB\nにC\nちD\nは ", 1)]
  220. public void Draw_Vertical_TopBottom_LeftRight_Middle (string text, int height, string expectedText, int expectedY)
  221. {
  222. IDriver driver = CreateFakeDriver ();
  223. TextFormatter tf = new ()
  224. {
  225. Text = text,
  226. Direction = TextDirection.TopBottom_LeftRight,
  227. VerticalAlignment = Alignment.Center
  228. };
  229. int width = text.ToRunes ().Max (r => r.GetColumns ());
  230. if (text.Contains ("\n"))
  231. {
  232. width++;
  233. }
  234. tf.ConstrainToWidth = width;
  235. tf.ConstrainToHeight = height;
  236. tf.Draw (new (0, 0, 5, height), Attribute.Default, Attribute.Default, driver: driver);
  237. Rectangle rect = DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  238. Assert.Equal (expectedY, rect.Y);
  239. }
  240. [Theory]
  241. [InlineData ("A", 5, "A")]
  242. [InlineData (
  243. "AB12",
  244. 5,
  245. @"
  246. A
  247. B
  248. 1
  249. 2")]
  250. [InlineData (
  251. "AB\n12",
  252. 5,
  253. @"
  254. A1
  255. B2")]
  256. [InlineData ("", 1, "")]
  257. [InlineData (
  258. "AB1 2",
  259. 2,
  260. @"
  261. A12
  262. B ")]
  263. [InlineData (
  264. "こんにちは",
  265. 1,
  266. @"
  267. こん")]
  268. [InlineData (
  269. "こんにちは",
  270. 2,
  271. @"
  272. こに
  273. んち")]
  274. [InlineData (
  275. "こんにちは",
  276. 5,
  277. @"
  278. は")]
  279. public void Draw_Vertical_TopBottom_LeftRight_Top (string text, int height, string expectedText)
  280. {
  281. IDriver driver = CreateFakeDriver ();
  282. TextFormatter tf = new ()
  283. {
  284. Text = text,
  285. Direction = TextDirection.TopBottom_LeftRight
  286. };
  287. tf.ConstrainToWidth = 5;
  288. tf.ConstrainToHeight = height;
  289. tf.Draw (new (0, 0, 5, height), Attribute.Default, Attribute.Default, driver: driver);
  290. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  291. }
  292. [Fact]
  293. public void FillRemaining_True_False ()
  294. {
  295. IDriver driver = CreateFakeDriver ();
  296. driver.SetScreenSize (22, 5);
  297. Attribute [] attrs =
  298. {
  299. Attribute.Default, new (ColorName16.Green, ColorName16.BrightMagenta),
  300. new (ColorName16.Blue, ColorName16.Cyan)
  301. };
  302. var tf = new TextFormatter { ConstrainToSize = new (14, 3), Text = "Test\nTest long\nTest long long\n", MultiLine = true };
  303. tf.Draw (
  304. new (1, 1, 19, 3),
  305. attrs [1],
  306. attrs [2],
  307. driver: driver);
  308. Assert.False (tf.FillRemaining);
  309. DriverAssert.AssertDriverContentsWithFrameAre (
  310. @"
  311. Test
  312. Test long
  313. Test long long",
  314. output,
  315. driver);
  316. DriverAssert.AssertDriverAttributesAre (
  317. @"
  318. 000000000000000000000
  319. 011110000000000000000
  320. 011111111100000000000
  321. 011111111111111000000
  322. 000000000000000000000",
  323. output,
  324. driver,
  325. attrs);
  326. tf.FillRemaining = true;
  327. tf.Draw (
  328. new (1, 1, 19, 3),
  329. attrs [1],
  330. attrs [2],
  331. driver: driver);
  332. DriverAssert.AssertDriverAttributesAre (
  333. @"
  334. 000000000000000000000
  335. 011111111111111111110
  336. 011111111111111111110
  337. 011111111111111111110
  338. 000000000000000000000",
  339. output,
  340. driver,
  341. attrs);
  342. }
  343. [Theory]
  344. [InlineData ("Hello World", 15, 1, "Hello World")]
  345. [InlineData (
  346. "Well Done\nNice Work",
  347. 15,
  348. 2,
  349. @"
  350. Well Done
  351. Nice Work")]
  352. [InlineData ("你好 世界", 15, 1, "你好 世界")]
  353. [InlineData (
  354. "做 得好\n幹 得好",
  355. 15,
  356. 2,
  357. @"
  358. 做 得好
  359. 幹 得好")]
  360. public void Justify_Horizontal (string text, int width, int height, string expectedText)
  361. {
  362. IDriver driver = CreateFakeDriver ();
  363. TextFormatter tf = new ()
  364. {
  365. Text = text,
  366. Alignment = Alignment.Fill,
  367. ConstrainToSize = new Size (width, height),
  368. MultiLine = true
  369. };
  370. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  371. DriverAssert.AssertDriverContentsWithFrameAre (expectedText, output, driver);
  372. }
  373. [Fact]
  374. public void UICatalog_AboutBox_Text ()
  375. {
  376. IDriver? driver = CreateFakeDriver ();
  377. TextFormatter tf = new ()
  378. {
  379. Text = UICatalogTop.GetAboutBoxMessage (),
  380. Alignment = Alignment.Center,
  381. VerticalAlignment = Alignment.Start,
  382. WordWrap = false,
  383. MultiLine = true,
  384. HotKeySpecifier = (Rune)0xFFFF
  385. };
  386. Size tfSize = tf.FormatAndGetSize ();
  387. Assert.Equal (new (59, 13), tfSize);
  388. driver!.SetScreenSize (tfSize.Width, tfSize.Height);
  389. driver.FillRect (driver.Screen, (Rune)'*');
  390. tf.Draw (driver.Screen, Attribute.Default, Attribute.Default, driver: driver);
  391. var expectedText = """
  392. UI Catalog: A comprehensive sample library and test app for
  393. ***********************************************************
  394. _______ _ _ _____ _ *
  395. |__ __| (_) | | / ____| (_)*
  396. | | ___ _ __ _ __ ___ _ _ __ __ _| || | __ _ _ _ *
  397. | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |*
  398. | | __/ | | | | | | | | | | | (_| | || |__| | |_| | |*
  399. |_|\___|_| |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|*
  400. ***********************************************************
  401. **********************v2 - Pre-Alpha***********************
  402. ***********************************************************
  403. **********https://github.com/gui-cs/Terminal.Gui***********
  404. ***********************************************************
  405. """;
  406. DriverAssert.AssertDriverContentsAre (expectedText.ReplaceLineEndings (), output, driver);
  407. }
  408. #region FormatAndGetSizeTests
  409. // TODO: Add multi-line examples
  410. // TODO: Add other TextDirection examples
  411. [Theory]
  412. [InlineData ("界1234", 10, 10, TextDirection.LeftRight_TopBottom, 6, 1, @"界1234")]
  413. [InlineData ("01234", 10, 10, TextDirection.LeftRight_TopBottom, 5, 1, @"01234")]
  414. [InlineData (
  415. "界1234",
  416. 10,
  417. 10,
  418. TextDirection.TopBottom_LeftRight,
  419. 2,
  420. 5,
  421. """
  422. 1
  423. 2
  424. 3
  425. 4
  426. """)]
  427. [InlineData (
  428. "01234",
  429. 10,
  430. 10,
  431. TextDirection.TopBottom_LeftRight,
  432. 1,
  433. 5,
  434. """
  435. 0
  436. 1
  437. 2
  438. 3
  439. 4
  440. """)]
  441. [InlineData (
  442. "界1234",
  443. 3,
  444. 3,
  445. TextDirection.LeftRight_TopBottom,
  446. 3,
  447. 2,
  448. """
  449. 界1
  450. 234
  451. """)]
  452. [InlineData (
  453. "01234",
  454. 3,
  455. 3,
  456. TextDirection.LeftRight_TopBottom,
  457. 3,
  458. 2,
  459. """
  460. 012
  461. 34
  462. """)]
  463. [InlineData (
  464. "界1234",
  465. 3,
  466. 3,
  467. TextDirection.TopBottom_LeftRight,
  468. 3,
  469. 3,
  470. """
  471. 界3
  472. 1 4
  473. 2
  474. """)]
  475. [InlineData (
  476. "01234",
  477. 3,
  478. 3,
  479. TextDirection.TopBottom_LeftRight,
  480. 2,
  481. 3,
  482. """
  483. 03
  484. 14
  485. 2
  486. """)]
  487. [InlineData ("01234", 2, 1, TextDirection.LeftRight_TopBottom, 2, 1, @"01")]
  488. public void FormatAndGetSize_Returns_Correct_Size (
  489. string text,
  490. int width,
  491. int height,
  492. TextDirection direction,
  493. int expectedWidth,
  494. int expectedHeight,
  495. string expectedDraw
  496. )
  497. {
  498. IDriver driver = CreateFakeDriver ();
  499. TextFormatter tf = new ()
  500. {
  501. Direction = direction,
  502. ConstrainToWidth = width,
  503. ConstrainToHeight = height,
  504. Text = text
  505. };
  506. Assert.True (tf.WordWrap);
  507. Size size = tf.FormatAndGetSize ();
  508. Assert.Equal (new (expectedWidth, expectedHeight), size);
  509. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  510. DriverAssert.AssertDriverContentsWithFrameAre (expectedDraw, output, driver);
  511. }
  512. [Theory]
  513. [InlineData ("界1234", 10, 10, TextDirection.LeftRight_TopBottom, 6, 1, @"界1234")]
  514. [InlineData ("01234", 10, 10, TextDirection.LeftRight_TopBottom, 5, 1, @"01234")]
  515. [InlineData (
  516. "界1234",
  517. 10,
  518. 10,
  519. TextDirection.TopBottom_LeftRight,
  520. 2,
  521. 5,
  522. """
  523. 1
  524. 2
  525. 3
  526. 4
  527. """)]
  528. [InlineData (
  529. "01234",
  530. 10,
  531. 10,
  532. TextDirection.TopBottom_LeftRight,
  533. 1,
  534. 5,
  535. """
  536. 0
  537. 1
  538. 2
  539. 3
  540. 4
  541. """)]
  542. [InlineData ("界1234", 3, 3, TextDirection.LeftRight_TopBottom, 3, 1, @"界1")]
  543. [InlineData ("01234", 3, 3, TextDirection.LeftRight_TopBottom, 3, 1, @"012")]
  544. [InlineData (
  545. "界1234",
  546. 3,
  547. 3,
  548. TextDirection.TopBottom_LeftRight,
  549. 2,
  550. 3,
  551. """
  552. 1
  553. 2
  554. """)]
  555. [InlineData (
  556. "01234",
  557. 3,
  558. 3,
  559. TextDirection.TopBottom_LeftRight,
  560. 1,
  561. 3,
  562. """
  563. 0
  564. 1
  565. 2
  566. """)]
  567. public void FormatAndGetSize_WordWrap_False_Returns_Correct_Size (
  568. string text,
  569. int width,
  570. int height,
  571. TextDirection direction,
  572. int expectedWidth,
  573. int expectedHeight,
  574. string expectedDraw
  575. )
  576. {
  577. IDriver driver = CreateFakeDriver ();
  578. TextFormatter tf = new ()
  579. {
  580. Direction = direction,
  581. ConstrainToSize = new (width, height),
  582. Text = text,
  583. WordWrap = false
  584. };
  585. Assert.False (tf.WordWrap);
  586. Size size = tf.FormatAndGetSize ();
  587. Assert.Equal (new (expectedWidth, expectedHeight), size);
  588. tf.Draw (new (0, 0, width, height), Attribute.Default, Attribute.Default, driver: driver);
  589. DriverAssert.AssertDriverContentsWithFrameAre (expectedDraw, output, driver);
  590. }
  591. #endregion
  592. }