Fixed more unit tests

This commit is contained in:
Tig
2024-10-17 12:22:07 -06:00
parent 949f59347f
commit 11b3eb090d
3 changed files with 11 additions and 0 deletions

View File

@@ -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);

View File

@@ -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));

View File

@@ -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