mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Fix more issue in the layout.
This commit is contained in:
@@ -544,12 +544,11 @@ namespace Terminal.Gui.ViewTests {
|
||||
// Assert.Throws<InvalidOperationException> (() => super.LayoutSubviews ());
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This is an intentionally obtuse test. See https://github.com/gui-cs/Terminal.Gui/issues/2461
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DimCombine_ObtuseScenario_Does_Not_Throw ()
|
||||
public void DimCombine_ObtuseScenario_Throw ()
|
||||
{
|
||||
var t = new View ("top") { Width = 80, Height = 25 };
|
||||
|
||||
@@ -571,11 +570,12 @@ namespace Terminal.Gui.ViewTests {
|
||||
w.Add (f);
|
||||
t.Add (w);
|
||||
|
||||
// BUGBUG: v2 - f references t here; t is f's super-superview. This is not supported!
|
||||
// BUGBUG: v2 - f references t here; t is f's super-superview. This is supported!
|
||||
// BUGBUG: v2 - f references v2 here; v2 is f's subview. This is not supported!
|
||||
f.Width = Dim.Width (t) - Dim.Width (v2); // 80 - 74 = 6
|
||||
f.Height = Dim.Height (t) - Dim.Height (v2); // 25 - 19 = 6
|
||||
|
||||
t.LayoutSubviews ();
|
||||
Assert.Throws<InvalidOperationException> (t.LayoutSubviews);
|
||||
Assert.Equal (80, t.Frame.Width);
|
||||
Assert.Equal (25, t.Frame.Height);
|
||||
Assert.Equal (78, w.Frame.Width);
|
||||
@@ -583,10 +583,10 @@ namespace Terminal.Gui.ViewTests {
|
||||
// BUGBUG: v2 - this no longer works - see above
|
||||
//Assert.Equal (6, f.Frame.Width);
|
||||
//Assert.Equal (6, f.Frame.Height);
|
||||
Assert.Equal (76, v1.Frame.Width);
|
||||
Assert.Equal (21, v1.Frame.Height);
|
||||
Assert.Equal (74, v2.Frame.Width);
|
||||
Assert.Equal (19, v2.Frame.Height);
|
||||
//Assert.Equal (76, v1.Frame.Width);
|
||||
//Assert.Equal (21, v1.Frame.Height);
|
||||
//Assert.Equal (74, v2.Frame.Width);
|
||||
//Assert.Equal (19, v2.Frame.Height);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1039,5 +1039,33 @@ namespace Terminal.Gui.ViewTests {
|
||||
Assert.Equal (61, label.Frame.Y);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosCombine_Referencing_Same_View ()
|
||||
{
|
||||
var super = new View ("super") {
|
||||
Width = 10,
|
||||
Height = 10
|
||||
};
|
||||
var view1 = new View ("view1") {
|
||||
Width = 2,
|
||||
Height = 2,
|
||||
};
|
||||
var view2 = new View ("view2") {
|
||||
Width = 2,
|
||||
Height = 2,
|
||||
};
|
||||
view2.X = Pos.AnchorEnd () - (Pos.Right (view2) - Pos.Left (view2));
|
||||
|
||||
super.Add (view1, view2);
|
||||
super.BeginInit ();
|
||||
super.EndInit ();
|
||||
|
||||
var exception = Record.Exception (super.LayoutSubviews);
|
||||
Assert.Null (exception);
|
||||
Assert.Equal (new Rect (0, 0, 10, 10), super.Frame);
|
||||
Assert.Equal (new Rect (0, 0, 2, 2), view1.Frame);
|
||||
Assert.Equal (new Rect (8, 0, 2, 2), view2.Frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user