From 11b3eb090d7a8f47d11879d70a5f82c90d85ed77 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 17 Oct 2024 12:22:07 -0600 Subject: [PATCH] Fixed more unit tests --- UnitTests/View/Layout/SetRelativeLayoutTests.cs | 1 + UnitTests/View/Layout/ToScreenTests.cs | 8 ++++++++ UnitTests/View/Layout/ViewportTests.cs | 2 ++ 3 files changed, 11 insertions(+) diff --git a/UnitTests/View/Layout/SetRelativeLayoutTests.cs b/UnitTests/View/Layout/SetRelativeLayoutTests.cs index 60a47435a..556b77f3a 100644 --- a/UnitTests/View/Layout/SetRelativeLayoutTests.cs +++ b/UnitTests/View/Layout/SetRelativeLayoutTests.cs @@ -246,6 +246,7 @@ public class SetRelativeLayoutTests Height = 1 }; superView.Add (testView); + superView.Layout (); testView.SetRelativeLayout (superView.Frame.Size); Assert.Equal (4, testView.Frame.X); Assert.Equal (4, testView.Frame.Y); diff --git a/UnitTests/View/Layout/ToScreenTests.cs b/UnitTests/View/Layout/ToScreenTests.cs index 3e724f0ed..72ad2c9dd 100644 --- a/UnitTests/View/Layout/ToScreenTests.cs +++ b/UnitTests/View/Layout/ToScreenTests.cs @@ -23,6 +23,8 @@ public class ToScreenTests (ITestOutputHelper output) public void FrameToScreen_NoSuperView (int frameX, int frameY, int expectedScreenX, int expectedScreenY) { var view = new View { X = frameX, Y = frameY, Width = 10, Height = 10 }; + view.Layout (); + var expected = new Rectangle (expectedScreenX, expectedScreenY, 10, 10); Rectangle actual = view.FrameToScreen (); Assert.Equal (expected, actual); @@ -48,6 +50,8 @@ public class ToScreenTests (ITestOutputHelper output) var view = new View { X = frameX, Y = frameY, Width = 10, Height = 10 }; super.Add (view); + super.Layout (); + var expected = new Rectangle (expectedScreenX, expectedScreenY, 10, 10); Rectangle actual = view.FrameToScreen (); Assert.Equal (expected, actual); @@ -337,6 +341,7 @@ public class ToScreenTests (ITestOutputHelper output) Width = 10, Height = 10 }; + view.Layout (); view.SetContentSize (new (20, 20)); Point testPoint = new (0, 0); @@ -633,10 +638,12 @@ public class ToScreenTests (ITestOutputHelper output) Height = 10, ViewportSettings = ViewportSettings.AllowNegativeLocation }; + view.Layout (); Rectangle testRect = new Rectangle (0, 0, 1, 1); Assert.Equal (new Point (0, 0), view.ViewportToScreen (testRect).Location); view.Viewport = view.Viewport with { Location = new Point (1, 1) }; + Assert.Equal (new Rectangle (1, 1, 10, 10), view.Viewport); Assert.Equal (new Point (0, 0), view.ViewportToScreen (testRect).Location); } @@ -654,6 +661,7 @@ public class ToScreenTests (ITestOutputHelper output) var view = new View (); view.Frame = frame; + view.Layout (); // Act var screen = view.ViewportToScreen (new Point (viewportX, 0)); diff --git a/UnitTests/View/Layout/ViewportTests.cs b/UnitTests/View/Layout/ViewportTests.cs index 419cef649..c210d8215 100644 --- a/UnitTests/View/Layout/ViewportTests.cs +++ b/UnitTests/View/Layout/ViewportTests.cs @@ -160,6 +160,7 @@ public class ViewportTests (ITestOutputHelper output) Height = 10, ViewportSettings = ViewportSettings.AllowNegativeLocation }; + view.Layout (); Assert.Equal (new Rectangle (0, 0, 10, 10), view.Frame); @@ -237,6 +238,7 @@ public class ViewportTests (ITestOutputHelper output) Width = viewWidth, Height = viewHeight, }; + view.Layout (); var newViewport = new Rectangle (viewportX, viewportY, viewWidth, viewHeight); // Act