mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Merge branch 'develop' into unittest_reorg
This commit is contained in:
@@ -37,9 +37,9 @@ public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute {
|
||||
/// <param name="fakeClipboardIsSupportedAlwaysTrue">Only valid if <paramref name="autoInit"/> is true.
|
||||
/// Only valid if <see cref="consoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.</param>
|
||||
public AutoInitShutdownAttribute (bool autoInit = true, bool autoShutdown = true,
|
||||
Type consoleDriverType = null,
|
||||
bool useFakeClipboard = false,
|
||||
bool fakeClipboardAlwaysThrowsNotSupportedException = false,
|
||||
Type consoleDriverType = null,
|
||||
bool useFakeClipboard = false,
|
||||
bool fakeClipboardAlwaysThrowsNotSupportedException = false,
|
||||
bool fakeClipboardIsSupportedAlwaysTrue = false)
|
||||
{
|
||||
//Assert.True (autoInit == false && consoleDriverType == null);
|
||||
@@ -54,7 +54,7 @@ public class AutoInitShutdownAttribute : Xunit.Sdk.BeforeAfterTestAttribute {
|
||||
|
||||
static bool _init = false;
|
||||
bool AutoInit { get; }
|
||||
bool AutoShutdown { get; }
|
||||
bool AutoShutdown { get; }
|
||||
Type DriverType;
|
||||
|
||||
public override void Before (MethodInfo methodUnderTest)
|
||||
@@ -251,7 +251,7 @@ class TestHelpers {
|
||||
|
||||
var match = expectedColors.Where (e => e.Value == val).ToList ();
|
||||
if (match.Count == 0) {
|
||||
throw new Exception ($"Unexpected color {DescribeColor (val)} was used at row {r} and col {c} (indexes start at 0). Color value was {val} (expected colors were {string.Join (",", expectedColors.Select (c => c.Value))})");
|
||||
throw new Exception ($"Unexpected color {DescribeColor (val)} was used at row {r} and col {c} (indexes start at 0). Color value was {val} (expected colors were {string.Join (",", expectedColors.Select (c => DescribeColor (c.Value)))})");
|
||||
} else if (match.Count > 1) {
|
||||
throw new ArgumentException ($"Bad value for expectedColors, {match.Count} Attributes had the same Value");
|
||||
}
|
||||
@@ -260,7 +260,7 @@ class TestHelpers {
|
||||
var userExpected = line [c];
|
||||
|
||||
if (colorUsed != userExpected) {
|
||||
throw new Exception ($"Colors used did not match expected at row {r} and col {c} (indexes start at 0). Color index used was {DescribeColor (colorUsed)} but test expected {DescribeColor (userExpected)} (these are indexes into the expectedColors array)");
|
||||
throw new Exception ($"Colors used did not match expected at row {r} and col {c} (indexes start at 0). Color index used was {colorUsed} ({DescribeColor (val)}) but test expected {userExpected} ({DescribeColor (expectedColors [int.Parse (userExpected.ToString ())].Value)}) (these are indexes into the expectedColors array)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4247,5 +4247,46 @@ This TextFormatter (tf2) is rewritten.
|
||||
0111000000
|
||||
0000000000", expectedColors);
|
||||
}
|
||||
|
||||
[Fact, AutoInitShutdown]
|
||||
public void Colors_On_TextAlignment_Right_And_Bottom ()
|
||||
{
|
||||
var labelRight = new Label ("Test") {
|
||||
Width = 6,
|
||||
Height = 1,
|
||||
TextAlignment = TextAlignment.Right,
|
||||
ColorScheme = Colors.Base
|
||||
};
|
||||
var labelBottom = new Label ("Test", TextDirection.TopBottom_LeftRight) {
|
||||
Y = 1,
|
||||
Width = 1,
|
||||
Height = 6,
|
||||
VerticalTextAlignment = VerticalTextAlignment.Bottom,
|
||||
ColorScheme = Colors.Base
|
||||
};
|
||||
var top = Application.Top;
|
||||
top.Add (labelRight, labelBottom);
|
||||
|
||||
Application.Begin (top);
|
||||
((FakeDriver)Application.Driver).SetBufferSize (7, 7);
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
Test
|
||||
|
||||
|
||||
T
|
||||
e
|
||||
s
|
||||
t ", output);
|
||||
|
||||
TestHelpers.AssertDriverColorsAre (@"
|
||||
000000
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0", new Attribute [] { Colors.Base.Normal });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4117,5 +4117,64 @@ This is a tes
|
||||
view.Enabled = false;
|
||||
Assert.Equal (view.ColorScheme.Disabled, view.GetHotNormalColor ());
|
||||
}
|
||||
|
||||
[Theory, AutoInitShutdown]
|
||||
[InlineData (true)]
|
||||
[InlineData (false)]
|
||||
public void Clear_Does_Not_Spillover_Its_Parent (bool label)
|
||||
{
|
||||
var root = new View () { Width = 20, Height = 10 };
|
||||
|
||||
var v = label == true ?
|
||||
new Label (new string ('c', 100)) {
|
||||
Width = Dim.Fill ()
|
||||
} :
|
||||
(View)new TextView () {
|
||||
Height = 1,
|
||||
Text = new string ('c', 100),
|
||||
Width = Dim.Fill ()
|
||||
};
|
||||
|
||||
root.Add (v);
|
||||
|
||||
Application.Top.Add (root);
|
||||
Application.Begin (Application.Top);
|
||||
|
||||
if (label) {
|
||||
Assert.True (v.AutoSize);
|
||||
Assert.False (v.CanFocus);
|
||||
Assert.Equal (new Rect (0, 0, 100, 1), v.Frame);
|
||||
} else {
|
||||
Assert.False (v.AutoSize);
|
||||
Assert.True (v.CanFocus);
|
||||
Assert.Equal (new Rect (0, 0, 20, 1), v.Frame);
|
||||
}
|
||||
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
cccccccccccccccccccc", output);
|
||||
|
||||
var attributes = new Attribute [] {
|
||||
Colors.TopLevel.Normal,
|
||||
Colors.TopLevel.Focus,
|
||||
|
||||
};
|
||||
if (label) {
|
||||
TestHelpers.AssertDriverColorsAre (@"
|
||||
000000000000000000000", attributes);
|
||||
} else {
|
||||
TestHelpers.AssertDriverColorsAre (@"
|
||||
111111111111111111110", attributes);
|
||||
}
|
||||
|
||||
if (label) {
|
||||
root.CanFocus = true;
|
||||
v.CanFocus = true;
|
||||
Assert.False (v.HasFocus);
|
||||
v.SetFocus ();
|
||||
Application.Refresh ();
|
||||
TestHelpers.AssertDriverColorsAre (@"
|
||||
111111111111111111110", attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user