|
@@ -1,235 +1,231 @@
|
|
|
-using System.Threading.Tasks;
|
|
|
+using System.Text;
|
|
|
using Xunit;
|
|
|
using Xunit.Abstractions;
|
|
|
-using System.Text;
|
|
|
-using Terminal.Gui;
|
|
|
-using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities;
|
|
|
|
|
|
-namespace Terminal.Gui.DialogTests {
|
|
|
+namespace Terminal.Gui.DialogTests;
|
|
|
|
|
|
- public class MessageBoxTests {
|
|
|
- readonly ITestOutputHelper output;
|
|
|
+public class MessageBoxTests {
|
|
|
+ readonly ITestOutputHelper _output;
|
|
|
|
|
|
- public MessageBoxTests (ITestOutputHelper output)
|
|
|
- {
|
|
|
- this.output = output;
|
|
|
- }
|
|
|
+ public MessageBoxTests (ITestOutputHelper output) => _output = output;
|
|
|
|
|
|
- [Fact]
|
|
|
- [AutoInitShutdown]
|
|
|
- public void Size_Default ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_Default ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (string.Empty, string.Empty, null);
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (string.Empty, string.Empty, null);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
|
|
|
- Assert.IsType<Dialog> (Application.Current);
|
|
|
- // Default size is Percent(60)
|
|
|
- Assert.Equal (new Size ((int)(100 * .60), 5), Application.Current.Frame.Size);
|
|
|
+ Assert.IsType<Dialog> (Application.Current);
|
|
|
+ // Default size is Percent(60)
|
|
|
+ Assert.Equal (new Size ((int)(100 * .60), 5), Application.Current.Frame.Size);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
-
|
|
|
- [Fact]
|
|
|
- [AutoInitShutdown]
|
|
|
- public void Location_Default ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
-
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (string.Empty, string.Empty, null);
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Location_Default ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
|
|
|
- Assert.IsType<Dialog> (Application.Current);
|
|
|
- // Default location is centered, so
|
|
|
- // X = (100 / 2) - (60 / 2) = 20
|
|
|
- // Y = (100 / 2) - (5 / 2) = 47
|
|
|
- Assert.Equal (new Point (20, 47), Application.Current.Frame.Location);
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (string.Empty, string.Empty, null);
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
|
|
|
- [Theory]
|
|
|
- [InlineData (0, 0)]
|
|
|
- [InlineData (1, 1)]
|
|
|
- [InlineData (7, 5)]
|
|
|
- [InlineData (50, 50)]
|
|
|
- [AutoInitShutdown]
|
|
|
- public void Size_Not_Default_No_Message (int height, int width)
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
+ Assert.IsType<Dialog> (Application.Current);
|
|
|
+ // Default location is centered, so
|
|
|
+ // X = (100 / 2) - (60 / 2) = 20
|
|
|
+ // Y = (100 / 2) - (5 / 2) = 47
|
|
|
+ Assert.Equal (new Point (20, 47), Application.Current.Frame.Location);
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (height, width, string.Empty, string.Empty, null);
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
+ [Theory]
|
|
|
+ [InlineData (0, 0)]
|
|
|
+ [InlineData (1, 1)]
|
|
|
+ [InlineData (7, 5)]
|
|
|
+ [InlineData (50, 50)]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_Not_Default_No_Message (int height, int width)
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
+
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
+
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (height, width, string.Empty, string.Empty, null);
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+
|
|
|
+ Assert.IsType<Dialog> (Application.Current);
|
|
|
+ Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- Assert.IsType<Dialog> (Application.Current);
|
|
|
- Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
|
|
|
+ [Theory]
|
|
|
+ [InlineData (0, 0, "1")]
|
|
|
+ [InlineData (1, 1, "1")]
|
|
|
+ [InlineData (7, 5, "1")]
|
|
|
+ [InlineData (50, 50, "1")]
|
|
|
+ [InlineData (0, 0, "message")]
|
|
|
+ [InlineData (1, 1, "message")]
|
|
|
+ [InlineData (7, 5, "message")]
|
|
|
+ [InlineData (50, 50, "message")]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_Not_Default_Message (int height, int width, string message)
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
+
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
+
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (height, width, string.Empty, message, null);
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+
|
|
|
+ Assert.IsType<Dialog> (Application.Current);
|
|
|
+ Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- [Theory]
|
|
|
- [InlineData (0, 0, "1")]
|
|
|
- [InlineData (1, 1, "1")]
|
|
|
- [InlineData (7, 5, "1")]
|
|
|
- [InlineData (50, 50, "1")]
|
|
|
- [InlineData (0, 0, "message")]
|
|
|
- [InlineData (1, 1, "message")]
|
|
|
- [InlineData (7, 5, "message")]
|
|
|
- [InlineData (50, 50, "message")]
|
|
|
- [AutoInitShutdown]
|
|
|
- public void Size_Not_Default_Message (int height, int width, string message)
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
-
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
-
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (height, width, string.Empty, message, null);
|
|
|
-
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
-
|
|
|
- Assert.IsType<Dialog> (Application.Current);
|
|
|
- Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
|
|
|
-
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- [Theory]
|
|
|
- [InlineData (0, 0, "1")]
|
|
|
- [InlineData (1, 1, "1")]
|
|
|
- [InlineData (7, 5, "1")]
|
|
|
- [InlineData (50, 50, "1")]
|
|
|
- [InlineData (0, 0, "message")]
|
|
|
- [InlineData (1, 1, "message")]
|
|
|
- [InlineData (7, 5, "message")]
|
|
|
- [InlineData (50, 50, "message")]
|
|
|
- [AutoInitShutdown]
|
|
|
- public void Size_Not_Default_Message_Button (int height, int width, string message)
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
-
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
-
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (height, width, string.Empty, message, "_Ok");
|
|
|
-
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
-
|
|
|
- Assert.IsType<Dialog> (Application.Current);
|
|
|
- Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
|
|
|
-
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
+ [Theory]
|
|
|
+ [InlineData (0, 0, "1")]
|
|
|
+ [InlineData (1, 1, "1")]
|
|
|
+ [InlineData (7, 5, "1")]
|
|
|
+ [InlineData (50, 50, "1")]
|
|
|
+ [InlineData (0, 0, "message")]
|
|
|
+ [InlineData (1, 1, "message")]
|
|
|
+ [InlineData (7, 5, "message")]
|
|
|
+ [InlineData (50, 50, "message")]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_Not_Default_Message_Button (int height, int width, string message)
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (100, 100);
|
|
|
+
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
+
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (height, width, string.Empty, message, "_Ok");
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+
|
|
|
+ Assert.IsType<Dialog> (Application.Current);
|
|
|
+ Assert.Equal (new Size (height, width), Application.Current.Frame.Size);
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Size_None_No_Buttons ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_None_No_Buttons ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query ("Title", "Message");
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query ("Title", "Message");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
+ Application.RequestStop ();
|
|
|
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
┌┤Title├───────────────────────────────────────┐
|
|
|
│ Message │
|
|
|
│ │
|
|
|
│ │
|
|
|
└──────────────────────────────────────────────┘
|
|
|
-", output);
|
|
|
+", _output);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Size_No_With_Button ()
|
|
|
- {
|
|
|
- Application.Top.BorderStyle = LineStyle.Double;
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_No_With_Button ()
|
|
|
+ {
|
|
|
+ Application.Top.BorderStyle = LineStyle.Double;
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
|
|
|
- var aboutMessage = new StringBuilder ();
|
|
|
- aboutMessage.AppendLine (@"0123456789012345678901234567890123456789");
|
|
|
- aboutMessage.AppendLine (@"https://github.com/gui-cs/Terminal.Gui");
|
|
|
- var message = aboutMessage.ToString ();
|
|
|
- var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Ok {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
+ var aboutMessage = new StringBuilder ();
|
|
|
+ aboutMessage.AppendLine (@"0123456789012345678901234567890123456789");
|
|
|
+ aboutMessage.AppendLine (@"https://github.com/gui-cs/Terminal.Gui");
|
|
|
+ var message = aboutMessage.ToString ();
|
|
|
+ var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Ok {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (40 + 4, 8);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (40 + 4, 8);
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
+ if (iterations == 0) {
|
|
|
|
|
|
- MessageBox.Query (string.Empty, message, "_Ok");
|
|
|
+ MessageBox.Query (string.Empty, message, "_Ok");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
╔══════════════════════════════════════════╗
|
|
|
║┌────────────────────────────────────────┐║
|
|
|
║│0123456789012345678901234567890123456789│║
|
|
@@ -238,100 +234,103 @@ namespace Terminal.Gui.DialogTests {
|
|
|
║│ {btn} │║
|
|
|
║└────────────────────────────────────────┘║
|
|
|
╚══════════════════════════════════════════╝
|
|
|
-", output);
|
|
|
+", _output);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Size_Tiny_Fixed_Size ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_Tiny_Fixed_Size ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (7, 5, string.Empty, "Message", "_Ok");
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (7, 5, string.Empty, "Message", "_Ok");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
|
|
|
- Assert.Equal (new Size (7, 5), Application.Current.Frame.Size);
|
|
|
+ Assert.Equal (new Size (7, 5), Application.Current.Frame.Size);
|
|
|
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
┌─────┐
|
|
|
│Messa│
|
|
|
│ ge │
|
|
|
│ Ok {CM.Glyphs.RightDefaultIndicator}│
|
|
|
└─────┘
|
|
|
-", output);
|
|
|
+", _output);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Size_JustBigEnough_Fixed_Size ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Ok {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Size_JustBigEnough_Fixed_Size ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} Ok {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (11, 5, string.Empty, "Message", "_Ok");
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (11, 5, string.Empty, "Message", "_Ok");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
┌─────────┐
|
|
|
│ Message │
|
|
|
│ │
|
|
|
│{btn} │
|
|
|
└─────────┘
|
|
|
-", output);
|
|
|
+", _output);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Message_Long_Without_Spaces_WrapMessage_True ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- Application.Top.BorderStyle = LineStyle.Double;
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Message_Long_Without_Spaces_WrapMessage_True ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ Application.Top.BorderStyle = LineStyle.Double;
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
|
|
|
- var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- // 50 characters should make the height of the wrapped text 7
|
|
|
- MessageBox.Query (string.Empty, new string ('f', 50), defaultButton: 0, wrapMessage: true, "btn");
|
|
|
+ if (iterations == 0) {
|
|
|
+ // 50 characters should make the height of the wrapped text 7
|
|
|
+ MessageBox.Query (string.Empty, new string ('f', 50), 0, true, "btn");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
╔══════════════════╗
|
|
|
║┌────────────────┐║
|
|
|
║│ffffffffffffffff│║
|
|
@@ -341,15 +340,15 @@ namespace Terminal.Gui.DialogTests {
|
|
|
║│ │║
|
|
|
║│ {btn} │║
|
|
|
║└────────────────┘║
|
|
|
-╚══════════════════╝", output);
|
|
|
- Assert.Equal (new Size (20 - 2, 10 - 2), Application.Current.Frame.Size);
|
|
|
- Application.RequestStop ();
|
|
|
-
|
|
|
- // Really long text
|
|
|
- MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: true, "btn");
|
|
|
- } else if (iterations == 2) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+╚══════════════════╝", _output);
|
|
|
+ Assert.Equal (new Size (20 - 2, 10 - 2), Application.Current.Frame.Size);
|
|
|
+ Application.RequestStop ();
|
|
|
+
|
|
|
+ // Really long text
|
|
|
+ MessageBox.Query (string.Empty, new string ('f', 500), 0, true, "btn");
|
|
|
+ } else if (iterations == 2) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
╔┌────────────────┐╗
|
|
|
║│ffffffffffffffff│║
|
|
|
║│ffffffffffffffff│║
|
|
@@ -359,38 +358,40 @@ namespace Terminal.Gui.DialogTests {
|
|
|
║│ffffffffffffffff│║
|
|
|
║│ffffffffffffffff│║
|
|
|
║│ {btn} │║
|
|
|
-╚└────────────────┘╝", output);
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+╚└────────────────┘╝", _output);
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Message_With_Spaces_WrapMessage_True ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- Application.Top.BorderStyle = LineStyle.Double;
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Message_With_Spaces_WrapMessage_True ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ Application.Top.BorderStyle = LineStyle.Double;
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
|
|
|
- var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
+ var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- var sb = new StringBuilder ();
|
|
|
- for (int i = 0; i < 17; i++)
|
|
|
- sb.Append ("ff ");
|
|
|
+ if (iterations == 0) {
|
|
|
+ var sb = new StringBuilder ();
|
|
|
+ for (var i = 0; i < 17; i++) {
|
|
|
+ sb.Append ("ff ");
|
|
|
+ }
|
|
|
|
|
|
- MessageBox.Query (string.Empty, sb.ToString (), defaultButton: 0, wrapMessage: true, "btn");
|
|
|
+ MessageBox.Query (string.Empty, sb.ToString (), 0, true, "btn");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
╔══════════════════╗
|
|
|
║ ┌──────────────┐ ║
|
|
|
║ │ff ff ff ff ff│ ║
|
|
@@ -400,14 +401,14 @@ namespace Terminal.Gui.DialogTests {
|
|
|
║ │ │ ║
|
|
|
║ │ {btn} │ ║
|
|
|
║ └──────────────┘ ║
|
|
|
-╚══════════════════╝", output);
|
|
|
- Application.RequestStop ();
|
|
|
-
|
|
|
- // Really long text
|
|
|
- MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: true, "btn");
|
|
|
- } else if (iterations == 2) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+╚══════════════════╝", _output);
|
|
|
+ Application.RequestStop ();
|
|
|
+
|
|
|
+ // Really long text
|
|
|
+ MessageBox.Query (string.Empty, new string ('f', 500), 0, true, "btn");
|
|
|
+ } else if (iterations == 2) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
╔┌────────────────┐╗
|
|
|
║│ffffffffffffffff│║
|
|
|
║│ffffffffffffffff│║
|
|
@@ -417,34 +418,35 @@ namespace Terminal.Gui.DialogTests {
|
|
|
║│ffffffffffffffff│║
|
|
|
║│ffffffffffffffff│║
|
|
|
║│ {btn} │║
|
|
|
-╚└────────────────┘╝", output);
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
+╚└────────────────┘╝", _output);
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Message_Without_Spaces_WrapMessage_False ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- Application.Top.BorderStyle = LineStyle.Double;
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Message_Without_Spaces_WrapMessage_False ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ Application.Top.BorderStyle = LineStyle.Double;
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
|
|
|
- var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
+ var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (string.Empty, new string ('f', 50), defaultButton: 0, wrapMessage: false, "btn");
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (string.Empty, new string ('f', 50), 0, false, "btn");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
╔══════════════════╗
|
|
|
║ ║
|
|
|
────────────────────
|
|
@@ -454,15 +456,15 @@ ffffffffffffffffffff
|
|
|
────────────────────
|
|
|
║ ║
|
|
|
║ ║
|
|
|
-╚══════════════════╝", output);
|
|
|
+╚══════════════════╝", _output);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
+ Application.RequestStop ();
|
|
|
|
|
|
- // Really long text
|
|
|
- MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: false, "btn");
|
|
|
- } else if (iterations == 2) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ // Really long text
|
|
|
+ MessageBox.Query (string.Empty, new string ('f', 500), 0, false, "btn");
|
|
|
+ } else if (iterations == 2) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
╔══════════════════╗
|
|
|
║ ║
|
|
|
────────────────────
|
|
@@ -472,38 +474,40 @@ ffffffffffffffffffff
|
|
|
────────────────────
|
|
|
║ ║
|
|
|
║ ║
|
|
|
-╚══════════════════╝", output);
|
|
|
+╚══════════════════╝", _output);
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- [Fact, AutoInitShutdown]
|
|
|
- public void Message_With_Spaces_WrapMessage_False ()
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
- Application.Top.BorderStyle = LineStyle.Double;
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
- var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
-
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
|
|
|
- if (iterations == 0) {
|
|
|
- var sb = new StringBuilder ();
|
|
|
- for (int i = 0; i < 17; i++)
|
|
|
- sb.Append ("ff ");
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void Message_With_Spaces_WrapMessage_False ()
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+ Application.Top.BorderStyle = LineStyle.Double;
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (20, 10);
|
|
|
+ var btn = $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
|
|
|
+
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
+
|
|
|
+ if (iterations == 0) {
|
|
|
+ var sb = new StringBuilder ();
|
|
|
+ for (var i = 0; i < 17; i++) {
|
|
|
+ sb.Append ("ff ");
|
|
|
+ }
|
|
|
|
|
|
- MessageBox.Query (string.Empty, sb.ToString (), defaultButton: 0, wrapMessage: false, "btn");
|
|
|
+ MessageBox.Query (string.Empty, sb.ToString (), 0, false, "btn");
|
|
|
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
╔══════════════════╗
|
|
|
║ ║
|
|
|
────────────────────
|
|
@@ -513,14 +517,14 @@ ff ff ff ff ff ff ff
|
|
|
────────────────────
|
|
|
║ ║
|
|
|
║ ║
|
|
|
-╚══════════════════╝", output);
|
|
|
- Application.RequestStop ();
|
|
|
-
|
|
|
- // Really long text
|
|
|
- MessageBox.Query (string.Empty, new string ('f', 500), defaultButton: 0, wrapMessage: false, "btn");
|
|
|
- } else if (iterations == 2) {
|
|
|
- Application.Refresh ();
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+╚══════════════════╝", _output);
|
|
|
+ Application.RequestStop ();
|
|
|
+
|
|
|
+ // Really long text
|
|
|
+ MessageBox.Query (string.Empty, new string ('f', 500), 0, false, "btn");
|
|
|
+ } else if (iterations == 2) {
|
|
|
+ Application.Refresh ();
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
╔══════════════════╗
|
|
|
║ ║
|
|
|
────────────────────
|
|
@@ -530,58 +534,159 @@ ffffffffffffffffffff
|
|
|
────────────────────
|
|
|
║ ║
|
|
|
║ ║
|
|
|
-╚══════════════════╝", output);
|
|
|
- Application.RequestStop ();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
-
|
|
|
- [Theory, AutoInitShutdown]
|
|
|
- [InlineData (" ", true, 1)]
|
|
|
- [InlineData (" ", false, 1)]
|
|
|
- [InlineData ("", true, 1)]
|
|
|
- [InlineData ("", false, 1)]
|
|
|
- [InlineData ("\n", true, 1)]
|
|
|
- [InlineData ("\n", false, 1)]
|
|
|
- [InlineData (" \n", true, 1)]
|
|
|
- [InlineData (" \n", false, 2)]
|
|
|
- public void Message_Empty_Or_A_NewLline_WrapMessagge_True_Or_False (string message, bool wrapMessage, int linesLength)
|
|
|
- {
|
|
|
- var iterations = -1;
|
|
|
- Application.Begin (Application.Top);
|
|
|
-
|
|
|
- Application.Iteration += (s, a) => {
|
|
|
- iterations++;
|
|
|
-
|
|
|
- if (iterations == 0) {
|
|
|
- MessageBox.Query (string.Empty, message, 0, wrapMessage, "ok");
|
|
|
-
|
|
|
- Application.RequestStop ();
|
|
|
- } else if (iterations == 1) {
|
|
|
- Application.Refresh ();
|
|
|
- if (linesLength == 1) {
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+╚══════════════════╝", _output);
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
+
|
|
|
+ [Theory]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ [InlineData (" ", true, 1)]
|
|
|
+ [InlineData (" ", false, 1)]
|
|
|
+ [InlineData ("", true, 1)]
|
|
|
+ [InlineData ("", false, 1)]
|
|
|
+ [InlineData ("\n", true, 1)]
|
|
|
+ [InlineData ("\n", false, 1)]
|
|
|
+ [InlineData (" \n", true, 1)]
|
|
|
+ [InlineData (" \n", false, 2)]
|
|
|
+ public void Message_Empty_Or_A_NewLline_WrapMessagge_True_Or_False (string message, bool wrapMessage, int linesLength)
|
|
|
+ {
|
|
|
+ var iterations = -1;
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iterations++;
|
|
|
+
|
|
|
+ if (iterations == 0) {
|
|
|
+ MessageBox.Query (string.Empty, message, 0, wrapMessage, "ok");
|
|
|
+
|
|
|
+ Application.RequestStop ();
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ Application.Refresh ();
|
|
|
+ if (linesLength == 1) {
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
┌──────────────────────────────────────────────┐
|
|
|
│ │
|
|
|
│ │
|
|
|
│ {CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} ok {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket} │
|
|
|
- └──────────────────────────────────────────────┘", output);
|
|
|
- } else {
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
+ └──────────────────────────────────────────────┘", _output);
|
|
|
+ } else {
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@$"
|
|
|
┌──────────────────────────────────────────────┐
|
|
|
│ │
|
|
|
│ │
|
|
|
│ │
|
|
|
│ {CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} ok {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket} │
|
|
|
- └──────────────────────────────────────────────┘", output);
|
|
|
- }
|
|
|
- Application.RequestStop ();
|
|
|
+ └──────────────────────────────────────────────┘", _output);
|
|
|
}
|
|
|
- };
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ Application.Run ();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void KeyBindings_Esc_Closes ()
|
|
|
+ {
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+
|
|
|
+ var result = 999;
|
|
|
+
|
|
|
+ var iteration = 0;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iteration++;
|
|
|
+ switch (iteration) {
|
|
|
+ case 1:
|
|
|
+ result = MessageBox.Query (title: string.Empty, message: string.Empty, defaultButton: 0, wrapMessage: false, "btn0", "btn1");
|
|
|
+ Application.RequestStop ();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ Application.OnKeyDown (Key.Esc);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ Assert.Fail ();
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Application.Run ();
|
|
|
+
|
|
|
+ Assert.Equal (-1, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void KeyBindings_Enter_Causes_Focused_Button_Click ()
|
|
|
+ {
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+
|
|
|
+ var result = -1;
|
|
|
+
|
|
|
+ var iteration = 0;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iteration++;
|
|
|
+ switch (iteration) {
|
|
|
+ case 1:
|
|
|
+ result = MessageBox.Query (title: string.Empty, message: string.Empty, defaultButton: 0, wrapMessage: false, "btn0", "btn1");
|
|
|
+ Application.RequestStop ();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ // Tab to btn2
|
|
|
+ Application.OnKeyDown (Key.Tab);
|
|
|
+ Application.OnKeyDown (Key.Enter);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ Assert.Fail ();
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Application.Run ();
|
|
|
+
|
|
|
+ Assert.Equal (1, result);
|
|
|
+ }
|
|
|
|
|
|
- Application.Run ();
|
|
|
- }
|
|
|
+ [Fact]
|
|
|
+ [AutoInitShutdown]
|
|
|
+ public void KeyBindings_Space_Causes_Focused_Button_Click ()
|
|
|
+ {
|
|
|
+ Application.Begin (Application.Top);
|
|
|
+
|
|
|
+ var result = -1;
|
|
|
+
|
|
|
+ var iteration = 0;
|
|
|
+ Application.Iteration += (s, a) => {
|
|
|
+ iteration++;
|
|
|
+ switch (iteration) {
|
|
|
+ case 1:
|
|
|
+ result = MessageBox.Query (title: string.Empty, message: string.Empty, defaultButton: 0, wrapMessage: false, "btn0", "btn1");
|
|
|
+ Application.RequestStop ();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ // Tab to btn2
|
|
|
+ Application.OnKeyDown (Key.Tab);
|
|
|
+ Application.OnKeyDown (Key.Space);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ Assert.Fail ();
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Application.Run ();
|
|
|
+
|
|
|
+ Assert.Equal (1, result);
|
|
|
}
|
|
|
-}
|
|
|
+}
|