mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 00:46:39 +01:00
All unit tests pass.
Made TextFormatter have independent Width/Height.
This commit is contained in:
@@ -306,7 +306,7 @@ public partial class DimAutoTests
|
||||
[Theory]
|
||||
[InlineData (0, 10, 0, 10, 10, 2)]
|
||||
[InlineData (0, 5, 0, 5, 5, 3)] // max width of 5 should cause wordwrap at 5 giving a height of 2 + 1
|
||||
//[InlineData (0, 19, 0, 9, 19, 9)]
|
||||
[InlineData (0, 19, 0, 9, 11, 2)]
|
||||
//[InlineData (0, 20, 0, 10, 20, 10)]
|
||||
//[InlineData (0, 21, 0, 11, 21, 11)]
|
||||
//[InlineData (1, 21, 1, 11, 21, 11)]
|
||||
|
||||
@@ -528,6 +528,25 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
|
||||
#region DimAutoStyle.Auto tests
|
||||
|
||||
[Theory]
|
||||
[InlineData ("", 0, 0)]
|
||||
[InlineData (" ", 1, 1)]
|
||||
[InlineData ("01234", 5, 1)]
|
||||
[InlineData ("01234\nABCDE", 5, 2)]
|
||||
public void DimAutoStyle_Auto_JustText_Sizes_Correctly (string text, int expectedW, int expectedH)
|
||||
{
|
||||
var view = new View ();
|
||||
view.Width = Auto ();
|
||||
view.Height = Auto ();
|
||||
|
||||
view.Text = text;
|
||||
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DimAutoStyle_Auto_Text_Size_Is_Used ()
|
||||
{
|
||||
@@ -622,6 +641,7 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
[InlineData ("", 0, 0)]
|
||||
[InlineData (" ", 1, 1)]
|
||||
[InlineData ("01234", 5, 1)]
|
||||
[InlineData ("01234\nABCDE", 5, 2)]
|
||||
public void DimAutoStyle_Text_Sizes_Correctly (string text, int expectedW, int expectedH)
|
||||
{
|
||||
var view = new View ();
|
||||
@@ -677,7 +697,10 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
[InlineData ("", 0, 0)]
|
||||
[InlineData (" ", 1, 1)]
|
||||
[InlineData ("01234", 5, 1)]
|
||||
public void DimAutoStyle_Text_Ignores_ContentSize (string text, int expectedW, int expectedH)
|
||||
[InlineData ("01234ABCDE", 10, 1)]
|
||||
[InlineData ("01234\nABCDE", 5, 2)]
|
||||
|
||||
public void DimAutoStyle_Text_NoMin_Not_Constrained_By_ContentSize (string text, int expectedW, int expectedH)
|
||||
{
|
||||
var view = new View ();
|
||||
view.Width = Auto (DimAutoStyle.Text);
|
||||
@@ -688,6 +711,31 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData ("", 0, 0)]
|
||||
[InlineData (" ", 1, 1)]
|
||||
[InlineData ("01234", 5, 1)]
|
||||
[InlineData ("01234ABCDE", 10, 1)]
|
||||
[InlineData ("01234\nABCDE", 5, 2)]
|
||||
public void DimAutoStyle_Text_NoMin_Not_Constrained_By_SuperView (string text, int expectedW, int expectedH)
|
||||
{
|
||||
var superView = new View ()
|
||||
{
|
||||
Width = 1, Height = 1
|
||||
};
|
||||
|
||||
var view = new View ();
|
||||
|
||||
view.Width = Auto (DimAutoStyle.Text);
|
||||
view.Height = Auto (DimAutoStyle.Text);
|
||||
view.Text = text;
|
||||
superView.Add (view);
|
||||
|
||||
superView.SetRelativeLayout (Application.Screen.Size);
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DimAutoStyle_Text_Pos_AnchorEnd_Locates_Correctly ()
|
||||
{
|
||||
@@ -902,7 +950,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Height = 1,
|
||||
Width = Auto ()
|
||||
};
|
||||
Assert.Equal (new (expected, 1), view.TextFormatter.Size);
|
||||
Assert.Equal (expected, view.TextFormatter.Width);
|
||||
Assert.Equal (1, view.TextFormatter.Height);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -917,7 +966,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
Assert.Equal (new (expected, 1), view.TextFormatter.Size);
|
||||
Assert.Equal (expected, view.TextFormatter.Width);
|
||||
Assert.Equal (1, view.TextFormatter.Height);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
@@ -927,7 +977,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Width = 1,
|
||||
Height = Auto ()
|
||||
};
|
||||
Assert.Equal (new (1, expected), view.TextFormatter.Size);
|
||||
Assert.Equal (1, view.TextFormatter.Width);
|
||||
Assert.Equal (expected, view.TextFormatter.Height);
|
||||
}
|
||||
|
||||
// Test variations of Frame
|
||||
|
||||
Reference in New Issue
Block a user