diff --git a/CommunityToolkitExample/LoginView.cs b/CommunityToolkitExample/LoginView.cs index 8d66f29bb..f7a572c65 100644 --- a/CommunityToolkitExample/LoginView.cs +++ b/CommunityToolkitExample/LoginView.cs @@ -59,7 +59,7 @@ internal partial class LoginView : IRecipient> } } SetText(); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } private void SetText () diff --git a/Terminal.Gui/Application/Application.Keyboard.cs b/Terminal.Gui/Application/Application.Keyboard.cs index 211c900bc..28091cfc0 100644 --- a/Terminal.Gui/Application/Application.Keyboard.cs +++ b/Terminal.Gui/Application/Application.Keyboard.cs @@ -200,7 +200,7 @@ public static partial class Application // Keyboard handling Command.Refresh, static () => { - Refresh (); + LayoutAndDrawToplevels (); return true; } diff --git a/Terminal.Gui/Application/Application.Run.cs b/Terminal.Gui/Application/Application.Run.cs index 1aad9c351..dccbc4794 100644 --- a/Terminal.Gui/Application/Application.Run.cs +++ b/Terminal.Gui/Application/Application.Run.cs @@ -207,7 +207,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) NotifyNewRunState?.Invoke (toplevel, new (rs)); // Force an Idle event so that an Iteration (and Refresh) happen. - Application.Invoke(() => {}); + Application.Invoke (() => { }); return rs; } @@ -496,33 +496,29 @@ public static partial class Application // Run (Begin, Run, End, Stop) public static void Wakeup () { MainLoop?.Wakeup (); } /// - /// Refreshes layout and the display. Only Views that need to be laid out (see ) will be laid out. + /// Causes any Toplevels that need layout to be laid out. Then draws any Toplevels that need dispplay. Only Views that need to be laid out (see ) will be laid out. /// Only Views that need to be drawn (see ) will be drawn. /// - /// If the entire View hierarchy will be redrawn. The default is and should only be overriden for testing. - public static void Refresh (bool forceRedraw = false, object context = null) + /// If the entire View hierarchy will be redrawn. The default is and should only be overriden for testing. + public static void LayoutAndDrawToplevels (bool forceDraw = false) { - //WindowsConsole.InputRecord rec = new WindowsConsole.InputRecord(); - //if (context is WindowsConsole.InputRecord record) - //{ - // rec = record; - // if (record is { EventType: WindowsConsole.EventType.Focus }) - // { - // return; - // } - - // if (record is { EventType: WindowsConsole.EventType.Key }) - // { - // var key = (WindowsConsole.KeyEventRecord)record.KeyEvent; - // if (key is { dwControlKeyState: WindowsConsole.ControlKeyState.LeftAltPressed }) - // { - // return; - // } - // } - - //} - bool neededLayout = false; + neededLayout = LayoutToplevels (); + + if (forceDraw) + { + Driver?.ClearContents (); + } + + DrawToplevels (neededLayout || forceDraw); + + Driver?.Refresh (); + } + + private static bool LayoutToplevels () + { + bool neededLayout = false; + foreach (Toplevel tl in TopLevels.Reverse ()) { if (tl.NeedsLayout) @@ -532,48 +528,23 @@ public static partial class Application // Run (Begin, Run, End, Stop) } } - if (forceRedraw) - { - Driver?.ClearContents (); - } + return neededLayout; + } + private static void DrawToplevels (bool forceDraw) + { foreach (Toplevel tl in TopLevels.Reverse ()) { - if (neededLayout) + if (forceDraw) { tl.SetNeedsDisplay (); } tl.Draw (); } - - // Stack redrawStack = new (TopLevels); - - //// Debug.WriteLine ($"{DateTime.Now}.{DateTime.Now.Millisecond} - Refresh {rec} = {redrawStack.Count}"); - // while (redrawStack.Count > 0) - // { - // Toplevel? tlToDraw = redrawStack.Pop (); - - // if (forceRedraw) - // { - // tlToDraw.SetNeedsDisplay (); - // } - - // if (View.CanBeVisible (tlToDraw)) - // { - // bool needs = tlToDraw.NeedsDisplay || tlToDraw.SubViewNeedsDisplay; - // tlToDraw.Draw (); - - // if (needs && redrawStack.TryPeek (out var nexToplevel)) - // { - // nexToplevel.SetNeedsDisplay (); - // } - // } - // } - - Driver?.Refresh (); } + /// This event is raised on each iteration of the main loop. /// See also public static event EventHandler? Iteration; @@ -633,9 +604,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) state.Toplevel.OnReady (); } - object ctx = state.Context; MainLoop.RunIteration (); - state.Context = ctx; Iteration?.Invoke (null, new ()); } @@ -647,7 +616,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) return firstIteration; } - Refresh (context: state.Context); + LayoutAndDrawToplevels (); if (PositionCursor ()) { @@ -747,6 +716,6 @@ public static partial class Application // Run (Begin, Run, End, Stop) runState.Toplevel = null; runState.Dispose (); - Refresh (context: "End"); + LayoutAndDrawToplevels (); } } diff --git a/Terminal.Gui/Application/Application.Screen.cs b/Terminal.Gui/Application/Application.Screen.cs index 0a9d3b796..66ae84027 100644 --- a/Terminal.Gui/Application/Application.Screen.cs +++ b/Terminal.Gui/Application/Application.Screen.cs @@ -63,7 +63,7 @@ public static partial class Application // Screen related stuff t.SetNeedsLayout (); } - Refresh (); + LayoutAndDrawToplevels (); return true; } diff --git a/Terminal.Gui/Application/RunState.cs b/Terminal.Gui/Application/RunState.cs index b60c29ed0..0c1387ff8 100644 --- a/Terminal.Gui/Application/RunState.cs +++ b/Terminal.Gui/Application/RunState.cs @@ -10,8 +10,6 @@ public class RunState : IDisposable /// The belonging to this . public Toplevel Toplevel { get; internal set; } - public object Context { get; internal set; } - /// Releases all resource used by the object. /// Call when you are finished using the . /// diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index 24df65626..54f29a6fe 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -608,7 +608,7 @@ internal sealed class Menu : View Application.UngrabMouse (); _host.CloseAllMenus (); Application.Driver!.ClearContents (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); _host.Run (action); } diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index e69e9f0c7..af3667b46 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -1117,7 +1117,7 @@ public class MenuBar : View, IDesignable Application.UngrabMouse (); CloseAllMenus (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); _openedByAltKey = true; return Run (item.Action); diff --git a/UICatalog/Scenarios/GraphViewExample.cs b/UICatalog/Scenarios/GraphViewExample.cs index e9a6bdf0f..3bb27a10e 100644 --- a/UICatalog/Scenarios/GraphViewExample.cs +++ b/UICatalog/Scenarios/GraphViewExample.cs @@ -214,7 +214,7 @@ public class GraphViewExample : Scenario ? ViewDiagnosticFlags.Thickness | ViewDiagnosticFlags.Ruler : ViewDiagnosticFlags.Off; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } private void Margin (bool left, bool increase) diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs index 96173e6b8..b3afcd800 100644 --- a/UICatalog/Scenarios/Images.cs +++ b/UICatalog/Scenarios/Images.cs @@ -100,7 +100,7 @@ public class Images : Scenario } imageView.SetImage (img); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; Application.Run (win); diff --git a/UICatalog/Scenarios/Localization.cs b/UICatalog/Scenarios/Localization.cs index f28750a0d..1a32b6c2c 100644 --- a/UICatalog/Scenarios/Localization.cs +++ b/UICatalog/Scenarios/Localization.cs @@ -38,7 +38,7 @@ public class Localization : Scenario CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } public override void Main () diff --git a/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs b/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs index ed2e34a11..65417b01f 100644 --- a/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs +++ b/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs @@ -115,7 +115,7 @@ public class RuneWidthGreaterThanOne : Scenario _labelV.Text = "This is a test text 你"; _win.Title = "HACC Demo 你"; _lastRunesUsed = "Mixed"; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } private void NarrowMessage (object sender, EventArgs e) { MessageBox.Query ("Say Hello", $"Hello {_text.Text}", "Ok"); } @@ -135,7 +135,7 @@ public class RuneWidthGreaterThanOne : Scenario _labelV.Text = "This is a test text"; _win.Title = "HACC Demo"; _lastRunesUsed = "Narrow"; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } private void UnsetClickedEvent () @@ -174,6 +174,6 @@ public class RuneWidthGreaterThanOne : Scenario _labelV.Text = "あなたの名前を入力してください"; _win.Title = "デモエムポンズ"; _lastRunesUsed = "Wide"; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } } diff --git a/UICatalog/Scenarios/SingleBackgroundWorker.cs b/UICatalog/Scenarios/SingleBackgroundWorker.cs index 1650628e0..d75e31535 100644 --- a/UICatalog/Scenarios/SingleBackgroundWorker.cs +++ b/UICatalog/Scenarios/SingleBackgroundWorker.cs @@ -176,7 +176,7 @@ public class SingleBackgroundWorker : Scenario $"Worker {_startStaging}.{_startStaging:fff} was completed at {DateTime.Now}." ); _listLog.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var builderUI = new StagingUIController (_startStaging, e.Result as ObservableCollection); diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 0c2fe42b0..ee69d8104 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -754,7 +754,7 @@ public class UICatalogApp { Application.Force16Colors = args.NewValue == CheckState.Checked; MiForce16Colors!.Checked = Application.Force16Colors; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; _statusBar.Add ( @@ -1266,7 +1266,7 @@ public class UICatalogApp ((CheckBox)ShForce16Colors!.CommandView!).CheckedState = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; menuItems.Add (MiForce16Colors); diff --git a/UnitTests/Dialogs/DialogTests.cs b/UnitTests/Dialogs/DialogTests.cs index 54926aaba..969fe2e66 100644 --- a/UnitTests/Dialogs/DialogTests.cs +++ b/UnitTests/Dialogs/DialogTests.cs @@ -933,7 +933,7 @@ public class DialogTests dlg.Loaded += (s, a) => { - Refresh (); + LayoutAndDrawToplevels (); var expected = @$" ┌──────────────────┐ @@ -1038,7 +1038,7 @@ public class DialogTests } else if (iterations == 1) { - Refresh (); + LayoutAndDrawToplevels (); // BUGBUG: This seems wrong; is it a bug in Dim.Percent(85)?? No _ = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); @@ -1110,7 +1110,7 @@ public class DialogTests case 0: Top.SetNeedsLayout(); Top.SetNeedsDisplay(); - Refresh (); + LayoutAndDrawToplevels (); break; @@ -1119,7 +1119,7 @@ public class DialogTests break; case 2: - Refresh (); + LayoutAndDrawToplevels (); expected = @$" ┌───────────────────────┐ @@ -1136,7 +1136,7 @@ public class DialogTests break; case 3: - Refresh (); + LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @$" @@ -1155,7 +1155,7 @@ public class DialogTests break; case 4: - Refresh (); + LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre (expected, _output); diff --git a/UnitTests/Dialogs/MessageBoxTests.cs b/UnitTests/Dialogs/MessageBoxTests.cs index caad58da5..c4faded8c 100644 --- a/UnitTests/Dialogs/MessageBoxTests.cs +++ b/UnitTests/Dialogs/MessageBoxTests.cs @@ -219,7 +219,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -236,7 +236,7 @@ public class MessageBoxTests } else if (iterations == 2) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -291,7 +291,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -311,7 +311,7 @@ public class MessageBoxTests } else if (iterations == 2) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @$" @@ -361,7 +361,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.IsType (Application.Top); Assert.Equal (new (height, width), Application.Top.Frame.Size); @@ -398,7 +398,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.IsType (Application.Top); Assert.Equal (new (height, width), Application.Top.Frame.Size); @@ -431,7 +431,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.IsType (Application.Top); Assert.Equal (new (height, width), Application.Top.Frame.Size); @@ -471,7 +471,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); string expectedText = """ ┌────────────────────────────────────────────────────────────────────┐ diff --git a/UnitTests/Drawing/RulerTests.cs b/UnitTests/Drawing/RulerTests.cs index be9dd9859..d253edeba 100644 --- a/UnitTests/Drawing/RulerTests.cs +++ b/UnitTests/Drawing/RulerTests.cs @@ -68,7 +68,7 @@ public class RulerTests // Postive offset top.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); r.Draw (new (1, 1)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -83,7 +83,7 @@ public class RulerTests // Negative offset top.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); r.Draw (new (-1, 1)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -98,7 +98,7 @@ public class RulerTests // Clip top.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); r.Draw (new (10, 1)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -144,7 +144,7 @@ public class RulerTests ); f.SetNeedsDisplay(); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); r.Length = len; r.Draw (new (1, 0), 1); @@ -207,7 +207,7 @@ public class RulerTests // Postive offset f.SetNeedsDisplay (); - Application.Refresh (true); + Application.LayoutAndDrawToplevels (true); r.Draw (new (1, 1)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -237,7 +237,7 @@ public class RulerTests // Negative offset f.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); r.Draw (new (1, -1)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -268,7 +268,7 @@ public class RulerTests // Clip f.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); r.Draw (new (1, 10)); TestHelpers.AssertDriverContentsWithFrameAre ( @@ -343,7 +343,7 @@ public class RulerTests _output ); f.SetNeedsDisplay (); - Application.Refresh (true); + Application.LayoutAndDrawToplevels (true); r.Length = len; r.Draw (new (0, 1), 1); diff --git a/UnitTests/View/Draw/DrawTests.cs b/UnitTests/View/Draw/DrawTests.cs index 6404773f0..d21f9eafa 100644 --- a/UnitTests/View/Draw/DrawTests.cs +++ b/UnitTests/View/Draw/DrawTests.cs @@ -590,7 +590,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.X = -1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -605,12 +605,12 @@ public class DrawTests (ITestOutputHelper _output) ); content.X = -2; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre (@"", _output); content.X = 0; content.Y = -1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -625,7 +625,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -6; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -640,7 +640,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -19; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -651,12 +651,12 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -20; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); content.X = -2; content.Y = 0; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); top.Dispose (); } @@ -696,7 +696,7 @@ public class DrawTests (ITestOutputHelper _output) top.SubviewsLaidOut += Top_LayoutComplete; Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -707,7 +707,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.X = -1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -719,7 +719,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -730,12 +730,12 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -2; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); content.X = -20; content.Y = 0; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); top.Dispose (); @@ -783,7 +783,7 @@ public class DrawTests (ITestOutputHelper _output) top.Add (container); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -797,7 +797,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.X = -1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -812,12 +812,12 @@ public class DrawTests (ITestOutputHelper _output) ); content.X = -2; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre (@"", _output); content.X = 0; content.Y = -1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -832,7 +832,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -6; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -847,7 +847,7 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -19; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( """ @@ -858,12 +858,12 @@ public class DrawTests (ITestOutputHelper _output) ); content.Y = -20; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); content.X = -2; content.Y = 0; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("", _output); top.Dispose (); } diff --git a/UnitTests/View/SubviewTests.cs b/UnitTests/View/SubviewTests.cs index e25d923a4..75a3be55e 100644 --- a/UnitTests/View/SubviewTests.cs +++ b/UnitTests/View/SubviewTests.cs @@ -145,7 +145,7 @@ public class SubviewTests Assert.False (v2AddedToWin.CanFocus); Assert.False (svAddedTov1.CanFocus); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; winAddedToTop.Initialized += (s, e) => @@ -201,7 +201,7 @@ public class SubviewTests Application.Iteration += (s, a) => { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); top.Running = false; }; @@ -253,7 +253,7 @@ public class SubviewTests Assert.False (v1.CanFocus); Assert.False (v2.CanFocus); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; w.Initialized += (s, e) => @@ -297,7 +297,7 @@ public class SubviewTests v1.Add (sv1); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); t.Running = false; }; diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index 8778615fe..d53ff0209 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -212,7 +212,7 @@ cccccccccccccccccccc", Assert.True (v.HasFocus); v.SetFocus (); Assert.True (v.HasFocus); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverAttributesAre ( @" diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs index 3031d9f73..3cadb07a2 100644 --- a/UnitTests/Views/CheckBoxTests.cs +++ b/UnitTests/Views/CheckBoxTests.cs @@ -359,7 +359,7 @@ public class CheckBoxTests (ITestOutputHelper output) Assert.Equal (new (0, 0, 30, 5), pos); checkBox.CheckedState = CheckState.Checked; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @$" ┌┤Test Demo 你├──────────────┐ @@ -429,7 +429,7 @@ public class CheckBoxTests (ITestOutputHelper output) Application.RunIteration (ref rs); Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame); Assert.Equal (_size25x1, checkBox2.TextFormatter.ConstrainToSize); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @$" ┌┤Test Demo 你├──────────────┐ @@ -480,7 +480,7 @@ public class CheckBoxTests (ITestOutputHelper output) Assert.Equal (new (0, 0, 30, 5), pos); checkBox.CheckedState = CheckState.Checked; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @$" ┌┤Test Demo 你├──────────────┐ @@ -531,7 +531,7 @@ public class CheckBoxTests (ITestOutputHelper output) Assert.Equal (new (0, 0, 30, 5), pos); checkBox.CheckedState = CheckState.Checked; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @$" ┌┤Test Demo 你├──────────────┐ diff --git a/UnitTests/Views/ContextMenuTests.cs b/UnitTests/Views/ContextMenuTests.cs index 668b46952..74369fc64 100644 --- a/UnitTests/Views/ContextMenuTests.cs +++ b/UnitTests/Views/ContextMenuTests.cs @@ -138,7 +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 (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new Rectangle (2, 2, 15, 4), top.Frame); Assert.Equal (top, Application.Top); @@ -209,7 +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 (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new Rectangle (2, 2, 15, 4), testWindow.Frame); @@ -275,7 +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 (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new Rectangle (2, 2, 15, 4), dialog.Frame); Assert.Equal (dialog, Application.Top); @@ -336,7 +336,7 @@ public class ContextMenuTests (ITestOutputHelper output) cm.Show (menuItems); Assert.Equal (new Point (-1, -2), cm.Position); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -351,7 +351,7 @@ public class ContextMenuTests (ITestOutputHelper output) cm.ForceMinimumPosToZero = false; cm.Show (menuItems); Assert.Equal (new Point (-1, -2), cm.Position); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" One │ @@ -443,7 +443,7 @@ public class ContextMenuTests (ITestOutputHelper output) Toplevel top = new (); Application.Begin (top); cm.Show (menuItems); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -463,7 +463,7 @@ public class ContextMenuTests (ITestOutputHelper output) ); cm.Show (menuItems); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" ┌─────────┐ @@ -801,7 +801,7 @@ public class ContextMenuTests (ITestOutputHelper output) Toplevel top = new (); Application.Begin (top); cm.Show (menuItems); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -815,7 +815,7 @@ public class ContextMenuTests (ITestOutputHelper output) cm.Position = new Point (5, 10); cm.Show (menuItems); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" ┌──────┐ @@ -936,7 +936,7 @@ public class ContextMenuTests (ITestOutputHelper output) Application.Begin (top); cm.Show (menuItems); Assert.Equal (Point.Empty, cm.Position); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -974,7 +974,7 @@ public class ContextMenuTests (ITestOutputHelper output) Application.Begin (top); cm.Show (menuItems); Assert.Equal (Point.Empty, cm.Position); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──── @@ -1085,7 +1085,7 @@ public class ContextMenuTests (ITestOutputHelper output) Application.Begin (top); cm.Show (menuItems); Assert.Equal (new Point (80, 25), cm.Position); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -1170,7 +1170,7 @@ public class ContextMenuTests (ITestOutputHelper output) Application.Begin (top); cm.Show (menuItems); Assert.True (ContextMenu.IsShow); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -1184,7 +1184,7 @@ public class ContextMenuTests (ITestOutputHelper output) cm.Hide (); Assert.False (ContextMenu.IsShow); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = ""; @@ -1224,7 +1224,7 @@ public class ContextMenuTests (ITestOutputHelper output) RunState rs = Application.Begin (top); cm.Show (menuItems); Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top!.Subviews [0].Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1317,7 +1317,7 @@ public class ContextMenuTests (ITestOutputHelper output) cm.Show (menuItems); Assert.Equal (new Rectangle (5, 11, 10, 5), Application.Top.Subviews [0].Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/FrameViewTests.cs b/UnitTests/Views/FrameViewTests.cs index 88a5c786c..8af00d227 100644 --- a/UnitTests/Views/FrameViewTests.cs +++ b/UnitTests/Views/FrameViewTests.cs @@ -50,7 +50,7 @@ public class FrameViewTests (ITestOutputHelper output) fv.Height = 5; fv.Width = 5; Assert.Equal (new (0, 0, 5, 5), fv.Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -65,7 +65,7 @@ public class FrameViewTests (ITestOutputHelper output) fv.X = 1; fv.Y = 2; Assert.Equal (new (1, 2, 5, 5), fv.Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -80,7 +80,7 @@ public class FrameViewTests (ITestOutputHelper output) fv.X = -1; fv.Y = -2; Assert.Equal (new (-1, -2, 5, 5), fv.Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -93,7 +93,7 @@ public class FrameViewTests (ITestOutputHelper output) fv.X = 7; fv.Y = 8; Assert.Equal (new (7, 8, 5, 5), fv.Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index 068ac2119..62419c43c 100644 --- a/UnitTests/Views/LabelTests.cs +++ b/UnitTests/Views/LabelTests.cs @@ -111,7 +111,7 @@ public class LabelTests (ITestOutputHelper output) label.Text = "Say Hello 你 changed"; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" ┌────────────────────────────┐ @@ -151,7 +151,7 @@ public class LabelTests (ITestOutputHelper output) label.Text = "Say Hello 你 changed"; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" ┌────────────────────────────┐ @@ -244,7 +244,7 @@ This TextFormatter (tf2) is rewritten. ", var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 16, 1), label.Frame); @@ -265,7 +265,7 @@ Demo Simple Rune var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.NotNull (label.Width); Assert.NotNull (label.Height); @@ -301,7 +301,7 @@ e var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" デ @@ -472,7 +472,7 @@ e var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 6, 3), label.Frame); Assert.Equal (new (0, 0, 4, 1), label.Viewport); @@ -496,7 +496,7 @@ e var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 6, 2), label.Frame); Assert.Equal (new (0, 0, 4, 1), label.Viewport); Application.Begin (top); @@ -1224,7 +1224,7 @@ e Assert.Equal (10, text.Length); //label.Width = Dim.Fill () - text.Length; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 5, 1), label.Frame); Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize); @@ -1283,7 +1283,7 @@ e Assert.Equal (10, text.Length); //label.Width = Dim.Fill () - text.Length; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 5, 1), label.Frame); Assert.Equal (new (5, 1), label.TextFormatter.ConstrainToSize); diff --git a/UnitTests/Views/ListViewTests.cs b/UnitTests/Views/ListViewTests.cs index 0ab0ecb33..29af6e3b6 100644 --- a/UnitTests/Views/ListViewTests.cs +++ b/UnitTests/Views/ListViewTests.cs @@ -56,7 +56,7 @@ public class ListViewTests (ITestOutputHelper output) top.Add (win); Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (12, 12); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (-1, lv.SelectedItem); @@ -305,7 +305,7 @@ public class ListViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -319,7 +319,7 @@ Item 4", // EnsureSelectedItemVisible is auto enabled on the OnSelectedChanged lv.SelectedItem = 6; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -343,7 +343,7 @@ Item 6", var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal ("Second ", GetContents (0)); Assert.Equal (new (' ', 7), GetContents (1)); @@ -725,7 +725,7 @@ Item 6", var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (1), lv.Border.Thickness); Assert.Equal (-1, lv.SelectedItem); @@ -799,7 +799,7 @@ Item 6", var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -812,7 +812,7 @@ Item 6", lv.LeftItem = 1; lv.TopItem = 1; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/MenuBarTests.cs b/UnitTests/Views/MenuBarTests.cs index 613c41508..c1a8599ec 100644 --- a/UnitTests/Views/MenuBarTests.cs +++ b/UnitTests/Views/MenuBarTests.cs @@ -100,7 +100,7 @@ public class MenuBarTests (ITestOutputHelper output) new () { Position = new (0, 0), Flags = MouseFlags.Button1Pressed, View = menu } ) ); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @$" @@ -880,7 +880,7 @@ public class MenuBarTests (ITestOutputHelper output) Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ──────┐ @@ -895,7 +895,7 @@ public class MenuBarTests (ITestOutputHelper output) menu.CloseAllMenus (); menu.Frame = new (-1, -2, menu.Frame.Width, menu.Frame.Height); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" One │ @@ -910,7 +910,7 @@ public class MenuBarTests (ITestOutputHelper output) menu.Frame = new (0, 0, menu.Frame.Width, menu.Frame.Height); ((FakeDriver)Application.Driver!).SetBufferSize (7, 5); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" ┌────── @@ -926,7 +926,7 @@ public class MenuBarTests (ITestOutputHelper output) menu.Frame = new (0, 0, menu.Frame.Width, menu.Frame.Height); ((FakeDriver)Application.Driver!).SetBufferSize (7, 3); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" ┌────── @@ -960,7 +960,7 @@ public class MenuBarTests (ITestOutputHelper output) Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ne @@ -972,7 +972,7 @@ wo menu.CloseAllMenus (); menu.Frame = new (-2, -2, menu.Frame.Width, menu.Frame.Height); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" wo @@ -984,7 +984,7 @@ wo menu.Frame = new (0, 0, menu.Frame.Width, menu.Frame.Height); ((FakeDriver)Application.Driver!).SetBufferSize (3, 2); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" On @@ -997,7 +997,7 @@ wo menu.Frame = new (0, 0, menu.Frame.Width, menu.Frame.Height); ((FakeDriver)Application.Driver!).SetBufferSize (3, 1); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expected = @" On @@ -1024,7 +1024,7 @@ wo Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────┐ @@ -1056,7 +1056,7 @@ wo Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" One @@ -1479,7 +1479,7 @@ wo Application.Begin (top); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1527,7 +1527,7 @@ wo Application.Begin (top); menu.OpenMenu (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1660,7 +1660,7 @@ wo ); Assert.True (menu.NewKeyDownEvent (Key.CursorRight)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1771,7 +1771,7 @@ wo ); Assert.True (menu.NewKeyDownEvent (Key.CursorRight)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1942,7 +1942,7 @@ wo Application.Iteration += (s, a) => { Toplevel top = Application.Top; - Application.Refresh(); + Application.LayoutAndDrawToplevels(); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1974,7 +1974,7 @@ wo ); Assert.True (top.Subviews [0].NewKeyDownEvent (Key.CursorRight)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/RadioGroupTests.cs b/UnitTests/Views/RadioGroupTests.cs index ad0ccd630..5b3aa1b1f 100644 --- a/UnitTests/Views/RadioGroupTests.cs +++ b/UnitTests/Views/RadioGroupTests.cs @@ -549,7 +549,7 @@ public class RadioGroupTests (ITestOutputHelper output) Assert.Equal (new (0, 0, 30, 5), pos); rg.Orientation = Orientation.Horizontal; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (Orientation.Horizontal, rg.Orientation); Assert.Equal (2, rg.HorizontalSpace); @@ -570,7 +570,7 @@ public class RadioGroupTests (ITestOutputHelper output) Assert.Equal (new (0, 0, 30, 5), pos); rg.HorizontalSpace = 4; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (Orientation.Horizontal, rg.Orientation); Assert.Equal (4, rg.HorizontalSpace); diff --git a/UnitTests/Views/ScrollBarViewTests.cs b/UnitTests/Views/ScrollBarViewTests.cs index efc0f4530..57be234e1 100644 --- a/UnitTests/Views/ScrollBarViewTests.cs +++ b/UnitTests/Views/ScrollBarViewTests.cs @@ -178,7 +178,7 @@ public class ScrollBarViewTests Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (width, height); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌─┐ @@ -231,7 +231,7 @@ public class ScrollBarViewTests { _scrollBar = new ScrollBarView (_hostView, true); Application.Begin (_hostView.SuperView as Toplevel); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); AddHandlers (); @@ -252,7 +252,7 @@ public class ScrollBarViewTests { _scrollBar = new ScrollBarView (_hostView, true); Application.Begin (_hostView.SuperView as Toplevel); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); AddHandlers (); @@ -288,7 +288,7 @@ public class ScrollBarViewTests { _scrollBar = new ScrollBarView (_hostView, true); Application.Begin (_hostView.SuperView as Toplevel); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); AddHandlers (); @@ -312,7 +312,7 @@ public class ScrollBarViewTests var sbv = new ScrollBarView (label, true, false) { Size = 100 }; Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.True (sbv.Visible); @@ -430,7 +430,7 @@ This is a test Assert.Equal (newScrollBarView.Position, listView.LeftItem); listView.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; @@ -511,7 +511,7 @@ This is a test Assert.Equal (newScrollBarView.Position, listView.TopItem); listView.SetNeedsDisplay (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); }; @@ -562,7 +562,7 @@ This is a test var sbv = new ScrollBarView (label, true) { Size = 100 }; sbv.OtherScrollBarView.Size = 100; Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (100, sbv.Size); Assert.Equal (100, sbv.OtherScrollBarView.Size); @@ -646,7 +646,7 @@ This is a tes▼ var sbv = new ScrollBarView (label, true, false) { Size = 100 }; Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (100, sbv.Size); Assert.Null (sbv.OtherScrollBarView); @@ -691,7 +691,7 @@ This is a test { _scrollBar = new ScrollBarView (_hostView, true); Application.Begin (_hostView.SuperView as Toplevel); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); AddHandlers (); @@ -1168,7 +1168,7 @@ This is a test var sbv = new ScrollBarView (label, true, false) { Size = 5 }; Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (5, sbv.Size); Assert.Null (sbv.OtherScrollBarView); @@ -1196,7 +1196,7 @@ This is a test ", Assert.Equal (5, sbv.Size); Assert.False (sbv.ShowScrollIndicator); Assert.True (sbv.Visible); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.False (sbv.Visible); TestHelpers.AssertDriverContentsWithFrameAre ( diff --git a/UnitTests/Views/ScrollViewTests.cs b/UnitTests/Views/ScrollViewTests.cs index 6122f0e64..92ebb6dda 100644 --- a/UnitTests/Views/ScrollViewTests.cs +++ b/UnitTests/Views/ScrollViewTests.cs @@ -195,7 +195,7 @@ public class ScrollViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (topLabel, sv, bottomLabel); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -250,7 +250,7 @@ public class ScrollViewTests (ITestOutputHelper output) sv.Add (new Window { X = 3, Y = 3, Width = 20, Height = 20 }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -297,7 +297,7 @@ public class ScrollViewTests (ITestOutputHelper output) ); sv.ContentOffset = new (20, 20); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -461,7 +461,7 @@ public class ScrollViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (sv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (-25, -25), sv.ContentOffset); Assert.Equal (new (50, 50), sv.GetContentSize ()); @@ -497,7 +497,7 @@ public class ScrollViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (sv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (50, sv.GetContentSize ().Width); Assert.Equal (50, sv.GetContentSize ().Height); @@ -567,7 +567,7 @@ public class ScrollViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (win); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); var expected = @" ┌──────────────────┐ @@ -898,7 +898,7 @@ public class ScrollViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (sv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -917,7 +917,7 @@ public class ScrollViewTests (ITestOutputHelper output) sv.ContentOffset = new (5, 5); sv.LayoutSubviews (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1085,7 +1085,7 @@ public class ScrollViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (sv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (4, sv.Subviews.Count); Assert.Equal (2, sv.Subviews [0].Subviews.Count); diff --git a/UnitTests/Views/TabViewTests.cs b/UnitTests/Views/TabViewTests.cs index dc66cc298..5c9d80f4a 100644 --- a/UnitTests/Views/TabViewTests.cs +++ b/UnitTests/Views/TabViewTests.cs @@ -145,21 +145,21 @@ public class TabViewTests (ITestOutputHelper output) { args = new () { ScreenPosition = new (i, 1), Flags = MouseFlags.ReportMousePosition }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Null (clicked); Assert.Equal (tab1, tv.SelectedTab); } args = new () { ScreenPosition = new (3, 1), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab1, clicked); Assert.Equal (tab1, tv.SelectedTab); // Click to tab2 args = new () { ScreenPosition = new (6, 1), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab2, clicked); Assert.Equal (tab2, tv.SelectedTab); @@ -172,7 +172,7 @@ public class TabViewTests (ITestOutputHelper output) args = new () { ScreenPosition = new (3, 1), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); // Tab 1 was clicked but event handler blocked navigation Assert.Equal (tab1, clicked); @@ -180,7 +180,7 @@ public class TabViewTests (ITestOutputHelper output) args = new () { ScreenPosition = new (12, 1), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); // Clicking beyond last tab should raise event with null Tab Assert.Null (clicked); @@ -235,7 +235,7 @@ public class TabViewTests (ITestOutputHelper output) // Click the right arrow var args = new MouseEventArgs { ScreenPosition = new (6, 2), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Null (clicked); Assert.Equal (tab1, oldChanged); Assert.Equal (tab2, newChanged); @@ -255,7 +255,7 @@ public class TabViewTests (ITestOutputHelper output) // Click the left arrow args = new () { ScreenPosition = new (0, 2), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Null (clicked); Assert.Equal (tab2, oldChanged); Assert.Equal (tab1, newChanged); @@ -326,7 +326,7 @@ public class TabViewTests (ITestOutputHelper output) // Click the right arrow var args = new MouseEventArgs { ScreenPosition = new (7, 3), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Null (clicked); Assert.Equal (tab1, oldChanged); Assert.Equal (tab2, newChanged); @@ -348,7 +348,7 @@ public class TabViewTests (ITestOutputHelper output) // Click the left arrow args = new () { ScreenPosition = new (1, 3), Flags = MouseFlags.Button1Clicked }; Application.RaiseMouseEvent (args); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Null (clicked); Assert.Equal (tab2, oldChanged); Assert.Equal (tab1, newChanged); @@ -399,7 +399,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the cursor up key to focus the selected tab Application.RaiseKeyDownEvent (Key.CursorUp); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); // Is the selected tab focused Assert.Equal (tab1, tv.SelectedTab); @@ -417,7 +417,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the cursor right key to select the next tab Application.RaiseKeyDownEvent (Key.CursorRight); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab1, oldChanged); Assert.Equal (tab2, newChanged); Assert.Equal (tab2, tv.SelectedTab); @@ -475,7 +475,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the cursor left key to select the previous tab Application.RaiseKeyDownEvent (Key.CursorLeft); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab2, oldChanged); Assert.Equal (tab1, newChanged); Assert.Equal (tab1, tv.SelectedTab); @@ -485,7 +485,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the end key to select the last tab Application.RaiseKeyDownEvent (Key.End); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab1, oldChanged); Assert.Equal (tab2, newChanged); Assert.Equal (tab2, tv.SelectedTab); @@ -494,7 +494,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the home key to select the first tab Application.RaiseKeyDownEvent (Key.Home); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab2, oldChanged); Assert.Equal (tab1, newChanged); Assert.Equal (tab1, tv.SelectedTab); @@ -503,7 +503,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the page down key to select the next set of tabs Application.RaiseKeyDownEvent (Key.PageDown); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab1, oldChanged); Assert.Equal (tab2, newChanged); Assert.Equal (tab2, tv.SelectedTab); @@ -512,7 +512,7 @@ public class TabViewTests (ITestOutputHelper output) // Press the page up key to select the previous set of tabs Application.RaiseKeyDownEvent (Key.PageUp); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (tab2, oldChanged); Assert.Equal (tab1, newChanged); Assert.Equal (tab1, tv.SelectedTab); diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index 83ba93cc8..b4cbaa7d1 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -723,7 +723,7 @@ public class TextViewTests var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); @@ -796,7 +796,7 @@ This is the second line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.True (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); @@ -869,7 +869,7 @@ This is the second line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); @@ -942,7 +942,7 @@ This is the second line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.True (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); @@ -6738,7 +6738,7 @@ This is the second line. Assert.True (_textView.Multiline); _textView.NewKeyDownEvent (Key.Tab); Assert.Equal ("\tTAB to jump between text fields.", _textView.Text); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6747,7 +6747,7 @@ TAB to jump between text field", ); _textView.TabWidth = 4; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6758,7 +6758,7 @@ TAB to jump between text field", _textView.NewKeyDownEvent (Key.Tab.WithShift); Assert.Equal ("TAB to jump between text fields.", _textView.Text); Assert.True (_textView.NeedsDisplay); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6824,7 +6824,7 @@ TAB to jump between text field", top.Add (win); Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (15, 15); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); //this passes Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre ( @@ -6853,7 +6853,7 @@ TAB to jump between text field", tv.Used = false; tv.CursorPosition = Point.Empty; tv.InsertText ("\r\naaa\r\nbbb"); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6902,7 +6902,7 @@ TAB to jump between text field", top.Add (win); Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (15, 15); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); //this passes Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre ( @@ -6931,7 +6931,7 @@ TAB to jump between text field", tv.Used = false; tv.CursorPosition = Point.Empty; tv.InsertText ("\naaa\nbbb"); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -7000,7 +7000,7 @@ TAB to jump between text field", var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); @@ -8173,7 +8173,7 @@ line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (Point.Empty, tv.CursorPosition); Assert.Equal (0, tv.LeftColumn); @@ -8187,7 +8187,7 @@ aaaa tv.CursorPosition = new Point (5, 0); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8198,7 +8198,7 @@ aaa ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8209,7 +8209,7 @@ aa ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8220,7 +8220,7 @@ a ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8231,7 +8231,7 @@ a ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8253,7 +8253,7 @@ a _textView.Text = "Line 1.\nLine 2."; _textView.WordWrap = true; Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.True (_textView.WordWrap); @@ -8268,12 +8268,12 @@ Line 2.", Assert.Equal ("Line 1.", _textView.SelectedText); Assert.True (_textView.NewKeyDownEvent (new Key (del))); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ("Line 2.", _output); Assert.True (_textView.NewKeyDownEvent (Key.H.WithShift)); Assert.NotEqual (Rectangle.Empty, _textView._needsDisplayRect); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -8910,7 +8910,7 @@ line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -8922,7 +8922,7 @@ This is the second line.", tv.Width = 10; tv.Height = 25; tv.WordWrap = true; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -8964,7 +8964,7 @@ line. ", var top = new Toplevel (); top.Add (tv); RunState rs = Application.Begin (top); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.True (tv.InheritsPreviousAttribute); @@ -9006,7 +9006,7 @@ Error "; TestHelpers.AssertDriverAttributesAre (expectedColor, _output, Application.Driver, attributes); tv.WordWrap = true; - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output); TestHelpers.AssertDriverAttributesAre (expectedColor, _output, Application.Driver, attributes); @@ -9018,7 +9018,7 @@ Error "; tv.IsSelecting = false; tv.CursorPosition = new (2, 4); tv.Paste (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expectedText = @" TopLevel @@ -9053,7 +9053,7 @@ Dialogror "; tv.IsSelecting = false; tv.CursorPosition = new (2, 4); tv.Paste (); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); expectedText = @" TopLevel diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 301c44307..b200b68f7 100644 --- a/UnitTests/Views/ToplevelTests.cs +++ b/UnitTests/Views/ToplevelTests.cs @@ -456,7 +456,7 @@ public partial class ToplevelTests (ITestOutputHelper output) ScreenPosition = new (2, 2), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (Application.Top.Border, Application.MouseGrabView); Assert.Equal (new (1, 2, 10, 3), Application.Top.Frame); @@ -478,7 +478,7 @@ public partial class ToplevelTests (ITestOutputHelper output) { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (Application.Top!.Border, Application.MouseGrabView); Assert.Equal (new (1, 1, 10, 3), Application.Top.Frame); @@ -497,7 +497,7 @@ public partial class ToplevelTests (ITestOutputHelper output) // Ungrab the mouse Application.RaiseMouseEvent (new () { ScreenPosition = new (2, 1), Flags = MouseFlags.Button1Released }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Null (Application.MouseGrabView); } @@ -752,7 +752,7 @@ public partial class ToplevelTests (ITestOutputHelper output) top.SetNeedsLayout (); top.LayoutSubviews (); Assert.Equal (new (6, 6, 191, 91), win.Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Application.RaiseMouseEvent ( new () @@ -763,7 +763,7 @@ public partial class ToplevelTests (ITestOutputHelper output) top.SetNeedsLayout (); top.LayoutSubviews (); Assert.Equal (new (2, 2, 195, 95), win.Frame); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 5), Flags = MouseFlags.Button1Released }); @@ -784,7 +784,7 @@ public partial class ToplevelTests (ITestOutputHelper output) RunState rsTop = Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (40, 10); RunState rsWindow = Application.Begin (window); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 40, 10), top.Frame); Assert.Equal (new (0, 0, 20, 3), window.Frame); @@ -800,7 +800,7 @@ public partial class ToplevelTests (ITestOutputHelper output) ScreenPosition = new (-11, -4), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 40, 10), top.Frame); Assert.Equal (new (-11, -4, 20, 3), window.Frame); @@ -813,7 +813,7 @@ public partial class ToplevelTests (ITestOutputHelper output) ScreenPosition = new (-1, -1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 20, 3), top.Frame); Assert.Equal (new (-1, -1, 20, 3), window.Frame); @@ -826,7 +826,7 @@ public partial class ToplevelTests (ITestOutputHelper output) ScreenPosition = new (-1, -1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 19, 2), top.Frame); Assert.Equal (new (-1, -1, 20, 3), window.Frame); @@ -836,7 +836,7 @@ public partial class ToplevelTests (ITestOutputHelper output) ScreenPosition = new (18, 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 19, 2), top.Frame); Assert.Equal (new (18, 1, 20, 3), window.Frame); @@ -847,7 +847,7 @@ public partial class ToplevelTests (ITestOutputHelper output) ScreenPosition = new (19, 2), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); Assert.Equal (new (0, 0, 19, 2), top.Frame); Assert.Equal (new (19, 2, 20, 3), window.Frame); //TestHelpers.AssertDriverContentsWithFrameAre (@"", output); @@ -986,7 +986,7 @@ public partial class ToplevelTests (ITestOutputHelper output) Application.RaiseMouseEvent (new () { ScreenPosition = new (5, 2), Flags = MouseFlags.Button1Clicked }); - Application.Refresh (); + Application.LayoutAndDrawToplevels (); TestHelpers.AssertDriverContentsWithFrameAre ( @$" diff --git a/UnitTests/Views/ViewDisposalTest.cs b/UnitTests/Views/ViewDisposalTest.cs index 9938415a0..a25dd392a 100644 --- a/UnitTests/Views/ViewDisposalTest.cs +++ b/UnitTests/Views/ViewDisposalTest.cs @@ -60,7 +60,7 @@ public class ViewDisposalTest (ITestOutputHelper output) // make sure the application is doing to the views whatever its supposed to do to the views for (var i = 0; i < 100; i++) { - Application.Refresh (); + Application.LayoutAndDrawToplevels (); } top.Remove (container);