Pos.AnchorEndTests.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnitTests;
  2. namespace Terminal.Gui.LayoutTests;
  3. public class PosAnchorEndTests ()
  4. {
  5. // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
  6. // TODO: A new test that calls SetRelativeLayout directly is needed.
  7. [Fact]
  8. [AutoInitShutdown]
  9. public void PosAnchorEnd_Equal_Inside_Window ()
  10. {
  11. var viewWidth = 10;
  12. var viewHeight = 1;
  13. var tv = new TextView
  14. {
  15. X = Pos.AnchorEnd (viewWidth), Y = Pos.AnchorEnd (viewHeight), Width = viewWidth, Height = viewHeight
  16. };
  17. var win = new Window ();
  18. win.Add (tv);
  19. Toplevel top = new ();
  20. top.Add (win);
  21. RunState rs = Application.Begin (top);
  22. Assert.Equal (new (0, 0, 80, 25), top.Frame);
  23. Assert.Equal (new (0, 0, 80, 25), win.Frame);
  24. Assert.Equal (new (68, 22, 10, 1), tv.Frame);
  25. Application.End (rs);
  26. top.Dispose ();
  27. }
  28. //// TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
  29. //// TODO: A new test that calls SetRelativeLayout directly is needed.
  30. //[Fact]
  31. //[AutoInitShutdown]
  32. //public void PosAnchorEnd_Equal_Inside_Window_With_MenuBar_And_StatusBar_On_Toplevel ()
  33. //{
  34. // var viewWidth = 10;
  35. // var viewHeight = 1;
  36. // var tv = new TextView
  37. // {
  38. // X = Pos.AnchorEnd (viewWidth), Y = Pos.AnchorEnd (viewHeight), Width = viewWidth, Height = viewHeight
  39. // };
  40. // var win = new Window ();
  41. // win.Add (tv);
  42. // var menu = new MenuBar ();
  43. // var status = new StatusBar ();
  44. // Toplevel top = new ();
  45. // top.Add (win, menu, status);
  46. // RunState rs = Application.Begin (top);
  47. // Assert.Equal (new (0, 0, 80, 25), top.Frame);
  48. // Assert.Equal (new (0, 0, 80, 1), menu.Frame);
  49. // Assert.Equal (new (0, 24, 80, 1), status.Frame);
  50. // Assert.Equal (new (0, 1, 80, 23), win.Frame);
  51. // Assert.Equal (new (68, 20, 10, 1), tv.Frame);
  52. // Application.End (rs);
  53. // top.Dispose ();
  54. //}
  55. }