Skip to content
50 changes: 50 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue34114.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.Maui.Controls.Shapes;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 34114, "Label with background clip is not working properly", PlatformAffected.iOS | PlatformAffected.macOS | PlatformAffected.UWP)]
public class Issue34114 : ContentPage
{
Label _clipTestLabel;
Button _changeClipButton;
public Issue34114()
{
_clipTestLabel = new Label
{
Text = "Clipped Label",
BackgroundColor = Colors.Red,
HorizontalTextAlignment = TextAlignment.Center,
VerticalTextAlignment = TextAlignment.Center,
WidthRequest = 300,
HeightRequest = 300,
AutomationId = "ClippedLabel",
Clip = new EllipseGeometry
{
Center = new Point(150, 150),
RadiusX = 150,
RadiusY = 150
}
};

_changeClipButton = new Button
{
Text = "Change Clip",
AutomationId = "ChangeClip"
};

_changeClipButton.Clicked += (s, e) =>
{
_clipTestLabel.Clip = new RoundRectangleGeometry(new CornerRadius(50), new Rect(75, 100, 150, 100));
};

Content = new VerticalStackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
{
_clipTestLabel,
_changeClipButton
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if TEST_FAILS_ON_WINDOWS // This test fails on Windows because of a known issue with clipping in WinUI.

using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue34114 : _IssuesUITest
{
public Issue34114(TestDevice device) : base(device) { }

public override string Issue => "Label with background clip is not working properly";

[Test, Order(0)]
[Category(UITestCategories.Label)]
public void VerifyLabelBackgroundIsClippedWithEllipseGeometry()
{
App.WaitForElement("ClippedLabel");
VerifyScreenshot();
}

[Test, Order(1)]
[Category(UITestCategories.Label)]
public void VerifyLabelBackgroundIsClippedWithRectangleGeometry()
{
App.WaitForElement("ClippedLabel");
App.Tap("ChangeClip");
VerifyScreenshot();
}
Comment thread
Shalini-Ashokan marked this conversation as resolved.
Resolved
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Label/LabelHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void MapBackground(ILabelHandler handler, ILabel label)
{
handler.UpdateValue(nameof(IViewHandler.ContainerView));

handler.ToPlatform().UpdateBackground(label);
handler.PlatformView?.UpdateBackground(label);
Comment thread
Shalini-Ashokan marked this conversation as resolved.
Resolved
}

public static void MapText(ILabelHandler handler, ILabel label)
Expand Down
Loading