Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Added Android LineBreakMode test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Feb 24, 2021
1 parent 674f97b commit d626393
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.Threading.Tasks;
using Android.Text;
using Android.Widget;
using Xamarin.Forms;
using Xamarin.Platform.Handlers.DeviceTests.Stubs;
using Xunit;

namespace Xamarin.Platform.Handlers.DeviceTests
{
Expand All @@ -25,5 +28,33 @@ Task ValidateNativeBackgroundColor(ILabel label, Color color)

int GetNativeMaxLines(LabelHandler labelHandler) =>
GetNativeLabel(labelHandler).MaxLines;

TextUtils.TruncateAt GetNativeEllipsize(LabelHandler labelHandler) =>
GetNativeLabel(labelHandler).Ellipsize;

[Fact(DisplayName = "[LabelHandler] LineBreakMode Initializes Correctly")]
public async Task LineBreakModeInitializesCorrectly()
{
var xplatLineBreakMode = LineBreakMode.TailTruncation;

var labelStub = new LabelStub()
{
LineBreakMode = xplatLineBreakMode
};

var expectedValue = TextUtils.TruncateAt.End;

var values = await GetValueAsync(labelStub, (handler) =>
{
return new
{
ViewValue = labelStub.LineBreakMode,
NativeViewValue = GetNativeEllipsize(handler)
};
});

Assert.Equal(xplatLineBreakMode, values.ViewValue);
Assert.Equal(expectedValue, values.NativeViewValue);
}
}
}

0 comments on commit d626393

Please sign in to comment.