ScrollViewTests.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. using NStack;
  2. using Xunit;
  3. using Xunit.Abstractions;
  4. namespace Terminal.Gui.ViewTests {
  5. public class ScrollViewTests {
  6. readonly ITestOutputHelper output;
  7. public ScrollViewTests (ITestOutputHelper output)
  8. {
  9. this.output = output;
  10. }
  11. [Fact]
  12. public void Constructors_Defaults ()
  13. {
  14. var sv = new ScrollView ();
  15. Assert.Equal (LayoutStyle.Computed, sv.LayoutStyle);
  16. Assert.True (sv.CanFocus);
  17. Assert.Equal (new Rect (0, 0, 0, 0), sv.Frame);
  18. Assert.Equal (Rect.Empty, sv.Frame);
  19. Assert.Null (sv.X);
  20. Assert.Null (sv.Y);
  21. Assert.Null (sv.Width);
  22. Assert.Null (sv.Height);
  23. Assert.Equal (Point.Empty, sv.ContentOffset);
  24. Assert.Equal (Size.Empty, sv.ContentSize);
  25. Assert.True (sv.AutoHideScrollBars);
  26. Assert.True (sv.KeepContentAlwaysInViewport);
  27. sv = new ScrollView (new Rect (1, 2, 20, 10));
  28. Assert.Equal (LayoutStyle.Absolute, sv.LayoutStyle);
  29. Assert.True (sv.CanFocus);
  30. Assert.Equal (new Rect (1, 2, 20, 10), sv.Frame);
  31. Assert.Null (sv.X);
  32. Assert.Null (sv.Y);
  33. Assert.Null (sv.Width);
  34. Assert.Null (sv.Height);
  35. Assert.Equal (Point.Empty, sv.ContentOffset);
  36. Assert.Equal (Size.Empty, sv.ContentSize);
  37. Assert.True (sv.AutoHideScrollBars);
  38. Assert.True (sv.KeepContentAlwaysInViewport);
  39. }
  40. [Fact]
  41. public void Adding_Views ()
  42. {
  43. var sv = new ScrollView (new Rect (0, 0, 20, 10)) {
  44. ContentSize = new Size (30, 20)
  45. };
  46. sv.Add (new View () { Width = 10, Height = 5 },
  47. new View () { X = 12, Y = 7, Width = 10, Height = 5 });
  48. Assert.Equal (new Size (30, 20), sv.ContentSize);
  49. Assert.Equal (2, sv.Subviews [0].Subviews.Count);
  50. }
  51. [Fact]
  52. public void KeyBindings_Command ()
  53. {
  54. var sv = new ScrollView (new Rect (0, 0, 20, 10)) {
  55. ContentSize = new Size (40, 20)
  56. };
  57. sv.Add (new View () { Width = 20, Height = 5 },
  58. new View () { X = 22, Y = 7, Width = 10, Height = 5 });
  59. sv.BeginInit (); sv.EndInit ();
  60. Assert.True (sv.KeepContentAlwaysInViewport);
  61. Assert.True (sv.AutoHideScrollBars);
  62. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  63. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ())));
  64. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  65. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
  66. Assert.Equal (new Point (0, -1), sv.ContentOffset);
  67. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ())));
  68. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  69. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageUp, new KeyModifiers ())));
  70. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  71. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageDown, new KeyModifiers ())));
  72. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  73. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageDown, new KeyModifiers ())));
  74. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  75. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
  76. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  77. Assert.True (sv.ProcessKey (new KeyEvent ((Key)'v' | Key.AltMask, new KeyModifiers ())));
  78. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  79. Assert.True (sv.ProcessKey (new KeyEvent (Key.V | Key.CtrlMask, new KeyModifiers ())));
  80. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  81. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
  82. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  83. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
  84. Assert.Equal (new Point (-1, -10), sv.ContentOffset);
  85. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
  86. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  87. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageUp | Key.CtrlMask, new KeyModifiers ())));
  88. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  89. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageDown | Key.CtrlMask, new KeyModifiers ())));
  90. Assert.Equal (new Point (-20, -10), sv.ContentOffset);
  91. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
  92. Assert.Equal (new Point (-20, -10), sv.ContentOffset);
  93. Assert.True (sv.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
  94. Assert.Equal (new Point (-20, 0), sv.ContentOffset);
  95. Assert.False (sv.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
  96. Assert.Equal (new Point (-20, 0), sv.ContentOffset);
  97. Assert.True (sv.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ())));
  98. Assert.Equal (new Point (-20, -10), sv.ContentOffset);
  99. Assert.False (sv.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ())));
  100. Assert.Equal (new Point (-20, -10), sv.ContentOffset);
  101. Assert.True (sv.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
  102. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  103. Assert.False (sv.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
  104. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  105. Assert.True (sv.ProcessKey (new KeyEvent (Key.End | Key.CtrlMask, new KeyModifiers ())));
  106. Assert.Equal (new Point (-20, -10), sv.ContentOffset);
  107. Assert.False (sv.ProcessKey (new KeyEvent (Key.End | Key.CtrlMask, new KeyModifiers ())));
  108. Assert.Equal (new Point (-20, -10), sv.ContentOffset);
  109. Assert.True (sv.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
  110. Assert.Equal (new Point (-20, 0), sv.ContentOffset);
  111. Assert.True (sv.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
  112. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  113. sv.KeepContentAlwaysInViewport = false;
  114. Assert.False (sv.KeepContentAlwaysInViewport);
  115. Assert.True (sv.AutoHideScrollBars);
  116. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  117. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ())));
  118. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  119. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
  120. Assert.Equal (new Point (0, -1), sv.ContentOffset);
  121. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorUp, new KeyModifiers ())));
  122. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  123. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageUp, new KeyModifiers ())));
  124. Assert.Equal (new Point (0, 0), sv.ContentOffset);
  125. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageDown, new KeyModifiers ())));
  126. Assert.Equal (new Point (0, -10), sv.ContentOffset);
  127. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageDown, new KeyModifiers ())));
  128. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  129. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageDown, new KeyModifiers ())));
  130. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  131. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers ())));
  132. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  133. Assert.True (sv.ProcessKey (new KeyEvent ((Key)'v' | Key.AltMask, new KeyModifiers ())));
  134. Assert.Equal (new Point (0, -9), sv.ContentOffset);
  135. Assert.True (sv.ProcessKey (new KeyEvent (Key.V | Key.CtrlMask, new KeyModifiers ())));
  136. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  137. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
  138. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  139. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
  140. Assert.Equal (new Point (-1, -19), sv.ContentOffset);
  141. Assert.True (sv.ProcessKey (new KeyEvent (Key.CursorLeft, new KeyModifiers ())));
  142. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  143. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageUp | Key.CtrlMask, new KeyModifiers ())));
  144. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  145. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageDown | Key.CtrlMask, new KeyModifiers ())));
  146. Assert.Equal (new Point (-20, -19), sv.ContentOffset);
  147. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageDown | Key.CtrlMask, new KeyModifiers ())));
  148. Assert.Equal (new Point (-39, -19), sv.ContentOffset);
  149. Assert.False (sv.ProcessKey (new KeyEvent (Key.PageDown | Key.CtrlMask, new KeyModifiers ())));
  150. Assert.Equal (new Point (-39, -19), sv.ContentOffset);
  151. Assert.False (sv.ProcessKey (new KeyEvent (Key.CursorRight, new KeyModifiers ())));
  152. Assert.Equal (new Point (-39, -19), sv.ContentOffset);
  153. Assert.True (sv.ProcessKey (new KeyEvent (Key.PageUp | Key.CtrlMask, new KeyModifiers ())));
  154. Assert.Equal (new Point (-19, -19), sv.ContentOffset);
  155. Assert.True (sv.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
  156. Assert.Equal (new Point (-19, 0), sv.ContentOffset);
  157. Assert.False (sv.ProcessKey (new KeyEvent (Key.Home, new KeyModifiers ())));
  158. Assert.Equal (new Point (-19, 0), sv.ContentOffset);
  159. Assert.True (sv.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ())));
  160. Assert.Equal (new Point (-19, -19), sv.ContentOffset);
  161. Assert.False (sv.ProcessKey (new KeyEvent (Key.End, new KeyModifiers ())));
  162. Assert.Equal (new Point (-19, -19), sv.ContentOffset);
  163. Assert.True (sv.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
  164. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  165. Assert.False (sv.ProcessKey (new KeyEvent (Key.Home | Key.CtrlMask, new KeyModifiers ())));
  166. Assert.Equal (new Point (0, -19), sv.ContentOffset);
  167. Assert.True (sv.ProcessKey (new KeyEvent (Key.End | Key.CtrlMask, new KeyModifiers ())));
  168. Assert.Equal (new Point (-39, -19), sv.ContentOffset);
  169. Assert.False (sv.ProcessKey (new KeyEvent (Key.End | Key.CtrlMask, new KeyModifiers ())));
  170. Assert.Equal (new Point (-39, -19), sv.ContentOffset);
  171. }
  172. [Fact, AutoInitShutdown]
  173. public void AutoHideScrollBars_False_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
  174. {
  175. var sv = new ScrollView {
  176. Width = 10,
  177. Height = 10,
  178. AutoHideScrollBars = false
  179. };
  180. sv.ShowHorizontalScrollIndicator = true;
  181. sv.ShowVerticalScrollIndicator = true;
  182. Application.Top.Add (sv);
  183. Application.Begin (Application.Top);
  184. Assert.False (sv.AutoHideScrollBars);
  185. Assert.True (sv.ShowHorizontalScrollIndicator);
  186. Assert.True (sv.ShowVerticalScrollIndicator);
  187. sv.Redraw (sv.Bounds);
  188. TestHelpers.AssertDriverContentsAre (@"
  189. ◄├─────┤►
  190. ", output);
  191. sv.ShowHorizontalScrollIndicator = false;
  192. sv.ShowVerticalScrollIndicator = true;
  193. Assert.False (sv.AutoHideScrollBars);
  194. Assert.False (sv.ShowHorizontalScrollIndicator);
  195. Assert.True (sv.ShowVerticalScrollIndicator);
  196. sv.Redraw (sv.Bounds);
  197. TestHelpers.AssertDriverContentsAre (@"
  198. ", output);
  199. sv.ShowHorizontalScrollIndicator = true;
  200. sv.ShowVerticalScrollIndicator = false;
  201. Assert.False (sv.AutoHideScrollBars);
  202. Assert.True (sv.ShowHorizontalScrollIndicator);
  203. Assert.False (sv.ShowVerticalScrollIndicator);
  204. sv.Redraw (sv.Bounds);
  205. TestHelpers.AssertDriverContentsAre (@"
  206. ◄├─────┤►
  207. ", output);
  208. sv.ShowHorizontalScrollIndicator = false;
  209. sv.ShowVerticalScrollIndicator = false;
  210. Assert.False (sv.AutoHideScrollBars);
  211. Assert.False (sv.ShowHorizontalScrollIndicator);
  212. Assert.False (sv.ShowVerticalScrollIndicator);
  213. sv.Redraw (sv.Bounds);
  214. TestHelpers.AssertDriverContentsAre (@"
  215. ", output);
  216. }
  217. [Fact, AutoInitShutdown]
  218. public void AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
  219. {
  220. var sv = new ScrollView {
  221. Width = 10,
  222. Height = 10
  223. };
  224. Application.Top.Add (sv);
  225. Application.Begin (Application.Top);
  226. Assert.True (sv.AutoHideScrollBars);
  227. Assert.False (sv.ShowHorizontalScrollIndicator);
  228. Assert.False (sv.ShowVerticalScrollIndicator);
  229. TestHelpers.AssertDriverContentsWithFrameAre ("", output);
  230. sv.AutoHideScrollBars = false;
  231. sv.ShowHorizontalScrollIndicator = true;
  232. sv.ShowVerticalScrollIndicator = true;
  233. sv.LayoutSubviews ();
  234. sv.Redraw (sv.Bounds);
  235. TestHelpers.AssertDriverContentsWithFrameAre (@"
  236. ◄├─────┤►
  237. ", output);
  238. }
  239. [Fact, AutoInitShutdown]
  240. public void ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
  241. {
  242. var sv = new ScrollView {
  243. Width = 10,
  244. Height = 10,
  245. ContentSize = new Size (50, 50)
  246. };
  247. Application.Top.Add (sv);
  248. Application.Begin (Application.Top);
  249. Assert.Equal (50, sv.ContentSize.Width);
  250. Assert.Equal (50, sv.ContentSize.Height);
  251. Assert.True (sv.AutoHideScrollBars);
  252. Assert.True (sv.ShowHorizontalScrollIndicator);
  253. Assert.True (sv.ShowVerticalScrollIndicator);
  254. TestHelpers.AssertDriverContentsWithFrameAre (@"
  255. ◄├┤░░░░░►
  256. ", output);
  257. }
  258. [Fact, AutoInitShutdown]
  259. public void ContentOffset_ContentSize_AutoHideScrollBars_ShowHorizontalScrollIndicator_ShowVerticalScrollIndicator ()
  260. {
  261. var sv = new ScrollView {
  262. Width = 10,
  263. Height = 10,
  264. ContentSize = new Size (50, 50),
  265. ContentOffset = new Point (25, 25)
  266. };
  267. Application.Top.Add (sv);
  268. Application.Begin (Application.Top);
  269. Assert.Equal (-25, sv.ContentOffset.X);
  270. Assert.Equal (-25, sv.ContentOffset.Y);
  271. Assert.Equal (50, sv.ContentSize.Width);
  272. Assert.Equal (50, sv.ContentSize.Height);
  273. Assert.True (sv.AutoHideScrollBars);
  274. Assert.True (sv.ShowHorizontalScrollIndicator);
  275. Assert.True (sv.ShowVerticalScrollIndicator);
  276. TestHelpers.AssertDriverContentsWithFrameAre (@"
  277. ◄░░░├─┤░►
  278. ", output);
  279. }
  280. // BUGBUG: v2 - I can't figure out what this test is trying to test and it fails in weird ways
  281. // Disabling for now
  282. //[Fact, AutoInitShutdown]
  283. //public void Frame_And_Labels_Does_Not_Overspill_ScrollView ()
  284. //{
  285. // var sv = new ScrollView {
  286. // X = 3,
  287. // Y = 3,
  288. // Width = 10,
  289. // Height = 10,
  290. // ContentSize = new Size (50, 50)
  291. // };
  292. // for (int i = 0; i < 8; i++) {
  293. // sv.Add (new CustomButton ("█", $"Button {i}", 20, 3) { Y = i * 3 });
  294. // }
  295. // Application.Top.Add (sv);
  296. // Application.Begin (Application.Top);
  297. // TestHelpers.AssertDriverContentsWithFrameAre (@"
  298. // █████████▲
  299. // ██████But┬
  300. // █████████┴
  301. // ┌────────░
  302. // │ But░
  303. // └────────░
  304. // ┌────────░
  305. // │ But░
  306. // └────────▼
  307. // ◄├┤░░░░░► ", output);
  308. // sv.ContentOffset = new Point (5, 5);
  309. // sv.LayoutSubviews ();
  310. // Application.Refresh ();
  311. // TestHelpers.AssertDriverContentsWithFrameAre (@"
  312. // ─────────▲
  313. // ─────────┬
  314. // Button 2│
  315. // ─────────┴
  316. // ─────────░
  317. // Button 3░
  318. // ─────────░
  319. // ─────────░
  320. // Button 4▼
  321. // ◄├─┤░░░░► ", output);
  322. //}
  323. //private class CustomButton : FrameView {
  324. // private Label labelFill;
  325. // private Label labelText;
  326. // public CustomButton (string fill, ustring text, int width, int height) : base ()
  327. // {
  328. // Width = width;
  329. // Height = height;
  330. // labelFill = new Label () { AutoSize = false, X = Pos.Center (), Y = Pos.Center (), Width = Dim.Fill (), Height = Dim.Fill (), Visible = false };
  331. // labelFill.LayoutComplete += (s, e) => {
  332. // var fillText = new System.Text.StringBuilder ();
  333. // for (int i = 0; i < labelFill.Bounds.Height; i++) {
  334. // if (i > 0) {
  335. // fillText.AppendLine ("");
  336. // }
  337. // for (int j = 0; j < labelFill.Bounds.Width; j++) {
  338. // fillText.Append (fill);
  339. // }
  340. // }
  341. // labelFill.Text = fillText.ToString ();
  342. // };
  343. // labelText = new Label (text) { X = Pos.Center (), Y = Pos.Center () };
  344. // Add (labelFill, labelText);
  345. // CanFocus = true;
  346. // }
  347. // public override bool OnEnter (View view)
  348. // {
  349. // Border.BorderStyle = BorderStyle.None;
  350. // Border.DrawMarginFrame = false;
  351. // labelFill.Visible = true;
  352. // view = this;
  353. // return base.OnEnter (view);
  354. // }
  355. // public override bool OnLeave (View view)
  356. // {
  357. // Border.BorderStyle = BorderStyle.Single;
  358. // Border.DrawMarginFrame = true;
  359. // labelFill.Visible = false;
  360. // if (view == null)
  361. // view = this;
  362. // return base.OnLeave (view);
  363. // }
  364. //}
  365. [Fact, AutoInitShutdown]
  366. public void Clear_Window_Inside_ScrollView ()
  367. {
  368. var topLabel = new Label ("At 15,0") { X = 15 };
  369. var sv = new ScrollView {
  370. X = 3,
  371. Y = 3,
  372. Width = 10,
  373. Height = 10,
  374. ContentSize = new Size (23, 23),
  375. KeepContentAlwaysInViewport = false
  376. };
  377. var bottomLabel = new Label ("At 15,15") { X = 15, Y = 15 };
  378. Application.Top.Add (topLabel, sv, bottomLabel);
  379. Application.Begin (Application.Top);
  380. TestHelpers.AssertDriverContentsWithFrameAre (@"
  381. At 15,0
  382. ◄├┤░░░░░►
  383. At 15,15", output);
  384. var attributes = new Attribute [] {
  385. Colors.TopLevel.Normal,
  386. Colors.TopLevel.Focus,
  387. Colors.Base.Normal
  388. };
  389. TestHelpers.AssertDriverColorsAre (@"
  390. 00000000000000000000000
  391. 00000000000000000000000
  392. 00000000000000000000000
  393. 00000000000010000000000
  394. 00000000000010000000000
  395. 00000000000010000000000
  396. 00000000000010000000000
  397. 00000000000010000000000
  398. 00000000000010000000000
  399. 00000000000010000000000
  400. 00000000000010000000000
  401. 00000000000010000000000
  402. 00011111111110000000000
  403. 00000000000000000000000
  404. 00000000000000000000000
  405. 00000000000000000000000", attributes);
  406. sv.Add (new Window ("1") { X = 3, Y = 3, Width = 20, Height = 20 });
  407. Application.Refresh ();
  408. TestHelpers.AssertDriverContentsWithFrameAre (@"
  409. At 15,0
  410. ┌┤1├──░
  411. │ ░
  412. │ ░
  413. │ ░
  414. │ ░
  415. │ ▼
  416. ◄├┤░░░░░►
  417. At 15,15", output);
  418. TestHelpers.AssertDriverColorsAre (@"
  419. 00000000000000000000000
  420. 00000000000000000000000
  421. 00000000000000000000000
  422. 00000000000010000000000
  423. 00000000000010000000000
  424. 00000000000010000000000
  425. 00000022222210000000000
  426. 00000022222210000000000
  427. 00000022222210000000000
  428. 00000022222210000000000
  429. 00000022222210000000000
  430. 00000022222210000000000
  431. 00011111111110000000000
  432. 00000000000000000000000
  433. 00000000000000000000000
  434. 00000000000000000000000", attributes);
  435. sv.ContentOffset = new Point (20, 20);
  436. Application.Refresh ();
  437. TestHelpers.AssertDriverContentsWithFrameAre (@"
  438. At 15,0
  439. │ ▲
  440. │ ░
  441. ──┘ ░
  442. ◄░░░░├─┤►
  443. At 15,15", output);
  444. TestHelpers.AssertDriverColorsAre (@"
  445. 00000000000000000000000
  446. 00000000000000000000000
  447. 00000000000000000000000
  448. 00022200000010000000000
  449. 00022200000010000000000
  450. 00022200000010000000000
  451. 00000000000010000000000
  452. 00000000000010000000000
  453. 00000000000010000000000
  454. 00000000000010000000000
  455. 00000000000010000000000
  456. 00000000000010000000000
  457. 00011111111110000000000
  458. 00000000000000000000000
  459. 00000000000000000000000
  460. 00000000000000000000000", attributes);
  461. }
  462. }
  463. }