From 563d58a380112a4961977226c4b487190a1ace89 Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 3 Nov 2024 11:13:24 -0700 Subject: [PATCH] Code cleanup and refactor --- CommunityToolkitExample/LoginView.cs | 2 +- .../Application/Application.Keyboard.cs | 2 +- Terminal.Gui/Application/Application.Run.cs | 7 ++- .../Application/Application.Screen.cs | 2 +- Terminal.Gui/Views/Menu/Menu.cs | 2 +- Terminal.Gui/Views/Menu/MenuBar.cs | 2 +- UICatalog/Scenarios/GraphViewExample.cs | 2 +- UICatalog/Scenarios/Images.cs | 2 +- UICatalog/Scenarios/Localization.cs | 2 +- .../Scenarios/RuneWidthGreaterThanOne.cs | 6 +-- UICatalog/Scenarios/SingleBackgroundWorker.cs | 2 +- UICatalog/UICatalog.cs | 4 +- UnitTests/Dialogs/MessageBoxTests.cs | 16 +++---- UnitTests/View/SubviewTests.cs | 8 ++-- UnitTests/View/ViewTests.cs | 2 +- UnitTests/Views/CheckBoxTests.cs | 8 ++-- UnitTests/Views/FrameViewTests.cs | 8 ++-- UnitTests/Views/LabelTests.cs | 18 ++++---- UnitTests/Views/ListViewTests.cs | 14 +++--- UnitTests/Views/MenuBarTests.cs | 34 +++++++------- UnitTests/Views/RadioGroupTests.cs | 4 +- UnitTests/Views/TextViewTests.cs | 46 +++++++++---------- UnitTests/Views/ToplevelTests.cs | 22 ++++----- UnitTests/Views/ViewDisposalTest.cs | 2 +- 24 files changed, 108 insertions(+), 109 deletions(-) diff --git a/CommunityToolkitExample/LoginView.cs b/CommunityToolkitExample/LoginView.cs index f7a572c65..7f8fbe53d 100644 --- a/CommunityToolkitExample/LoginView.cs +++ b/CommunityToolkitExample/LoginView.cs @@ -59,7 +59,7 @@ internal partial class LoginView : IRecipient> } } SetText(); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } private void SetText () diff --git a/Terminal.Gui/Application/Application.Keyboard.cs b/Terminal.Gui/Application/Application.Keyboard.cs index 28091cfc0..a883dea8e 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 () => { - LayoutAndDrawToplevels (); + LayoutAndDraw (); return true; } diff --git a/Terminal.Gui/Application/Application.Run.cs b/Terminal.Gui/Application/Application.Run.cs index c8793f7a9..e40e30c30 100644 --- a/Terminal.Gui/Application/Application.Run.cs +++ b/Terminal.Gui/Application/Application.Run.cs @@ -495,13 +495,12 @@ public static partial class Application // Run (Begin, Run, End, Stop) /// Wakes up the running application that might be waiting on input. public static void Wakeup () { MainLoop?.Wakeup (); } - // TODO: Rename this to LayoutAndDrawRunnables in https://github.com/gui-cs/Terminal.Gui/issues/2491 /// /// 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 LayoutAndDrawToplevels (bool forceDraw = false) + public static void LayoutAndDraw (bool forceDraw = false) { bool neededLayout = View.Layout (TopLevels.Reverse (), Screen.Size); @@ -588,7 +587,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) return firstIteration; } - LayoutAndDrawToplevels (); + LayoutAndDraw (); if (PositionCursor ()) { @@ -688,6 +687,6 @@ public static partial class Application // Run (Begin, Run, End, Stop) runState.Toplevel = null; runState.Dispose (); - LayoutAndDrawToplevels (); + LayoutAndDraw (); } } diff --git a/Terminal.Gui/Application/Application.Screen.cs b/Terminal.Gui/Application/Application.Screen.cs index a57334202..d2d04295e 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 (); } - LayoutAndDrawToplevels (); + LayoutAndDraw (); return true; } diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs index ce1710312..fa38e0dda 100644 --- a/Terminal.Gui/Views/Menu/Menu.cs +++ b/Terminal.Gui/Views/Menu/Menu.cs @@ -609,7 +609,7 @@ internal sealed class Menu : View Application.UngrabMouse (); _host.CloseAllMenus (); Application.Driver!.ClearContents (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); _host.Run (action); } diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index d66d2a573..7bba8b714 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); _openedByAltKey = true; return Run (item.Action); diff --git a/UICatalog/Scenarios/GraphViewExample.cs b/UICatalog/Scenarios/GraphViewExample.cs index cb60237db..056086c64 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } private void Margin (bool left, bool increase) diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs index b8e3eb37c..6a7aebffc 100644 --- a/UICatalog/Scenarios/Images.cs +++ b/UICatalog/Scenarios/Images.cs @@ -288,7 +288,7 @@ public class Images : Scenario _imageView.SetImage (img); ApplyShowTabViewHack (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } private void ApplyShowTabViewHack () diff --git a/UICatalog/Scenarios/Localization.cs b/UICatalog/Scenarios/Localization.cs index 1a32b6c2c..994b5bd8d 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } public override void Main () diff --git a/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs b/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs index 65417b01f..8450d1c66 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } private void UnsetClickedEvent () @@ -174,6 +174,6 @@ public class RuneWidthGreaterThanOne : Scenario _labelV.Text = "あなたの名前を入力してください"; _win.Title = "デモエムポンズ"; _lastRunesUsed = "Wide"; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } } diff --git a/UICatalog/Scenarios/SingleBackgroundWorker.cs b/UICatalog/Scenarios/SingleBackgroundWorker.cs index faf7ca7f5..ca51321ed 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.SetNeedsDraw (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); var builderUI = new StagingUIController (_startStaging, e.Result as ObservableCollection); diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 3df0ebf30..4598e9365 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); }; _statusBar.Add ( @@ -1266,7 +1266,7 @@ public class UICatalogApp ((CheckBox)ShForce16Colors!.CommandView!).CheckedState = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); }; menuItems.Add (MiForce16Colors); diff --git a/UnitTests/Dialogs/MessageBoxTests.cs b/UnitTests/Dialogs/MessageBoxTests.cs index c4faded8c..6d7176b03 100644 --- a/UnitTests/Dialogs/MessageBoxTests.cs +++ b/UnitTests/Dialogs/MessageBoxTests.cs @@ -219,7 +219,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -236,7 +236,7 @@ public class MessageBoxTests } else if (iterations == 2) { - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -291,7 +291,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -311,7 +311,7 @@ public class MessageBoxTests } else if (iterations == 2) { - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @$" @@ -361,7 +361,7 @@ public class MessageBoxTests } else if (iterations == 1) { - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); string expectedText = """ ┌────────────────────────────────────────────────────────────────────┐ diff --git a/UnitTests/View/SubviewTests.cs b/UnitTests/View/SubviewTests.cs index 75a3be55e..34826427d 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); }; winAddedToTop.Initialized += (s, e) => @@ -201,7 +201,7 @@ public class SubviewTests Application.Iteration += (s, a) => { - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); top.Running = false; }; @@ -253,7 +253,7 @@ public class SubviewTests Assert.False (v1.CanFocus); Assert.False (v2.CanFocus); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); }; w.Initialized += (s, e) => @@ -297,7 +297,7 @@ public class SubviewTests v1.Add (sv1); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); t.Running = false; }; diff --git a/UnitTests/View/ViewTests.cs b/UnitTests/View/ViewTests.cs index 8bafb0c08..d92c2d019 100644 --- a/UnitTests/View/ViewTests.cs +++ b/UnitTests/View/ViewTests.cs @@ -210,7 +210,7 @@ cccccccccccccccccccc", Assert.True (v.HasFocus); v.SetFocus (); Assert.True (v.HasFocus); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverAttributesAre ( @" diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs index 3cadb07a2..1579a1c2b 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expected = @$" ┌┤Test Demo 你├──────────────┐ diff --git a/UnitTests/Views/FrameViewTests.cs b/UnitTests/Views/FrameViewTests.cs index 8af00d227..ee43d04e8 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/LabelTests.cs b/UnitTests/Views/LabelTests.cs index 39391c21b..c58be7974 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expected = @" ┌────────────────────────────┐ @@ -151,7 +151,7 @@ public class LabelTests (ITestOutputHelper output) label.Text = "Say Hello 你 changed"; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expected = @" ┌────────────────────────────┐ @@ -244,7 +244,7 @@ This TextFormatter (tf2) is rewritten. ", var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.NotNull (label.Width); Assert.NotNull (label.Height); @@ -301,7 +301,7 @@ e var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); var expected = @" デ @@ -472,7 +472,7 @@ e var top = new Toplevel (); top.Add (label); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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 c809cc6e0..965c7107d 100644 --- a/UnitTests/Views/ListViewTests.cs +++ b/UnitTests/Views/ListViewTests.cs @@ -56,7 +56,7 @@ public class ListViewTests (ITestOutputHelper output) top.Add (win); RunState rs = Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (12, 12); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (-1, lv.SelectedItem); @@ -304,7 +304,7 @@ public class ListViewTests (ITestOutputHelper output) var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -318,7 +318,7 @@ Item 4", // EnsureSelectedItemVisible is auto enabled on the OnSelectedChanged lv.SelectedItem = 6; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -342,7 +342,7 @@ Item 6", var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal ("Second ", GetContents (0)); Assert.Equal (new (' ', 7), GetContents (1)); @@ -724,7 +724,7 @@ Item 6", var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (new (1), lv.Border.Thickness); Assert.Equal (-1, lv.SelectedItem); @@ -798,7 +798,7 @@ Item 6", var top = new Toplevel (); top.Add (lv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -811,7 +811,7 @@ Item 6", lv.LeftItem = 1; lv.TopItem = 1; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/MenuBarTests.cs b/UnitTests/Views/MenuBarTests.cs index 96c6e0807..5abff5a95 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @$" @@ -880,7 +880,7 @@ public class MenuBarTests (ITestOutputHelper output) Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expected = @" ┌────── @@ -960,7 +960,7 @@ public class MenuBarTests (ITestOutputHelper output) Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); var expected = @" ne @@ -972,7 +972,7 @@ wo menu.CloseAllMenus (); menu.Frame = new (-2, -2, menu.Frame.Width, menu.Frame.Height); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expected = @" On @@ -1024,7 +1024,7 @@ wo Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); var expected = @" ┌──────┐ @@ -1056,7 +1056,7 @@ wo Toplevel top = new (); Application.Begin (top); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); var expected = @" One @@ -1479,7 +1479,7 @@ wo Application.Begin (top); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1527,7 +1527,7 @@ wo Application.Begin (top); menu.OpenMenu (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1661,7 +1661,7 @@ wo ); Assert.True (menu.NewKeyDownEvent (Key.CursorRight)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1773,7 +1773,7 @@ wo ); Assert.True (menu.NewKeyDownEvent (Key.CursorRight)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1945,7 +1945,7 @@ wo Application.Iteration += (s, a) => { Toplevel top = Application.Top; - Application.LayoutAndDrawToplevels(); + Application.LayoutAndDraw(); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -1977,7 +1977,7 @@ wo ); Assert.True (top.Subviews [0].NewKeyDownEvent (Key.CursorRight)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" diff --git a/UnitTests/Views/RadioGroupTests.cs b/UnitTests/Views/RadioGroupTests.cs index 5b3aa1b1f..8c11b5b6e 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (Orientation.Horizontal, rg.Orientation); Assert.Equal (4, rg.HorizontalSpace); diff --git a/UnitTests/Views/TextViewTests.cs b/UnitTests/Views/TextViewTests.cs index d55cfc84d..d1ed9fd74 100644 --- a/UnitTests/Views/TextViewTests.cs +++ b/UnitTests/Views/TextViewTests.cs @@ -6742,7 +6742,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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6751,7 +6751,7 @@ TAB to jump between text field", ); _textView.TabWidth = 4; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6762,7 +6762,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.NeedsDraw); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6828,7 +6828,7 @@ TAB to jump between text field", top.Add (win); Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (15, 15); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); //this passes Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre ( @@ -6857,7 +6857,7 @@ TAB to jump between text field", tv.Used = false; tv.CursorPosition = Point.Empty; tv.InsertText ("\r\naaa\r\nbbb"); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -6906,7 +6906,7 @@ TAB to jump between text field", top.Add (win); Application.Begin (top); ((FakeDriver)Application.Driver!).SetBufferSize (15, 15); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); //this passes Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre ( @@ -6935,7 +6935,7 @@ TAB to jump between text field", tv.Used = false; tv.CursorPosition = Point.Empty; tv.InsertText ("\naaa\nbbb"); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -7004,7 +7004,7 @@ TAB to jump between text field", var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.False (tv.WordWrap); Assert.Equal (Point.Empty, tv.CursorPosition); @@ -8177,7 +8177,7 @@ line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (Point.Empty, tv.CursorPosition); Assert.Equal (0, tv.LeftColumn); @@ -8191,7 +8191,7 @@ aaaa tv.CursorPosition = new Point (5, 0); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8202,7 +8202,7 @@ aaa ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8213,7 +8213,7 @@ aa ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8224,7 +8224,7 @@ a ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8235,7 +8235,7 @@ a ); Assert.True (tv.NewKeyDownEvent (Key.Backspace)); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (0, tv.LeftColumn); TestHelpers.AssertDriverContentsAre ( @@ -8257,7 +8257,7 @@ a _textView.Text = "Line 1.\nLine 2."; _textView.WordWrap = true; Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.True (_textView.WordWrap); @@ -8272,12 +8272,12 @@ Line 2.", Assert.Equal ("Line 1.", _textView.SelectedText); Assert.True (_textView.NewKeyDownEvent (new Key (del))); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ("Line 2.", _output); Assert.True (_textView.NewKeyDownEvent (Key.H.WithShift)); Assert.NotEqual (Rectangle.Empty, _textView._needsDrawRect); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -8915,7 +8915,7 @@ line. var top = new Toplevel (); top.Add (tv); Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -8927,7 +8927,7 @@ This is the second line.", tv.Width = 10; tv.Height = 25; tv.WordWrap = true; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre ( @" @@ -8969,7 +8969,7 @@ line. ", var top = new Toplevel (); top.Add (tv); RunState rs = Application.Begin (top); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.True (tv.InheritsPreviousAttribute); @@ -9011,7 +9011,7 @@ Error "; TestHelpers.AssertDriverAttributesAre (expectedColor, _output, Application.Driver, attributes); tv.WordWrap = true; - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); TestHelpers.AssertDriverContentsWithFrameAre (expectedText, _output); TestHelpers.AssertDriverAttributesAre (expectedColor, _output, Application.Driver, attributes); @@ -9023,7 +9023,7 @@ Error "; tv.IsSelecting = false; tv.CursorPosition = new (2, 4); tv.Paste (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expectedText = @" TopLevel @@ -9058,7 +9058,7 @@ Dialogror "; tv.IsSelecting = false; tv.CursorPosition = new (2, 4); tv.Paste (); - Application.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); expectedText = @" TopLevel diff --git a/UnitTests/Views/ToplevelTests.cs b/UnitTests/Views/ToplevelTests.cs index 4dda14090..9bab94026 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); Assert.Equal (new (0, 0, 19, 2), top.Frame); Assert.Equal (new (19, 2, 20, 3), window.Frame); //TestHelpers.AssertDriverContentsWithFrameAre (@"", output); diff --git a/UnitTests/Views/ViewDisposalTest.cs b/UnitTests/Views/ViewDisposalTest.cs index a25dd392a..1c70f5335 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.LayoutAndDrawToplevels (); + Application.LayoutAndDraw (); } top.Remove (container);