unit test issue

This commit is contained in:
Tig
2024-09-22 16:30:38 -06:00
parent 5293a84e61
commit cdfc49ece5
4 changed files with 22 additions and 16 deletions

View File

@@ -396,7 +396,7 @@ public partial class View // Drawing APIs
}
Attribute disabled = new (cs.Disabled.Foreground, cs.Disabled.Background);
if (Diagnostics.HasFlag (ViewDiagnosticFlags.Hover) && _Hover)
if (Diagnostics.HasFlag (ViewDiagnosticFlags.Hover) && _hovering)
{
disabled = new (disabled.Foreground.GetDarkerColor (), disabled.Background.GetDarkerColor ());
}
@@ -406,7 +406,7 @@ public partial class View // Drawing APIs
private Attribute GetColor (Attribute inputAttribute)
{
Attribute attr = inputAttribute;
if (Diagnostics.HasFlag (ViewDiagnosticFlags.Hover) && _Hover)
if (Diagnostics.HasFlag (ViewDiagnosticFlags.Hover) && _hovering)
{
attr = new (attr.Foreground.GetDarkerColor (), attr.Background.GetDarkerColor ());
}

View File

@@ -126,7 +126,8 @@ public partial class View // Mouse APIs
#region MouseEnterLeave
private bool _Hover;
private bool _hovering;
private ColorScheme? _savedNonHoverColorScheme;
/// <summary>
/// INTERNAL Called by <see cref="Application.OnMouseEvent"/> when the mouse moves over the View's <see cref="Frame"/>.
@@ -154,7 +155,7 @@ public partial class View // Mouse APIs
MouseEnter?.Invoke (this, eventArgs);
_Hover = !eventArgs.Cancel;
_hovering = !eventArgs.Cancel;
if (eventArgs.Cancel)
{
@@ -166,9 +167,8 @@ public partial class View // Mouse APIs
HighlightStyle copy = HighlightStyle;
HighlightStyle hover = HighlightStyle.Hover;
CancelEventArgs<HighlightStyle> args = new (ref copy, ref hover);
RaiseHighlight (args);
if (args.Cancel)
if (RaiseHighlight (args) || args.Cancel)
{
return args.Cancel;
}
@@ -180,7 +180,7 @@ public partial class View // Mouse APIs
cs = new ();
}
_savedNonHighlightColorScheme = cs;
_savedNonHoverColorScheme = cs;
ColorScheme = ColorScheme.GetHighlightColorScheme ();
}
@@ -260,7 +260,7 @@ public partial class View // Mouse APIs
MouseLeave?.Invoke (this, EventArgs.Empty);
_Hover = false;
_hovering = false;
if ((HighlightStyle.HasFlag (HighlightStyle.Hover) || Diagnostics.HasFlag (ViewDiagnosticFlags.Hover)))
{
@@ -268,8 +268,11 @@ public partial class View // Mouse APIs
HighlightStyle hover = HighlightStyle.None;
RaiseHighlight (new (ref copy, ref hover));
ColorScheme = _savedNonHighlightColorScheme;
_savedNonHighlightColorScheme = default;
if (_savedNonHoverColorScheme is { })
{
ColorScheme = _savedNonHoverColorScheme;
_savedNonHoverColorScheme = null;
}
}
}
@@ -447,9 +450,6 @@ public partial class View // Mouse APIs
/// </summary>
public event EventHandler<CancelEventArgs<HighlightStyle>>? Highlight;
private ColorScheme _savedNonHighlightColorScheme;
/// <summary>
/// Enables the highlight for the view when the mouse is pressed. Called from OnMouseEvent.

View File

@@ -77,7 +77,7 @@ public class Button : View, IDesignable
ShadowStyle = DefaultShadow;
HighlightStyle = DefaultHighlightStyle;
}
private bool _wantContinuousButtonPressed;
/// <inheritdoc />
@@ -169,7 +169,7 @@ public class Button : View, IDesignable
/// <inheritdoc/>
protected override void UpdateTextFormatterText ()
{
base.UpdateTextFormatterText();
base.UpdateTextFormatterText ();
if (NoDecorations)
{
TextFormatter.Text = Text;

View File

@@ -662,6 +662,12 @@ public class MenuBarTests (ITestOutputHelper output)
{
((FakeDriver)Application.Driver).SetBufferSize (40, 15);
// Override CM
Window.DefaultBorderStyle = LineStyle.Single;
Dialog.DefaultButtonAlignment = Alignment.Center;
Dialog.DefaultBorderStyle = LineStyle.Single;
Button.DefaultShadow = ShadowStyle.None;
Assert.Equal (new (0, 0, 40, 15), Application.Driver?.Clip);
TestHelpers.AssertDriverContentsWithFrameAre (@"", output);