Skip to content

Conversation

@TamilarasanSF4853
Copy link
Contributor

@TamilarasanSF4853 TamilarasanSF4853 commented Jan 23, 2026

This pull request includes targeted improvements to test reliability and platform-specific code handling in the test suite. The main changes address platform differences for cookie retrieval and enhance test stability by adding retries and synchronization points.

Platform-specific handling:

  • In CookiesCorrectlyLoadWithMultipleWebViews test, an Android-specific code path was added to retrieve cookies using Android.Webkit.CookieManager.Instance?.GetCookie, while other platforms continue to use EvaluateJavaScriptAsync. This ensures correct cookie retrieval behaviour on Android.

Test stability improvements:

  • In SafeAreaBorderMultipleOrientationChanges test, the [Retry(2)] attribute was added to reduce flakiness by retrying failed tests up to two times.
  • In ApplyingRotationWithZeroDurationShouldNotCrash test, an additional App.WaitForElement("RotateButton") was inserted to ensure UI stability before proceeding with the next action.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 23, 2026
@dotnet-policy-service
Copy link
Contributor

Hey there @@TamilarasanSF4853! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 23, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review January 23, 2026 13:57
Copilot AI review requested due to automatic review settings January 23, 2026 13:57
@sheiksyedm sheiksyedm added the area-testing Unit tests, device tests label Jan 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves UI test reliability by adding retries/synchronization and adjusting cookie retrieval logic for Android.

Changes:

  • Add an NUnit retry to reduce flakiness in the SafeArea border orientation test.
  • Add extra synchronization between taps in a rotation regression test.
  • Add an Android-specific cookie retrieval path in the HostApp issue page.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28986_SafeAreaBorderOrientation.cs Adds [Retry(2)] to mitigate intermittent failures during repeated orientation changes.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18420.cs Adds additional WaitForElement calls to stabilize repeated tap interactions.
src/Controls/tests/TestCases.HostApp/Issues/Issue18452.cs Minor formatting/newline change only.
src/Controls/tests/TestCases.HostApp/Issues/Issue12134.cs Adds Android cookie retrieval via Android.Webkit.CookieManager instead of JS evaluation.

Comment on lines 49 to 53
private async void WebViewOnNavigated(object sender, WebNavigatedEventArgs e)
{
#if ANDROID
var result = Android.Webkit.CookieManager.Instance?.GetCookie("https://dotnet.microsoft.com");
#else
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebViewOnNavigated is marked async, but under #if ANDROID there is no await, which produces CS1998. This repo sets TreatWarningsAsErrors=true (see Directory.Build.props:16), so Android builds will fail. Consider restructuring so the method always awaits (e.g., wrap the Android cookie lookup in a Task and await it), or conditional-compile a non-async Android handler.

Copilot uses AI. Check for mistakes.
#else
var result = await ((WebView)sender).EvaluateJavaScriptAsync("document.cookie");
#endif
_label.Text = result.Contains(_guid.ToString(), StringComparison.OrdinalIgnoreCase) ? "Success" : "Failed";
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android.Webkit.CookieManager.Instance?.GetCookie(...) can return null (or the Instance can be null), and the next line calls result.Contains(...), which will throw on Android. Please make the check null-safe and treat null/empty as "Failed".

Suggested change
_label.Text = result.Contains(_guid.ToString(), StringComparison.OrdinalIgnoreCase) ? "Success" : "Failed";
var success = !string.IsNullOrEmpty(result) && result.Contains(_guid.ToString(), StringComparison.OrdinalIgnoreCase);
_label.Text = success ? "Success" : "Failed";

Copilot uses AI. Check for mistakes.
@rmarinho
Copy link
Member

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests 

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

PureWeen added a commit that referenced this pull request Jan 29, 2026
- Issue18751/18896 local images: covered by #33737
- Issue12134 timeout: covered by #33689 (uses native CookieManager)
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like CookiesCorrectlyLoadWithMultipleWebViews failed

PureWeen added a commit that referenced this pull request Jan 29, 2026
- Issue18751/18896 local images: covered by #33737
- Issue12134 timeout: covered by #33689 (uses native CookieManager)
@TamilarasanSF4853
Copy link
Contributor Author

looks like CookiesCorrectlyLoadWithMultipleWebViews failed

@PureWeen Restricted the CookiesCorrectlyLoadWithMultipleWebViews test for Android.

@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests 

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

github-actions bot pushed a commit that referenced this pull request Jan 29, 2026
- Issue18751/18896 local images: covered by #33737
- Issue12134 timeout: covered by #33689 (uses native CookieManager)
PureWeen added a commit that referenced this pull request Jan 31, 2026
…33749)

> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Description

This PR improves the reliability of several flaky UI tests by:

1. **Replacing `Thread.Sleep` with `retryTimeout`** - The `retryTimeout`
parameter keeps retrying screenshot comparisons until they match or
timeout, adapting to actual UI timing across different machines/load
conditions.

2. **Fixing Issue10563 SwipeView button animations** - Added flat
`Background = SolidColorBrush(Colors.LightGray)` to buttons to prevent
ripple animation artifacts that caused visual differences on CI.

## Changes

| Test | Issue | Fix |
|------|-------|-----|
| Issue10563 | Button ripple animation artifacts in SwipeView test |
Flat button background + updated baselines |
| Issue18857 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue24856 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue25192 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue27418 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue28657 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue30575 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(3)` |

## Related PRs (not overlapping)

- #33737 - Fixes Issue18751/18896 (local monkey images)
- #33689 - Fixes Issue12134 (WebView cookies)

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
kubaflo pushed a commit to kubaflo/maui that referenced this pull request Feb 2, 2026
…otnet#33749)

> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Description

This PR improves the reliability of several flaky UI tests by:

1. **Replacing `Thread.Sleep` with `retryTimeout`** - The `retryTimeout`
parameter keeps retrying screenshot comparisons until they match or
timeout, adapting to actual UI timing across different machines/load
conditions.

2. **Fixing Issue10563 SwipeView button animations** - Added flat
`Background = SolidColorBrush(Colors.LightGray)` to buttons to prevent
ripple animation artifacts that caused visual differences on CI.

## Changes

| Test | Issue | Fix |
|------|-------|-----|
| Issue10563 | Button ripple animation artifacts in SwipeView test |
Flat button background + updated baselines |
| Issue18857 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue24856 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue25192 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue27418 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue28657 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(2)` |
| Issue30575 | Thread.Sleep causes flakiness | `retryTimeout:
TimeSpan.FromSeconds(3)` |

## Related PRs (not overlapping)

- dotnet#33737 - Fixes Issue18751/18896 (local monkey images)
- dotnet#33689 - Fixes Issue12134 (WebView cookies)

---------

Co-authored-by: Ahamed-Ali <102580874+Ahamed-Ali@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-testing Unit tests, device tests community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants