Skip to content

Commit c044ed3

Browse files
kubafloPureWeen
authored andcommitted
Fixed Test case failure in PR 26153 - iOS (#29906)
1 parent 1ef4976 commit c044ed3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ await AttachAndRun(layout, async (handler) =>
333333

334334
label.TextType = TextType.Html;
335335

336+
// We need to delay here because platformLabel.UpdateTextHtml(label) and label.InvalidateMeasure()
337+
// are dispatched asynchronously to the main thread and may not complete immediately.
338+
// https://github.com/dotnet/maui/pull/26153
339+
await Task.Delay(100);
336340
await platformView.AssertDoesNotContainColor(Colors.Red, MauiContext);
337341
});
338342
}
@@ -517,9 +521,13 @@ public async Task FontStuffAppliesEvenInHtmlMode()
517521
Text = "<p>Test</p>"
518522
};
519523

520-
await InvokeOnMainThreadAsync(() =>
524+
await InvokeOnMainThreadAsync(async () =>
521525
{
522526
var handler = CreateHandler<LabelHandler>(label);
527+
// We need to delay here because platformLabel.UpdateTextHtml(label) and label.InvalidateMeasure()
528+
// are dispatched asynchronously to the main thread and may not complete immediately.
529+
// https://github.com/dotnet/maui/pull/26153
530+
await Task.Delay(100);
523531
AssertEquivalentFont(handler, label.ToFont());
524532
});
525533
}
@@ -715,9 +723,13 @@ public async Task FontStuffAfterTextTypeIsCorrect()
715723
Text = "<p>Test</p>"
716724
};
717725

718-
await InvokeOnMainThreadAsync(() =>
726+
await InvokeOnMainThreadAsync(async () =>
719727
{
720728
var handler = CreateHandler<LabelHandler>(label);
729+
// We need to delay here because platformLabel.UpdateTextHtml(label) and label.InvalidateMeasure()
730+
// are dispatched asynchronously to the main thread and may not complete immediately.
731+
// https://github.com/dotnet/maui/pull/26153
732+
await Task.Delay(100);
721733
label.FontFamily = "Baskerville";
722734
label.FontSize = 64;
723735
AssertEquivalentFont(handler, label.ToFont());

0 commit comments

Comments
 (0)