Skip to content

Commit

Permalink
Add failing tests for #17699.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed Dec 5, 2024
1 parent 18fcfcc commit 6b90c5c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
71 changes: 71 additions & 0 deletions tests/Avalonia.Controls.UnitTests/Primitives/UniformGridTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Controls.Primitives;
using Avalonia.UnitTests;
using Xunit;

namespace Avalonia.Controls.UnitTests.Primitives
Expand Down Expand Up @@ -140,5 +141,75 @@ public void Not_Visible_Children_Are_Ignored()
// 2 * 2 grid
Assert.Equal(new Size(2 * 50, 2 * 70), target.Bounds.Size);
}

[Fact]
public void Children_Do_Not_Overlap_With_125_Percent_Scaling_1()
{
// Issue #17699
var target = new UniformGrid
{
Columns = 2,
Children =
{
new Border(),
new Border(),
new Border(),
new Border(),
}
};

var root = new TestRoot
{
LayoutScaling = 1.25,
Child = new Border
{
Width = 100,
Height = 100,
Child = target,
}
};

root.ExecuteInitialLayoutPass();

Assert.Equal(new(0, 0, 50.4, 50.4), target.Children[0].Bounds);
Assert.Equal(new(50.4, 0, 49.6, 50.4), target.Children[1].Bounds);
Assert.Equal(new(0, 50.4, 50.4, 49.6), target.Children[2].Bounds);
Assert.Equal(new(50.4, 50.4, 49.6, 49.6), target.Children[3].Bounds);
}

[Fact]
public void Children_Do_Not_Overlap_With_125_Percent_Scaling_2()
{
// Issue #17699
var target = new UniformGrid
{
Columns = 4,
Children =
{
new Border(),
new Border(),
new Border(),
new Border(),
}
};

var root = new TestRoot
{
LayoutScaling = 1.25,
Child = new Border
{
Width = 100,
Height = 100,
Child = target,
}
};

root.ExecuteInitialLayoutPass();

Assert.Equal(new(0, 0, 25.6, 100), target.Children[0].Bounds);
Assert.Equal(new(25.6, 0, 24.8, 100), target.Children[1].Bounds);
Assert.Equal(new(50.4, 0, 24.8, 100), target.Children[2].Bounds);
Assert.Equal(new(75.2, 0, 24.8, 100), target.Children[3].Bounds);
}
}
}
2 changes: 1 addition & 1 deletion tests/Avalonia.UnitTests/TestRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public TestRoot(bool useGlobalStyles, Control child)
internal ILayoutManager LayoutManager { get; set; }
ILayoutManager ILayoutRoot.LayoutManager => LayoutManager;

public double RenderScaling => 1;
public double RenderScaling => LayoutScaling;

internal IRenderer Renderer { get; set; }
internal IHitTester HitTester { get; set; }
Expand Down

0 comments on commit 6b90c5c

Please sign in to comment.