Pos.AnchorEndTests.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using UnitTests;
  2. namespace UnitTests.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. AutoInitShutdownAttribute.FakeResize (new Size (80,25));
  23. Assert.Equal (new (0, 0, 80, 25), top.Frame);
  24. Assert.Equal (new (0, 0, 80, 25), win.Frame);
  25. Assert.Equal (new (68, 22, 10, 1), tv.Frame);
  26. Application.End (rs);
  27. top.Dispose ();
  28. }
  29. //// TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
  30. //// TODO: A new test that calls SetRelativeLayout directly is needed.
  31. //[Fact]
  32. //[AutoInitShutdown]
  33. //public void PosAnchorEnd_Equal_Inside_Window_With_MenuBar_And_StatusBar_On_Toplevel ()
  34. //{
  35. // var viewWidth = 10;
  36. // var viewHeight = 1;
  37. // var tv = new TextView
  38. // {
  39. // X = Pos.AnchorEnd (viewWidth), Y = Pos.AnchorEnd (viewHeight), Width = viewWidth, Height = viewHeight
  40. // };
  41. // var win = new Window ();
  42. // win.Add (tv);
  43. // var menu = new MenuBar ();
  44. // var status = new StatusBar ();
  45. // Toplevel top = new ();
  46. // top.Add (win, menu, status);
  47. // RunState rs = Application.Begin (top);
  48. // Assert.Equal (new (0, 0, 80, 25), top.Frame);
  49. // Assert.Equal (new (0, 0, 80, 1), menu.Frame);
  50. // Assert.Equal (new (0, 24, 80, 1), status.Frame);
  51. // Assert.Equal (new (0, 1, 80, 23), win.Frame);
  52. // Assert.Equal (new (68, 20, 10, 1), tv.Frame);
  53. // Application.End (rs);
  54. // top.Dispose ();
  55. //}
  56. }