Skip to content

Commit c7d78c5

Browse files
Update unit tests to reflect fixed behavior and enhance background rect width protection
Co-authored-by: PaulAndersonS <[email protected]>
1 parent 0fd4268 commit c7d78c5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

maui/src/TextInputLayout/SfTextInputLayout.Methods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,14 +1609,14 @@ void UpdateOutlineBackgroundRectF()
16091609
{
16101610
_backgroundRectF.X = (float)(_outlineRectF.X + (FocusedStrokeThickness / 2));
16111611
_backgroundRectF.Y = (float)(_outlineRectF.Y + (FocusedStrokeThickness / 2));
1612-
_backgroundRectF.Width = (float)(_outlineRectF.Width - (FocusedStrokeThickness));
1612+
_backgroundRectF.Width = (float)Math.Max(1, _outlineRectF.Width - FocusedStrokeThickness);
16131613
_backgroundRectF.Height = (float)(_outlineRectF.Height - (FocusedStrokeThickness));
16141614
}
16151615
else
16161616
{
16171617
_backgroundRectF.X = (float)(_outlineRectF.X + (UnfocusedStrokeThickness / 2));
16181618
_backgroundRectF.Y = (float)(_outlineRectF.Y + (UnfocusedStrokeThickness / 2));
1619-
_backgroundRectF.Width = (float)(_outlineRectF.Width - (UnfocusedStrokeThickness));
1619+
_backgroundRectF.Width = (float)Math.Max(1, _outlineRectF.Width - UnfocusedStrokeThickness);
16201620
_backgroundRectF.Height = (float)(_outlineRectF.Height - (UnfocusedStrokeThickness));
16211621
}
16221622

maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfTextInputLayoutUnitTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -715,12 +715,12 @@ public void TestUpdateIconRectFMethod()
715715
TrailingViewPosition = ViewPosition.Outside
716716
};
717717
InvokePrivateMethod(inputLayout, "UpdateIconRectF");
718-
var outRectExpected = new RectF() { X = 21, Y = 2, Width = -43, Height = -24 };
718+
var outRectExpected = new RectF() { X = 21, Y = 2, Width = 1, Height = -24 };
719719
var resultOutRect = GetPrivateField(inputLayout, "_outlineRectF");
720-
Assert.Equal(resultOutRect, outRectExpected);
721-
var backgroundRectExpected = new RectF() { X = 19, Y = 0, Width = -39, Height = -22 };
720+
Assert.Equal(outRectExpected, resultOutRect);
721+
var backgroundRectExpected = new RectF() { X = 19, Y = 0, Width = 1, Height = -22 };
722722
var resultBackgroundRect = GetPrivateField(inputLayout, "_backgroundRectF");
723-
Assert.Equal(resultBackgroundRect, backgroundRectExpected);
723+
Assert.Equal(backgroundRectExpected, resultBackgroundRect);
724724
var _passwordToggleIconRectF = new RectF() { X = -83, Y = -27, Width = 32, Height = 32 };
725725
var resultPassToggleRect = GetPrivateField(inputLayout, "_passwordToggleIconRectF");
726726
Assert.Equal(resultPassToggleRect, _passwordToggleIconRectF);
@@ -816,7 +816,7 @@ public void TestUpdateHelperTextPositionMethod()
816816
TrailingView = new Entry(),
817817
TrailingViewPosition = ViewPosition.Outside
818818
};
819-
var expected = new RectF() { X = 60, Y = -18, Width = -96, Height = 16 };
819+
var expected = new RectF() { X = 60, Y = -18, Width = 1, Height = 16 };
820820
InvokePrivateMethod(inputLayout, "UpdateHelperTextPosition");
821821
var result = GetPrivateField(inputLayout, "_helperTextRect");
822822
Assert.Equal(expected, result);
@@ -873,7 +873,7 @@ public void TestUpdateErrorTextPositionMethod()
873873
{
874874
var inputLayout = new SfTextInputLayout();
875875
InvokePrivateMethod(inputLayout, "UpdateErrorTextPosition");
876-
RectF expectedRect = new RectF() { X = 16, Y = -18, Width = -33, Height = 16 };
876+
RectF expectedRect = new RectF() { X = 16, Y = -18, Width = 1, Height = 16 };
877877
var result = GetPrivateField(inputLayout, "_errorTextRect");
878878
Assert.Equal(expectedRect, result);
879879
}

0 commit comments

Comments
 (0)