mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixed Dialog/MessageBox tests
This commit is contained in:
@@ -11,12 +11,14 @@ public class MessageBoxTests
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void KeyBindings_Enter_Causes_Focused_Button_Click ()
|
||||
public void KeyBindings_Enter_Causes_Focused_Button_Click_No_Accept ()
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
var iteration = 0;
|
||||
|
||||
int btnAcceptCount = 0;
|
||||
|
||||
Application.Iteration += (s, a) =>
|
||||
{
|
||||
iteration++;
|
||||
@@ -32,6 +34,12 @@ public class MessageBoxTests
|
||||
case 2:
|
||||
// Tab to btn2
|
||||
Application.OnKeyDown (Key.Tab);
|
||||
|
||||
Button btn = Application.Navigation!.GetFocused () as Button;
|
||||
|
||||
btn.Accept += (sender, e) => { btnAcceptCount++; };
|
||||
|
||||
// Click
|
||||
Application.OnKeyDown (Key.Enter);
|
||||
|
||||
break;
|
||||
@@ -44,7 +52,8 @@ public class MessageBoxTests
|
||||
};
|
||||
Application.Run ().Dispose ();
|
||||
|
||||
Assert.Equal (1, result);
|
||||
Assert.Equal (0, result);
|
||||
Assert.Equal (btnAcceptCount, 1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -85,12 +94,14 @@ public class MessageBoxTests
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void KeyBindings_Space_Causes_Focused_Button_Click ()
|
||||
public void KeyBindings_Space_Causes_Focused_Button_Click_No_Accept ()
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
var iteration = 0;
|
||||
|
||||
int btnAcceptCount = 0;
|
||||
|
||||
Application.Iteration += (s, a) =>
|
||||
{
|
||||
iteration++;
|
||||
@@ -106,6 +117,11 @@ public class MessageBoxTests
|
||||
case 2:
|
||||
// Tab to btn2
|
||||
Application.OnKeyDown (Key.Tab);
|
||||
|
||||
Button btn = Application.Navigation!.GetFocused () as Button;
|
||||
|
||||
btn.Accept += (sender, e) => { btnAcceptCount++; };
|
||||
|
||||
Application.OnKeyDown (Key.Space);
|
||||
|
||||
break;
|
||||
@@ -118,7 +134,9 @@ public class MessageBoxTests
|
||||
};
|
||||
Application.Run ().Dispose ();
|
||||
|
||||
Assert.Equal (1, result);
|
||||
Assert.Equal (0, result);
|
||||
Assert.Equal (btnAcceptCount, 1);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
Reference in New Issue
Block a user