[Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control#34283
[Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control#34283LogishaSelvarajSF4525 wants to merge 5 commits intodotnet:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34283Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34283" |
|
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. |
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
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 (
CheckBoxFeatureMatrixViewModel→CheckBoxViewModel), 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); |
There was a problem hiding this comment.
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.
| App.Tap(IsCheckedSwitch); | |
| Assert.That(App.FindElement(IsCheckedSwitch).IsEnabled(), Is.False); |
| App.WaitForElement(IsEnabledSwitch); | ||
| App.Tap(IsEnabledSwitch); | ||
| App.WaitForElement(IsCheckedSwitch); | ||
| App.Tap(IsCheckedSwitch); |
There was a problem hiding this comment.
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.
| App.Tap(IsCheckedSwitch); |
| CommandParameter="{Binding CommandParameter}" | ||
| CheckedChanged="OnCheckBoxCheckedChanged" | ||
| AutomationId="CheckBoxControl"/> | ||
| <CheckBox x:Name="MyCheckBox" |
There was a problem hiding this comment.
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.
| <CheckBox x:Name="MyCheckBox" | |
| <CheckBox |
| <Entry Text="{Binding CommandParameter}" | ||
| Placeholder="Enter command parameter" | ||
| AutomationId="CommandParameterEntry"/> |
There was a problem hiding this comment.
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.
| <Entry Text="{Binding CommandParameter}" | |
| Placeholder="Enter command parameter" | |
| AutomationId="CommandParameterEntry"/> | |
| <local:UITestEntry Text="{Binding CommandParameter}" | |
| Placeholder="Enter command parameter" | |
| AutomationId="CommandParameterEntry" | |
| IsCursorVisible="False"/> |
| using System.Windows.Input; | ||
| using Microsoft.Maui; | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Graphics; |
There was a problem hiding this comment.
using Microsoft.Maui; appears unused in this file. Removing it would keep the ViewModel leaner and avoid unnecessary imports.
| using Microsoft.Maui.Graphics; |
| [Test, Order(1)] | ||
| [Category(UITestCategories.CheckBox)] | ||
| public void CheckBox_ValidateDefaultValues_VerifyLabels() | ||
| { |
There was a problem hiding this comment.
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().
| { | |
| { | |
| App.WaitForElement(IsCheckedLabel); |
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:
CheckBoxFeatureMatrixViewModeltoCheckBoxViewModel, moved the color-setting logic into the ViewModel, and added a newReset()method to centralize state resets. The ViewModel now also exposes aHasShadowproperty and a correspondingShadowproperty, allowing the CheckBox to visually display a shadow when toggled. [1] [2] [3]UI and Binding Updates:
CheckBoxControlPage.xamlto use the new ViewModel name, bind the CheckBox'sShadowproperty, and add a UI toggle for the shadow feature. The reset button now calls the ViewModel'sReset()method. The color buttons were updated with text, color, and width for clarity. [1] [2] [3]Logic and Usability Improvements:
IsCheckedis now disabled when the CheckBox is disabled, ensuring consistent behavior and preventing user interaction when not allowed.Test Constants Update:
HasShadowCheckBox, color buttons, and command parameter entry).Code Cleanup:
These changes improve maintainability, testability, and feature coverage for the CheckBox control in the test app.
Issues Identified