Merge branch 'v2_develop' into copilot/fix-e6dde989-9ea1-4d83-8522-54ed8f70815a

This commit is contained in:
Tig
2025-10-19 12:02:16 -06:00
committed by GitHub
35 changed files with 1462 additions and 303 deletions

View File

@@ -0,0 +1,27 @@
using Xunit;
namespace Terminal.Gui.DrawingTests;
public class ColorStandardColorTests
{
[Fact]
public void ToString_Returns_Standard_Name_For_StandardColor_CadetBlue()
{
// Without the fix, this uses Color(in StandardColor) -> this((int)colorName),
// which sets A=0x00 and prevents name resolution (expects A=0xFF).
var c = new Terminal.Gui.Drawing.Color(Terminal.Gui.Drawing.StandardColor.CadetBlue);
// Expected: named color
Assert.Equal("CadetBlue", c.ToString());
}
[Fact]
public void ToString_G_Prints_Opaque_ARGB_For_StandardColor_CadetBlue()
{
// Without the fix, A=0x00, so "G" prints "#005F9EA0" instead of "#FF5F9EA0".
var c = new Terminal.Gui.Drawing.Color(Terminal.Gui.Drawing.StandardColor.CadetBlue);
// Expected: #AARRGGBB with A=FF (opaque)
Assert.Equal("#FF5F9EA0", c.ToString("G", null));
}
}

View File

@@ -10,7 +10,6 @@ public class SchemeGetAttributeForRoleAlgorithmTests
Attribute normal = new ("Red", "Blue");
Scheme scheme = new (normal);
Assert.NotNull (scheme.Normal);
Assert.Equal (normal, scheme.GetAttributeForRole (VisualRole.Normal));
}

View File

@@ -39,6 +39,40 @@ public class SchemeTests
Assert.True (schemes.ContainsKey ("TopLevel"));
}
[Fact]
public void GetHardCodedSchemes_Have_Expected_Normal_Attributes ()
{
var schemes = Scheme.GetHardCodedSchemes ();
Assert.NotNull (schemes);
// Base
var baseScheme = schemes! ["Base"];
Assert.NotNull (baseScheme);
Assert.Equal (new Attribute (StandardColor.LightBlue, StandardColor.RaisinBlack), baseScheme!.Normal);
// Dialog
var dialogScheme = schemes ["Dialog"];
Assert.NotNull (dialogScheme);
Assert.Equal (new Attribute (StandardColor.LightSkyBlue, StandardColor.OuterSpace), dialogScheme!.Normal);
// Error
var errorScheme = schemes ["Error"];
Assert.NotNull (errorScheme);
Assert.Equal (new Attribute (StandardColor.IndianRed, StandardColor.RaisinBlack), errorScheme!.Normal);
// Menu (Bold style)
var menuScheme = schemes ["Menu"];
Assert.NotNull (menuScheme);
Assert.Equal (new Attribute (StandardColor.Charcoal, StandardColor.LightBlue, TextStyle.Bold), menuScheme!.Normal);
// Toplevel
var toplevelScheme = schemes ["Toplevel"];
Assert.NotNull (toplevelScheme);
Assert.Equal (new Attribute (StandardColor.CadetBlue, StandardColor.Charcoal).ToString (), toplevelScheme!.Normal.ToString ());
}
[Fact]
public void Built_Ins_Are_Implicit ()
{

View File

@@ -142,6 +142,7 @@ public class SchemeTests
var customScheme = SchemeManager.GetHardCodedSchemes ()? ["Error"]! with { Normal = Attribute.Default };
Assert.NotEqual (Attribute.Default, view.GetScheme ().Normal);
view.GettingScheme += (sender, args) =>
{
args.Result = customScheme;
@@ -174,13 +175,13 @@ public class SchemeTests
var customAttribute = new Attribute (Color.BrightRed, Color.BrightYellow);
view.GettingAttributeForRole += (sender, args) =>
{
if (args.Role == VisualRole.Focus)
{
args.Result = customAttribute;
args.Handled = true;
}
};
{
if (args.Role == VisualRole.Focus)
{
args.Result = customAttribute;
args.Handled = true;
}
};
Assert.Equal (customAttribute, view.GetAttributeForRole (VisualRole.Focus));
view.Dispose ();
@@ -199,6 +200,7 @@ public class SchemeTests
Assert.Contains ("Toplevel", schemes.Keys);
}
[Fact]
public void SchemeName_OverridesSuperViewScheme ()
{
@@ -243,6 +245,7 @@ public class SchemeTests
protected override bool OnGettingScheme (out Scheme? scheme)
{
scheme = SchemeManager.GetHardCodedSchemes ()? ["Error"];
return true;
}
@@ -265,4 +268,5 @@ public class SchemeTests
view.Dispose ();
}
}
}