mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Fixed Dialog/MessageBox tests
This commit is contained in:
@@ -697,7 +697,7 @@ public class MainLoopTests
|
||||
{
|
||||
Assert.Null (btn);
|
||||
Assert.Equal (zero, total);
|
||||
Assert.True (btnLaunch.NewKeyDownEvent (Key.Space));
|
||||
Assert.False (btnLaunch.NewKeyDownEvent (Key.Space));
|
||||
|
||||
if (btn == null)
|
||||
{
|
||||
@@ -714,7 +714,7 @@ public class MainLoopTests
|
||||
{
|
||||
Assert.Equal (clickMe, btn.Text);
|
||||
Assert.Equal (zero, total);
|
||||
Assert.True (btn.NewKeyDownEvent (Key.Space));
|
||||
Assert.False (btn.NewKeyDownEvent (Key.Space));
|
||||
Assert.Equal (cancel, btn.Text);
|
||||
Assert.Equal (one, total);
|
||||
}
|
||||
|
||||
@@ -1095,7 +1095,7 @@ public class DialogTests
|
||||
|
||||
if (iterations == 0)
|
||||
{
|
||||
Assert.True (btn1.NewKeyDownEvent (Key.Space));
|
||||
Assert.False (btn1.NewKeyDownEvent (Key.Space));
|
||||
}
|
||||
else if (iterations == 1)
|
||||
{
|
||||
@@ -1110,7 +1110,7 @@ public class DialogTests
|
||||
└───────────────────────┘";
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
|
||||
|
||||
Assert.True (btn2.NewKeyDownEvent (Key.Space));
|
||||
Assert.False (btn2.NewKeyDownEvent (Key.Space));
|
||||
}
|
||||
else if (iterations == 2)
|
||||
{
|
||||
@@ -1127,13 +1127,13 @@ public class DialogTests
|
||||
_output
|
||||
);
|
||||
|
||||
Assert.True (Top!.NewKeyDownEvent (Key.Enter));
|
||||
Assert.False (Top!.NewKeyDownEvent (Key.Enter));
|
||||
}
|
||||
else if (iterations == 3)
|
||||
{
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
|
||||
|
||||
Assert.True (btn3.NewKeyDownEvent (Key.Space));
|
||||
Assert.False (btn3.NewKeyDownEvent (Key.Space));
|
||||
}
|
||||
else if (iterations == 4)
|
||||
{
|
||||
|
||||
@@ -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