mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Rebased with v2_develop
This commit is contained in:
@@ -339,7 +339,7 @@ public class DrawTests (ITestOutputHelper _output)
|
||||
Text = "Test",
|
||||
Width = 6,
|
||||
Height = 1,
|
||||
TextAlignment = TextAlignment.Right,
|
||||
TextAlignment = Alignment.End,
|
||||
ColorScheme = Colors.ColorSchemes ["Base"]
|
||||
};
|
||||
|
||||
@@ -350,7 +350,7 @@ public class DrawTests (ITestOutputHelper _output)
|
||||
Y = 1,
|
||||
Width = 1,
|
||||
Height = 6,
|
||||
VerticalTextAlignment = VerticalTextAlignment.Bottom,
|
||||
VerticalTextAlignment = Alignment.End,
|
||||
ColorScheme = Colors.ColorSchemes ["Base"]
|
||||
};
|
||||
Toplevel top = new ();
|
||||
|
||||
@@ -787,11 +787,11 @@ public class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.Equal (Size.Empty, view.Frame.Size);
|
||||
|
||||
view.TextFormatter.Alignment = TextAlignment.Justified;
|
||||
view.TextFormatter.Alignment = Alignment.Fill;
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.Equal (Size.Empty, view.Frame.Size);
|
||||
|
||||
view.TextFormatter.VerticalAlignment = VerticalTextAlignment.Middle;
|
||||
view.TextFormatter.VerticalAlignment = Alignment.Center;
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.Equal (Size.Empty, view.Frame.Size);
|
||||
|
||||
@@ -815,11 +815,11 @@ public class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.Equal (Size.Empty, view.Frame.Size);
|
||||
|
||||
view.TextAlignment = TextAlignment.Justified;
|
||||
view.TextAlignment = Alignment.Fill;
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.Equal (Size.Empty, view.Frame.Size);
|
||||
|
||||
view.VerticalTextAlignment = VerticalTextAlignment.Middle;
|
||||
view.VerticalTextAlignment = Alignment.Center;
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.Equal (Size.Empty, view.Frame.Size);
|
||||
|
||||
@@ -844,7 +844,7 @@ public class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.NotEqual (Size.Empty, view.Frame.Size);
|
||||
|
||||
view.TextAlignment = TextAlignment.Justified;
|
||||
view.TextAlignment = Alignment.Fill;
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.NotEqual (Size.Empty, view.Frame.Size);
|
||||
|
||||
@@ -853,7 +853,7 @@ public class DimAutoTests (ITestOutputHelper output)
|
||||
Text = "_1234",
|
||||
Width = Dim.Auto ()
|
||||
};
|
||||
view.VerticalTextAlignment = VerticalTextAlignment.Middle;
|
||||
view.VerticalTextAlignment = Alignment.Center;
|
||||
Assert.False (view.TextFormatter.AutoSize);
|
||||
Assert.NotEqual (Size.Empty, view.Frame.Size);
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Terminal.Gui.LayoutTests;
|
||||
|
||||
public class DimPercentTests
|
||||
{
|
||||
//private readonly ITestOutputHelper _output;
|
||||
|
||||
[Fact]
|
||||
public void DimFactor_Calculate_ReturnsCorrectValue ()
|
||||
{
|
||||
|
||||
99
UnitTests/View/Layout/Pos.AlignTests.cs
Normal file
99
UnitTests/View/Layout/Pos.AlignTests.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
using static Unix.Terminal.Delegates;
|
||||
|
||||
namespace Terminal.Gui.PosDimTests;
|
||||
|
||||
public class PosAlignTests ()
|
||||
{
|
||||
[Fact]
|
||||
public void PosAlign_Constructor ()
|
||||
{
|
||||
var posAlign = new PosAlign ()
|
||||
{
|
||||
Aligner = new Aligner(),
|
||||
};
|
||||
Assert.NotNull (posAlign);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (Alignment.Start, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
|
||||
[InlineData (Alignment.Center, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
|
||||
[InlineData (Alignment.Start, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
[InlineData (Alignment.Center, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
[InlineData (Alignment.Start, Alignment.Start, AlignmentModes.StartToEnd, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
public void PosAlign_Equals (Alignment align1, Alignment align2, AlignmentModes mode1, AlignmentModes mode2, bool expectedEquals)
|
||||
{
|
||||
var posAlign1 = new PosAlign ()
|
||||
{
|
||||
Aligner = new Aligner ()
|
||||
{
|
||||
Alignment = align1,
|
||||
AlignmentModes = mode1
|
||||
}
|
||||
};
|
||||
var posAlign2 = new PosAlign ()
|
||||
{
|
||||
Aligner = new Aligner ()
|
||||
{
|
||||
Alignment = align2,
|
||||
AlignmentModes = mode2
|
||||
}
|
||||
};
|
||||
|
||||
Assert.Equal (expectedEquals, posAlign1.Equals (posAlign2));
|
||||
Assert.Equal (expectedEquals, posAlign2.Equals (posAlign1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosAlign_Equals_CachedLocation_Not_Used ()
|
||||
{
|
||||
View superView = new ()
|
||||
{
|
||||
Width = 10,
|
||||
Height = 25
|
||||
};
|
||||
View view = new ();
|
||||
superView.Add (view);
|
||||
|
||||
var posAlign1 = Pos.Align (Alignment.Center, AlignmentModes.AddSpaceBetweenItems);
|
||||
view.X = posAlign1;
|
||||
var pos1 = posAlign1.Calculate (10, Dim.Absolute(0)!, view, Dimension.Width);
|
||||
|
||||
var posAlign2 = Pos.Align (Alignment.Center, AlignmentModes.AddSpaceBetweenItems);
|
||||
view.Y = posAlign2;
|
||||
var pos2 = posAlign2.Calculate (25, Dim.Absolute (0)!, view, Dimension.Height);
|
||||
|
||||
Assert.NotEqual(pos1, pos2);
|
||||
Assert.Equal (posAlign1, posAlign2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosAlign_ToString ()
|
||||
{
|
||||
var posAlign = Pos.Align (Alignment.Fill);
|
||||
var expectedString = "Align(alignment=Fill,modes=AddSpaceBetweenItems,groupId=0)";
|
||||
|
||||
Assert.Equal (expectedString, posAlign.ToString ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosAlign_Anchor ()
|
||||
{
|
||||
var posAlign = Pos.Align (Alignment.Start);
|
||||
var width = 50;
|
||||
var expectedAnchor = -width;
|
||||
|
||||
Assert.Equal (expectedAnchor, posAlign.GetAnchor (width));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosAlign_CreatesCorrectInstance ()
|
||||
{
|
||||
var pos = Pos.Align (Alignment.Start);
|
||||
Assert.IsType<PosAlign> (pos);
|
||||
}
|
||||
|
||||
// TODO: Test scenarios where views with matching GroupId's are added/removed from a Superview
|
||||
|
||||
// TODO: Make AlignAndUpdateGroup internal and write low-level unit tests for it
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class PosTests ()
|
||||
{
|
||||
Application.Init (new FakeDriver ());
|
||||
|
||||
Toplevel t = new Toplevel();
|
||||
Toplevel t = new Toplevel ();
|
||||
|
||||
var w = new Window { X = Pos.Left (t) + 2, Y = Pos.Top (t) + 2 };
|
||||
var f = new FrameView ();
|
||||
|
||||
@@ -5,7 +5,7 @@ using Xunit.Abstractions;
|
||||
namespace Terminal.Gui.ViewTests;
|
||||
|
||||
[Trait("Category","Output")]
|
||||
public class NeedsDisplayTests (ITestOutputHelper output)
|
||||
public class NeedsDisplayTests ()
|
||||
{
|
||||
[Fact]
|
||||
public void NeedsDisplay_False_If_Width_Height_Zero ()
|
||||
|
||||
@@ -850,7 +850,7 @@ Y
|
||||
Y = 1,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
TextAlignment = TextAlignment.Centered
|
||||
TextAlignment = Alignment.Center
|
||||
};
|
||||
|
||||
if (autoSize)
|
||||
@@ -865,7 +865,7 @@ Y
|
||||
Y = 2,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
TextAlignment = TextAlignment.Right
|
||||
TextAlignment = Alignment.End
|
||||
};
|
||||
|
||||
if (autoSize)
|
||||
@@ -880,7 +880,7 @@ Y
|
||||
Y = 3,
|
||||
Width = width,
|
||||
Height = 1,
|
||||
TextAlignment = TextAlignment.Justified
|
||||
TextAlignment = Alignment.Fill
|
||||
};
|
||||
|
||||
if (autoSize)
|
||||
@@ -974,7 +974,7 @@ Y
|
||||
Width = 1,
|
||||
Height = height,
|
||||
TextDirection = TextDirection.TopBottom_LeftRight,
|
||||
VerticalTextAlignment = VerticalTextAlignment.Middle
|
||||
VerticalTextAlignment = Alignment.Center
|
||||
};
|
||||
|
||||
if (autoSize)
|
||||
@@ -990,7 +990,7 @@ Y
|
||||
Width = 1,
|
||||
Height = height,
|
||||
TextDirection = TextDirection.TopBottom_LeftRight,
|
||||
VerticalTextAlignment = VerticalTextAlignment.Bottom
|
||||
VerticalTextAlignment = Alignment.End
|
||||
};
|
||||
|
||||
if (autoSize)
|
||||
@@ -1006,7 +1006,7 @@ Y
|
||||
Width = 1,
|
||||
Height = height,
|
||||
TextDirection = TextDirection.TopBottom_LeftRight,
|
||||
VerticalTextAlignment = VerticalTextAlignment.Justified
|
||||
VerticalTextAlignment = Alignment.Fill
|
||||
};
|
||||
|
||||
if (autoSize)
|
||||
@@ -1227,7 +1227,7 @@ Y
|
||||
{
|
||||
Text = "01234",
|
||||
TextDirection = TextDirection.LeftRight_TopBottom,
|
||||
TextAlignment = TextAlignment.Centered,
|
||||
TextAlignment = Alignment.Center,
|
||||
Width = 10,
|
||||
Height = Dim.Auto (DimAutoStyle.Text)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user