This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…3311 fixes #12473 fixes #8157 * Add Issue3311.cs * Update Issue331.cs test file * Fix RTL issue on FormattedText * Add relevant RTL FormattedText test * Update Issue3311.cs * Add Issue12473 * Add BackgroundColor to test labels for clarit * Add LabelTest for RTL Label with LineHeight * Add missing closing EmbeddedResource tag * Remove UITest template code * Update RTL tests to be more thorough * 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) * Remove TextType from tests TextType on FormattedText labels causes app crash. This separate issue will be fixed in a follow-up PR
- Loading branch information
1 parent
42a3faa
commit 1304996
Showing
7 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<controls:TestContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue12473"> | ||
<ScrollView Margin="20"> | ||
<StackLayout> | ||
<Label Text="This test passes if all proceeding labels are properly right-aligned" FontSize="20" HorizontalTextAlignment="Center" /> | ||
|
||
<Label Text="This is a normal text label with RTL" FlowDirection="RightToLeft" BackgroundColor="Red"/> | ||
<Label Text="This is a normal text label with RTL and LineHeight" FlowDirection="RightToLeft" LineHeight="3" BackgroundColor="Yellow"/> | ||
|
||
<!--Test the same thing with Labels in an RTL language--> | ||
<Label Text="هذا نص حشو عشوائي أتمنى ترجمته بشكل صحيح من الإنجليزية" FlowDirection="RightToLeft" BackgroundColor="Red"/> | ||
<Label Text="هذا نص حشو عشوائي أتمنى ترجمته بشكل صحيح من الإنجليزية" FlowDirection="RightToLeft" LineHeight="3" BackgroundColor="Yellow"/> | ||
|
||
<!--Test the same thing with Labels using both LTR and RTL languages--> | ||
<Label Text="foo هذا نص حشو عشوائي أتمنى ترجمته بشكل صحيح من الإنجليزية" FlowDirection="RightToLeft" BackgroundColor="Red"/> | ||
<Label Text="foo هذا نص حشو عشوائي أتمنى ترجمته بشكل صحيح من الإنجليزية" FlowDirection="RightToLeft" LineHeight="3" BackgroundColor="Yellow"/> | ||
</StackLayout> | ||
</ScrollView> | ||
</controls:TestContentPage> |
35 changes: 35 additions & 0 deletions
35
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue12473.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
{ | ||
|
||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3311.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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, "RTL is not working for iOS Label with FormattedText", 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 = "This test passes if all proceeding labels are properly right-aligned", | ||
HorizontalTextAlignment = TextAlignment.Center, | ||
FontSize = 20 | ||
}, | ||
new Label() | ||
{ | ||
AutomationId = "Issue3311NormalTextLabel", | ||
Text = "RTL normal text", | ||
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, | ||
TextColor = Color.Blue, | ||
TextTransform = TextTransform.Uppercase, | ||
TextType = TextType.Html, | ||
HorizontalTextAlignment = TextAlignment.Start | ||
}, | ||
new Label() | ||
{ | ||
AutomationId = "Issue3311FormattedTextLabel", | ||
FormattedText = formattedString, | ||
FlowDirection = FlowDirection.RightToLeft, | ||
|
||
BackgroundColor = Color.Yellow, | ||
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, | ||
HorizontalTextAlignment = TextAlignment.Start | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using UIKit; | ||
|
||
namespace Xamarin.Forms.Platform.iOS.UnitTests | ||
{ | ||
[TestFixture] | ||
public class LabelTests : PlatformTestFixture | ||
{ | ||
[Test, Category("Label"), Category("RTL"), Category("FormattedText")] | ||
[Description("RTL should work on Label with FormattedText")] | ||
public async Task RTLWorksOnLabelWithFormattedText() | ||
{ | ||
var formattedString = new FormattedString(); | ||
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 => | ||
{ | ||
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.HorizontalTextAlignment = TextAlignment.Start; | ||
label.VerticalTextAlignment = TextAlignment.Center; | ||
return uiLabel.TextAlignment; | ||
}); | ||
Assert.That(actual, Is.EqualTo(expected)); | ||
} | ||
|
||
[Test, Category("Label"), Category("RTL"), Category("LineHeight")] | ||
[Description("RTL should work on Label with LineHeight")] | ||
public async Task RTLWorksOnLabelWithLineHeight() | ||
{ | ||
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 => | ||
{ | ||
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters