Fixed more tests

This commit is contained in:
Tig
2024-04-18 18:18:30 -06:00
parent 7b5df8386e
commit a4d3bc7e58
8 changed files with 52 additions and 77 deletions

View File

@@ -640,14 +640,14 @@ public class DimAutoTests
var view = new View ()
{
Text = "01234567",
Width = Auto (DimAutoStyle.Text),
Height = Auto (DimAutoStyle.Text),
Text = "New text"
};
Rectangle expectedViewport = new (0, 0, 8, 1);
Assert.Equal (expectedViewport, view.Viewport);
super.Add (view);
Rectangle expectedViewport = new (0, 0, 8, 1);
Assert.Equal (expectedViewport, view.Viewport);
super.LayoutSubviews ();

View File

@@ -1,4 +1,5 @@
using Xunit.Abstractions;
using static Terminal.Gui.Pos;
namespace Terminal.Gui.ViewTests;
@@ -209,29 +210,6 @@ public class AutoSizeFalseTests
Assert.Equal ("Absolute(1)", view.Height.ToString ());
}
[Fact]
public void AutoSize_False_Text_Does_Not_Change_Size ()
{
var view = new View { Width = Dim.Fill (), Height = Dim.Fill () };
view.SetRelativeLayout (new (10, 4));
Assert.Equal (new (0, 0, 10, 4), view.Frame);
Assert.Equal (new (0, 0), view.TextFormatter.Size);
Assert.False (view.AutoSize);
Assert.True (view.TextFormatter.NeedsFormat);
Assert.Equal (string.Empty, view.TextFormatter.Format ()); // There's no size, so it returns an empty string
Assert.False (view.TextFormatter.NeedsFormat);
Assert.Single (view.TextFormatter.GetLines ());
Assert.True (string.IsNullOrEmpty (view.TextFormatter.GetLines () [0]));
view.Text = "Views";
Assert.True (view.TextFormatter.NeedsFormat);
Assert.Equal (new (0, 0), view.TextFormatter.Size);
Assert.Equal (string.Empty, view.TextFormatter.Format ()); // There's no size, so it returns an empty string
Assert.False (view.TextFormatter.NeedsFormat);
Assert.Single (view.TextFormatter.GetLines ());
Assert.True (string.IsNullOrEmpty (view.TextFormatter.GetLines () [0]));
}
[Fact]
[SetupFakeDriver]

View File

@@ -1746,7 +1746,7 @@ Y
// Setting to false causes Width and Height to be set to the current ContentSize
view.AutoSize = false;
Assert.Equal (new Rectangle (0, 0, 1, 12), view.Frame);
Assert.Equal (new Rectangle (0, 0, 12, 12), view.Frame);
view.Height = 1;
view.Width = 12;

View File

@@ -160,8 +160,7 @@ public class ViewTests
{
Assert.True (v.AutoSize);
Assert.False (v.CanFocus);
// The text is 100 characters long, but Dim.Auto constrains to SuperView, so it should be truncated.
Assert.Equal (new Rectangle (0, 0, 100, 1), v.Frame);
Assert.Equal (new Rectangle (0, 0, 20, 1), v.Frame);
}
else
{