Skip to content

Commit 4cc543c

Browse files
[Windows] Fix ImageHandler Vertical&Horizontal Options with AspectFit (#30936)
* Fix `ImageHandler` Vertical&Horizontal Options with AspectFit * Add testcases screenshots * Add comments for added GetDesiredSize override * Refactor GetDesiredSize and MapSourceAsync for improved aspect handling * Adjust GetDesiredSize and MapHeight for different alignment values * Update test case snapshots for `NoScrollbars` and `ShadowsDontRespectControlShape`
1 parent 86c038a commit 4cc543c

17 files changed

+147
-3
lines changed
100 KB
Loading
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 30403, "Image under WinUI does not respect VerticalOptions and HorizontalOptions with AspectFit", PlatformAffected.UWP)]
4+
public class Issue30403 : TestContentPage
5+
{
6+
protected override void Init()
7+
{
8+
Title = "Issue 30403";
9+
10+
Content = new Grid
11+
{
12+
BackgroundColor = Colors.LightGray,
13+
Children =
14+
{
15+
new Image
16+
{
17+
AutomationId = "TestImage",
18+
Source = "dotnet_bot.png",
19+
Aspect = Aspect.AspectFit,
20+
VerticalOptions = LayoutOptions.Center,
21+
HorizontalOptions = LayoutOptions.Center,
22+
}
23+
}
24+
};
25+
}
26+
}
27 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue30403 : _IssuesUITest
8+
{
9+
public Issue30403(TestDevice testDevice) : base(testDevice)
10+
{
11+
}
12+
13+
public override string Issue => "Image under WinUI does not respect VerticalOptions and HorizontalOptions with AspectFit";
14+
15+
[Test]
16+
[Category(UITestCategories.Image)]
17+
public void ImageRespectsVerticalAndHorizontalOptionsWithAspectFit()
18+
{
19+
App.WaitForElement("TestImage");
20+
21+
// Verify that the image is positioned correctly according to VerticalOptions.Center and HorizontalOptions.Center
22+
// with AspectFit aspect ratio. The image should appear in the center of the Grid.
23+
VerifyScreenshot();
24+
}
25+
}
30.8 KB
Loading
-5.12 KB
Loading
-68.8 KB
Loading
-43.5 KB
Loading
-79.8 KB
Loading
-2.25 KB
Loading

0 commit comments

Comments
 (0)