diff --git a/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs b/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs index 4e7679b6b..1eb68f1d1 100644 --- a/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs +++ b/Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs @@ -39,7 +39,6 @@ public class CharacterMap : Scenario { X = 0, Y = 1, - Width = Dim.Fill (Dim.Func (() => _categoryList!.Frame.Width)), Height = Dim.Fill (), // SchemeName = "Base" @@ -172,6 +171,8 @@ public class CharacterMap : Scenario }; top.Add (menu); + _charMap.Width = Dim.Fill (Dim.FuncWithView (v => v!.Frame.Width, _categoryList)); + _charMap.SelectedCodePoint = 0; _charMap.SetFocus (); diff --git a/Terminal.Gui/App/Application.Run.cs b/Terminal.Gui/App/Application.Run.cs index 30c1384a3..eafe91f14 100644 --- a/Terminal.Gui/App/Application.Run.cs +++ b/Terminal.Gui/App/Application.Run.cs @@ -189,7 +189,7 @@ public static partial class Application // Run (Begin, Run, End, Stop) if (!toplevel.IsInitialized) { toplevel.BeginInit (); - toplevel.EndInit (); // Calls Layout + toplevel.EndInit (); // Calls SetNeedsLayout } // Call ConfigurationManager Apply here to ensure all subscribers to ConfigurationManager.Applied @@ -212,8 +212,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. - Invoke (() => { }); + LayoutAndDraw (true); return rs; } diff --git a/Terminal.Gui/ViewBase/Layout/Dim.cs b/Terminal.Gui/ViewBase/Layout/Dim.cs index 83cc2e42e..c674d3333 100644 --- a/Terminal.Gui/ViewBase/Layout/Dim.cs +++ b/Terminal.Gui/ViewBase/Layout/Dim.cs @@ -148,6 +148,16 @@ public abstract record Dim : IEqualityOperators /// The returned from the function. public static Dim Func (Func function) { return new DimFunc (function); } + /// + /// Creates a function object that computes the dimension based on the passed view and by executing + /// the provided function. + /// The function will be called every time the dimension is needed. + /// + /// The function to be executed. + /// The view where the data will be retrieved. + /// The returned from the function based on the passed view. + public static Dim FuncWithView (Func function, View? view) { return new DimFuncWithView (function, view); } + /// Creates a object that tracks the Height of the specified . /// The height of the other . /// The view that will be tracked. diff --git a/Terminal.Gui/ViewBase/Layout/DimFuncWithView.cs b/Terminal.Gui/ViewBase/Layout/DimFuncWithView.cs new file mode 100644 index 000000000..2ff16bc9f --- /dev/null +++ b/Terminal.Gui/ViewBase/Layout/DimFuncWithView.cs @@ -0,0 +1,35 @@ +#nullable enable +namespace Terminal.Gui.ViewBase; + +/// +/// Represents a function object that computes the dimension based on the passed view and by +/// executing the provided function. +/// +/// +/// This is a low-level API that is typically used internally by the layout system. Use the various static +/// methods on the class to create objects instead. +/// +/// The function that computes the dimension. If this function throws ... +/// The returned from the function based on the passed view. +public record DimFuncWithView (Func Fn, View? View) : Dim +{ + /// + /// Gets the function that computes the dimension. + /// + public Func Fn { get; } = Fn; + + /// + /// Gets the passed view that the dimension is based on. + /// + public View View { get; } = View ?? throw new ArgumentNullException (nameof (View), @"View cannot be null"); + + /// + public override string ToString () { return $"DimFuncWithView({Fn (View)})"; } + + internal override int GetAnchor (int size) + { + View?.Layout (); + + return Fn (View!); + } +} \ No newline at end of file diff --git a/Terminal.Gui/ViewBase/View.cs b/Terminal.Gui/ViewBase/View.cs index 2061ef482..75b9d9d4b 100644 --- a/Terminal.Gui/ViewBase/View.cs +++ b/Terminal.Gui/ViewBase/View.cs @@ -245,12 +245,6 @@ public partial class View : IDisposable, ISupportInitializeNotification } } - if (ApplicationImpl.Instance.IsLegacy) - { - // TODO: Figure out how to move this out of here and just depend on LayoutNeeded in Mainloop - Layout (); // the EventLog in AllViewsTester fails to layout correctly if this is not here (convoluted Dim.Fill(Func)). - } - SetNeedsLayout (); Initialized?.Invoke (this, EventArgs.Empty); diff --git a/Tests/UnitTests/View/Adornment/ShadowStyleTests.cs b/Tests/UnitTests/View/Adornment/ShadowStyleTests.cs index 6d45ac9b7..2c9dc6d66 100644 --- a/Tests/UnitTests/View/Adornment/ShadowStyleTests.cs +++ b/Tests/UnitTests/View/Adornment/ShadowStyleTests.cs @@ -152,6 +152,7 @@ public class ShadowStyleTests (ITestOutputHelper output) superView.Add (view); superView.BeginInit (); superView.EndInit (); + superView.Layout (); Thickness origThickness = view.Margin!.Thickness; view.NewMouseEvent (new () { Flags = MouseFlags.Button1Pressed, Position = new (0, 0) }); diff --git a/Tests/UnitTests/View/Draw/ClearViewportTests.cs b/Tests/UnitTests/View/Draw/ClearViewportTests.cs index 5aa69954f..0b46dbd0b 100644 --- a/Tests/UnitTests/View/Draw/ClearViewportTests.cs +++ b/Tests/UnitTests/View/Draw/ClearViewportTests.cs @@ -113,8 +113,7 @@ public class ClearViewportTests (ITestOutputHelper output) superView.Add (view); superView.BeginInit (); superView.EndInit (); - superView.LayoutSubViews (); - + superView.Layout (); superView.Draw (); DriverAssert.AssertDriverContentsWithFrameAre ( @@ -163,7 +162,7 @@ public class ClearViewportTests (ITestOutputHelper output) superView.Add (view); superView.BeginInit (); superView.EndInit (); - superView.LayoutSubViews (); + superView.Layout (); superView.Draw (); diff --git a/Tests/UnitTests/View/Draw/ClipTests.cs b/Tests/UnitTests/View/Draw/ClipTests.cs index 893900e59..744002666 100644 --- a/Tests/UnitTests/View/Draw/ClipTests.cs +++ b/Tests/UnitTests/View/Draw/ClipTests.cs @@ -79,7 +79,7 @@ public class ClipTests (ITestOutputHelper _output) superView.Add (view); superView.BeginInit (); superView.EndInit (); - superView.LayoutSubViews (); + superView.Layout (); superView.Draw (); @@ -258,6 +258,7 @@ public class ClipTests (ITestOutputHelper _output) view.Border!.Thickness = new (1); view.BeginInit (); view.EndInit (); + view.Layout (); Assert.Equal (view.Frame, View.GetClip ()!.GetBounds ()); // Act @@ -291,6 +292,7 @@ public class ClipTests (ITestOutputHelper _output) view.Border!.Thickness = new (1); view.BeginInit (); view.EndInit (); + view.Layout (); Assert.Equal (view.Frame, View.GetClip ()!.GetBounds ()); view.Viewport = view.Viewport with { X = 1, Y = 1 }; diff --git a/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs b/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs index 03e6ad28f..cae736429 100644 --- a/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs +++ b/Tests/UnitTests/View/Layout/GetViewsUnderLocationTests.cs @@ -327,6 +327,7 @@ public class GetViewsUnderLocationTests Application.Top.Padding.Add (subview); Application.Top.BeginInit (); Application.Top.EndInit (); + Application.Top.LayoutSubViews (); View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); @@ -489,6 +490,7 @@ public class GetViewsUnderLocationTests Application.Top.Add (subview); Application.Top.BeginInit (); Application.Top.EndInit (); + Application.Top.LayoutSubViews (); View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); @@ -540,6 +542,7 @@ public class GetViewsUnderLocationTests Application.Top.Add (subview); Application.Top.BeginInit (); Application.Top.EndInit (); + Application.Top.LayoutSubViews (); View? found = View.GetViewsUnderLocation (new (testX, testY), ViewportSettingsFlags.TransparentMouse).LastOrDefault (); diff --git a/Tests/UnitTests/View/Mouse/MouseTests.cs b/Tests/UnitTests/View/Mouse/MouseTests.cs index 6d8a68eab..0718cb4f6 100644 --- a/Tests/UnitTests/View/Mouse/MouseTests.cs +++ b/Tests/UnitTests/View/Mouse/MouseTests.cs @@ -191,6 +191,7 @@ public class MouseTests : TestsAllViews // When mouse is held down me.Flags = pressed; + view.Layout (); view.NewMouseEvent (me); Assert.Equal (0, clickedCount); me.Handled = false; diff --git a/Tests/UnitTests/View/TextTests.cs b/Tests/UnitTests/View/TextTests.cs index 4a75be09a..4c342f4ee 100644 --- a/Tests/UnitTests/View/TextTests.cs +++ b/Tests/UnitTests/View/TextTests.cs @@ -1024,6 +1024,7 @@ w "; top.Add (frame); top.BeginInit (); top.EndInit (); + top.Layout (); Assert.Equal (new (0, 0, 20, 1), horizontalView.Frame); Assert.Equal (new (0, 3, 1, 20), verticalView.Frame); @@ -1127,6 +1128,7 @@ w "; view = new Label { Text = text }; view.BeginInit (); view.EndInit (); + view.Layout (); view.Draw (); DriverAssert.AssertDriverContentsWithFrameAre (text, output); diff --git a/Tests/UnitTests/View/ViewTests.cs b/Tests/UnitTests/View/ViewTests.cs index 67c52e133..0493476fd 100644 --- a/Tests/UnitTests/View/ViewTests.cs +++ b/Tests/UnitTests/View/ViewTests.cs @@ -291,6 +291,7 @@ public class ViewTests r.BeginInit (); r.EndInit (); + r.Layout (); Assert.False (r.CanFocus); Assert.False (r.HasFocus); Assert.Equal (new (0, 0, 1, 13), r.Viewport); diff --git a/Tests/UnitTests/Views/ButtonTests.cs b/Tests/UnitTests/Views/ButtonTests.cs index 2e84f96ab..7c9f9aed9 100644 --- a/Tests/UnitTests/Views/ButtonTests.cs +++ b/Tests/UnitTests/Views/ButtonTests.cs @@ -232,6 +232,7 @@ public class ButtonTests (ITestOutputHelper output) Assert.True (btn.CanFocus); Application.Driver?.ClearContents (); + btn.Layout (); btn.Draw (); expected = @$" diff --git a/Tests/UnitTests/Views/ColorPicker16Tests.cs b/Tests/UnitTests/Views/ColorPicker16Tests.cs index 53182a950..23e2af725 100644 --- a/Tests/UnitTests/Views/ColorPicker16Tests.cs +++ b/Tests/UnitTests/Views/ColorPicker16Tests.cs @@ -14,7 +14,7 @@ public class ColorPicker16Tests colorPicker.BeginInit (); colorPicker.EndInit (); - colorPicker.LayoutSubViews (); + colorPicker.Layout (); Assert.Equal (new (0, 0, 32, 4), colorPicker.Frame); } diff --git a/Tests/UnitTests/Views/ColorPickerTests.cs b/Tests/UnitTests/Views/ColorPickerTests.cs index 22144245d..f6f88db9b 100644 --- a/Tests/UnitTests/Views/ColorPickerTests.cs +++ b/Tests/UnitTests/Views/ColorPickerTests.cs @@ -675,7 +675,7 @@ public class ColorPickerTests // Switch to HSV cp.Style.ColorModel = ColorModel.HSV; cp.ApplyStyleChanges (); - + cp.Layout (); cp.Draw (); ColorBar h = GetColorBar (cp, ColorPickerPart.Bar1); diff --git a/Tests/UnitTests/Views/LabelTests.cs b/Tests/UnitTests/Views/LabelTests.cs index 374750f2b..57c8a214d 100644 --- a/Tests/UnitTests/Views/LabelTests.cs +++ b/Tests/UnitTests/Views/LabelTests.cs @@ -1053,7 +1053,7 @@ e win.Add (label); win.BeginInit (); win.EndInit (); - win.LayoutSubViews (); + win.Layout (); win.Draw (); Assert.Equal (5, text.Length); diff --git a/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs b/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs index 087823380..f3d31e6dd 100644 --- a/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs +++ b/Tests/UnitTests/Views/Menuv1/MenuBarv1Tests.cs @@ -2130,6 +2130,7 @@ wo Assert.True (menu.NewKeyDownEvent (menu.Key)); Assert.True (menu.IsMenuOpen); View.SetClipToScreen (); + top.Layout (); top.Draw (); DriverAssert.AssertDriverContentsAre (expectedMenu.ExpectedSubMenuOpen (0), output); diff --git a/Tests/UnitTests/Views/ProgressBarTests.cs b/Tests/UnitTests/Views/ProgressBarTests.cs index 744ce198f..f59408653 100644 --- a/Tests/UnitTests/Views/ProgressBarTests.cs +++ b/Tests/UnitTests/Views/ProgressBarTests.cs @@ -12,7 +12,7 @@ public class ProgressBarTests var pb = new ProgressBar (); pb.BeginInit (); pb.EndInit (); - + pb.Layout (); Assert.False (pb.CanFocus); Assert.Equal (0, pb.Fraction); @@ -32,7 +32,7 @@ public class ProgressBarTests pb.BeginInit (); pb.EndInit (); - pb.LayoutSubViews (); + pb.Layout (); for (var i = 0; i <= pb.Frame.Width; i++) { @@ -174,7 +174,7 @@ public class ProgressBarTests pb.BeginInit (); pb.EndInit (); - pb.LayoutSubViews (); + pb.Layout (); for (var i = 0; i < 38; i++) { @@ -879,7 +879,7 @@ public class ProgressBarTests pb.BeginInit (); pb.EndInit (); - pb.LayoutSubViews (); + pb.Layout (); for (var i = 0; i < 38; i++) { diff --git a/Tests/UnitTests/Views/SliderTests.cs b/Tests/UnitTests/Views/SliderTests.cs index 69c56e593..afe3f1dc1 100644 --- a/Tests/UnitTests/Views/SliderTests.cs +++ b/Tests/UnitTests/Views/SliderTests.cs @@ -514,6 +514,7 @@ public class SliderTests view.Add (slider); view.BeginInit (); view.EndInit (); + view.Layout (); Size expectedSize = slider.Frame.Size; @@ -547,6 +548,7 @@ public class SliderTests view.Add (slider); view.BeginInit (); view.EndInit (); + view.Layout (); Size expectedSize = slider.Frame.Size; @@ -580,6 +582,7 @@ public class SliderTests view.Add (slider); view.BeginInit (); view.EndInit (); + view.Layout (); Size expectedSize = slider.Frame.Size; diff --git a/Tests/UnitTests/Views/TextFieldTests.cs b/Tests/UnitTests/Views/TextFieldTests.cs index 822871a55..a42dff91e 100644 --- a/Tests/UnitTests/Views/TextFieldTests.cs +++ b/Tests/UnitTests/Views/TextFieldTests.cs @@ -1673,6 +1673,7 @@ Les Miśerables", var tf = new TextField { Width = 5, Text = "\u001b" }; tf.BeginInit (); tf.EndInit (); + tf.Layout (); tf.Draw (); DriverAssert.AssertDriverContentsWithFrameAre ("\u241b", output); diff --git a/Tests/UnitTests/Views/TileViewTests.cs b/Tests/UnitTests/Views/TileViewTests.cs index 8981738e7..f46051b6b 100644 --- a/Tests/UnitTests/Views/TileViewTests.cs +++ b/Tests/UnitTests/Views/TileViewTests.cs @@ -819,6 +819,10 @@ public class TileViewTests (ITestOutputHelper output) Assert.Equal (1, myReusableView.DisposalCount); } ); + + Assert.NotNull (Application.Top); + Application.Top.Dispose (); + Application.Shutdown (); } [Theory] @@ -848,6 +852,10 @@ public class TileViewTests (ITestOutputHelper output) Assert.True (myReusableView.DisposalCount >= 1); } ); + + Assert.NotNull (Application.Top); + Application.Top.Dispose (); + Application.Shutdown (); } [Fact] diff --git a/Tests/UnitTestsParallelizable/View/Layout/Dim.AutoTests.PosTypes.cs b/Tests/UnitTestsParallelizable/View/Layout/Dim.AutoTests.PosTypes.cs index fd854b1e4..7bb7bf950 100644 --- a/Tests/UnitTestsParallelizable/View/Layout/Dim.AutoTests.PosTypes.cs +++ b/Tests/UnitTestsParallelizable/View/Layout/Dim.AutoTests.PosTypes.cs @@ -263,6 +263,7 @@ public partial class DimAutoTests view.BeginInit (); view.EndInit (); + view.Layout (); // subview should be centered in the parent view + 1 Assert.Equal ((view.Viewport.Width - subview.Frame.Width) / 2 + 1, subview.Frame.X); @@ -338,6 +339,7 @@ public partial class DimAutoTests view.BeginInit (); view.EndInit (); + view.Layout (); // subview should be at the end of the view Assert.Equal (view.Viewport.Width - subview.Frame.Width, subview.Frame.X); @@ -392,6 +394,7 @@ public partial class DimAutoTests view.BeginInit (); view.EndInit (); + view.Layout (); // subview should be at the end of the view Assert.Equal (view.Viewport.Width - subview.Frame.Width, subview.Frame.X); @@ -446,6 +449,7 @@ public partial class DimAutoTests view.BeginInit (); view.EndInit (); + view.Layout (); // subview should be at the end of the view Assert.Equal (view.Viewport.Width - subview.Frame.Width, subview.Frame.X); @@ -508,6 +512,7 @@ public partial class DimAutoTests view.BeginInit (); view.EndInit (); + view.Layout (); // subview should be at the end of the view Assert.Equal (view.Viewport.Width - subview.Frame.Width, subview.Frame.X); @@ -572,11 +577,13 @@ public partial class DimAutoTests view.BeginInit (); view.EndInit (); + view.Layout (); // subview should be at the end of the view Assert.Equal (view.Viewport.Width - subview.Frame.Width, subview.Frame.X); Assert.Equal (view.Viewport.Height - subview.Frame.Height, subview.Frame.Y); } + [Theory] [InlineData (0, 10, 0, 10, 10, 2)] [InlineData (0, 5, 0, 5, 5, 3)] // max width of 5 should cause wordwrap at 5 giving a height of 2 + 1 diff --git a/Tests/UnitTestsParallelizable/View/Layout/Dim.FuncWithViewTests.cs b/Tests/UnitTestsParallelizable/View/Layout/Dim.FuncWithViewTests.cs new file mode 100644 index 000000000..75e3a1bf9 --- /dev/null +++ b/Tests/UnitTestsParallelizable/View/Layout/Dim.FuncWithViewTests.cs @@ -0,0 +1,58 @@ +using Xunit.Abstractions; +using static Terminal.Gui.ViewBase.Dim; + +namespace Terminal.Gui.LayoutTests; + +public class DimFuncWithViewTests (ITestOutputHelper output) +{ + private readonly ITestOutputHelper _output = output; + + [Fact] + public void DimFuncWithView_Equal () + { + Func f1 = v => v.Frame.Width; + Func f2 = v => v.Frame.Width; + View view1 = new (); + View view2 = new (); + + Dim dim1 = FuncWithView (f1, view1); + Dim dim2 = FuncWithView (f1, view1); + Assert.Equal (dim1, dim2); + + dim2 = FuncWithView (f2, view2); + Assert.NotEqual (dim1, dim2); + + view2.Width = 1; + Assert.NotEqual (dim1, dim2); + Assert.Equal (1, f2 (view2)); + } + + [Fact] + public void DimFuncWithView_SetsValue () + { + View view = new () { Text = "Test" }; + Dim dim = FuncWithView (v => v.Text.Length, view); + Assert.Equal ("DimFuncWithView(4)", dim.ToString ()); + + view.Text = "New Test"; + Assert.Equal ("DimFuncWithView(8)", dim.ToString ()); + + view.Text = ""; + Assert.Equal ("DimFuncWithView(0)", dim.ToString ()); + } + + [Fact] + public void DimFuncWithView_Calculate_ReturnsCorrectValue () + { + View view = new () { Width = 10 }; + var dim = new DimFuncWithView (v => v.Frame.Width, view); + int result = dim.Calculate (0, 100, view, Dimension.None); + Assert.Equal (10, result); + } + + [Fact] + public void DimFuncWithView_Throws_ArgumentNullException_If_View_Is_Null () + { + Assert.Throws (() => FuncWithView (v => 0, null)); + } +} diff --git a/Tests/UnitTestsParallelizable/View/Layout/SetLayoutTests.cs b/Tests/UnitTestsParallelizable/View/Layout/SetLayoutTests.cs index 2aa4e6514..f8a560787 100644 --- a/Tests/UnitTestsParallelizable/View/Layout/SetLayoutTests.cs +++ b/Tests/UnitTestsParallelizable/View/Layout/SetLayoutTests.cs @@ -376,24 +376,24 @@ public class SetLayoutTests : GlobalTestSetup Assert.Equal (0, layoutStartedCount); Assert.Equal (0, layoutCompleteCount); - superView.EndInit (); - Assert.Equal (1, borderLayoutStartedCount); - Assert.Equal (1, borderLayoutCompleteCount); - Assert.Equal (2, layoutStartedCount); - Assert.Equal (2, layoutCompleteCount); + superView.EndInit (); // Only sets NeedsLayout + Assert.Equal (0, borderLayoutStartedCount); + Assert.Equal (0, borderLayoutCompleteCount); + Assert.Equal (0, layoutStartedCount); + Assert.Equal (0, layoutCompleteCount); superView.LayoutSubViews (); - Assert.Equal (1, borderLayoutStartedCount); - Assert.Equal (1, borderLayoutCompleteCount); - Assert.Equal (3, layoutStartedCount); - Assert.Equal (3, layoutCompleteCount); + Assert.Equal (0, borderLayoutStartedCount); // No Border + Assert.Equal (0, borderLayoutCompleteCount); // No Border + Assert.Equal (1, layoutStartedCount); + Assert.Equal (1, layoutCompleteCount); superView.SetNeedsLayout (); superView.LayoutSubViews (); - Assert.Equal (1, borderLayoutStartedCount); - Assert.Equal (1, borderLayoutCompleteCount); - Assert.Equal (4, layoutStartedCount); - Assert.Equal (4, layoutCompleteCount); + Assert.Equal (0, borderLayoutStartedCount); // No Border + Assert.Equal (0, borderLayoutCompleteCount); // No Border + Assert.Equal (2, layoutStartedCount); + Assert.Equal (2, layoutCompleteCount); superView.Dispose (); } @@ -443,8 +443,8 @@ public class SetLayoutTests : GlobalTestSetup superView.BeginInit (); superView.EndInit (); superView.LayoutSubViews (); - Assert.Equal (3, layoutStartedRaised); - Assert.Equal (3, layoutCompleteRaised); + Assert.Equal (2, layoutStartedRaised); + Assert.Equal (2, layoutCompleteRaised); } [Fact] diff --git a/Tests/UnitTestsParallelizable/View/Layout/SetRelativeLayoutTests.cs b/Tests/UnitTestsParallelizable/View/Layout/SetRelativeLayoutTests.cs index 133ac3ab3..38be25a02 100644 --- a/Tests/UnitTestsParallelizable/View/Layout/SetRelativeLayoutTests.cs +++ b/Tests/UnitTestsParallelizable/View/Layout/SetRelativeLayoutTests.cs @@ -409,6 +409,7 @@ public class SetRelativeLayoutTests // BUGBUG: IsInitialized need to be true before calculate view.BeginInit (); view.EndInit (); + view.Layout (); view.SetRelativeLayout (screen); Assert.Equal (27, view.Frame.X); Assert.Equal (0, view.Frame.Y); diff --git a/Tests/UnitTestsParallelizable/View/TextTests.cs b/Tests/UnitTestsParallelizable/View/TextTests.cs index 31ca7eea8..f86fdcc39 100644 --- a/Tests/UnitTestsParallelizable/View/TextTests.cs +++ b/Tests/UnitTestsParallelizable/View/TextTests.cs @@ -170,6 +170,7 @@ public class TextTests () }; view.BeginInit (); view.EndInit (); + view.Layout (); Assert.Equal (new (0, 0, 10, 1), view.Frame); Assert.Equal (new (0, 0, 10, 1), view.Viewport); diff --git a/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs b/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs index a38f6188b..664479259 100644 --- a/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs +++ b/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs @@ -543,6 +543,7 @@ public class TextFieldTests var tf = new TextField { Width = 5 }; tf.BeginInit (); tf.EndInit (); + tf.Layout (); tf.NewKeyDownEvent (new ("📄")); Assert.Equal (1, tf.CursorPosition);