mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-02-10 04:03:41 +01:00
* Phase 5: Add IsFixed and RequiresTargetLayout categorization properties Co-authored-by: tig <585482+tig@users.noreply.github.com> * Further simplify DimAuto.Calculate using IsFixed property Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor for-loops to foreach and clarify DimFill logic Refactored multiple for-loops iterating over view lists to use foreach loops for improved readability and reduced boilerplate. Removed unused variables such as viewsNeedingLayout and index counters. Clarified DimFill handling by continuing early if the DimFill is not valid or lacks a To property, reducing nesting and improving intent. Made minor formatting and code style improvements for consistency. * Refactor subview filtering and sizing logic Refactored repeated LINQ queries for subview filtering into reusable helper methods (`GetViewsThatMatch`, `GetViewsThatHavePos<TPos>`, `GetViewsThatHaveDim<TDim>`), reducing duplication and improving readability. Moved max content size calculations for various subview types into new helper methods (`GetMaxSizePos<TPos>`, `GetMaxSizeDim<TDim>`). Updated main logic to use these helpers. Adornment thickness calculation now uses a switch expression. These changes improve modularity and maintainability. * Refactor subview categorization for layout calculation Refactored layout calculation to use a single-pass CategorizeSubViews method, grouping subviews by relevant Pos/Dim types into a new CategorizedViews struct. This replaces multiple helper methods and reduces redundant iterations. Updated main logic to use these categorized lists, and unified size calculation helpers to further reduce code duplication. Improves performance and maintainability by consolidating subview processing and removing obsolete methods. * Revert perf POC commits and add missing overrides to Combine types Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add helper methods and simplify DimAuto.Calculate with foreach loops Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor layout calculation in DimAuto.cs Removed commented-out code and unnecessary list declarations to clean up the layout calculation logic. * removed old plan file * Code cleanup * Add performance analysis and improvement plan for DimAuto.Calculate Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add DimAuto benchmarks and benchmark documentation Co-authored-by: tig <585482+tig@users.noreply.github.com> * Implement Phase 1 & 2 performance optimizations for DimAuto.Calculate Co-authored-by: tig <585482+tig@users.noreply.github.com> * Code cleanup * Delete plans/dimauto-perf-plan.md --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Tig <tig@users.noreply.github.com>
187 lines
3.8 KiB
C#
187 lines
3.8 KiB
C#
#nullable disable
|
|
|
|
// Claude - Opus 4.5
|
|
|
|
namespace ViewBaseTests.Layout;
|
|
|
|
/// <summary>
|
|
/// Tests for Phase 5 categorization properties: IsFixed and RequiresTargetLayout.
|
|
/// These properties help DimAuto categorize Pos/Dim types without type checking.
|
|
/// </summary>
|
|
public class CategorizationPropertiesTests
|
|
{
|
|
#region IsFixed Tests - Dim
|
|
|
|
[Fact]
|
|
public void DimAbsolute_IsFixed ()
|
|
{
|
|
Dim dim = Dim.Absolute (42);
|
|
Assert.True (dim.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimFunc_IsFixed ()
|
|
{
|
|
Dim dim = Dim.Func (_ => 25);
|
|
Assert.True (dim.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimAuto_IsFixed ()
|
|
{
|
|
Dim dim = Dim.Auto ();
|
|
Assert.True (dim.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimPercent_IsNotFixed ()
|
|
{
|
|
Dim dim = Dim.Percent (50);
|
|
Assert.False (dim.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimFill_IsNotFixed ()
|
|
{
|
|
Dim dim = Dim.Fill ();
|
|
Assert.False (dim.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimView_IsNotFixed ()
|
|
{
|
|
View view = new ();
|
|
Dim dim = Dim.Width (view);
|
|
Assert.False (dim.IsFixed);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IsFixed Tests - Pos
|
|
|
|
[Fact]
|
|
public void PosAbsolute_IsFixed ()
|
|
{
|
|
Pos pos = Pos.Absolute (10);
|
|
Assert.True (pos.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosFunc_IsFixed ()
|
|
{
|
|
Pos pos = Pos.Func (_ => 15);
|
|
Assert.True (pos.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosCenter_IsNotFixed ()
|
|
{
|
|
Pos pos = Pos.Center ();
|
|
Assert.False (pos.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosPercent_IsNotFixed ()
|
|
{
|
|
Pos pos = Pos.Percent (50);
|
|
Assert.False (pos.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosAnchorEnd_IsNotFixed ()
|
|
{
|
|
Pos pos = Pos.AnchorEnd ();
|
|
Assert.False (pos.IsFixed);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosView_IsNotFixed ()
|
|
{
|
|
View view = new ();
|
|
Pos pos = Pos.Left (view);
|
|
Assert.False (pos.IsFixed);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RequiresTargetLayout Tests - Dim
|
|
|
|
[Fact]
|
|
public void DimView_RequiresTargetLayout ()
|
|
{
|
|
View view = new ();
|
|
Dim dim = Dim.Width (view);
|
|
Assert.True (dim.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimAbsolute_DoesNotRequireTargetLayout ()
|
|
{
|
|
Dim dim = Dim.Absolute (42);
|
|
Assert.False (dim.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimFunc_DoesNotRequireTargetLayout ()
|
|
{
|
|
Dim dim = Dim.Func (_ => 25);
|
|
Assert.False (dim.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimPercent_DoesNotRequireTargetLayout ()
|
|
{
|
|
Dim dim = Dim.Percent (50);
|
|
Assert.False (dim.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void DimFill_DoesNotRequireTargetLayout ()
|
|
{
|
|
Dim dim = Dim.Fill ();
|
|
Assert.False (dim.RequiresTargetLayout);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RequiresTargetLayout Tests - Pos
|
|
|
|
[Fact]
|
|
public void PosView_RequiresTargetLayout ()
|
|
{
|
|
View view = new ();
|
|
Pos pos = Pos.Left (view);
|
|
Assert.True (pos.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosAbsolute_DoesNotRequireTargetLayout ()
|
|
{
|
|
Pos pos = Pos.Absolute (10);
|
|
Assert.False (pos.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosFunc_DoesNotRequireTargetLayout ()
|
|
{
|
|
Pos pos = Pos.Func (_ => 15);
|
|
Assert.False (pos.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosCenter_DoesNotRequireTargetLayout ()
|
|
{
|
|
Pos pos = Pos.Center ();
|
|
Assert.False (pos.RequiresTargetLayout);
|
|
}
|
|
|
|
[Fact]
|
|
public void PosPercent_DoesNotRequireTargetLayout ()
|
|
{
|
|
Pos pos = Pos.Percent (50);
|
|
Assert.False (pos.RequiresTargetLayout);
|
|
}
|
|
|
|
#endregion
|
|
}
|