Working on shortcut

This commit is contained in:
Tig
2024-10-19 10:25:53 -06:00
parent 5dc832b6e3
commit 2d48bc9d49
21 changed files with 186 additions and 159 deletions

View File

@@ -10,6 +10,7 @@ public class DateFieldTests
public void Constructors_Defaults ()
{
var df = new DateField ();
df.Layout ();
Assert.Equal (DateTime.MinValue, df.Date);
Assert.Equal (1, df.CursorPosition);
Assert.Equal (new Rectangle (0, 0, 12, 1), df.Frame);
@@ -17,12 +18,14 @@ public class DateFieldTests
DateTime date = DateTime.Now;
df = new DateField (date);
df.Layout ();
Assert.Equal (date, df.Date);
Assert.Equal (1, df.CursorPosition);
Assert.Equal (new Rectangle (0, 0, 12, 1), df.Frame);
Assert.Equal ($" {date.ToString (CultureInfo.InvariantCulture.DateTimeFormat.ShortDatePattern)}", df.Text);
df = new DateField (date) { X = 1, Y = 2 };
df.Layout ();
Assert.Equal (date, df.Date);
Assert.Equal (1, df.CursorPosition);
Assert.Equal (new Rectangle (1, 2, 12, 1), df.Frame);

View File

@@ -22,7 +22,7 @@ public class HexViewTests
public void BytesPerLine_Calculates_Correctly (int width, int expectedBpl)
{
var hv = new HexView (LoadStream (null, out long _)) { Width = width, Height = 10, AddressWidth = 0 };
hv.LayoutSubviews ();
hv.Layout ();
Assert.Equal (expectedBpl, hv.BytesPerLine);
}
@@ -370,7 +370,7 @@ public class HexViewTests
Application.Top = new Toplevel ();
Application.Top.Add (hv);
hv.LayoutSubviews ();
hv.Layout ();
Assert.True (hv.NewKeyDownEvent (Key.End));
Assert.Equal (MEM_STRING_LENGTH - 1, hv.DisplayStart);

View File

@@ -211,11 +211,11 @@ This TextFormatter (tf2) with fill will be cleared on rewritten. ",
);
Assert.False (label.NeedsDisplay);
Assert.False (label.IsLayoutNeeded ());
Assert.False (label.NeedsLayout);
Assert.False (label.SubViewNeedsDisplay);
label.Text = "This label is rewritten.";
Assert.True (label.NeedsDisplay);
Assert.True (label.IsLayoutNeeded ());
Assert.True (label.NeedsLayout);
//Assert.False (label.SubViewNeedsDisplay);
label.Draw ();
@@ -1360,6 +1360,7 @@ e
Application.Navigation = new ();
Application.Top = new ();
Application.Top.Add (otherView, label, nextView);
Application.Top.Layout ();
Application.Top.SetFocus ();
@@ -1432,6 +1433,7 @@ e
};
Application.Top.Add (label, otherView);
Application.Top.SetFocus ();
Application.Top.Layout ();
Assert.True (label.CanFocus);
Assert.True (label.HasFocus);

View File

@@ -10,6 +10,7 @@ public class LineViewTests
Assert.Equal (Orientation.Horizontal, horizontal.Orientation);
Assert.Equal (Dim.Fill (), horizontal.Width);
horizontal.Layout ();
Assert.Equal (1, horizontal.Frame.Height);
}
@@ -21,6 +22,7 @@ public class LineViewTests
Assert.Equal (Orientation.Horizontal, horizontal.Orientation);
Assert.Equal (Dim.Fill (), horizontal.Width);
horizontal.Layout ();
Assert.Equal (1, horizontal.Frame.Height);
}
@@ -32,6 +34,7 @@ public class LineViewTests
Assert.Equal (Orientation.Vertical, vert.Orientation);
Assert.Equal (Dim.Fill (), vert.Height);
vert.Layout ();
Assert.Equal (1, vert.Frame.Width);
}
}

View File

@@ -879,6 +879,7 @@ public class MenuBarTests (ITestOutputHelper output)
new (new MenuItem [] { new ("One", "", null), new ("Two", "", null) })
]
};
menu.Layout ();
Assert.Equal (new (-1, -1), new Point (menu.Frame.X, menu.Frame.Y));
@@ -958,6 +959,7 @@ public class MenuBarTests (ITestOutputHelper output)
new (new MenuItem [] { new ("One", "", null), new ("Two", "", null) })
]
};
menu.Layout ();
Assert.Equal (new (-2, -1), new Point (menu.Frame.X, menu.Frame.Y));

View File

@@ -105,16 +105,20 @@ public class ProgressBarTests
var pb2 = new ProgressBar { ProgressBarStyle = ProgressBarStyle.MarqueeContinuous };
pb1.ProgressBarFormat = ProgressBarFormat.Simple;
pb1.Layout ();
Assert.Equal (ProgressBarFormat.Simple, pb1.ProgressBarFormat);
Assert.Equal (1, pb1.Frame.Height);
pb2.ProgressBarFormat = ProgressBarFormat.Simple;
pb2.Layout ();
Assert.Equal (ProgressBarFormat.Simple, pb2.ProgressBarFormat);
Assert.Equal (1, pb2.Frame.Height);
pb1.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
pb1.Layout ();
Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb1.ProgressBarFormat);
Assert.Equal (1, pb1.Frame.Height);
pb2.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
pb2.Layout ();
Assert.Equal (ProgressBarFormat.SimplePlusPercentage, pb2.ProgressBarFormat);
Assert.Equal (1, pb2.Frame.Height);
}
@@ -126,9 +130,11 @@ public class ProgressBarTests
var pb = new ProgressBar ();
pb.ProgressBarFormat = ProgressBarFormat.Simple;
pb.Layout ();
Assert.Equal (1, pb.Frame.Height);
pb.ProgressBarFormat = ProgressBarFormat.SimplePlusPercentage;
pb.Layout ();
Assert.Equal (1, pb.Frame.Height);
}

View File

@@ -65,6 +65,7 @@ public class ScrollViewTests (ITestOutputHelper output)
Assert.False (sv.AutoHideScrollBars);
Assert.False (sv.ShowHorizontalScrollIndicator);
Assert.True (sv.ShowVerticalScrollIndicator);
top.Layout ();
sv.Draw ();
TestHelpers.AssertDriverContentsAre (
@@ -89,6 +90,7 @@ public class ScrollViewTests (ITestOutputHelper output)
Assert.False (sv.AutoHideScrollBars);
Assert.True (sv.ShowHorizontalScrollIndicator);
Assert.False (sv.ShowVerticalScrollIndicator);
top.Layout ();
sv.Draw ();
TestHelpers.AssertDriverContentsAre (
@@ -113,6 +115,7 @@ public class ScrollViewTests (ITestOutputHelper output)
Assert.False (sv.AutoHideScrollBars);
Assert.False (sv.ShowHorizontalScrollIndicator);
Assert.False (sv.ShowVerticalScrollIndicator);
top.Layout ();
sv.Draw ();
TestHelpers.AssertDriverContentsAre (

View File

@@ -20,8 +20,10 @@ public class ShortcutTests
public void Size_Defaults ()
{
var shortcut = new Shortcut ();
shortcut.BeginInit();
shortcut.EndInit();
shortcut.SetRelativeLayout (new (100, 100));
shortcut.Layout ();
Assert.Equal (2, shortcut.Frame.Width);
Assert.Equal (1, shortcut.Frame.Height);
Assert.Equal (2, shortcut.Viewport.Width);
@@ -31,10 +33,10 @@ public class ShortcutTests
Assert.Equal (1, shortcut.CommandView.Viewport.Height);
Assert.Equal (0, shortcut.HelpView.Viewport.Width);
Assert.Equal (1, shortcut.HelpView.Viewport.Height);
Assert.Equal (0, shortcut.HelpView.Viewport.Height);
Assert.Equal (0, shortcut.KeyView.Viewport.Width);
Assert.Equal (1, shortcut.KeyView.Viewport.Height);
Assert.Equal (0, shortcut.KeyView.Viewport.Height);
// 0123456789
// " 0 A "