From 33610e1a423351de4e3ccd13d525b68d9a90df78 Mon Sep 17 00:00:00 2001 From: Jakub Florkowski Date: Tue, 10 Jun 2025 17:51:53 +0200 Subject: [PATCH] Fixed Test case failure in PR 26153 - iOS --- .../DeviceTests/Elements/Label/LabelTests.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs index d779e6798e29..d1f265ac44af 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs @@ -333,6 +333,10 @@ await AttachAndRun(layout, async (handler) => label.TextType = TextType.Html; + // We need to delay here because platformLabel.UpdateTextHtml(label) and label.InvalidateMeasure() + // are dispatched asynchronously to the main thread and may not complete immediately. + // https://github.com/dotnet/maui/pull/26153 + await Task.Delay(100); await platformView.AssertDoesNotContainColor(Colors.Red, MauiContext); }); } @@ -517,9 +521,13 @@ public async Task FontStuffAppliesEvenInHtmlMode() Text = "

Test

" }; - await InvokeOnMainThreadAsync(() => + await InvokeOnMainThreadAsync(async () => { var handler = CreateHandler(label); + // We need to delay here because platformLabel.UpdateTextHtml(label) and label.InvalidateMeasure() + // are dispatched asynchronously to the main thread and may not complete immediately. + // https://github.com/dotnet/maui/pull/26153 + await Task.Delay(100); AssertEquivalentFont(handler, label.ToFont()); }); } @@ -715,9 +723,13 @@ public async Task FontStuffAfterTextTypeIsCorrect() Text = "

Test

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