Switched back to Application.Begin not calling Refresh

This commit is contained in:
Tig
2024-10-22 12:00:38 -06:00
parent 98a2265db2
commit 6e98d10f34
12 changed files with 115 additions and 63 deletions

View File

@@ -57,8 +57,8 @@ public class AppendAutocompleteTests (ITestOutputHelper output)
// Should reappear when you press next letter
Application.Driver?.SendKeys ('i', ConsoleKey.I, false, false, false);
tf.Draw ();
tf.PositionCursor ();
tf.Draw ();
TestHelpers.AssertDriverContentsAre ("fish", output);
Assert.Equal ("fi", tf.Text);
Application.Top.Dispose ();

View File

@@ -138,6 +138,7 @@ public class ContextMenuTests (ITestOutputHelper output)
var top = new Toplevel { X = 2, Y = 2, Width = 15, Height = 4 };
top.Add (new TextField { X = Pos.Center (), Width = 10, Text = "Test" });
RunState rs = Application.Begin (top);
Application.Refresh ();
Assert.Equal (new Rectangle (2, 2, 15, 4), top.Frame);
Assert.Equal (top, Application.Top);
@@ -208,6 +209,7 @@ public class ContextMenuTests (ITestOutputHelper output)
var testWindow = new Window { X = 2, Y = 2, Width = 15, Height = 4 };
testWindow.Add (new TextField { X = Pos.Center (), Width = 10, Text = "Test" });
RunState rsDialog = Application.Begin (testWindow);
Application.Refresh ();
Assert.Equal (new Rectangle (2, 2, 15, 4), testWindow.Frame);
@@ -273,6 +275,7 @@ public class ContextMenuTests (ITestOutputHelper output)
var dialog = new Window { X = 2, Y = 2, Width = 15, Height = 4 };
dialog.Add (new TextField { X = Pos.Center (), Width = 10, Text = "Test" });
RunState rs = Application.Begin (dialog);
Application.Refresh ();
Assert.Equal (new Rectangle (2, 2, 15, 4), dialog.Frame);
Assert.Equal (dialog, Application.Top);

View File

@@ -192,7 +192,8 @@ public class LabelTests (ITestOutputHelper output)
var top = new Toplevel ();
top.Add (label);
Application.Begin (top);
RunState runState = Application.Begin (top);
Application.RunIteration (ref runState);
Assert.False (label.TextFormatter.FillRemaining);
Assert.False (tf1.FillRemaining);
@@ -243,6 +244,7 @@ This TextFormatter (tf2) is rewritten. ",
var top = new Toplevel ();
top.Add (label);
Application.Begin (top);
Application.Refresh ();
Assert.Equal (new (0, 0, 16, 1), label.Frame);
@@ -263,7 +265,7 @@ Demo Simple Rune
var top = new Toplevel ();
top.Add (label);
Application.Begin (top);
Application.Refresh ();
Assert.NotNull (label.Width);
Assert.NotNull (label.Height);
@@ -299,6 +301,7 @@ e
var top = new Toplevel ();
top.Add (label);
Application.Begin (top);
Application.Refresh ();
var expected = @"
@@ -469,6 +472,7 @@ e
var top = new Toplevel ();
top.Add (label);
Application.Begin (top);
Application.Refresh ();
Assert.Equal (new (0, 0, 6, 3), label.Frame);
Assert.Equal (new (0, 0, 4, 1), label.Viewport);
@@ -492,7 +496,7 @@ e
var top = new Toplevel ();
top.Add (label);
Application.Begin (top);
Application.Refresh ();
Assert.Equal (new (0, 0, 6, 2), label.Frame);
Assert.Equal (new (0, 0, 4, 1), label.Viewport);
Application.Begin (top);

View File

@@ -305,6 +305,7 @@ public class ListViewTests (ITestOutputHelper output)
var top = new Toplevel ();
top.Add (lv);
Application.Begin (top);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -342,6 +343,7 @@ Item 6",
var top = new Toplevel ();
top.Add (lv);
Application.Begin (top);
Application.Refresh ();
Assert.Equal ("Second ", GetContents (0));
Assert.Equal (new (' ', 7), GetContents (1));
@@ -723,6 +725,7 @@ Item 6",
var top = new Toplevel ();
top.Add (lv);
Application.Begin (top);
Application.Refresh ();
Assert.Equal (new (1), lv.Border.Thickness);
Assert.Equal (-1, lv.SelectedItem);
@@ -796,6 +799,7 @@ Item 6",
var top = new Toplevel ();
top.Add (lv);
Application.Begin (top);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"

View File

@@ -569,6 +569,7 @@ public class MenuBarTests (ITestOutputHelper output)
}
RunState rsDialog = Application.Begin (dialog);
Application.RunIteration (ref rsDialog);
Assert.Equal (new (2, 2, 15, 4), dialog.Frame);
@@ -594,8 +595,7 @@ public class MenuBarTests (ITestOutputHelper output)
Assert.Equal ("File", menu.Menus [0].Title);
menu.OpenMenu ();
var firstIteration = false;
Application.RunIteration (ref rsDialog, firstIteration);
Application.RunIteration (ref rsDialog);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -619,10 +619,9 @@ public class MenuBarTests (ITestOutputHelper output)
Application.RaiseMouseEvent (new () { ScreenPosition = new (20, 5), Flags = MouseFlags.Button1Clicked });
firstIteration = false;
// Need to fool MainLoop into thinking it's running
Application.MainLoop.Running = true;
bool firstIteration = true;
Application.RunIteration (ref rsDialog, firstIteration);
Assert.Equal (items [0], menu.Menus [0].Title);
@@ -652,15 +651,13 @@ public class MenuBarTests (ITestOutputHelper output)
Application.RaiseMouseEvent (new () { ScreenPosition = new (20, 5 + i), Flags = MouseFlags.Button1Clicked });
firstIteration = false;
Application.RunIteration (ref rsDialog, firstIteration);
Application.RunIteration (ref rsDialog);
Assert.Equal (items [i], menu.Menus [0].Title);
}
((FakeDriver)Application.Driver!).SetBufferSize (20, 15);
menu.OpenMenu ();
firstIteration = false;
Application.RunIteration (ref rsDialog, firstIteration);
Application.RunIteration (ref rsDialog);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -781,6 +778,7 @@ public class MenuBarTests (ITestOutputHelper output)
}
RunState rs = Application.Begin (dialog);
Application.RunIteration (ref rs);
Assert.Equal (new (2, 2, 15, 4), dialog.Frame);
@@ -795,8 +793,7 @@ public class MenuBarTests (ITestOutputHelper output)
Assert.Equal ("File", menu.Menus [0].Title);
menu.OpenMenu ();
var firstIteration = false;
Application.RunIteration (ref rs, firstIteration);
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -815,11 +812,9 @@ public class MenuBarTests (ITestOutputHelper output)
Application.RaiseMouseEvent (new () { ScreenPosition = new (20, 5), Flags = MouseFlags.Button1Clicked });
firstIteration = false;
// Need to fool MainLoop into thinking it's running
Application.MainLoop.Running = true;
Application.RunIteration (ref rs, firstIteration);
Application.RunIteration (ref rs);
Assert.Equal (items [0], menu.Menus [0].Title);
TestHelpers.AssertDriverContentsWithFrameAre (
@@ -837,15 +832,13 @@ public class MenuBarTests (ITestOutputHelper output)
Application.RaiseMouseEvent (new () { ScreenPosition = new (20, 5 + i), Flags = MouseFlags.Button1Clicked });
firstIteration = false;
Application.RunIteration (ref rs, firstIteration);
Application.RunIteration (ref rs);
Assert.Equal (items [i], menu.Menus [0].Title);
}
((FakeDriver)Application.Driver!).SetBufferSize (20, 15);
menu.OpenMenu ();
firstIteration = false;
Application.RunIteration (ref rs, firstIteration);
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1857,7 +1850,8 @@ wo
};
win.Add (menu);
((FakeDriver)Application.Driver!).SetBufferSize (40, 8);
Application.Begin (win);
RunState rs = Application.Begin (win);
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1873,7 +1867,7 @@ wo
);
Assert.True (win.NewKeyDownEvent (menu.Key));
win.Draw ();
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1889,7 +1883,7 @@ wo
);
Assert.True (menu.NewKeyDownEvent (Key.CursorRight));
Application.Refresh ();
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1905,7 +1899,7 @@ wo
);
Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
win.Draw ();
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1921,7 +1915,7 @@ wo
);
Assert.True (menu._openMenu.NewKeyDownEvent (Key.CursorRight));
win.Draw ();
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
@@ -1947,6 +1941,7 @@ wo
Application.Iteration += (s, a) =>
{
Toplevel top = Application.Top;
Application.Refresh();
TestHelpers.AssertDriverContentsWithFrameAre (
@"

View File

@@ -178,6 +178,7 @@ public class ScrollBarViewTests
Application.Begin (top);
((FakeDriver)Application.Driver!).SetBufferSize (width, height);
Application.Refresh ();
var expected = @"
┌─┐
@@ -230,6 +231,7 @@ public class ScrollBarViewTests
{
_scrollBar = new ScrollBarView (_hostView, true);
Application.Begin (_hostView.SuperView as Toplevel);
Application.Refresh ();
AddHandlers ();
@@ -250,6 +252,7 @@ public class ScrollBarViewTests
{
_scrollBar = new ScrollBarView (_hostView, true);
Application.Begin (_hostView.SuperView as Toplevel);
Application.Refresh ();
AddHandlers ();
@@ -285,6 +288,7 @@ public class ScrollBarViewTests
{
_scrollBar = new ScrollBarView (_hostView, true);
Application.Begin (_hostView.SuperView as Toplevel);
Application.Refresh ();
AddHandlers ();
@@ -308,6 +312,7 @@ public class ScrollBarViewTests
var sbv = new ScrollBarView (label, true, false) { Size = 100 };
Application.Begin (top);
Application.Refresh ();
Assert.True (sbv.Visible);
@@ -425,6 +430,8 @@ This is a test
Assert.Equal (newScrollBarView.Position, listView.LeftItem);
listView.SetNeedsDisplay ();
Application.Refresh ();
};
listView.DrawContent += (s, e) =>
@@ -504,6 +511,8 @@ This is a test
Assert.Equal (newScrollBarView.Position, listView.TopItem);
listView.SetNeedsDisplay ();
Application.Refresh ();
};
listView.DrawContent += (s, e) =>
@@ -553,6 +562,7 @@ This is a test
var sbv = new ScrollBarView (label, true) { Size = 100 };
sbv.OtherScrollBarView.Size = 100;
Application.Begin (top);
Application.Refresh ();
Assert.Equal (100, sbv.Size);
Assert.Equal (100, sbv.OtherScrollBarView.Size);
@@ -636,6 +646,7 @@ This is a tes▼
var sbv = new ScrollBarView (label, true, false) { Size = 100 };
Application.Begin (top);
Application.Refresh ();
Assert.Equal (100, sbv.Size);
Assert.Null (sbv.OtherScrollBarView);
@@ -680,6 +691,7 @@ This is a test
{
_scrollBar = new ScrollBarView (_hostView, true);
Application.Begin (_hostView.SuperView as Toplevel);
Application.Refresh ();
AddHandlers ();
@@ -1156,6 +1168,7 @@ This is a test
var sbv = new ScrollBarView (label, true, false) { Size = 5 };
Application.Begin (top);
Application.Refresh ();
Assert.Equal (5, sbv.Size);
Assert.Null (sbv.OtherScrollBarView);