Tons of Layout refactoring. LayoutSubviews is now internal.

This commit is contained in:
Tig
2024-10-17 10:39:56 -06:00
parent f5ddf6b584
commit 8c7982f9c0
47 changed files with 933 additions and 706 deletions

View File

@@ -96,7 +96,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (width, 5);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = string.Empty;
switch (width)
@@ -227,10 +227,9 @@ public class BorderTests (ITestOutputHelper output)
win.Border.Thickness = win.Border.Thickness with { Top = 3 };
RunState rs = Application.Begin (win);
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (width, 4);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, false);
var expected = string.Empty;
switch (width)
@@ -364,7 +363,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (width, 4);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = string.Empty;
switch (width)
@@ -487,7 +486,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (20, height);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = string.Empty;
switch (height)
@@ -549,7 +548,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (width, 3);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = string.Empty;
switch (width)
@@ -729,7 +728,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (5, 5);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = @"
╔═══╗
@@ -757,7 +756,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (10, 4);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = @"
╔════════╗
@@ -780,7 +779,7 @@ public class BorderTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (3, 3);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = @"
┌─┐

View File

@@ -7,6 +7,139 @@ namespace Terminal.Gui.ViewTests;
[Trait ("Category", "Output")]
public class DrawTests (ITestOutputHelper _output)
{
[Fact]
public void NeedsDisplay_True_After_Constructor ()
{
var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
Assert.True (view.NeedsDisplay);
}
[Fact]
public void NeedsDisplay_False_After_BeginInit ()
{
var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
Assert.True (view.NeedsDisplay);
view.BeginInit ();
Assert.True (view.NeedsDisplay);
view.NeedsDisplay = false;
view.BeginInit ();
Assert.False (view.NeedsDisplay);
}
[Fact]
public void NeedsDisplay_False_After_EndInit ()
{
var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
Assert.True (view.NeedsDisplay);
view.BeginInit ();
Assert.True (view.NeedsDisplay);
view.EndInit ();
Assert.True (view.NeedsDisplay);
view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
view.BeginInit ();
view.NeedsDisplay = false;
view.EndInit ();
Assert.False (view.NeedsDisplay);
}
[Fact]
public void NeedsDisplay_False_After_SetRelativeLayout ()
{
var view = new View { Width = 2, Height = 2 };
Assert.True (view.NeedsDisplay);
view.BeginInit ();
Assert.True (view.NeedsDisplay);
view.EndInit ();
Assert.True (view.NeedsDisplay);
view.SetRelativeLayout (Application.Screen.Size);
Assert.True (view.NeedsDisplay);
view.NeedsDisplay = false;
view.SetRelativeLayout (new (10, 10));
Assert.False (view.NeedsDisplay);
view = new View { Width = Dim.Percent(50), Height = Dim.Percent(50) };
View superView = new ()
{
Id = "superView",
Width = Dim.Fill(),
Height = Dim.Fill()
};
superView.Add (view);
superView.BeginInit ();
Assert.True (view.NeedsDisplay);
Assert.True (superView.NeedsDisplay);
superView.EndInit ();
Assert.True (view.NeedsDisplay);
Assert.True (superView.NeedsDisplay);
superView.SetRelativeLayout (Application.Screen.Size);
Assert.True (view.NeedsDisplay);
Assert.True (superView.NeedsDisplay);
superView.NeedsDisplay = false;
superView.SetRelativeLayout (new (10, 10));
Assert.False (superView.NeedsDisplay);
Assert.False (view.NeedsDisplay);
view.SetRelativeLayout (new (11, 11));
Assert.True (superView.NeedsDisplay);
Assert.True (view.NeedsDisplay);
}
[Fact]
public void NeedsDisplay_True_After_LayoutSubviews ()
{
var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
Assert.True (view.NeedsDisplay);
view.BeginInit ();
Assert.True (view.NeedsDisplay);
view.EndInit ();
Assert.True (view.NeedsDisplay);
view.SetRelativeLayout (Application.Screen.Size);
Assert.True (view.NeedsDisplay);
view.LayoutSubviews ();
Assert.True (view.NeedsDisplay);
}
[Fact]
public void NeedsDisplay_False_After_Draw ()
{
var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
Assert.True (view.NeedsDisplay);
view.BeginInit ();
Assert.True (view.NeedsDisplay);
view.EndInit ();
Assert.True (view.NeedsDisplay);
view.SetRelativeLayout (Application.Screen.Size);
Assert.True (view.NeedsDisplay);
view.LayoutSubviews ();
Assert.True (view.NeedsDisplay);
view.Draw ();
Assert.False (view.NeedsDisplay);
}
[Fact]
[SetupFakeDriver]
public void Move_Is_Constrained_To_Viewport ()
@@ -17,18 +150,18 @@ public class DrawTests (ITestOutputHelper _output)
Y = 1,
Width = 3, Height = 3
};
view.Margin.Thickness = new Thickness (1);
view.Margin.Thickness = new (1);
// Only valid location w/in Viewport is 0, 0 (view) - 2, 2 (screen)
view.Move (0, 0);
Assert.Equal (new Point (2, 2), new Point (Application.Driver!.Col, Application.Driver!.Row));
Assert.Equal (new (2, 2), new Point (Application.Driver!.Col, Application.Driver!.Row));
view.Move (-1, -1);
Assert.Equal (new Point (2, 2), new Point (Application.Driver!.Col, Application.Driver!.Row));
Assert.Equal (new (2, 2), new Point (Application.Driver!.Col, Application.Driver!.Row));
view.Move (1, 1);
Assert.Equal (new Point (2, 2), new Point (Application.Driver!.Col, Application.Driver!.Row));
Assert.Equal (new (2, 2), new Point (Application.Driver!.Col, Application.Driver!.Row));
}
[Fact]
@@ -41,7 +174,7 @@ public class DrawTests (ITestOutputHelper _output)
Y = 1,
Width = 3, Height = 3
};
view.Margin.Thickness = new Thickness (1);
view.Margin.Thickness = new (1);
View.Diagnostics = ViewDiagnosticFlags.Padding;
view.BeginInit ();
view.EndInit ();
@@ -84,6 +217,7 @@ public class DrawTests (ITestOutputHelper _output)
superView.LayoutSubviews ();
superView.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -93,6 +227,7 @@ public class DrawTests (ITestOutputHelper _output)
Rectangle toFill = new (x, y, width, height);
view.FillRect (toFill);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -103,6 +238,7 @@ public class DrawTests (ITestOutputHelper _output)
// Now try to clear beyond Viewport (invalid; clipping should prevent)
superView.SetNeedsDisplay ();
superView.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -111,6 +247,7 @@ public class DrawTests (ITestOutputHelper _output)
_output);
toFill = new (-width, -height, width, height);
view.FillRect (toFill);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -121,6 +258,7 @@ public class DrawTests (ITestOutputHelper _output)
// Now try to clear beyond Viewport (valid)
superView.SetNeedsDisplay ();
superView.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -129,6 +267,7 @@ public class DrawTests (ITestOutputHelper _output)
_output);
toFill = new (-1, -1, width + 1, height + 1);
view.FillRect (toFill);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -139,6 +278,7 @@ public class DrawTests (ITestOutputHelper _output)
// Now clear too much size
superView.SetNeedsDisplay ();
superView.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -147,6 +287,7 @@ public class DrawTests (ITestOutputHelper _output)
_output);
toFill = new (0, 0, width * 2, height * 2);
view.FillRect (toFill);
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -174,6 +315,7 @@ public class DrawTests (ITestOutputHelper _output)
superView.LayoutSubviews ();
superView.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -182,6 +324,7 @@ public class DrawTests (ITestOutputHelper _output)
_output);
view.Clear ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -210,6 +353,7 @@ public class DrawTests (ITestOutputHelper _output)
superView.LayoutSubviews ();
superView.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -218,6 +362,7 @@ public class DrawTests (ITestOutputHelper _output)
_output);
view.Clear ();
TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌─┐
@@ -226,7 +371,6 @@ public class DrawTests (ITestOutputHelper _output)
_output);
}
[Fact]
[AutoInitShutdown]
[Trait ("Category", "Unicode")]
@@ -243,7 +387,7 @@ public class DrawTests (ITestOutputHelper _output)
Assert.Equal (2, r.GetColumns ());
var win = new Window { Title = us };
var view = new View { Text = r.ToString (), Height = Dim.Fill (), Width = Dim.Fill ()};
var view = new View { Text = r.ToString (), Height = Dim.Fill (), Width = Dim.Fill () };
var tf = new TextField { Text = us, Y = 1, Width = 3 };
win.Add (view, tf);
Toplevel top = new ();
@@ -317,7 +461,7 @@ public class DrawTests (ITestOutputHelper _output)
""";
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expectedOutput, _output);
Assert.Equal (new Rectangle (0, 0, 30, 10), pos);
Assert.Equal (new (0, 0, 30, 10), pos);
Application.End (rsDiag);
dg.Dispose ();
@@ -352,12 +496,13 @@ public class DrawTests (ITestOutputHelper _output)
Toplevel top = new ();
top.Add (viewRight, viewBottom);
Application.Begin (top);
var rs = Application.Begin (top);
((FakeDriver)Application.Driver!).SetBufferSize (7, 7);
Application.RunIteration (ref rs);
TestHelpers.AssertDriverContentsWithFrameAre (
"""
Test
@@ -391,13 +536,25 @@ public class DrawTests (ITestOutputHelper _output)
public void Draw_Minimum_Full_Border_With_Empty_Viewport ()
{
var view = new View { Width = 2, Height = 2, BorderStyle = LineStyle.Single };
Assert.True (view.NeedsDisplay);
view.BeginInit ();
Assert.True (view.NeedsDisplay);
view.EndInit ();
Assert.True (view.NeedsDisplay);
view.SetRelativeLayout (Application.Screen.Size);
Assert.True (view.NeedsDisplay);
view.LayoutSubviews ();
Assert.True (view.NeedsDisplay);
Assert.Equal (new (0, 0, 2, 2), view.Frame);
Assert.Equal (Rectangle.Empty, view.Viewport);
Assert.True (view.NeedsDisplay);
view.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@@ -415,7 +572,7 @@ public class DrawTests (ITestOutputHelper _output)
public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Bottom ()
{
var view = new View { Width = 2, Height = 1, BorderStyle = LineStyle.Single };
view.Border.Thickness = new Thickness (1, 1, 1, 0);
view.Border.Thickness = new (1, 1, 1, 0);
view.BeginInit ();
view.EndInit ();
view.SetRelativeLayout (Application.Screen.Size);
@@ -433,7 +590,7 @@ public class DrawTests (ITestOutputHelper _output)
public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Left ()
{
var view = new View { Width = 1, Height = 2, BorderStyle = LineStyle.Single };
view.Border.Thickness = new Thickness (0, 1, 1, 1);
view.Border.Thickness = new (0, 1, 1, 1);
view.BeginInit ();
view.EndInit ();
view.SetRelativeLayout (Application.Screen.Size);
@@ -458,7 +615,7 @@ public class DrawTests (ITestOutputHelper _output)
public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Right ()
{
var view = new View { Width = 1, Height = 2, BorderStyle = LineStyle.Single };
view.Border.Thickness = new Thickness (1, 1, 0, 1);
view.Border.Thickness = new (1, 1, 0, 1);
view.BeginInit ();
view.EndInit ();
view.SetRelativeLayout (Application.Screen.Size);
@@ -483,7 +640,7 @@ public class DrawTests (ITestOutputHelper _output)
public void Draw_Minimum_Full_Border_With_Empty_Viewport_Without_Top ()
{
var view = new View { Width = 2, Height = 1, BorderStyle = LineStyle.Single };
view.Border.Thickness = new Thickness (1, 0, 1, 1);
view.Border.Thickness = new (1, 0, 1, 1);
view.BeginInit ();
view.EndInit ();
@@ -494,7 +651,8 @@ public class DrawTests (ITestOutputHelper _output)
view.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre ("││",
TestHelpers.AssertDriverContentsWithFrameAre (
"││",
_output
);
}
@@ -510,40 +668,40 @@ public class DrawTests (ITestOutputHelper _output)
Width = 1,
Height = 7,
Text = """
s
u
b
V
i
e
w
"""
s
u
b
V
i
e
w
"""
};
var view = new View
{
Id = "view", Width = 2, Height = 20, Text = """
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
"""
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
"""
};
view.Add (subView);
var content = new View { Id = "content", Width = 20, Height = 20 };
@@ -560,12 +718,12 @@ public class DrawTests (ITestOutputHelper _output)
container.Add (content);
Toplevel top = new ();
top.Add (container);
Application.Driver!.Clip = container.Frame;
Application.Begin (top);
var rs = Application.Begin (top);
top.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
"""
0s
1u
2b
@@ -580,7 +738,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
s
u
b
@@ -600,7 +758,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
1u
2b
3V
@@ -615,7 +773,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
6w
7
8
@@ -630,7 +788,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
9
""",
_output
@@ -682,9 +840,10 @@ public class DrawTests (ITestOutputHelper _output)
top.LayoutComplete += Top_LayoutComplete;
Application.Begin (top);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (
"""
01234
subVi
""",
@@ -696,7 +855,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
12345
ubVie
""",
@@ -708,7 +867,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
ubVie
""",
_output
@@ -766,12 +925,12 @@ public class DrawTests (ITestOutputHelper _output)
container.Add (content);
Toplevel top = new ();
top.Add (container);
Application.Driver!.Clip = container.Frame;
Application.Begin (top);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (
"""
0s
1u
2b
@@ -786,7 +945,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
s
u
b
@@ -806,7 +965,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
1u
2b
3V
@@ -821,7 +980,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
6w
7
8
@@ -836,7 +995,7 @@ public class DrawTests (ITestOutputHelper _output)
TestHelpers.AssertDriverContentsWithFrameAre (
"""
9
""",
_output
@@ -892,15 +1051,16 @@ public class DrawTests (ITestOutputHelper _output)
var expected = """
𝔹
𝔹
𝔹
""";
𝔹
𝔹
𝔹
""";
TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
TestHelpers.AssertDriverContentsAre (expected, _output);
top.Dispose ();
// This test has nothing to do with color - removing as it is not relevant and fragile
}
@@ -916,15 +1076,16 @@ public class DrawTests (ITestOutputHelper _output)
// Visible content is (1, 1, 10, 10)
// Expected clip is (1, 1, 10, 10) - same as visible content
Rectangle expectedClip = new (1, 1, 10, 10);
// Arrange
var view = new View ()
var view = new View
{
Width = Dim.Fill (),
Height = Dim.Fill (),
ViewportSettings = ViewportSettings.ClipContentOnly
};
view.SetContentSize (new Size (10, 10));
view.Border.Thickness = new Thickness (1);
view.Border.Thickness = new (1);
view.BeginInit ();
view.EndInit ();
Assert.Equal (view.Frame, Application.Driver?.Clip);
@@ -949,14 +1110,15 @@ public class DrawTests (ITestOutputHelper _output)
// Visible content is (1, 1, 10, 10)
// Expected clip is (1, 1, 23, 23) - same as Viewport
Rectangle expectedClip = new (1, 1, 23, 23);
// Arrange
var view = new View ()
var view = new View
{
Width = Dim.Fill (),
Height = Dim.Fill (),
Height = Dim.Fill ()
};
view.SetContentSize (new Size (10, 10));
view.Border.Thickness = new Thickness (1);
view.Border.Thickness = new (1);
view.BeginInit ();
view.EndInit ();
Assert.Equal (view.Frame, Application.Driver?.Clip);
@@ -970,7 +1132,6 @@ public class DrawTests (ITestOutputHelper _output)
view.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void Draw_Throws_IndexOutOfRangeException_With_Negative_Bounds ()
@@ -983,11 +1144,11 @@ public class DrawTests (ITestOutputHelper _output)
top.Add (view);
Application.Iteration += (s, a) =>
{
Assert.Equal (-2, view.X);
{
Assert.Equal (-2, view.X);
Application.RequestStop ();
};
Application.RequestStop ();
};
try
{
@@ -1000,8 +1161,8 @@ public class DrawTests (ITestOutputHelper _output)
}
top.Dispose ();
// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
}
}

View File

@@ -1,236 +0,0 @@
using Xunit.Abstractions;
namespace Terminal.Gui.LayoutTests;
public class AbsoluteLayoutTests (ITestOutputHelper output)
{
private readonly ITestOutputHelper _output = output;
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_Change_Height_or_Width_Absolute ()
{
var frame = new Rectangle (1, 2, 3, 4);
var newFrame = new Rectangle (1, 2, 30, 40);
var v = new View { Frame = frame };
v.Height = newFrame.Height;
v.Width = newFrame.Width;
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
new (0, 0, newFrame.Width, newFrame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal ($"Absolute({newFrame.Height})", v.Height.ToString ());
Assert.Equal ($"Absolute({newFrame.Width})", v.Width.ToString ());
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_Change_Height_or_Width_MakesComputed ()
{
var v = new View { Frame = Rectangle.Empty };
v.Height = Dim.Fill ();
v.Width = Dim.Fill ();
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_Change_X_or_Y_Absolute ()
{
var frame = new Rectangle (1, 2, 3, 4);
var newFrame = new Rectangle (10, 20, 3, 4);
var v = new View { Frame = frame };
v.X = newFrame.X;
v.Y = newFrame.Y;
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
new (0, 0, newFrame.Width, newFrame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
Assert.Equal ($"Absolute({newFrame.Y})", v.Y.ToString ());
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_Change_X_or_Y_MakesComputed ()
{
var v = new View { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_Change_X_Y_Height_Width_Absolute ()
{
var v = new View { Frame = Rectangle.Empty };
v.X = 1;
v.Y = 2;
v.Height = 3;
v.Width = 4;
v.Dispose ();
v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Dispose ();
v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.X = 1;
v.Dispose ();
v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Y = 2;
v.Dispose ();
v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Width = 3;
v.Dispose ();
v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Height = 3;
v.Dispose ();
v = new() { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.X = 1;
v.Y = 2;
v.Height = 3;
v.Width = 4;
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_Constructor ()
{
var v = new View ();
v.Dispose ();
var frame = Rectangle.Empty;
v = new() { Frame = frame };
Assert.Equal (frame, v.Frame);
Assert.Equal (
new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
frame = new (1, 2, 3, 4);
v = new() { Frame = frame };
Assert.Equal (frame, v.Frame);
Assert.Equal (
new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
v = new() { Frame = frame, Text = "v" };
Assert.Equal (frame, v.Frame);
Assert.Equal (
new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
v = new() { X = frame.X, Y = frame.Y, Text = "v" };
Assert.Equal (new (frame.X, frame.Y, 0, 0), v.Frame);
Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
v = new ();
Assert.Equal (new (0, 0, 0, 0), v.Frame);
Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
v = new() { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
Assert.Equal (new (frame.X, frame.Y, 3, 4), v.Frame);
Assert.Equal (new (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void AbsoluteLayout_LayoutSubviews ()
{
var superRect = new Rectangle (0, 0, 100, 100);
var super = new View { Frame = superRect, Text = "super" };
var v1 = new View { X = 0, Y = 0, Width = 10, Height = 10 };
var v2 = new View { X = 10, Y = 10, Width = 10, Height = 10 };
super.Add (v1, v2);
super.LayoutSubviews ();
Assert.Equal (new (0, 0, 10, 10), v1.Frame);
Assert.Equal (new (10, 10, 10, 10), v2.Frame);
super.Dispose ();
}
}

View File

@@ -4,12 +4,11 @@ using static Terminal.Gui.Dim;
namespace Terminal.Gui.LayoutTests;
[Trait("Category", "Layout")]
[Trait ("Category", "Layout")]
public partial class DimAutoTests (ITestOutputHelper output)
{
private readonly ITestOutputHelper _output = output;
[SetupFakeDriver]
[Fact]
public void Change_To_Non_Auto_Resets_ContentSize ()
{
@@ -26,6 +25,7 @@ public partial class DimAutoTests (ITestOutputHelper output)
// Change text to a longer string
view.Text = "0123456789";
view.Layout (new (100, 100));
Assert.Equal (new (0, 0, 10, 1), view.Frame);
Assert.Equal (new (10, 1), view.GetContentSize ());
@@ -33,6 +33,7 @@ public partial class DimAutoTests (ITestOutputHelper output)
view.Width = 5;
view.Height = 1;
view.SetRelativeLayout (new (100, 100));
Assert.Equal (new (5, 1), view.GetContentSize ());
}
@@ -216,7 +217,7 @@ public partial class DimAutoTests (ITestOutputHelper output)
Style: DimAutoStyle.Auto
);
var c = new DimAuto(
var c = new DimAuto (
MaximumContentDim: 2,
MinimumContentDim: 1,
Style: DimAutoStyle.Auto
@@ -966,9 +967,9 @@ public partial class DimAutoTests (ITestOutputHelper output)
[Fact]
public void DimAutoStyle_Content_UsesLargestSubview_WhenContentSizeNotSet ()
{
var view = new View ();
view.Add (new View { Frame = new (0, 0, 5, 5) }); // Smaller subview
view.Add (new View { Frame = new (0, 0, 10, 10) }); // Larger subview
var view = new View { Id = "view" };
view.Add (new View { Id = "smaller", Frame = new (0, 0, 5, 5) }); // Smaller subview
view.Add (new View { Id = "larger", Frame = new (0, 0, 10, 10) }); // Larger subview
Dim dim = Auto (DimAutoStyle.Content);
@@ -990,6 +991,8 @@ public partial class DimAutoTests (ITestOutputHelper output)
[Fact]
public void DimAutoStyle_Content_Pos_AnchorEnd_Locates_Correctly ()
{
Application.SetScreenSize (new Size (10, 10));
DimAutoTestView view = new (Auto (DimAutoStyle.Content), Auto (DimAutoStyle.Content));
View subView = new ()
@@ -999,24 +1002,23 @@ public partial class DimAutoTests (ITestOutputHelper output)
};
view.Add (subView);
view.SetRelativeLayout (new (10, 10));
view.Layout ();
Assert.Equal (new (5, 1), view.Frame.Size);
Assert.Equal (new (0, 0), view.Frame.Location);
view.X = 0;
view.Y = Pos.AnchorEnd (1);
view.SetRelativeLayout (new (10, 10));
view.Layout ();
Assert.Equal (new (5, 1), view.Frame.Size);
Assert.Equal (new (0, 9), view.Frame.Location);
view.Y = Pos.AnchorEnd ();
view.SetRelativeLayout (new (10, 10));
view.Layout ();
Assert.Equal (new (5, 1), view.Frame.Size);
Assert.Equal (new (0, 9), view.Frame.Location);
view.Y = Pos.AnchorEnd () - 1;
view.SetRelativeLayout (new (10, 10));
view.Layout ();
Assert.Equal (new (5, 1), view.Frame.Size);
Assert.Equal (new (0, 8), view.Frame.Location);
}

View File

@@ -6,6 +6,56 @@ public class LayoutTests (ITestOutputHelper output)
{
private readonly ITestOutputHelper _output = output;
[Fact]
[AutoInitShutdown]
public void Screen_Size_Change_Causes_Layout ()
{
Application.Top = new ();
var view = new View
{
X = 3,
Y = 2,
Width = 10,
Height = 1,
Text = "0123456789"
};
Application.Top.Add (view);
var rs = Application.Begin (Application.Top);
Assert.Equal (new (0, 0, 80, 25), new Rectangle (0, 0, View.Driver.Cols, View.Driver.Rows));
Assert.Equal (new (0, 0, View.Driver.Cols, View.Driver.Rows), Application.Top.Frame);
Assert.Equal (new (0, 0, 80, 25), Application.Top.Frame);
((FakeDriver)Application.Driver!).SetBufferSize (20, 10);
Assert.Equal (new (0, 0, View.Driver.Cols, View.Driver.Rows), Application.Top.Frame);
Assert.Equal (new (0, 0, 20, 10), Application.Top.Frame);
Application.End (rs);
}
[Fact]
[TestRespondersDisposed]
public void LayoutSubviews ()
{
var superRect = new Rectangle (0, 0, 100, 100);
var super = new View { Frame = superRect, Text = "super" };
var v1 = new View { X = 0, Y = 0, Width = 10, Height = 10 };
var v2 = new View { X = 10, Y = 10, Width = 10, Height = 10 };
super.Add (v1, v2);
super.LayoutSubviews ();
Assert.Equal (new (0, 0, 10, 10), v1.Frame);
Assert.Equal (new (10, 10, 10, 10), v2.Frame);
super.Dispose ();
}
[Fact]
public void LayoutSubviews_No_SuperView ()
{
@@ -35,7 +85,7 @@ public class LayoutTests (ITestOutputHelper output)
}
[Fact]
public void Add_Does_Not_Call_LayoutSubviews ()
public void Add_Does_Not_Call_Layout ()
{
var superView = new View { Id = "superView" };
var view = new View { Id = "view" };
@@ -49,10 +99,7 @@ public class LayoutTests (ITestOutputHelper output)
Assert.False (layoutStartedRaised);
Assert.False (layoutCompleteRaised);
superView.Remove(view);
superView.BeginInit();
superView.EndInit ();
superView.Remove (view);
superView.Add (view);
@@ -61,20 +108,6 @@ public class LayoutTests (ITestOutputHelper output)
}
[Fact]
public void BeginEndInit_Do_Not_Call_LayoutSubviews ()
{
var superView = new View { Id = "superView" };
bool layoutStartedRaised = false;
bool layoutCompleteRaised = false;
superView.LayoutStarted += (sender, e) => layoutStartedRaised = true;
superView.LayoutComplete += (sender, e) => layoutCompleteRaised = true;
superView.BeginInit ();
superView.EndInit ();
Assert.False (layoutStartedRaised);
Assert.False (layoutCompleteRaised);
}
[Fact]
public void LayoutSubViews_Raises_LayoutStarted_LayoutComplete ()
{
@@ -203,38 +236,376 @@ public class LayoutTests (ITestOutputHelper output)
{
var superView = new View ();
var view = new View ();
var layoutStartedCount = 0;
var layoutCompleteCount = 0;
var borderLayoutStartedCount = 0;
var borderLayoutCompleteCount = 0;
view.LayoutStarted += (sender, e) => layoutStartedCount++;
view.LayoutComplete += (sender, e) => layoutCompleteCount++;
view.Border.LayoutStarted += (sender, e) => borderLayoutStartedCount++;
view.Border.LayoutComplete += (sender, e) => borderLayoutCompleteCount++;
superView.Add (view);
Assert.Equal (0, borderLayoutStartedCount);
Assert.Equal (0, borderLayoutCompleteCount);
Assert.Equal (0, layoutStartedCount);
Assert.Equal (0, layoutCompleteCount);
superView.BeginInit ();
Assert.Equal (0, borderLayoutStartedCount);
Assert.Equal (0, borderLayoutCompleteCount);
Assert.Equal (0, layoutStartedCount);
Assert.Equal (0, layoutCompleteCount);
superView.EndInit ();
var layoutStarted = false;
var layoutComplete = false;
var borderLayoutStarted = false;
var borderLayoutComplete = false;
view.LayoutStarted += (sender, e) => layoutStarted = true;
view.LayoutComplete += (sender, e) => layoutComplete = true;
view.Border.LayoutStarted += (sender, e) =>
{
Assert.True (layoutStarted);
borderLayoutStarted = true;
};
view.Border.LayoutComplete += (sender, e) =>
{
Assert.True (layoutStarted);
Assert.False (layoutComplete);
borderLayoutComplete = true;
};
Assert.Equal (1, borderLayoutStartedCount);
Assert.Equal (1, borderLayoutCompleteCount);
Assert.Equal (1, layoutStartedCount);
Assert.Equal (1, layoutCompleteCount);
superView.LayoutSubviews ();
Assert.Equal (1, borderLayoutStartedCount);
Assert.Equal (1, borderLayoutCompleteCount);
Assert.Equal (1, layoutStartedCount);
Assert.Equal (1, layoutCompleteCount);
Assert.True (borderLayoutStarted);
Assert.True (borderLayoutComplete);
superView.SetLayoutNeeded ();
superView.LayoutSubviews ();
Assert.Equal (2, borderLayoutStartedCount);
Assert.Equal (2, borderLayoutCompleteCount);
Assert.Equal (2, layoutStartedCount);
Assert.Equal (2, layoutCompleteCount);
Assert.True (layoutStarted);
Assert.True (layoutComplete);
superView.Dispose ();
}
[Fact]
public void LayoutSubviews__Honors_IsLayoutNeeded ()
{
var superView = new View ();
var view = new View ();
var layoutStartedCount = 0;
var layoutCompleteCount = 0;
var borderLayoutStartedCount = 0;
var borderLayoutCompleteCount = 0;
view.LayoutStarted += (sender, e) => layoutStartedCount++;
view.LayoutComplete += (sender, e) => layoutCompleteCount++;
view.Border.LayoutStarted += (sender, e) => borderLayoutStartedCount++;
view.Border.LayoutComplete += (sender, e) => borderLayoutCompleteCount++;
superView.Add (view);
superView.LayoutSubviews ();
Assert.Equal (1, borderLayoutStartedCount);
Assert.Equal (1, borderLayoutCompleteCount);
Assert.Equal (1, layoutStartedCount);
Assert.Equal (1, layoutCompleteCount);
superView.LayoutSubviews ();
Assert.Equal (1, borderLayoutStartedCount);
Assert.Equal (1, borderLayoutCompleteCount);
Assert.Equal (1, layoutStartedCount);
Assert.Equal (1, layoutCompleteCount);
superView.SetLayoutNeeded ();
superView.LayoutSubviews ();
Assert.Equal (2, borderLayoutStartedCount);
Assert.Equal (2, borderLayoutCompleteCount);
Assert.Equal (2, layoutStartedCount);
Assert.Equal (2, layoutCompleteCount);
superView.Dispose ();
}
[Fact]
public void Set_X_Does_Not_Change_Frame_Until_Layout ()
{
var v = new View ();
Assert.Equal (0, v.Frame.X);
v.Layout ();
Assert.Equal (0, v.Frame.X);
v.X = 1;
Assert.Equal (0, v.Frame.X);
v.Layout ();
Assert.Equal (1, v.Frame.X);
v.X = 2;
Assert.Equal (1, v.Frame.X);
v.Layout ();
Assert.Equal (2, v.Frame.X);
}
[Fact]
public void Set_Y_Does_Not_Change_Frame_Until_Layout ()
{
var v = new View ();
Assert.Equal (0, v.Frame.Y);
v.Layout ();
Assert.Equal (0, v.Frame.Y);
v.Y = 1;
Assert.Equal (0, v.Frame.Y);
v.Layout ();
Assert.Equal (1, v.Frame.Y);
v.Y = 2;
Assert.Equal (1, v.Frame.Y);
v.Layout ();
Assert.Equal (2, v.Frame.Y);
}
[Fact]
public void Set_Width_Does_Not_Change_Frame_Until_Layout ()
{
var v = new View ();
Assert.Equal (0, v.Frame.Width);
v.Layout ();
Assert.Equal (0, v.Frame.Width);
v.Width = 1;
Assert.Equal (0, v.Frame.Width);
v.Layout ();
Assert.Equal (1, v.Frame.Width);
v.Width = 2;
Assert.Equal (1, v.Frame.Width);
v.Layout ();
Assert.Equal (2, v.Frame.Width);
}
[Fact]
public void Set_Height_Does_Not_Change_Frame_Until_Layout ()
{
var v = new View ();
Assert.Equal (0, v.Frame.Height);
v.Layout ();
Assert.Equal (0, v.Frame.Height);
v.Height = 1;
Assert.Equal (0, v.Frame.Height);
v.Layout ();
Assert.Equal (1, v.Frame.Height);
v.Height = 2;
Assert.Equal (1, v.Frame.Height);
v.Layout ();
Assert.Equal (2, v.Frame.Height);
}
[Fact]
[TestRespondersDisposed]
public void Change_Height_or_Width_MakesComputed ()
{
var v = new View { Frame = Rectangle.Empty };
v.Height = Dim.Fill ();
v.Width = Dim.Fill ();
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void Change_X_or_Y_Absolute ()
{
var frame = new Rectangle (1, 2, 3, 4);
var newFrame = new Rectangle (10, 20, 3, 4);
var v = new View { Frame = frame };
v.X = newFrame.X;
v.Y = newFrame.Y;
v.Layout ();
Assert.Equal (newFrame, v.Frame);
Assert.Equal (
new (0, 0, newFrame.Width, newFrame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal ($"Absolute({newFrame.X})", v.X.ToString ());
Assert.Equal ($"Absolute({newFrame.Y})", v.Y.ToString ());
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void Change_X_or_Y_MakesComputed ()
{
var v = new View { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Dispose ();
}
[Fact]
[TestRespondersDisposed]
public void Change_X_Y_Height_Width_Absolute ()
{
var v = new View { Frame = Rectangle.Empty };
v.X = 1;
v.Y = 2;
v.Height = 3;
v.Width = 4;
v.Dispose ();
v = new () { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Dispose ();
v = new () { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.X = 1;
v.Dispose ();
v = new () { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Y = 2;
v.Dispose ();
v = new () { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Width = 3;
v.Dispose ();
v = new () { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.Height = 3;
v.Dispose ();
v = new () { Frame = Rectangle.Empty };
v.X = Pos.Center ();
v.Y = Pos.Center ();
v.Width = Dim.Fill ();
v.Height = Dim.Fill ();
v.X = 1;
v.Y = 2;
v.Height = 3;
v.Width = 4;
v.Dispose ();
}
[Fact]
public void Constructor ()
{
var v = new View ();
v.Dispose ();
var frame = Rectangle.Empty;
v = new () { Frame = frame };
v.Layout ();
Assert.Equal (frame, v.Frame);
Assert.Equal (
new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
frame = new (1, 2, 3, 4);
v = new () { Frame = frame };
v.Layout ();
Assert.Equal (frame, v.Frame);
Assert.Equal (
new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
v = new () { Frame = frame, Text = "v" };
v.Layout ();
Assert.Equal (frame, v.Frame);
Assert.Equal (
new (0, 0, frame.Width, frame.Height),
v.Viewport
); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
v = new () { X = frame.X, Y = frame.Y, Text = "v" };
v.Layout ();
Assert.Equal (new (frame.X, frame.Y, 0, 0), v.Frame);
Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
v = new ();
v.Layout ();
Assert.Equal (new (0, 0, 0, 0), v.Frame);
Assert.Equal (new (0, 0, 0, 0), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (0), v.X);
Assert.Equal (Pos.Absolute (0), v.Y);
Assert.Equal (Dim.Absolute (0), v.Width);
Assert.Equal (Dim.Absolute (0), v.Height);
v.Dispose ();
v = new () { X = frame.X, Y = frame.Y, Width = frame.Width, Height = frame.Height };
v.Layout ();
Assert.Equal (new (frame.X, frame.Y, 3, 4), v.Frame);
Assert.Equal (new (0, 0, 3, 4), v.Viewport); // With Absolute Viewport *is* deterministic before Layout
Assert.Equal (Pos.Absolute (1), v.X);
Assert.Equal (Pos.Absolute (2), v.Y);
Assert.Equal (Dim.Absolute (3), v.Width);
Assert.Equal (Dim.Absolute (4), v.Height);
v.Dispose ();
}
}

View File

@@ -94,7 +94,7 @@ public class PosCenterTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (20, height);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = string.Empty;
switch (height)
@@ -241,7 +241,7 @@ public class PosCenterTests (ITestOutputHelper output)
var firstIteration = false;
((FakeDriver)Application.Driver!).SetBufferSize (width, 7);
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
var expected = string.Empty;
switch (width)

View File

@@ -960,7 +960,7 @@ public class ToScreenTests (ITestOutputHelper output)
};
Application.Top.Add (view);
Application.Begin (Application.Top);
var rs = Application.Begin (Application.Top);
Assert.Equal (new (0, 0, 80, 25), new Rectangle (0, 0, View.Driver.Cols, View.Driver.Rows));
Assert.Equal (new (0, 0, View.Driver.Cols, View.Driver.Rows), Application.Top.Frame);
@@ -970,6 +970,7 @@ public class ToScreenTests (ITestOutputHelper output)
Assert.Equal (new (0, 0, View.Driver.Cols, View.Driver.Rows), Application.Top.Frame);
Assert.Equal (new (0, 0, 20, 10), Application.Top.Frame);
_ = TestHelpers.AssertDriverContentsWithFrameAre (
@"
┌──────────────────┐

View File

@@ -103,12 +103,15 @@ public class MouseTests (ITestOutputHelper output) : TestsAllViews
var top = new Toplevel ();
top.Add (testView);
Application.Begin (top);
var rs = Application.Begin (top);
Assert.Equal (4, testView.Frame.X);
Assert.Equal (new Point (4, 4), testView.Frame.Location);
Application.RaiseMouseEvent (new () { ScreenPosition = new (xy, xy), Flags = MouseFlags.Button1Pressed });
Application.RaiseMouseEvent (new () { ScreenPosition = new (xy + 1, xy + 1), Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition });
Application.RunIteration(ref rs, false);
Assert.Equal (expectedMoved, new Point (5, 5) == testView.Frame.Location);
top.Dispose ();

View File

@@ -1025,7 +1025,7 @@ At 0,0
view.Visible = false;
var firstIteration = false;
Application.RunIteration (ref rs, ref firstIteration);
Application.RunIteration (ref rs, firstIteration);
TestHelpers.AssertDriverContentsWithFrameAre (
@"