mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* WIP - experiments in fixing shadow rendering issues based on #4465 Previously, shadow size was fixed at 1x1. This change introduces ShadowWidth and ShadowHeight properties to both Margin and View, allowing variable shadow dimensions. The Margin class now manages its own shadow sizing, enforcing valid values based on ShadowStyle (e.g., Opaque and Transparent require a minimum of 1, and Opaque only allows 1). Margin.Thickness is dynamically adjusted to account for shadow size, with original values preserved and restored as needed. ShadowView rendering is updated to correctly handle wide graphemes (such as emojis) in the shadow area, preventing rendering errors. The View class exposes ShadowWidth and ShadowHeight, synchronizing with Margin. Extensive new unit tests verify correct behavior for shadow sizing, style changes, thickness adjustments, and rendering, including edge cases and visual output. Additional minor bug fixes and refactoring are included, such as proper management of Margin's cached clip region and correcting a loop order bug in ShadowView. The codebase is also modernized with recent C# features. * more merge * added border tests * Experiment... * Incorporated latest wideglyphs * Comment tweaks * Add Adornments and ViewportSettings editors to WideGlyphs Introduce AdornmentsEditor and ViewportSettingsEditor with custom border styles and positioning, enhancing UI editing capabilities. Also update arrangeableViewAtEven to use Color.Black and Color.Green, and adjust a commented border style from Dashed to Dotted. * Fix scenario editors and tweak scenarios. Enhance ShadowStyles with a second shadow window (transparent style) and a button event handler that shows a message box. In WideGlyphs, add AdornmentsEditor and ViewportSettingsEditor for view property editing, apply custom color schemes to arrangeable views, and update superView with a transparent shadow and increased shadow width. These changes improve interactivity and visualization in the demo scenarios. * Fix scenario editors and tweak scenarios. Enhance ShadowStyles with a second shadow window (transparent style) and a button event handler that shows a message box. In WideGlyphs, add AdornmentsEditor and ViewportSettingsEditor for view property editing, apply custom color schemes to arrangeable views, and update superView with a transparent shadow and increased shadow width. These changes improve interactivity and visualization in the demo scenarios. * Make replacement char themeable via Glyphs.ReplacementChar Adds Glyphs.ReplacementChar as a configurable replacement character, replacing all uses of Rune.ReplacementChar. The default is now a space (' ') and can be set via config.json. Updates all rendering, string decoding, and buffer invalidation logic to use the new property, ensuring consistency and themeability. Updates tests and comments accordingly. Also includes minor UI tweaks in WideGlyphs.cs and .DotSettings updates. * merging * merge errors * merged * merged * Refactor shadow properties to Margin; update tests ShadowWidth and ShadowHeight are now managed solely in the Margin class, with related properties and validation logic removed from View. All code and tests now use view.Margin.ShadowWidth/ShadowHeight. Tests and documentation were updated accordingly, and wide glyph handling in test output was improved for consistency. * Simplify ShadowSize; remove it from View as it's infreqnetly used. Make it a Size to reduce API surface area. Replace ShadowWidth/ShadowHeight with a single ShadowSize property (of type Size) in the Margin class and related code. Update all usages, validation logic, and tests to use ShadowSize.Width and ShadowSize.Height. Introduce TryValidateShadowSize for unified validation. Modernize code with C# features and improve clarity and maintainability by treating shadow dimensions as a single unit. * reveted * Fix wide glyph attribute handling for second column Ensure the attribute for the second column of wide glyphs is set correctly when within the clip region, addressing issues #4258 and #4492. Add comprehensive unit tests to verify correct attribute assignment and output rendering, including scenarios with transparent shadows. Remove obsolete test code for clarity. This improves color/style consistency for wide glyphs, especially in overlapping UI situations. * added url
This commit is contained in:
@@ -50,25 +50,6 @@ public class AddRuneTests (ITestOutputHelper output) : FakeDriverBase
|
||||
Assert.Equal (expected, driver.Contents [0, 0].Grapheme);
|
||||
Assert.Equal (" ", driver.Contents [0, 1].Grapheme);
|
||||
|
||||
// var s = "a\u0301\u0300\u0306";
|
||||
|
||||
// DriverAsserts.AssertDriverContentsWithFrameAre (@"
|
||||
//ắ", output);
|
||||
|
||||
// tf.Text = "\u1eaf";
|
||||
// Application.Refresh ();
|
||||
// DriverAsserts.AssertDriverContentsWithFrameAre (@"
|
||||
//ắ", output);
|
||||
|
||||
// tf.Text = "\u0103\u0301";
|
||||
// Application.Refresh ();
|
||||
// DriverAsserts.AssertDriverContentsWithFrameAre (@"
|
||||
//ắ", output);
|
||||
|
||||
// tf.Text = "\u0061\u0306\u0301";
|
||||
// Application.Refresh ();
|
||||
// DriverAsserts.AssertDriverContentsWithFrameAre (@"
|
||||
//ắ", output);
|
||||
driver.Dispose ();
|
||||
}
|
||||
|
||||
@@ -148,31 +129,6 @@ public class AddRuneTests (ITestOutputHelper output) : FakeDriverBase
|
||||
Assert.Equal (0, driver.Row);
|
||||
Assert.Equal (2, driver.Col);
|
||||
|
||||
//driver.AddRune ('b');
|
||||
//Assert.Equal ((Text)'b', driver.Contents [0, 1].Text);
|
||||
//Assert.Equal (0, driver.Row);
|
||||
//Assert.Equal (2, driver.Col);
|
||||
|
||||
//// Move to the last column of the first row
|
||||
//var lastCol = driver.Cols - 1;
|
||||
//driver.Move (lastCol, 0);
|
||||
//Assert.Equal (0, driver.Row);
|
||||
//Assert.Equal (lastCol, driver.Col);
|
||||
|
||||
//// Add a rune to the last column of the first row; should increment the row or col even though it's now invalid
|
||||
//driver.AddRune ('c');
|
||||
//Assert.Equal ((Text)'c', driver.Contents [0, lastCol].Text);
|
||||
//Assert.Equal (lastCol + 1, driver.Col);
|
||||
|
||||
//// Add a rune; should succeed but do nothing as it's outside of Contents
|
||||
//driver.AddRune ('d');
|
||||
//Assert.Equal (lastCol + 2, driver.Col);
|
||||
//for (var col = 0; col < driver.Cols; col++) {
|
||||
// for (var row = 0; row < driver.Rows; row++) {
|
||||
// Assert.NotEqual ((Text)'d', driver.Contents [row, col].Text);
|
||||
// }
|
||||
//}
|
||||
|
||||
driver.Dispose ();
|
||||
}
|
||||
|
||||
@@ -183,7 +139,7 @@ public class AddRuneTests (ITestOutputHelper output) : FakeDriverBase
|
||||
driver.SetScreenSize (6, 3);
|
||||
driver.GetOutputBuffer ().SetWideGlyphReplacement ((Rune)'①');
|
||||
|
||||
driver!.Clip = new (driver.Screen);
|
||||
driver.Clip = new (driver.Screen);
|
||||
driver.Move (1, 0);
|
||||
driver.AddStr ("┌");
|
||||
driver.Move (2, 0);
|
||||
@@ -207,4 +163,125 @@ public class AddRuneTests (ITestOutputHelper output) : FakeDriverBase
|
||||
DriverAssert.AssertDriverOutputIs (@"\x1b[38;2;0;0;0m\x1b[48;2;0;0;0m①┌─┐🍎\x1b[38;2;255;255;255m\x1b[48;2;0;0;0m",
|
||||
output, driver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddStr_WideGlyph_Second_Column_Attribute_Set_When_In_Clip ()
|
||||
{
|
||||
// This test verifies the fix for issue #4258
|
||||
// When a wide glyph is added and the second column is within the clip region,
|
||||
// the attribute for column N+1 should be set to match the current attribute.
|
||||
// See: OutputBufferImpl.cs line 194
|
||||
using IDriver driver = CreateFakeDriver ();
|
||||
driver.SetScreenSize (4, 2);
|
||||
|
||||
// Set a specific attribute for the wide glyph
|
||||
Attribute wideGlyphAttr = new (Color.BrightRed, Color.BrightYellow);
|
||||
driver.CurrentAttribute = wideGlyphAttr;
|
||||
|
||||
// Add a wide glyph at position (0, 0)
|
||||
driver.Move (0, 0);
|
||||
driver.AddStr ("🍎");
|
||||
|
||||
// Verify the wide glyph is in column 0
|
||||
Assert.Equal ("🍎", driver.Contents! [0, 0].Grapheme);
|
||||
Assert.Equal (wideGlyphAttr, driver.Contents [0, 0].Attribute);
|
||||
|
||||
// Verify column 1 (the second column of the wide glyph) has the correct attribute set
|
||||
// This is the fix: column N+1 should have CurrentAttribute set (line 194 in OutputBufferImpl.cs)
|
||||
Assert.Equal (wideGlyphAttr, driver.Contents [0, 1].Attribute);
|
||||
|
||||
// Verify cursor moved to column 2
|
||||
Assert.Equal (2, driver.Col);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddStr_WideGlyph_Second_Column_Attribute_Not_Set_When_Outside_Clip ()
|
||||
{
|
||||
// This test verifies that when a wide glyph's second column is outside the clip,
|
||||
// the attribute for column N+1 is NOT modified
|
||||
using IDriver driver = CreateFakeDriver ();
|
||||
driver.SetScreenSize (4, 2);
|
||||
|
||||
// Set initial attribute for the entire contents
|
||||
Attribute initialAttr = new (Color.White, Color.Black);
|
||||
driver.CurrentAttribute = initialAttr;
|
||||
driver.Move (0, 0);
|
||||
driver.AddStr (" ");
|
||||
driver.Move (0, 1);
|
||||
driver.AddStr (" ");
|
||||
|
||||
// Create a clip that excludes column 1
|
||||
driver.Clip = new (new Rectangle (0, 0, 1, 2));
|
||||
|
||||
// Set a different attribute for the wide glyph
|
||||
Attribute wideGlyphAttr = new (Color.BrightRed, Color.BrightYellow);
|
||||
driver.CurrentAttribute = wideGlyphAttr;
|
||||
|
||||
// Try to add a wide glyph at position (0, 0)
|
||||
// Column 0 is in clip, but column 1 is NOT
|
||||
driver.Move (0, 0);
|
||||
driver.AddStr ("🍎");
|
||||
|
||||
// Verify column 0 has the replacement character (can't fit wide glyph)
|
||||
Assert.NotEqual ("🍎", driver.Contents! [0, 0].Grapheme);
|
||||
|
||||
// Verify column 1 still has the original attribute (NOT modified)
|
||||
Assert.Equal (initialAttr, driver.Contents [0, 1].Attribute);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddStr_WideGlyph_Second_Column_Attribute_Outputs_Correctly ()
|
||||
{
|
||||
// This test verifies the fix for issue #4258 by checking the actual driver output
|
||||
// This mimics what happens when TransparentShadow redraws a wide glyph from ScreenContents
|
||||
// WITHOUT line 194, column N+1's attribute doesn't get set, causing wrong colors in output
|
||||
// See: OutputBufferImpl.cs line ~196 (Contents [Row, Col].Attribute = CurrentAttribute;)
|
||||
using IDriver driver = CreateFakeDriver ();
|
||||
driver.SetScreenSize (3, 1);
|
||||
driver.Force16Colors = true;
|
||||
|
||||
// Step 1: Draw initial content - a wide glyph at column 1 with white-on-black
|
||||
driver.CurrentAttribute = new Attribute (Color.White, Color.Black);
|
||||
driver.Move (1, 0);
|
||||
driver.AddStr ("🍎X"); // Wide glyph at columns 1-2, 'X' at column 3 doesn't exist (off-screen)
|
||||
|
||||
// At this point:
|
||||
// - Column 0: space (default) with white-on-black
|
||||
// - Column 1: 🍎 with white-on-black
|
||||
// - Column 2: (part of 🍎) with white-on-black (from initial ClearContents)
|
||||
|
||||
// Step 2: Now redraw the SAME wide glyph at column 1 but with a DIFFERENT attribute (red-on-yellow)
|
||||
// This simulates what transparent shadow does - it redraws what's underneath with a dimmed attribute
|
||||
driver.CurrentAttribute = new Attribute (Color.BrightRed, Color.BrightYellow);
|
||||
driver.Move (1, 0);
|
||||
driver.AddStr ("🍎");
|
||||
|
||||
// Verify internal state
|
||||
Assert.Equal ("🍎", driver.Contents! [0, 1].Grapheme);
|
||||
Assert.Equal (new Attribute (Color.BrightRed, Color.BrightYellow), driver.Contents [0, 1].Attribute);
|
||||
|
||||
// THIS is the critical assertion - column 2's attribute MUST be red-on-yellow
|
||||
// WITHOUT line 194: column 2 retains white-on-black
|
||||
// WITH line 194: column 2 gets red-on-yellow
|
||||
Assert.Equal (new Attribute (Color.BrightRed, Color.BrightYellow), driver.Contents [0, 2].Attribute);
|
||||
|
||||
driver.Refresh ();
|
||||
|
||||
// Expected output:
|
||||
// Column 0: space with white-on-black
|
||||
// Columns 1-2: 🍎 with red-on-yellow (both columns must have same attribute!)
|
||||
//
|
||||
// WITHOUT line 196, the output would be:
|
||||
// \x1b[97m\x1b[40m (white-on-black for column 0)
|
||||
// \x1b[91m\x1b[103m🍎 (red-on-yellow starts at column 1)
|
||||
// \x1b[97m\x1b[40m (WRONG! Attribute changes mid-glyph because column 2 still has white-on-black)
|
||||
//
|
||||
// WITH line 196, the output is:
|
||||
// \x1b[97m\x1b[40m (white-on-black for column 0)
|
||||
// \x1b[91m\x1b[103m🍎 (red-on-yellow for both columns 1 and 2)
|
||||
DriverAssert.AssertDriverOutputIs (
|
||||
"\x1b[97m\x1b[40m \x1b[91m\x1b[103m🍎",
|
||||
output,
|
||||
driver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
#nullable enable
|
||||
using System.Text;
|
||||
using UnitTests;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace ViewBaseTests.Adornments;
|
||||
|
||||
[Collection ("Global Test Setup")]
|
||||
public class BorderArrangementTests (ITestOutputHelper output)
|
||||
{
|
||||
[Fact]
|
||||
public void Arrangement_Handles_Wide_Glyphs_Correctly ()
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
app.Driver?.SetScreenSize (6, 5);
|
||||
app.Driver?.GetOutputBuffer ().SetWideGlyphReplacement (Rune.ReplacementChar);
|
||||
|
||||
Runnable superview = new () { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
|
||||
superview.Text = """
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
""";
|
||||
|
||||
View view = new ()
|
||||
{
|
||||
X = 2, Width = 4, Height = 4, BorderStyle = LineStyle.Single,
|
||||
Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable, CanFocus = true
|
||||
};
|
||||
superview.Add (view);
|
||||
|
||||
app.Begin (superview);
|
||||
|
||||
Assert.Equal ("Absolute(2)", view.X.ToString ());
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
🍎┌──┐
|
||||
🍎│ │
|
||||
🍎│ │
|
||||
🍎└──┘
|
||||
🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.F5.WithCtrl));
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
🍎◊──┐
|
||||
🍎│ │
|
||||
🍎│ │
|
||||
🍎└──↘
|
||||
🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.CursorLeft));
|
||||
Assert.Equal ("Absolute(1)", view.X.ToString ());
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
<EFBFBD>◊──┐
|
||||
<EFBFBD>│ │
|
||||
<EFBFBD>│ │
|
||||
<EFBFBD>└──↘
|
||||
🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.CursorLeft));
|
||||
Assert.Equal ("Absolute(0)", view.X.ToString ());
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
◊──┐🍎
|
||||
│ │🍎
|
||||
│ │🍎
|
||||
└──↘🍎
|
||||
🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Arrangement_With_SubView_In_Border_Handles_Wide_Glyphs_Correctly ()
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
app.Driver?.SetScreenSize (8, 7);
|
||||
app.Driver?.GetOutputBuffer ().SetWideGlyphReplacement (Rune.ReplacementChar);
|
||||
|
||||
Runnable superview = new () { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
|
||||
superview.Text = """
|
||||
🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎
|
||||
""";
|
||||
|
||||
View view = new ()
|
||||
{
|
||||
X = 2, Width = 6, Height = 6, Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable, CanFocus = true
|
||||
};
|
||||
view.Border!.Thickness = new (1);
|
||||
view.Border.Add (new View { Height = Dim.Auto (), Width = Dim.Auto (), Text = "Hi" });
|
||||
superview.Add (view);
|
||||
|
||||
app.Begin (superview);
|
||||
|
||||
Assert.Equal ("Absolute(2)", view.X.ToString ());
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
🍎Hi
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.F5.WithCtrl));
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
🍎◊i
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎 ↘
|
||||
🍎🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.CursorLeft));
|
||||
Assert.Equal ("Absolute(1)", view.X.ToString ());
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
<EFBFBD>◊i
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
<EFBFBD>
|
||||
<EFBFBD> ↘
|
||||
🍎🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.CursorLeft));
|
||||
Assert.Equal ("Absolute(0)", view.X.ToString ());
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
◊i 🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
🍎
|
||||
↘🍎
|
||||
🍎🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
}
|
||||
}
|
||||
@@ -133,4 +133,26 @@ MMM",
|
||||
Assert.True (view.Margin!.ViewportSettings.HasFlag (ViewportSettingsFlags.Transparent), "Margin should be transparent when ShadowStyle is Opaque..");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Margin_Layouts_Correctly ()
|
||||
{
|
||||
View superview = new () { Width = 10, Height = 5 };
|
||||
View view = new () { Width = 3, Height = 1, BorderStyle = LineStyle.Single };
|
||||
view.Margin!.Thickness = new (1);
|
||||
View view2 = new () { X = Pos.Right (view), Width = 3, Height = 1, BorderStyle = LineStyle.Single };
|
||||
view2.Margin!.Thickness = new (1);
|
||||
View view3 = new () { Y = Pos.Bottom (view), Width = 3, Height = 1, BorderStyle = LineStyle.Single };
|
||||
view3.Margin!.Thickness = new (1);
|
||||
superview.Add (view, view2, view3);
|
||||
|
||||
superview.LayoutSubViews ();
|
||||
|
||||
Assert.Equal (new (0, 0, 10, 5), superview.Frame);
|
||||
Assert.Equal (new (0, 0, 3, 1), view.Frame);
|
||||
Assert.Equal (Rectangle.Empty, view.Viewport);
|
||||
Assert.Equal (new (3, 0, 3, 1), view2.Frame);
|
||||
Assert.Equal (Rectangle.Empty, view2.Viewport);
|
||||
Assert.Equal (new (0, 1, 3, 1), view3.Frame);
|
||||
Assert.Equal (Rectangle.Empty, view3.Viewport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
using UnitTests;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace ViewBaseTests.Adornments;
|
||||
|
||||
[Collection ("Global Test Setup")]
|
||||
|
||||
public class ShadowStyleTests (ITestOutputHelper output)
|
||||
{
|
||||
private readonly ITestOutputHelper _output = output;
|
||||
|
||||
[Fact]
|
||||
public void Default_None ()
|
||||
{
|
||||
var view = new View ();
|
||||
Assert.Equal (ShadowStyle.None, view.ShadowStyle);
|
||||
Assert.Equal (ShadowStyle.None, view.Margin!.ShadowStyle);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None)]
|
||||
[InlineData (ShadowStyle.Opaque)]
|
||||
[InlineData (ShadowStyle.Transparent)]
|
||||
public void Set_View_Sets_Margin (ShadowStyle style)
|
||||
{
|
||||
var view = new View ();
|
||||
|
||||
view.ShadowStyle = style;
|
||||
Assert.Equal (style, view.ShadowStyle);
|
||||
Assert.Equal (style, view.Margin!.ShadowStyle);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None, 0, 0, 0, 0)]
|
||||
[InlineData (ShadowStyle.Opaque, 0, 0, 1, 1)]
|
||||
[InlineData (ShadowStyle.Transparent, 0, 0, 1, 1)]
|
||||
public void ShadowStyle_Margin_Thickness (ShadowStyle style, int expectedLeft, int expectedTop, int expectedRight, int expectedBottom)
|
||||
{
|
||||
var superView = new View
|
||||
{
|
||||
Height = 10, Width = 10
|
||||
};
|
||||
|
||||
View view = new ()
|
||||
{
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto (),
|
||||
Text = "0123",
|
||||
HighlightStates = MouseState.Pressed,
|
||||
ShadowStyle = style,
|
||||
CanFocus = true
|
||||
};
|
||||
|
||||
superView.Add (view);
|
||||
superView.BeginInit ();
|
||||
superView.EndInit ();
|
||||
|
||||
Assert.Equal (new (expectedLeft, expectedTop, expectedRight, expectedBottom), view.Margin!.Thickness);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None, 3)]
|
||||
[InlineData (ShadowStyle.Opaque, 4)]
|
||||
[InlineData (ShadowStyle.Transparent, 4)]
|
||||
public void Style_Changes_Margin_Thickness (ShadowStyle style, int expected)
|
||||
{
|
||||
var view = new View ();
|
||||
view.Margin!.Thickness = new (3);
|
||||
view.ShadowStyle = style;
|
||||
Assert.Equal (new (3, 3, expected, expected), view.Margin.Thickness);
|
||||
|
||||
view.ShadowStyle = ShadowStyle.None;
|
||||
Assert.Equal (new (3), view.Margin.Thickness);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TransparentShadow_Draws_Transparent_At_Driver_Output ()
|
||||
{
|
||||
// Arrange
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
app.Driver!.SetScreenSize (5, 3);
|
||||
|
||||
// Force 16-bit colors off to get predictable RGB output
|
||||
app.Driver.Force16Colors = false;
|
||||
|
||||
var superView = new Runnable
|
||||
{
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
Text = "ABC".Repeat (40)!
|
||||
};
|
||||
superView.SetScheme (new (new Attribute (Color.White, Color.Blue)));
|
||||
superView.TextFormatter.WordWrap = true;
|
||||
|
||||
// Create an overlapped view with transparent shadow
|
||||
var overlappedView = new View
|
||||
{
|
||||
Width = 4,
|
||||
Height = 2,
|
||||
Text = "123",
|
||||
Arrangement = ViewArrangement.Overlapped,
|
||||
ShadowStyle = ShadowStyle.Transparent
|
||||
};
|
||||
overlappedView.SetScheme (new (new Attribute (Color.Black, Color.Green)));
|
||||
|
||||
superView.Add (overlappedView);
|
||||
|
||||
// Act
|
||||
SessionToken? token = app.Begin (superView);
|
||||
app.LayoutAndDraw ();
|
||||
app.Driver.Refresh ();
|
||||
|
||||
// Assert
|
||||
_output.WriteLine ("Actual driver contents:");
|
||||
_output.WriteLine (app.Driver.ToString ());
|
||||
_output.WriteLine ("\nActual driver output:");
|
||||
string? output = app.Driver.GetOutput ().GetLastOutput ();
|
||||
_output.WriteLine (output);
|
||||
|
||||
DriverAssert.AssertDriverOutputIs ("""
|
||||
\x1b[38;2;0;0;0m\x1b[48;2;0;128;0m123\x1b[38;2;0;0;0m\x1b[48;2;189;189;189mA\x1b[38;2;0;0;255m\x1b[48;2;255;255;255mBC\x1b[38;2;0;0;0m\x1b[48;2;189;189;189mABC\x1b[38;2;0;0;255m\x1b[48;2;255;255;255mABCABC
|
||||
""", _output, app.Driver);
|
||||
|
||||
// The output should contain ANSI color codes for the transparent shadow
|
||||
// which will have dimmed colors compared to the original
|
||||
Assert.Contains ("\x1b[38;2;", output); // Should have RGB foreground color codes
|
||||
Assert.Contains ("\x1b[48;2;", output); // Should have RGB background color codes
|
||||
|
||||
// Verify driver contents show the background text in shadow areas
|
||||
int shadowX = overlappedView.Frame.X + overlappedView.Frame.Width;
|
||||
int shadowY = overlappedView.Frame.Y + overlappedView.Frame.Height;
|
||||
|
||||
Cell shadowCell = app.Driver.Contents! [shadowY, shadowX];
|
||||
_output.WriteLine ($"\nShadow cell at [{shadowY},{shadowX}]: Grapheme='{shadowCell.Grapheme}', Attr={shadowCell.Attribute}");
|
||||
|
||||
// The grapheme should be from background text
|
||||
Assert.NotEqual (string.Empty, shadowCell.Grapheme);
|
||||
Assert.Contains (shadowCell.Grapheme, "ABC"); // Should be one of the background characters
|
||||
|
||||
// Cleanup
|
||||
if (token is { })
|
||||
{
|
||||
app.End (token);
|
||||
}
|
||||
|
||||
superView.Dispose ();
|
||||
app.Dispose ();
|
||||
}
|
||||
|
||||
}
|
||||
487
Tests/UnitTestsParallelizable/ViewBase/Adornment/ShadowTests.cs
Normal file
487
Tests/UnitTestsParallelizable/ViewBase/Adornment/ShadowTests.cs
Normal file
@@ -0,0 +1,487 @@
|
||||
using System.Text;
|
||||
using UnitTests;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace ViewBaseTests.Adornments;
|
||||
|
||||
[Collection ("Global Test Setup")]
|
||||
|
||||
public class ShadowTests (ITestOutputHelper output)
|
||||
{
|
||||
private readonly ITestOutputHelper _output = output;
|
||||
|
||||
[Fact]
|
||||
public void Default_None ()
|
||||
{
|
||||
var view = new View ();
|
||||
Assert.Equal (ShadowStyle.None, view.ShadowStyle);
|
||||
Assert.Equal (ShadowStyle.None, view.Margin!.ShadowStyle);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None)]
|
||||
[InlineData (ShadowStyle.Opaque)]
|
||||
[InlineData (ShadowStyle.Transparent)]
|
||||
public void Set_View_Sets_Margin (ShadowStyle style)
|
||||
{
|
||||
var view = new View ();
|
||||
|
||||
view.ShadowStyle = style;
|
||||
Assert.Equal (style, view.ShadowStyle);
|
||||
Assert.Equal (style, view.Margin!.ShadowStyle);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None, 0, 0, 0, 0)]
|
||||
[InlineData (ShadowStyle.Opaque, 0, 0, 1, 1)]
|
||||
[InlineData (ShadowStyle.Transparent, 0, 0, 1, 1)]
|
||||
public void ShadowStyle_Margin_Thickness (ShadowStyle style, int expectedLeft, int expectedTop, int expectedRight, int expectedBottom)
|
||||
{
|
||||
var superView = new View
|
||||
{
|
||||
Height = 10, Width = 10
|
||||
};
|
||||
|
||||
View view = new ()
|
||||
{
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto (),
|
||||
Text = "0123",
|
||||
HighlightStates = MouseState.Pressed,
|
||||
ShadowStyle = style,
|
||||
CanFocus = true
|
||||
};
|
||||
|
||||
superView.Add (view);
|
||||
superView.BeginInit ();
|
||||
superView.EndInit ();
|
||||
|
||||
Assert.Equal (new (expectedLeft, expectedTop, expectedRight, expectedBottom), view.Margin!.Thickness);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None, 3)]
|
||||
[InlineData (ShadowStyle.Opaque, 4)]
|
||||
[InlineData (ShadowStyle.Transparent, 4)]
|
||||
public void Style_Changes_Margin_Thickness (ShadowStyle style, int expected)
|
||||
{
|
||||
var view = new View ();
|
||||
view.Margin!.Thickness = new (3);
|
||||
view.ShadowStyle = style;
|
||||
Assert.Equal (new (3, 3, expected, expected), view.Margin.Thickness);
|
||||
|
||||
view.ShadowStyle = ShadowStyle.None;
|
||||
Assert.Equal (new (3), view.Margin.Thickness);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.Opaque)]
|
||||
[InlineData (ShadowStyle.Transparent)]
|
||||
public void ShadowWidth_ShadowHeight_Defaults_To_One (ShadowStyle style)
|
||||
{
|
||||
View view = new () { ShadowStyle = style };
|
||||
|
||||
Assert.Equal (new (1, 1), view.Margin!.ShadowSize);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None, 0)]
|
||||
[InlineData (ShadowStyle.Opaque, 1)]
|
||||
[InlineData (ShadowStyle.Transparent, 1)]
|
||||
public void Margin_ShadowWidth_ShadowHeight_Cannot_Be_Set_Less_Than_One (ShadowStyle style, int expectedLength)
|
||||
{
|
||||
View view = new () { ShadowStyle = style };
|
||||
view.Margin!.ShadowSize = new (-1, -1);
|
||||
Assert.Equal (expectedLength, view.Margin!.ShadowSize.Width);
|
||||
Assert.Equal (expectedLength, view.Margin!.ShadowSize.Height);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Changing_ShadowStyle_Correctly_Set_ShadowWidth_ShadowHeight_Thickness ()
|
||||
{
|
||||
View view = new () { ShadowStyle = ShadowStyle.Transparent };
|
||||
view.Margin!.ShadowSize = new (2, 2);
|
||||
|
||||
Assert.Equal (new (2, 2), view.Margin!.ShadowSize);
|
||||
Assert.Equal (new (0, 0, 2, 2), view.Margin.Thickness);
|
||||
|
||||
view.ShadowStyle = ShadowStyle.None;
|
||||
Assert.Equal (new (2, 2), view.Margin!.ShadowSize);
|
||||
Assert.Equal (new (0, 0, 0, 0), view.Margin.Thickness);
|
||||
|
||||
view.ShadowStyle = ShadowStyle.Opaque;
|
||||
Assert.Equal (new (1, 1), view.Margin!.ShadowSize);
|
||||
Assert.Equal (new (0, 0, 1, 1), view.Margin.Thickness);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShadowStyle_Transparent_Handles_Wide_Glyphs_Correctly ()
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
app.Driver?.SetScreenSize (6, 5);
|
||||
app.Driver?.GetOutputBuffer ().SetWideGlyphReplacement (Rune.ReplacementChar);
|
||||
|
||||
Runnable superview = new () { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
|
||||
superview.Text = """
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
""";
|
||||
|
||||
View view = new () { Width = Dim.Fill (), Height = Dim.Fill (), BorderStyle = LineStyle.Single, ShadowStyle = ShadowStyle.Transparent };
|
||||
view.Margin!.ShadowSize = view.Margin!.ShadowSize with { Width = 2 };
|
||||
superview.Add (view);
|
||||
|
||||
app.Begin (superview);
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
┌──┐🍎
|
||||
│ │🍎
|
||||
│ │🍎
|
||||
└──┘🍎
|
||||
<EFBFBD> 🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
view.Margin!.ShadowSize = new (1, 2);
|
||||
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
┌──┐🍎
|
||||
│ │<EFBFBD>
|
||||
└──┘<EFBFBD>
|
||||
<EFBFBD> 🍎🍎
|
||||
<EFBFBD> 🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShadowStyle_Opaque_Change_Thickness_On_Mouse_Pressed_Released ()
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
app.Driver?.SetScreenSize (10, 4);
|
||||
|
||||
Runnable superview = new () { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
View view = new () { Width = 7, Height = 2, ShadowStyle = ShadowStyle.Opaque, Text = "| Hi |", HighlightStates = MouseState.Pressed };
|
||||
superview.Add (view);
|
||||
|
||||
app.Begin (superview);
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
| Hi |▖
|
||||
▝▀▀▀▀▀▘
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
app.Mouse.RaiseMouseEvent (new () { ScreenPosition = new (2, 0), Flags = MouseFlags.Button1Pressed });
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
| Hi |
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
app.Mouse.RaiseMouseEvent (new () { ScreenPosition = new (2, 0), Flags = MouseFlags.Button1Released });
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
| Hi |▖
|
||||
▝▀▀▀▀▀▘
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShadowStyle_Transparent_Never_Throws_Navigating_Outside_Bounds ()
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
app.Driver?.SetScreenSize (6, 5);
|
||||
|
||||
Runnable superview = new () { Width = Dim.Fill (), Height = Dim.Fill () };
|
||||
|
||||
superview.Text = """
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
🍎🍎🍎
|
||||
""";
|
||||
|
||||
View view = new ()
|
||||
{
|
||||
Width = Dim.Fill (), Height = Dim.Fill (), BorderStyle = LineStyle.Single, ShadowStyle = ShadowStyle.Transparent,
|
||||
Arrangement = ViewArrangement.Movable, CanFocus = true
|
||||
};
|
||||
view.Margin!.ShadowSize = view.Margin!.ShadowSize with { Width = 2 };
|
||||
superview.Add (view);
|
||||
|
||||
app.Begin (superview);
|
||||
|
||||
Assert.Equal (new (0, 0), view.Frame.Location);
|
||||
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (Key.F5.WithCtrl));
|
||||
|
||||
int i = 0;
|
||||
DecrementValue (-10, Key.CursorLeft);
|
||||
Assert.Equal (-10, i);
|
||||
|
||||
IncrementValue (0, Key.CursorRight);
|
||||
Assert.Equal (0, i);
|
||||
|
||||
DecrementValue (-10, Key.CursorUp);
|
||||
Assert.Equal (-10, i);
|
||||
|
||||
IncrementValue (20, Key.CursorDown);
|
||||
Assert.Equal (20, i);
|
||||
|
||||
DecrementValue (0, Key.CursorUp);
|
||||
Assert.Equal (0, i);
|
||||
|
||||
IncrementValue (20, Key.CursorRight);
|
||||
Assert.Equal (20, i);
|
||||
|
||||
return;
|
||||
|
||||
void DecrementValue (int count, Key key)
|
||||
{
|
||||
for (; i > count; i--)
|
||||
{
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (key));
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
CheckAssertion (new (i - 1, 0), new (0, i - 1), key);
|
||||
}
|
||||
}
|
||||
|
||||
void IncrementValue (int count, Key key)
|
||||
{
|
||||
for (; i < count; i++)
|
||||
{
|
||||
Assert.True (app.Keyboard.RaiseKeyDownEvent (key));
|
||||
app.LayoutAndDraw ();
|
||||
|
||||
CheckAssertion (new (i + 1, 0), new (0, i + 1), key);
|
||||
}
|
||||
}
|
||||
|
||||
bool? IsColumn (Key key)
|
||||
{
|
||||
if (key == Key.CursorLeft || key == Key.CursorRight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == Key.CursorUp || key == Key.CursorDown)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void CheckAssertion (Point colLocation, Point rowLocation, Key key)
|
||||
{
|
||||
bool? isCol = IsColumn (key);
|
||||
|
||||
switch (isCol)
|
||||
{
|
||||
case true:
|
||||
Assert.Equal (colLocation, view.Frame.Location);
|
||||
|
||||
break;
|
||||
case false:
|
||||
Assert.Equal (rowLocation, view.Frame.Location);
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (ShadowStyle.None, 3)]
|
||||
[InlineData (ShadowStyle.Opaque, 4)]
|
||||
[InlineData (ShadowStyle.Transparent, 4)]
|
||||
public void Margin_Thickness_Changes_Adjust_Correctly (ShadowStyle style, int expected)
|
||||
{
|
||||
var view = new View ();
|
||||
view.Margin!.Thickness = new (3);
|
||||
view.ShadowStyle = style;
|
||||
Assert.Equal (new (3, 3, expected, expected), view.Margin.Thickness);
|
||||
|
||||
view.Margin.Thickness = new (3, 3, expected + 1, expected + 1);
|
||||
Assert.Equal (new (3, 3, expected + 1, expected + 1), view.Margin.Thickness);
|
||||
view.ShadowStyle = ShadowStyle.None;
|
||||
Assert.Equal (new (3, 3, 4, 4), view.Margin.Thickness);
|
||||
view.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Runnable_View_Overlap_Other_Runnables ()
|
||||
{
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
app.Driver?.SetScreenSize (10, 5);
|
||||
|
||||
Runnable superview = new () { Width = Dim.Fill (), Height = Dim.Fill (), Text = "🍎".Repeat (25)! };
|
||||
View view = new () { Width = 7, Height = 2, ShadowStyle = ShadowStyle.Opaque, Text = "| Hi |" };
|
||||
superview.Add (view);
|
||||
|
||||
app.Begin (superview);
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
| Hi |▖ 🍎
|
||||
▝▀▀▀▀▀▘ 🍎
|
||||
🍎🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎🍎
|
||||
🍎🍎🍎🍎🍎
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
Runnable modalSuperview = new () { Y = 1, Width = Dim.Fill (), Height = 4, BorderStyle = LineStyle.Single };
|
||||
View view1 = new () { Width = 8, Height = 2, ShadowStyle = ShadowStyle.Opaque, Text = "| Hey |" };
|
||||
modalSuperview.Add (view1);
|
||||
|
||||
app.Begin (modalSuperview);
|
||||
|
||||
Assert.True (modalSuperview.IsModal);
|
||||
|
||||
DriverAssert.AssertDriverContentsAre (
|
||||
"""
|
||||
| Hi |▖ 🍎
|
||||
┌────────┐
|
||||
│| Hey |▖│
|
||||
│▝▀▀▀▀▀▀▘│
|
||||
└────────┘
|
||||
""",
|
||||
output,
|
||||
app.Driver);
|
||||
|
||||
|
||||
app.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransparentShadow_Draws_Transparent_At_Driver_Output ()
|
||||
{
|
||||
// Arrange
|
||||
using IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
app.Driver!.SetScreenSize (2, 1);
|
||||
app.Driver.Force16Colors = true;
|
||||
|
||||
using Runnable superView = new ();
|
||||
superView.Width = Dim.Fill ();
|
||||
superView.Height = Dim.Fill ();
|
||||
superView.Text = "AB";
|
||||
superView.TextFormatter.WordWrap = true;
|
||||
superView.SetScheme (new (new Attribute (Color.Black, Color.White)));
|
||||
|
||||
// Create view with transparent shadow
|
||||
View viewWithShadow = new ()
|
||||
{
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto (),
|
||||
Text = "*",
|
||||
ShadowStyle = ShadowStyle.Transparent
|
||||
};
|
||||
// Make it so the margin is only on the right for simplicity
|
||||
viewWithShadow.Margin!.Thickness = new (0, 0, 1, 0);
|
||||
viewWithShadow.SetScheme (new (new Attribute (Color.Black, Color.White)));
|
||||
|
||||
superView.Add (viewWithShadow);
|
||||
|
||||
// Act
|
||||
app.Begin (superView);
|
||||
app.LayoutAndDraw ();
|
||||
app.Driver.Refresh ();
|
||||
|
||||
// Assert
|
||||
_output.WriteLine ("Actual driver contents:");
|
||||
_output.WriteLine (app.Driver.ToString ());
|
||||
_output.WriteLine ("\nActual driver output:");
|
||||
string? output = app.Driver.GetOutput ().GetLastOutput ();
|
||||
_output.WriteLine (output);
|
||||
|
||||
DriverAssert.AssertDriverOutputIs ("""
|
||||
\x1b[30m\x1b[107m*\x1b[90m\x1b[100mB
|
||||
""", _output, app.Driver);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TransparentShadow_OverWide_Draws_Transparent_At_Driver_Output ()
|
||||
{
|
||||
// Arrange
|
||||
using IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
app.Driver!.SetScreenSize (2, 3);
|
||||
app.Driver.Force16Colors = true;
|
||||
|
||||
using Runnable superView = new ();
|
||||
superView.Width = Dim.Fill ();
|
||||
superView.Height = Dim.Fill ();
|
||||
superView.Text = "🍎🍎🍎🍎";
|
||||
superView.TextFormatter.WordWrap = true;
|
||||
superView.SetScheme (new (new Attribute (Color.Black, Color.White)));
|
||||
|
||||
// Create view with transparent shadow
|
||||
View viewWithShadow = new ()
|
||||
{
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto (),
|
||||
Text = "*",
|
||||
ShadowStyle = ShadowStyle.Transparent
|
||||
};
|
||||
// Make it so the margin is only on the bottom for simplicity
|
||||
viewWithShadow.Margin!.Thickness = new (0, 0, 0, 1);
|
||||
viewWithShadow.SetScheme (new (new Attribute (Color.Black, Color.White)));
|
||||
|
||||
superView.Add (viewWithShadow);
|
||||
|
||||
// Act
|
||||
app.Begin (superView);
|
||||
app.LayoutAndDraw ();
|
||||
app.Driver.Refresh ();
|
||||
|
||||
// Assert
|
||||
_output.WriteLine ("Actual driver contents:");
|
||||
_output.WriteLine (app.Driver.ToString ());
|
||||
_output.WriteLine ("\nActual driver output:");
|
||||
string? output = app.Driver.GetOutput ().GetLastOutput ();
|
||||
_output.WriteLine (output);
|
||||
|
||||
DriverAssert.AssertDriverOutputIs ("""
|
||||
\x1b[30m\x1b[107m*\x1b[90m\x1b[103m \x1b[97m\x1b[40m \x1b[90m\x1b[100m \x1b[97m\x1b[40m🍎
|
||||
""", _output, app.Driver);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user