|
@@ -9,7 +9,7 @@ using System.Globalization;
|
|
|
using Xunit.Abstractions;
|
|
|
using NStack;
|
|
|
|
|
|
-namespace Terminal.Gui.Views {
|
|
|
+namespace Terminal.Gui.TopLevelTests {
|
|
|
|
|
|
public class DialogTests {
|
|
|
readonly ITestOutputHelper output;
|
|
@@ -29,7 +29,7 @@ namespace Terminal.Gui.Views {
|
|
|
[AutoInitShutdown]
|
|
|
public void ButtonAlignment_One ()
|
|
|
{
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
var title = "1234";
|
|
@@ -37,8 +37,8 @@ namespace Terminal.Gui.Views {
|
|
|
var btnText = "ok";
|
|
|
var buttonRow = $"{d.VLine} {d.LeftBracket} {btnText} {d.RightBracket} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
|
|
|
d.SetBufferSize (width, 3);
|
|
|
|
|
@@ -74,7 +74,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
// E.g "|[ yes ][ no ]|"
|
|
@@ -85,8 +85,8 @@ namespace Terminal.Gui.Views {
|
|
|
|
|
|
var buttonRow = $@"{d.VLine} {btn1} {btn2} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
@@ -123,7 +123,7 @@ namespace Terminal.Gui.Views {
|
|
|
Application.RunState runstate = null;
|
|
|
bool firstIteration = false;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
// E.g "|[ yes ][ no ]|"
|
|
@@ -134,8 +134,8 @@ namespace Terminal.Gui.Views {
|
|
|
|
|
|
var buttonRow = $@"{d.VLine} {btn1} {btn2} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
@@ -191,7 +191,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
// E.g "|[ yes ][ no ][ maybe ]|"
|
|
@@ -204,8 +204,8 @@ namespace Terminal.Gui.Views {
|
|
|
|
|
|
var buttonRow = $@"{d.VLine} {btn1} {btn2} {btn3} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
@@ -241,7 +241,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
|
|
@@ -257,8 +257,8 @@ namespace Terminal.Gui.Views {
|
|
|
|
|
|
var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
|
// Default - Center
|
|
@@ -294,7 +294,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
|
|
@@ -349,7 +349,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
|
|
@@ -368,8 +368,8 @@ namespace Terminal.Gui.Views {
|
|
|
// 12345 123456
|
|
|
var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}";
|
|
|
var width = ustring.Make (buttonRow).ConsoleWidth;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
d.SetBufferSize (width, 3);
|
|
|
|
|
|
// Default - Center
|
|
@@ -405,7 +405,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
|
|
@@ -423,8 +423,8 @@ namespace Terminal.Gui.Views {
|
|
|
// 12345 123456
|
|
|
var buttonRow = $"{d.VLine} {btn1} {btn2} {btn3} {btn4} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
|
// Default - Center
|
|
@@ -460,14 +460,14 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
|
|
|
var buttonRow = $"{d.VLine} {d.VLine}";
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
|
(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, null);
|
|
@@ -482,15 +482,15 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
var btnText = "ok";
|
|
|
var buttonRow = $"{d.VLine} {d.LeftBracket} {btnText} {d.RightBracket} {d.VLine}";
|
|
|
|
|
|
var width = buttonRow.Length;
|
|
|
- var topRow = $"┌ {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
- var bottomRow = $"└{new String (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
+ var topRow = $"┌ {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}┐";
|
|
|
+ var bottomRow = $"└{new string (d.HLine.ToString () [0], width - 2)}┘";
|
|
|
d.SetBufferSize (buttonRow.Length, 3);
|
|
|
|
|
|
(runstate, var _) = RunButtonTestDialog (title, width, Dialog.ButtonAlignments.Center, new Button (btnText));
|
|
@@ -504,7 +504,7 @@ namespace Terminal.Gui.Views {
|
|
|
{
|
|
|
Application.RunState runstate = null;
|
|
|
|
|
|
- var d = ((FakeDriver)Application.Driver);
|
|
|
+ var d = (FakeDriver)Application.Driver;
|
|
|
|
|
|
var title = "1234";
|
|
|
var btn1Text = "yes";
|
|
@@ -516,8 +516,8 @@ namespace Terminal.Gui.Views {
|
|
|
var width = $@"{d.VLine} {btn1} {btn2} {d.VLine}".Length;
|
|
|
d.SetBufferSize (width, 3);
|
|
|
|
|
|
- var topRow = $"{d.ULCorner} {title} {new String (d.HLine.ToString () [0], width - title.Length - 4)}{d.URCorner}";
|
|
|
- var bottomRow = $"{d.LLCorner}{new String (d.HLine.ToString () [0], width - 2)}{d.LRCorner}";
|
|
|
+ var topRow = $"{d.ULCorner} {title} {new string (d.HLine.ToString () [0], width - title.Length - 4)}{d.URCorner}";
|
|
|
+ var bottomRow = $"{d.LLCorner}{new string (d.HLine.ToString () [0], width - 2)}{d.LRCorner}";
|
|
|
|
|
|
// Default (center)
|
|
|
var dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Center };
|
|
@@ -550,7 +550,7 @@ namespace Terminal.Gui.Views {
|
|
|
// Right
|
|
|
dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Right };
|
|
|
runstate = Application.Begin (dlg);
|
|
|
- buttonRow = $"{d.VLine}{new String (' ', width - btn1.Length - 2)}{btn1}{d.VLine}";
|
|
|
+ buttonRow = $"{d.VLine}{new string (' ', width - btn1.Length - 2)}{btn1}{d.VLine}";
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
|
|
|
|
|
|
// Now add a second button
|
|
@@ -564,7 +564,7 @@ namespace Terminal.Gui.Views {
|
|
|
// Left
|
|
|
dlg = new Dialog (title, width, 3, new Button (btn1Text)) { ButtonAlignment = Dialog.ButtonAlignments.Left };
|
|
|
runstate = Application.Begin (dlg);
|
|
|
- buttonRow = $"{d.VLine}{btn1}{new String (' ', width - btn1.Length - 2)}{d.VLine}";
|
|
|
+ buttonRow = $"{d.VLine}{btn1}{new string (' ', width - btn1.Length - 2)}{d.VLine}";
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre ($"{topRow}\n{buttonRow}\n{bottomRow}", output);
|
|
|
|
|
|
// Now add a second button
|