Skip to content

[Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control#34283

Open
LogishaSelvarajSF4525 wants to merge 5 commits intodotnet:mainfrom
LogishaSelvarajSF4525:refactoring-checkbox-feature
Open

[Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control#34283
LogishaSelvarajSF4525 wants to merge 5 commits intodotnet:mainfrom
LogishaSelvarajSF4525:refactoring-checkbox-feature

Conversation

@LogishaSelvarajSF4525
Copy link
Contributor

This pull request refactors and enhances the CheckBox feature matrix test page and its associated ViewModel. The main changes include renaming and simplifying the ViewModel, adding support for a shadow property on the CheckBox, improving the reset logic, and updating the UI and test constants to match these changes.

ViewModel Refactoring and Enhancement:

  • Renamed CheckBoxFeatureMatrixViewModel to CheckBoxViewModel, moved the color-setting logic into the ViewModel, and added a new Reset() method to centralize state resets. The ViewModel now also exposes a HasShadow property and a corresponding Shadow property, allowing the CheckBox to visually display a shadow when toggled. [1] [2] [3]

UI and Binding Updates:

  • Updated CheckBoxControlPage.xaml to use the new ViewModel name, bind the CheckBox's Shadow property, and add a UI toggle for the shadow feature. The reset button now calls the ViewModel's Reset() method. The color buttons were updated with text, color, and width for clarity. [1] [2] [3]

Logic and Usability Improvements:

  • The Switch controlling IsChecked is now disabled when the CheckBox is disabled, ensuring consistent behavior and preventing user interaction when not allowed.

Test Constants Update:

  • Added new automation IDs and constants in the test file to support the new UI elements (HasShadowCheckBox, color buttons, and command parameter entry).

Code Cleanup:

  • Removed unused commands and redundant code from the code-behind, delegating all state logic to the ViewModel for a cleaner separation of concerns.

These changes improve maintainability, testability, and feature coverage for the CheckBox control in the test app.

Issues Identified

@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34283

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34283"

@dotnet-policy-service
Copy link
Contributor

Hey there @@LogishaSelvarajSF4525! 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 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Feb 27, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review February 27, 2026 14:08
Copilot AI review requested due to automatic review settings February 27, 2026 14:08
@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

This PR refactors the CheckBox FeatureMatrix test page and updates the corresponding FeatureMatrix UITests to match, including adding a “shadow” toggle and improving reset/state handling for more scenarios around checked/enabled/command/color behavior (related to #34278).

Changes:

  • Refactored the FeatureMatrix ViewModel (CheckBoxFeatureMatrixViewModelCheckBoxViewModel), moved color/shadow/reset logic into the VM, and simplified code-behind.
  • Updated the CheckBox FeatureMatrix page bindings/UI (new shadow toggle, shadow binding, updated reset behavior, updated color buttons and AutomationIds).
  • Expanded/reworked the FeatureMatrix UI tests and added an Android snapshot for CheckBox_VerifyColorAfterReset.

Reviewed changes

Copilot reviewed 4 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/CheckBoxFeatureTests.cs Reworked and expanded CheckBox FeatureMatrix UITests; added ordering and new scenarios (shadow/commands/reset/color).
src/Controls/tests/TestCases.HostApp/FeatureMatrix/CheckBox/CheckBoxViewModel.cs New simplified ViewModel with centralized reset, color command, and shadow support.
src/Controls/tests/TestCases.HostApp/FeatureMatrix/CheckBox/CheckBoxControlPage.xaml.cs Simplified code-behind; reset now delegates to VM; removed redundant command wiring.
src/Controls/tests/TestCases.HostApp/FeatureMatrix/CheckBox/CheckBoxControlPage.xaml Updated bindings/UI to use new VM, bind Shadow, add shadow toggle, and adjust color/reset UI.
src/Controls/tests/TestCases.Android.Tests/snapshots/android/CheckBox_VerifyColorAfterReset.png Added/updated Android baseline image for the new/updated screenshot test.

App.WaitForElement(IsEnabledSwitch);
App.Tap(IsEnabledSwitch);
App.WaitForElement(IsCheckedSwitch);
App.Tap(IsCheckedSwitch);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This test taps IsCheckedSwitch after toggling IsEnabledSwitch off, but in the updated XAML the IsCheckedSwitch is disabled when IsEnabled is false. That makes the tap either a no-op (so the assertion doesn’t validate behavior) or potentially causes interaction failures depending on platform/driver. Consider asserting IsCheckedSwitch is disabled (e.g., App.FindElement(IsCheckedSwitch).IsEnabled() == false) and/or remove the tap step to keep the test meaningful.

Suggested change
App.Tap(IsCheckedSwitch);
Assert.That(App.FindElement(IsCheckedSwitch).IsEnabled(), Is.False);

Copilot uses AI. Check for mistakes.
App.WaitForElement(IsEnabledSwitch);
App.Tap(IsEnabledSwitch);
App.WaitForElement(IsCheckedSwitch);
App.Tap(IsCheckedSwitch);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This test taps IsCheckedSwitch after disabling the checkbox (IsEnabledSwitch off), but the updated UI binds IsCheckedSwitch.IsEnabled to IsEnabled, so the switch is disabled in this state. The tap step doesn’t validate anything and can be flaky; instead, assert the switch is disabled and that IsChecked remains unchanged, or adjust the UI/test intent so the interaction being tested is actually possible.

Suggested change
App.Tap(IsCheckedSwitch);

Copilot uses AI. Check for mistakes.
CommandParameter="{Binding CommandParameter}"
CheckedChanged="OnCheckBoxCheckedChanged"
AutomationId="CheckBoxControl"/>
<CheckBox x:Name="MyCheckBox"
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The x:Name="MyCheckBox" is not referenced from the code-behind (the page uses bindings and automation IDs). Consider removing the unused x:Name to avoid accumulating dead identifiers.

Suggested change
<CheckBox x:Name="MyCheckBox"
<CheckBox

Copilot uses AI. Check for mistakes.
Comment on lines +123 to +125
<Entry Text="{Binding CommandParameter}"
Placeholder="Enter command parameter"
AutomationId="CommandParameterEntry"/>
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

This page is used by screenshot-based FeatureMatrix tests, but it uses a regular <Entry> for the command parameter. Many other FeatureMatrix pages use UITestEntry with IsCursorVisible="False" to avoid cursor-blink flakiness in screenshots; consider switching this to <local:UITestEntry ... IsCursorVisible="False" /> for more stable visual tests.

Suggested change
<Entry Text="{Binding CommandParameter}"
Placeholder="Enter command parameter"
AutomationId="CommandParameterEntry"/>
<local:UITestEntry Text="{Binding CommandParameter}"
Placeholder="Enter command parameter"
AutomationId="CommandParameterEntry"
IsCursorVisible="False"/>

Copilot uses AI. Check for mistakes.
using System.Windows.Input;
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

using Microsoft.Maui; appears unused in this file. Removing it would keep the ViewModel leaner and avoid unnecessary imports.

Suggested change
using Microsoft.Maui.Graphics;

Copilot uses AI. Check for mistakes.
[Test, Order(1)]
[Category(UITestCategories.CheckBox)]
public void CheckBox_ValidateDefaultValues_VerifyLabels()
{
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

CheckBox_ValidateDefaultValues_VerifyLabels reads IsCheckedLabel immediately without waiting for the page/label to be present. This can be flaky on slower devices/emulators; please WaitForElement(IsCheckedLabel) (or another stable page-ready element) before calling FindElement(...).GetText().

Suggested change
{
{
App.WaitForElement(IsCheckedLabel);

Copilot uses AI. Check for mistakes.
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.

3 participants