Skip to content

Commit bef57ff

Browse files
committed
Stabilize window size check in Issue2818 test
Replaced fixed delay with a polling loop to wait for the window width to stabilize after foregrounding the app. This change reduces test flakiness on platforms where layout size may temporarily change before settling.
1 parent dc81db8 commit bef57ff

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue2818.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST
1+
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST
22
// Orientation not supported in Catalyst and Windows
33
using NUnit.Framework;
44
using UITest.Appium;
@@ -51,7 +51,17 @@ public async Task RootViewSizeDoesntChangeAfterBackground()
5151
App.WaitForNoElement("RootLayout");
5252
App.ForegroundApp();
5353
var newWindowSize = App.WaitForElement("RootLayout");
54-
await Task.Delay(2000); // Wait for the app to settle after foregrounding
54+
55+
// Poll until the width stabilizes. After foregrounding, some platforms (esp. Android/iOS)
56+
// may momentarily report an intermediate layout size while the window / flyout re-applies
57+
// RTL + orientation constraints. This loop prevents test flakiness by waiting for the
58+
// final (restored) size instead of asserting too early
59+
int retries = 50;
60+
while (newWindowSize.GetRect().Width != windowSize.GetRect().Width && retries-- > 0)
61+
{
62+
await Task.Delay(100);
63+
}
64+
5565
Assert.That(newWindowSize.GetRect().Width, Is.EqualTo(windowSize.GetRect().Width));
5666
Assert.That(newWindowSize.GetRect().Height, Is.EqualTo(windowSize.GetRect().Height));
5767
}

0 commit comments

Comments
 (0)