mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
This commit is contained in:
@@ -80,7 +80,7 @@ public class ApplicationTests
|
||||
|
||||
void OnApplicationOnInitializedChanged (object s, EventArgs<bool> a)
|
||||
{
|
||||
if (a.CurrentValue)
|
||||
if (a.Value)
|
||||
{
|
||||
Application.Iteration += OnApplicationOnIteration;
|
||||
initialized = true;
|
||||
@@ -447,7 +447,7 @@ public class ApplicationTests
|
||||
|
||||
void OnApplicationOnInitializedChanged (object s, EventArgs<bool> a)
|
||||
{
|
||||
if (a.CurrentValue)
|
||||
if (a.Value)
|
||||
{
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@@ -447,9 +447,9 @@ public class KeyboardTests
|
||||
|
||||
void OnApplicationOnInitializedChanged (object s, EventArgs<bool> a)
|
||||
{
|
||||
_output.WriteLine ("OnApplicationOnInitializedChanged: {0}", a.CurrentValue);
|
||||
_output.WriteLine ("OnApplicationOnInitializedChanged: {0}", a.Value);
|
||||
|
||||
if (a.CurrentValue)
|
||||
if (a.Value)
|
||||
{
|
||||
Application.Iteration += OnApplicationOnIteration;
|
||||
initialized = true;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SettingsScopeTests
|
||||
|
||||
ThemeScope scope = dict [ThemeManager.DEFAULT_THEME_NAME];
|
||||
Assert.NotNull (scope);
|
||||
Assert.Equal (HighlightStyle.Hover | HighlightStyle.Pressed, scope ["Button.DefaultHighlightStyle"].PropertyValue);
|
||||
Assert.Equal (MouseState.In | MouseState.Pressed | MouseState.PressedOutside, scope ["Button.DefaultHighlightStates"].PropertyValue);
|
||||
|
||||
|
||||
RuntimeConfig = """
|
||||
@@ -60,13 +60,13 @@ public class SettingsScopeTests
|
||||
{
|
||||
"Default":
|
||||
{
|
||||
"Button.DefaultHighlightStyle": "None"
|
||||
"Button.DefaultHighlightStates": "None"
|
||||
}
|
||||
},
|
||||
{
|
||||
"NewTheme":
|
||||
{
|
||||
"Button.DefaultHighlightStyle": "Hover"
|
||||
"Button.DefaultHighlightStates": "In"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -77,8 +77,8 @@ public class SettingsScopeTests
|
||||
|
||||
// assert
|
||||
Assert.Equal (2, ThemeManager.GetThemes ().Count);
|
||||
Assert.Equal (HighlightStyle.None, (HighlightStyle)ThemeManager.GetCurrentTheme () ["Button.DefaultHighlightStyle"].PropertyValue!);
|
||||
Assert.Equal (HighlightStyle.Hover, (HighlightStyle)ThemeManager.GetThemes () ["NewTheme"] ["Button.DefaultHighlightStyle"].PropertyValue!);
|
||||
Assert.Equal (MouseState.None, (MouseState)ThemeManager.GetCurrentTheme () ["Button.DefaultHighlightStates"].PropertyValue!);
|
||||
Assert.Equal (MouseState.In, (MouseState)ThemeManager.GetThemes () ["NewTheme"] ["Button.DefaultHighlightStates"].PropertyValue!);
|
||||
|
||||
RuntimeConfig = """
|
||||
{
|
||||
@@ -86,7 +86,7 @@ public class SettingsScopeTests
|
||||
{
|
||||
"Default":
|
||||
{
|
||||
"Button.DefaultHighlightStyle": "Pressed"
|
||||
"Button.DefaultHighlightStates": "Pressed"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -96,8 +96,8 @@ public class SettingsScopeTests
|
||||
|
||||
// assert
|
||||
Assert.Equal (2, ThemeManager.GetThemes ().Count);
|
||||
Assert.Equal (HighlightStyle.Pressed, (HighlightStyle)ThemeManager.Themes! [ThemeManager.DEFAULT_THEME_NAME] ["Button.DefaultHighlightStyle"].PropertyValue!);
|
||||
Assert.Equal (HighlightStyle.Hover, (HighlightStyle)ThemeManager.Themes! ["NewTheme"] ["Button.DefaultHighlightStyle"].PropertyValue!);
|
||||
Assert.Equal (MouseState.Pressed, (MouseState)ThemeManager.Themes! [ThemeManager.DEFAULT_THEME_NAME] ["Button.DefaultHighlightStates"].PropertyValue!);
|
||||
Assert.Equal (MouseState.In, (MouseState)ThemeManager.Themes! ["NewTheme"] ["Button.DefaultHighlightStates"].PropertyValue!);
|
||||
|
||||
// clean up
|
||||
Disable (resetToHardCodedDefaults: true);
|
||||
@@ -272,11 +272,11 @@ public class SettingsScopeTests
|
||||
// Arrange: Create a ThemeScope and verify a property exists
|
||||
ThemeScope defaultThemeScope = new ThemeScope ();
|
||||
defaultThemeScope.LoadHardCodedDefaults ();
|
||||
Assert.True (defaultThemeScope.ContainsKey ("Button.DefaultHighlightStyle"));
|
||||
Assert.True (defaultThemeScope.ContainsKey ("Button.DefaultHighlightStates"));
|
||||
|
||||
ThemeScope darkThemeScope = new ThemeScope ();
|
||||
darkThemeScope.LoadHardCodedDefaults ();
|
||||
Assert.True (darkThemeScope.ContainsKey ("Button.DefaultHighlightStyle"));
|
||||
Assert.True (darkThemeScope.ContainsKey ("Button.DefaultHighlightStates"));
|
||||
|
||||
// Create a Themes list with two themes
|
||||
List<Dictionary<string, ThemeScope>> themesList =
|
||||
|
||||
@@ -598,7 +598,7 @@ public class WizardTests ()
|
||||
Assert.Equal (string.Empty, r.Title);
|
||||
|
||||
var expected = string.Empty;
|
||||
r.TitleChanged += (s, args) => { Assert.Equal (r.Title, args.CurrentValue); };
|
||||
r.TitleChanged += (s, args) => { Assert.Equal (r.Title, args.Value); };
|
||||
|
||||
expected = "title";
|
||||
r.Title = expected;
|
||||
|
||||
@@ -144,7 +144,7 @@ public class ShadowStyleTests (ITestOutputHelper output)
|
||||
Width = Dim.Auto (),
|
||||
Height = Dim.Auto (),
|
||||
Text = "0123",
|
||||
HighlightStyle = HighlightStyle.Pressed,
|
||||
HighlightStates = MouseState.Pressed,
|
||||
ShadowStyle = style,
|
||||
CanFocus = true
|
||||
};
|
||||
|
||||
@@ -291,66 +291,54 @@ public class MouseTests : TestsAllViews
|
||||
Assert.Equal (2, clickedCount);
|
||||
me.Handled = false;
|
||||
|
||||
// Stay in Viewport
|
||||
me.Flags = MouseFlags.Button1Pressed;
|
||||
me.Position = me.Position with { X = 0 };
|
||||
view.NewMouseEvent (me);
|
||||
Assert.Equal (3, clickedCount);
|
||||
me.Handled = false;
|
||||
|
||||
view.Dispose ();
|
||||
|
||||
// Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Theory (Skip = "This test needs to be redone.")]
|
||||
[InlineData (HighlightStyle.None, 0, 0)]
|
||||
[InlineData (HighlightStyle.Pressed | HighlightStyle.PressedOutside, 1, 1)]
|
||||
public void HighlightOnPress_Fires_Events_And_Highlights (HighlightStyle highlightOnPress, int expectedEnabling, int expectedDisabling)
|
||||
{
|
||||
var view = new View
|
||||
{
|
||||
CanFocus = true,
|
||||
HighlightStyle = highlightOnPress,
|
||||
Height = 1,
|
||||
Width = 1
|
||||
};
|
||||
//[Theory]
|
||||
//[InlineData (true, MouseState.None, 0, 0, 0, 0)]
|
||||
//[InlineData (true, MouseState.In, 0, 0, 0, 0)]
|
||||
//[InlineData (true, MouseState.Pressed, 0, 0, 1, 0)]
|
||||
//[InlineData (true, MouseState.PressedOutside, 0, 0, 0, 1)]
|
||||
//public void MouseState_Button1_Pressed_Then_Released_Outside (bool inViewport, MouseState highlightFlags, int noneCount, int expectedInCount, int expectedPressedCount, int expectedPressedOutsideCount)
|
||||
//{
|
||||
// var testView = new MouseEventTestView
|
||||
// {
|
||||
// HighlightStates = highlightFlags
|
||||
// };
|
||||
|
||||
var enablingHighlight = 0;
|
||||
var disablingHighlight = 0;
|
||||
view.Highlight += ViewHighlight;
|
||||
view.SetScheme (new (new Attribute (ColorName16.Red, ColorName16.Blue)));
|
||||
Scheme originalScheme = view.GetScheme ();
|
||||
// Assert.Equal (0, testView.MouseStateInCount);
|
||||
// Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
// Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
// Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
|
||||
view.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
// testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (inViewport ? 0 : 1, 0) });
|
||||
// Assert.Equal (expectedInCount, testView.MouseStateInCount);
|
||||
// Assert.Equal (expectedPressedCount, testView.MouseStatePressedCount);
|
||||
// Assert.Equal (expectedPressedOutsideCount, testView.MouseStatePressedOutsideCount);
|
||||
// Assert.Equal (noneCount, testView.MouseStateNoneCount);
|
||||
|
||||
if (highlightOnPress != HighlightStyle.None)
|
||||
{
|
||||
Assert.NotEqual (originalScheme, view.GetScheme ());
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (originalScheme, view.GetScheme ());
|
||||
}
|
||||
// testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Released, Position = new (inViewport ? 0 : 1, 0) });
|
||||
// Assert.Equal (expectedInCount, testView.MouseStateInCount);
|
||||
// Assert.Equal (expectedPressedCount, testView.MouseStatePressedCount);
|
||||
// Assert.Equal (expectedPressedOutsideCount, testView.MouseStatePressedOutsideCount);
|
||||
// Assert.Equal (noneCount, testView.MouseStateNoneCount);
|
||||
|
||||
view.NewMouseEvent (new () { Flags = MouseFlags.Button1Released });
|
||||
Assert.Equal (originalScheme, view.GetScheme ());
|
||||
Assert.Equal (expectedEnabling, enablingHighlight);
|
||||
Assert.Equal (expectedDisabling, disablingHighlight);
|
||||
// testView.Dispose ();
|
||||
|
||||
view.Dispose ();
|
||||
// // Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
// Application.ResetState (true);
|
||||
|
||||
// Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
Application.ResetState (true);
|
||||
|
||||
return;
|
||||
|
||||
void ViewHighlight (object sender, CancelEventArgs<HighlightStyle> e)
|
||||
{
|
||||
if (e.NewValue == HighlightStyle.None)
|
||||
{
|
||||
disablingHighlight++;
|
||||
}
|
||||
else
|
||||
{
|
||||
enablingHighlight++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
// TODO: Add tests for each combination of HighlightFlags
|
||||
|
||||
@@ -358,70 +346,298 @@ public class MouseTests : TestsAllViews
|
||||
[InlineData (0)]
|
||||
[InlineData (1)]
|
||||
[InlineData (10)]
|
||||
public void HighlightOnPress_Move_Keeps_Highlight (int x)
|
||||
public void MouseState_None_Button1_Pressed_Move_No_Changes (int x)
|
||||
{
|
||||
var view = new View
|
||||
var testView = new MouseEventTestView
|
||||
{
|
||||
CanFocus = true,
|
||||
HighlightStyle = HighlightStyle.Pressed | HighlightStyle.PressedOutside,
|
||||
Height = 1,
|
||||
Width = 1
|
||||
HighlightStates = MouseState.None
|
||||
};
|
||||
var enablingHighlight = 0;
|
||||
var disablingHighlight = 0;
|
||||
view.Highlight += ViewHighlight;
|
||||
bool inViewport = view.Viewport.Contains (x, 0);
|
||||
|
||||
bool inViewport = testView.Viewport.Contains (x, 0);
|
||||
|
||||
// Start at 0,0 ; in viewport
|
||||
view.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.Equal (1, enablingHighlight);
|
||||
Assert.Equal (0, disablingHighlight);
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
|
||||
// Move to x,0
|
||||
view.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (x, 0) });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (2, enablingHighlight);
|
||||
Assert.Equal (0, disablingHighlight);
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (2, enablingHighlight);
|
||||
Assert.Equal (0, disablingHighlight);
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
// Move backto 0,0 ; in viewport
|
||||
view.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (3, enablingHighlight);
|
||||
Assert.Equal (0, disablingHighlight);
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (3, enablingHighlight);
|
||||
Assert.Equal (0, disablingHighlight);
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
view.Dispose ();
|
||||
testView.Dispose ();
|
||||
|
||||
// Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
void ViewHighlight (object sender, CancelEventArgs<HighlightStyle> e)
|
||||
[Theory]
|
||||
[InlineData (0)]
|
||||
[InlineData (1)]
|
||||
[InlineData (10)]
|
||||
public void MouseState_Pressed_Button1_Pressed_Move_Keeps_Pressed (int x)
|
||||
{
|
||||
var testView = new MouseEventTestView
|
||||
{
|
||||
if (e.NewValue == HighlightStyle.None)
|
||||
HighlightStates = MouseState.Pressed
|
||||
};
|
||||
|
||||
bool inViewport = testView.Viewport.Contains (x, 0);
|
||||
|
||||
// Start at 0,0 ; in viewport
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
|
||||
// Move to x,0
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (x, 0) });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
// Move backto 0,0 ; in viewport
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
testView.Dispose ();
|
||||
|
||||
// Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0)]
|
||||
[InlineData (1)]
|
||||
[InlineData (10)]
|
||||
public void MouseState_PressedOutside_Button1_Pressed_Move_Raises_PressedOutside (int x)
|
||||
{
|
||||
var testView = new MouseEventTestView
|
||||
{
|
||||
HighlightStates = MouseState.PressedOutside,
|
||||
WantContinuousButtonPressed = false
|
||||
};
|
||||
|
||||
bool inViewport = testView.Viewport.Contains (x, 0);
|
||||
|
||||
// Start at 0,0 ; in viewport
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
|
||||
// Move to x,0
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (x, 0) });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
// Move backto 0,0 ; in viewport
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (1, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (1, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
testView.Dispose ();
|
||||
|
||||
// Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
Application.ResetState (true);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData (0)]
|
||||
[InlineData (1)]
|
||||
[InlineData (10)]
|
||||
public void MouseState_PressedOutside_Button1_Pressed_Move_Raises_PressedOutside_WantContinuousButtonPressed (int x)
|
||||
{
|
||||
var testView = new MouseEventTestView
|
||||
{
|
||||
HighlightStates = MouseState.PressedOutside,
|
||||
WantContinuousButtonPressed = true
|
||||
};
|
||||
|
||||
bool inViewport = testView.Viewport.Contains (x, 0);
|
||||
|
||||
// Start at 0,0 ; in viewport
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
|
||||
// Move to x,0
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (x, 0) });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
// Move backto 0,0 ; in viewport
|
||||
testView.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed });
|
||||
|
||||
if (inViewport)
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal (0, testView.MouseStateInCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedCount);
|
||||
Assert.Equal (0, testView.MouseStatePressedOutsideCount);
|
||||
Assert.Equal (0, testView.MouseStateNoneCount);
|
||||
}
|
||||
|
||||
testView.Dispose ();
|
||||
|
||||
// Button1Pressed, Button1Released cause Application.MouseGrabView to be set
|
||||
Application.ResetState (true);
|
||||
}
|
||||
private class MouseEventTestView : View
|
||||
{
|
||||
public int MouseEnterCount { get; private set; }
|
||||
public int MouseLeaveCount { get; private set; }
|
||||
public int MouseStatePressedOutsideCount { get; private set; }
|
||||
public int MouseStateInCount { get; private set; }
|
||||
public int MouseStatePressedCount { get; private set; }
|
||||
public int MouseStateNoneCount { get; private set; }
|
||||
|
||||
public MouseEventTestView ()
|
||||
{
|
||||
Height = 1;
|
||||
Width = 1;
|
||||
CanFocus = true;
|
||||
Id = "mouseEventTestView";
|
||||
|
||||
MouseLeave += (s, e) => { MouseEnterCount++; };
|
||||
MouseEnter += (s, e) => { MouseLeaveCount++; };
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void OnMouseStateChanged (EventArgs<MouseState> args)
|
||||
{
|
||||
switch (args.Value)
|
||||
{
|
||||
disablingHighlight++;
|
||||
}
|
||||
else
|
||||
{
|
||||
enablingHighlight++;
|
||||
case MouseState.None:
|
||||
MouseStateNoneCount++;
|
||||
|
||||
break;
|
||||
case MouseState.In:
|
||||
MouseStateInCount++;
|
||||
|
||||
break;
|
||||
|
||||
case MouseState.Pressed:
|
||||
MouseStatePressedCount++;
|
||||
|
||||
break;
|
||||
|
||||
case MouseState.PressedOutside:
|
||||
MouseStatePressedOutsideCount++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
base.OnMouseStateChanged (args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,10 +623,10 @@ public class CheckBoxTests (ITestOutputHelper output)
|
||||
|
||||
return;
|
||||
|
||||
void OnCheckedStateChanging (object sender, CancelEventArgs e)
|
||||
void OnCheckedStateChanging (object sender, ResultEventArgs<CheckState> e)
|
||||
{
|
||||
checkedInvoked = true;
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ public class ColorPickerTests
|
||||
cp.ColorChanged += (s, e) =>
|
||||
{
|
||||
count++;
|
||||
newColor = e.CurrentValue;
|
||||
newColor = e.Result;
|
||||
|
||||
Assert.Equal (cp.SelectedColor, e.CurrentValue);
|
||||
Assert.Equal (cp.SelectedColor, e.Result);
|
||||
};
|
||||
|
||||
cp.SelectedColor = new (1, 2, 3);
|
||||
|
||||
@@ -348,11 +348,11 @@ public class TextFieldTests (ITestOutputHelper output)
|
||||
|
||||
_textField.TextChanging += TextFieldTextChanging;
|
||||
|
||||
void TextFieldTextChanging (object sender, CancelEventArgs<string> e)
|
||||
void TextFieldTextChanging (object sender, ResultEventArgs<string> e)
|
||||
{
|
||||
if (e.NewValue.GetRuneCount () > 11)
|
||||
if (e.Result.GetRuneCount () > 11)
|
||||
{
|
||||
e.NewValue = e.NewValue [..11];
|
||||
e.Result = e.Result [..11];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,8 +416,8 @@ public class TextFieldTests (ITestOutputHelper output)
|
||||
|
||||
tf.TextChanging += (s, e) =>
|
||||
{
|
||||
newText = e.NewValue;
|
||||
oldText = e.CurrentValue;
|
||||
newText = e.Result;
|
||||
oldText = tf.Text;
|
||||
};
|
||||
|
||||
var top = new Toplevel ();
|
||||
@@ -957,11 +957,11 @@ public class TextFieldTests (ITestOutputHelper output)
|
||||
|
||||
_textField.TextChanging += (s, e) =>
|
||||
{
|
||||
Assert.Equal ("changing", e.NewValue);
|
||||
Assert.Equal ("changing", e.Result);
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user