From 280899b682e7683a290c4e2cb1980c9b3b7e2f1d Mon Sep 17 00:00:00 2001 From: rachelkang Date: Thu, 3 Dec 2020 16:10:43 -0500 Subject: [PATCH 01/13] Add Issue3311.cs --- .../Issue3311.cs | 66 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 1 + 2 files changed, 67 insertions(+) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs new file mode 100644 index 00000000000..db84ecad8b5 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -0,0 +1,66 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.Forms.Core.UITests; +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ +#if UITEST + [Category(UITestCategories.ManualReview)] +#endif + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 3311, "Issue Description", PlatformAffected.Default)] + public class Issue3311 : TestContentPage + { + protected override void Init() + { + + var formattedString = new FormattedString(); + formattedString.Spans.Add(new Span { Text = "RTL formatted text" }); + + Content = new StackLayout() + { + Margin = 20, + + Children = + { + new Label() + { + AutomationId = "Issue3311Label", + Text = "Issue 3311: RTL is not working for Label.FormattedText on iOS", + HorizontalTextAlignment = TextAlignment.Center, + FontSize = 20 + }, + new Label() + { + AutomationId = "Issue3311NormalTextLabel", + FlowDirection = FlowDirection.RightToLeft, + Text = "RTL normal text" + }, + new Label() + { + AutomationId = "Issue3311FormattedTextLabel", + FlowDirection = FlowDirection.RightToLeft, + FormattedText = formattedString + } + } + }; + } + +#if UITEST + [Test] + public void Issue1Test() + { + RunningApp.WaitForElement("Issue1Label"); + // Delete this and all other UITEST sections if there is no way to automate the test. Otherwise, be sure to rename the test and update the Category attribute on the class. Note that you can add multiple categories. + RunningApp.Screenshot("I am at Issue1"); + RunningApp.WaitForElement(q => q.Marked("Issue1Label")); + RunningApp.Screenshot("I see the Label"); + } +#endif + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 62e02049bfc..432c75315ea 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -1646,6 +1646,7 @@ + From 6cc15498114f31543f6dbd3a603df9b705637266 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 18 Dec 2020 09:47:09 -0500 Subject: [PATCH 02/13] Update Issue331.cs test file --- .../Issue3311.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs index db84ecad8b5..14f44a69e68 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -20,7 +20,7 @@ protected override void Init() { var formattedString = new FormattedString(); - formattedString.Spans.Add(new Span { Text = "RTL formatted text" }); + formattedString.Spans.Add(new Span { Text = "RTL \nformatted \ntext" }); Content = new StackLayout() { @@ -31,7 +31,7 @@ protected override void Init() new Label() { AutomationId = "Issue3311Label", - Text = "Issue 3311: RTL is not working for Label.FormattedText on iOS", + Text = "Issue 3311: RTL is not working for Label.FormattedText on iOS. This test passes if all proceeding labels are properly right-aligned.", HorizontalTextAlignment = TextAlignment.Center, FontSize = 20 }, @@ -45,8 +45,18 @@ protected override void Init() { AutomationId = "Issue3311FormattedTextLabel", FlowDirection = FlowDirection.RightToLeft, + BackgroundColor = Color.Red, + FormattedText = formattedString + }, + new Label() + { + AutomationId = "Issue3311FormattedTextWithLineHeightLabel", + FlowDirection = FlowDirection.RightToLeft, + LineHeight = 3, + BackgroundColor = Color.Red, FormattedText = formattedString } + } }; } From 5f080135e84aa8ef96b3c86200a01d7acedf7ea0 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 18 Dec 2020 09:47:32 -0500 Subject: [PATCH 03/13] Fix RTL issue on FormattedText --- Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs index b3cac2f3a29..d4391075573 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs @@ -173,7 +173,6 @@ protected override void OnElementChanged(ElementChangedEventArgs From 3f5904bbcf1ce27e1b3ea94a3a55e89d1afe412f Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 18 Dec 2020 16:23:41 -0500 Subject: [PATCH 05/13] Update Issue3311.cs --- .../Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs index 14f44a69e68..c6cb0e50ce2 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -13,7 +13,7 @@ namespace Xamarin.Forms.Controls.Issues [Category(UITestCategories.ManualReview)] #endif [Preserve(AllMembers = true)] - [Issue(IssueTracker.Github, 3311, "Issue Description", PlatformAffected.Default)] + [Issue(IssueTracker.Github, 3311, "RTL is not working for iOS Label with FormattedText", PlatformAffected.Default)] public class Issue3311 : TestContentPage { protected override void Init() @@ -31,7 +31,7 @@ protected override void Init() new Label() { AutomationId = "Issue3311Label", - Text = "Issue 3311: RTL is not working for Label.FormattedText on iOS. This test passes if all proceeding labels are properly right-aligned.", + Text = "This test passes if all proceeding labels are properly right-aligned", HorizontalTextAlignment = TextAlignment.Center, FontSize = 20 }, @@ -45,7 +45,6 @@ protected override void Init() { AutomationId = "Issue3311FormattedTextLabel", FlowDirection = FlowDirection.RightToLeft, - BackgroundColor = Color.Red, FormattedText = formattedString }, new Label() @@ -53,7 +52,6 @@ protected override void Init() AutomationId = "Issue3311FormattedTextWithLineHeightLabel", FlowDirection = FlowDirection.RightToLeft, LineHeight = 3, - BackgroundColor = Color.Red, FormattedText = formattedString } From 570901691d6b82981c240a07c7c3ba775e26cb9a Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 18 Dec 2020 16:23:59 -0500 Subject: [PATCH 06/13] Add Issue12473 --- .../Issue12473.xaml | 23 ++++++++++++ .../Issue12473.xaml.cs | 35 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 8 +++++ 3 files changed, 66 insertions(+) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml new file mode 100644 index 00000000000..20b52f7983c --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml.cs new file mode 100644 index 00000000000..67edce83d95 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml.cs @@ -0,0 +1,35 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; +using Xamarin.Forms.Xaml; + +#if UITEST +using Xamarin.Forms.Core.UITests; +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ +#if UITEST + [Category(UITestCategories.ManualReview)] +#endif +#if APP + [XamlCompilation(XamlCompilationOptions.Compile)] +#endif + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 12473, "iOS Label text alignment in RTL with LineHeight", PlatformAffected.iOS)] + public partial class Issue12473 : TestContentPage + { + public Issue12473() + { +#if APP + InitializeComponent(); +#endif + } + + protected override void Init() + { + + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 432c75315ea..f3bec88c825 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -1647,6 +1647,10 @@ + + Issue12473.xaml + Code + @@ -1992,6 +1996,10 @@ MSBuild:UpdateDesignTimeXaml + + Designer + MSBuild:UpdateDesignTimeXaml + From ba3c193d1566eeeb4918477fa620bce613943a5a Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 18 Dec 2020 16:43:51 -0500 Subject: [PATCH 07/13] Add BackgroundColor to test labels for clarit --- .../Issue12473.xaml | 12 ++++++------ .../Issue3311.cs | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml index 20b52f7983c..8922b19e3c9 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml @@ -8,16 +8,16 @@ \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs index c6cb0e50ce2..6f0c60c68c8 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -39,18 +39,21 @@ protected override void Init() { AutomationId = "Issue3311NormalTextLabel", FlowDirection = FlowDirection.RightToLeft, + BackgroundColor = Color.Red, Text = "RTL normal text" }, new Label() { AutomationId = "Issue3311FormattedTextLabel", FlowDirection = FlowDirection.RightToLeft, + BackgroundColor = Color.Yellow, FormattedText = formattedString }, new Label() { AutomationId = "Issue3311FormattedTextWithLineHeightLabel", FlowDirection = FlowDirection.RightToLeft, + BackgroundColor = Color.Red, LineHeight = 3, FormattedText = formattedString } From dab4abdefd95b543fada759de39448cc269d18c5 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 18 Dec 2020 16:58:21 -0500 Subject: [PATCH 08/13] Add LabelTest for RTL Label with LineHeight --- Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs b/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs index 895ebc2a426..a3ed0b03efd 100644 --- a/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs +++ b/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs @@ -9,7 +9,7 @@ public class LabelTests : PlatformTestFixture { [Test, Category("RTL"), Category("Label")] [Description("RTL should work on Label with FormattedText")] - public async Task LabelFormattedTextRTLWorks() + public async Task RTLLabelWithFormattedTextWorks() { var formattedString = new FormattedString(); formattedString.Spans.Add(new Span { Text = "RTL formatted text" }); @@ -19,5 +19,17 @@ public async Task LabelFormattedTextRTLWorks() var actual = await GetControlProperty(label, uiLabel => uiLabel.TextAlignment); Assert.That(actual, Is.EqualTo(expected)); } + + [Test, Category("RTL"), Category("Label")] + [Description("RTL should work on Label with LineHeight")] + public async Task RTLLabelWithLineHeightWorks() + { + var label = new Label { Text = "RTL text with LineHeight" }; + label.FlowDirection = FlowDirection.RightToLeft; + label.LineHeight = 3; + var expected = UITextAlignment.Right; + var actual = await GetControlProperty(label, uiLabel => uiLabel.TextAlignment); + Assert.That(actual, Is.EqualTo(expected)); + } } } \ No newline at end of file From f81a6be981868dc1b10002753ab5440f6a9a04a1 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Thu, 31 Dec 2020 14:44:14 -0500 Subject: [PATCH 09/13] Add missing closing EmbeddedResource tag --- .../Xamarin.Forms.Controls.Issues.Shared.projitems | 1 + 1 file changed, 1 insertion(+) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 1fbde04f65c..33acaea8ba9 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -2059,6 +2059,7 @@ Designer + MSBuild:UpdateDesignTimeXaml From 71eec9660efd032fd6757da687f09ab75515b0a4 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Tue, 12 Jan 2021 17:19:23 -0500 Subject: [PATCH 10/13] Remove UITest template code --- .../Issue3311.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs index 6f0c60c68c8..7bf440769f3 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -61,17 +61,4 @@ protected override void Init() } }; } - -#if UITEST - [Test] - public void Issue1Test() - { - RunningApp.WaitForElement("Issue1Label"); - // Delete this and all other UITEST sections if there is no way to automate the test. Otherwise, be sure to rename the test and update the Category attribute on the class. Note that you can add multiple categories. - RunningApp.Screenshot("I am at Issue1"); - RunningApp.WaitForElement(q => q.Marked("Issue1Label")); - RunningApp.Screenshot("I see the Label"); - } -#endif - } } \ No newline at end of file From 94310e5cc0327455bde309d6235fabd80e418191 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Thu, 14 Jan 2021 21:15:30 -0500 Subject: [PATCH 11/13] Update RTL tests to be more thorough --- .../Issue3311.cs | 49 +++++++++++---- .../LabelTests.cs | 60 ++++++++++++++++--- 2 files changed, 88 insertions(+), 21 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs index 7bf440769f3..c43e02b8912 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -14,13 +14,12 @@ namespace Xamarin.Forms.Controls.Issues #endif [Preserve(AllMembers = true)] [Issue(IssueTracker.Github, 3311, "RTL is not working for iOS Label with FormattedText", PlatformAffected.Default)] - public class Issue3311 : TestContentPage + public class Issue3311 : TestContentPage { protected override void Init() { - var formattedString = new FormattedString(); - formattedString.Spans.Add(new Span { Text = "RTL \nformatted \ntext" }); + formattedString.Spans.Add(new Span { Text = "RTL formatted text" }); Content = new StackLayout() { @@ -38,27 +37,51 @@ protected override void Init() new Label() { AutomationId = "Issue3311NormalTextLabel", + Text = "RTL normal text", FlowDirection = FlowDirection.RightToLeft, + BackgroundColor = Color.Red, - Text = "RTL normal text" + HeightRequest = 100, + LineBreakMode = LineBreakMode.WordWrap, + Margin = 20, + MaxLines = 1, + Opacity = 50, + Padding = 5, + TextDecorations = TextDecorations.Underline, + VerticalTextAlignment = TextAlignment.Center, + FontAttributes = FontAttributes.Bold, + FontSize = 20, + LineHeight = 3, + TextColor = Color.Blue, + TextTransform = TextTransform.Uppercase, + TextType = TextType.Html, + HorizontalTextAlignment = TextAlignment.Start }, new Label() { AutomationId = "Issue3311FormattedTextLabel", + FormattedText = formattedString, FlowDirection = FlowDirection.RightToLeft, + BackgroundColor = Color.Yellow, - FormattedText = formattedString - }, - new Label() - { - AutomationId = "Issue3311FormattedTextWithLineHeightLabel", - FlowDirection = FlowDirection.RightToLeft, - BackgroundColor = Color.Red, + HeightRequest = 100, + LineBreakMode = LineBreakMode.WordWrap, + Margin = 20, + MaxLines = 1, + Opacity = 50, + Padding = 5, + TextDecorations = TextDecorations.Underline, + VerticalTextAlignment = TextAlignment.Center, + FontAttributes = FontAttributes.Bold, + FontSize = 20, LineHeight = 3, - FormattedText = formattedString + TextColor = Color.Blue, + TextTransform = TextTransform.Uppercase, + TextType = TextType.Html, + HorizontalTextAlignment = TextAlignment.Start } - } }; } + } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs b/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs index a3ed0b03efd..94338eceb3c 100644 --- a/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs +++ b/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs @@ -7,28 +7,72 @@ namespace Xamarin.Forms.Platform.iOS.UnitTests [TestFixture] public class LabelTests : PlatformTestFixture { - [Test, Category("RTL"), Category("Label")] + [Test, Category("Label"), Category("RTL"), Category("FormattedText")] [Description("RTL should work on Label with FormattedText")] - public async Task RTLLabelWithFormattedTextWorks() + public async Task RTLWorksOnLabelWithFormattedText() { var formattedString = new FormattedString(); - formattedString.Spans.Add(new Span { Text = "RTL formatted text" }); + formattedString.Spans.Add(new Span { Text = "Label with RTL and FormattedText" }); var label = new Label { FormattedText = formattedString }; label.FlowDirection = FlowDirection.RightToLeft; var expected = UITextAlignment.Right; - var actual = await GetControlProperty(label, uiLabel => uiLabel.TextAlignment); + var actual = await GetControlProperty(label, uiLabel => + { + label.BackgroundColor = Color.Yellow; + label.HeightRequest = 50; + label.LineBreakMode = LineBreakMode.WordWrap; + label.Margin = 20; + label.MaxLines = 1; + label.Opacity = 50; + label.Padding = 5; + label.TextDecorations = TextDecorations.Underline; + + label.FontAttributes = FontAttributes.Bold; + label.FontSize = 20; + label.LineHeight = 3; + label.TextColor = Color.Blue; + label.TextTransform = TextTransform.Uppercase; + label.TextType = TextType.Html; + label.HorizontalTextAlignment = TextAlignment.Start; + label.VerticalTextAlignment = TextAlignment.Center; + + return uiLabel.TextAlignment; + }); Assert.That(actual, Is.EqualTo(expected)); } - [Test, Category("RTL"), Category("Label")] + [Test, Category("Label"), Category("RTL"), Category("LineHeight")] [Description("RTL should work on Label with LineHeight")] - public async Task RTLLabelWithLineHeightWorks() + public async Task RTLWorksOnLabelWithLineHeight() { - var label = new Label { Text = "RTL text with LineHeight" }; + var label = new Label { Text = "Label with RTL and LineHeight" }; label.FlowDirection = FlowDirection.RightToLeft; label.LineHeight = 3; var expected = UITextAlignment.Right; - var actual = await GetControlProperty(label, uiLabel => uiLabel.TextAlignment); + var actual = await GetControlProperty(label, uiLabel => + { + label.BackgroundColor = Color.Yellow; + label.HeightRequest = 50; + label.LineBreakMode = LineBreakMode.WordWrap; + label.Margin = 20; + label.MaxLines = 1; + label.Opacity = 50; + label.Padding = 5; + label.TextDecorations = TextDecorations.Underline; + + label.FontAttributes = FontAttributes.Bold; + label.FontSize = 20; + label.LineHeight = 3; + label.TextColor = Color.Blue; + label.TextTransform = TextTransform.Uppercase; + label.TextType = TextType.Html; + label.HorizontalTextAlignment = TextAlignment.Start; + label.VerticalTextAlignment = TextAlignment.Center; + + return uiLabel.TextAlignment; + }); + Assert.That(actual, Is.EqualTo(expected)); + } Assert.That(actual, Is.EqualTo(expected)); } } From 870e39b27b01a900bbbc3b03751aca4ee941c032 Mon Sep 17 00:00:00 2001 From: rachelkang Date: Thu, 14 Jan 2021 21:23:14 -0500 Subject: [PATCH 12/13] UpdateHorizontalTextAlignment on UpdateFormattedText Fix RTL issue that arises when certain text properties are set on a Label w/ RTL and FormattedText (i.e. FontAttributes, FontSize, LineHeight, TextColor, TextTransform, etc) --- Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs index d4391075573..d218e850e31 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs @@ -466,6 +466,8 @@ void UpdateFormattedText() Control.AttributedStringValue = _formatted.ToAttributed(Element, Element.TextColor, Element.HorizontalTextAlignment, Element.LineHeight); #endif _perfectSizeValid = false; + + UpdateHorizontalTextAlignment(); } void UpdateTextHtml() From 4239d00caefe79b4bcb677c008b7aefe07686dcd Mon Sep 17 00:00:00 2001 From: rachelkang Date: Fri, 15 Jan 2021 14:59:29 -0500 Subject: [PATCH 13/13] Remove TextType from tests TextType on FormattedText labels causes app crash. This separate issue will be fixed in a follow-up PR --- .../Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs | 1 - Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs | 3 --- 2 files changed, 4 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs index c43e02b8912..b6b1cd5262c 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs @@ -77,7 +77,6 @@ protected override void Init() LineHeight = 3, TextColor = Color.Blue, TextTransform = TextTransform.Uppercase, - TextType = TextType.Html, HorizontalTextAlignment = TextAlignment.Start } } diff --git a/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs b/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs index 94338eceb3c..5d2735210cc 100644 --- a/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs +++ b/Xamarin.Forms.Platform.iOS.UnitTests/LabelTests.cs @@ -32,7 +32,6 @@ public async Task RTLWorksOnLabelWithFormattedText() label.LineHeight = 3; label.TextColor = Color.Blue; label.TextTransform = TextTransform.Uppercase; - label.TextType = TextType.Html; label.HorizontalTextAlignment = TextAlignment.Start; label.VerticalTextAlignment = TextAlignment.Center; @@ -73,7 +72,5 @@ public async Task RTLWorksOnLabelWithLineHeight() }); Assert.That(actual, Is.EqualTo(expected)); } - Assert.That(actual, Is.EqualTo(expected)); - } } } \ No newline at end of file