[Testing] Feature matrix UITest Cases for SwipeView Control#30968
Conversation
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces comprehensive UI test cases for the SwipeView control to validate its behavior across different properties and interaction scenarios. The implementation includes a full feature matrix testing framework that covers SwipeItems for all directions, event validation, property testing, and programmatic control support.
- Adds extensive UI test coverage for SwipeView control functionality across platforms
- Implements a comprehensive feature matrix page with options to test various SwipeView configurations
- Creates test infrastructure to validate SwipeItems, events, properties, and programmatic actions
Reviewed Changes
Copilot reviewed 6 out of 77 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| SwipeViewFeatureTests.cs | Comprehensive test suite with 40+ test cases covering SwipeView functionality |
| SwipeViewViewModel.cs | ViewModel implementing property binding and command handling for SwipeView testing |
| SwipeViewOptionsPage.xaml.cs | Code-behind for options page providing UI configuration controls |
| SwipeViewOptionsPage.xaml | XAML layout for test configuration options with radio buttons and controls |
| SwipeViewControlPage.cs | Main test page implementation with dynamic content generation and event handling |
| CorePageView.cs | Gallery integration to make SwipeView feature matrix accessible in test app |
Comments suppressed due to low confidence (1)
src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/SwipeViewFeatureTests.cs:254
- The test methods are duplicating the navigation to Options page and configuration steps repeatedly. Consider extracting common setup logic into helper methods to reduce code duplication and improve maintainability.
App.WaitForElement("Options");
| _viewModel.RequestOpen += dir => | ||
| { | ||
| Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() => swipeView.Open(dir)); | ||
| }; | ||
|
|
||
| _viewModel.RequestClose += () => | ||
| { | ||
| Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() => swipeView.Close()); | ||
| }; |
There was a problem hiding this comment.
The event handlers for RequestOpen and RequestClose are being added every time WireUpOpenCloseHandlers is called, which could lead to memory leaks and multiple event subscriptions. Consider unsubscribing from previous handlers before adding new ones.
| _viewModel.RequestOpen += dir => | |
| { | |
| Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() => swipeView.Open(dir)); | |
| }; | |
| _viewModel.RequestClose += () => | |
| { | |
| Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() => swipeView.Close()); | |
| }; | |
| // Unsubscribe previous handlers if they exist | |
| if (_requestOpenHandler != null) | |
| _viewModel.RequestOpen -= _requestOpenHandler; | |
| if (_requestCloseHandler != null) | |
| _viewModel.RequestClose -= _requestCloseHandler; | |
| // Create new handlers | |
| _requestOpenHandler = dir => | |
| { | |
| Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() => swipeView.Open(dir)); | |
| }; | |
| _requestCloseHandler = () => | |
| { | |
| Microsoft.Maui.ApplicationModel.MainThread.BeginInvokeOnMainThread(() => swipeView.Close()); | |
| }; | |
| // Subscribe new handlers | |
| _viewModel.RequestOpen += _requestOpenHandler; | |
| _viewModel.RequestClose += _requestCloseHandler; |
There was a problem hiding this comment.
I have made the changes based on your valid suggestion and committed the latest updates.
| var swipeItems = CreateSwipeItems(swipeItemType); | ||
| var swipeView = new SwipeView | ||
| { | ||
| Content = itemLabel, | ||
| LeftItems = swipeItems, | ||
| RightItems = swipeItems, | ||
| TopItems = swipeItems, | ||
| BottomItems = swipeItems, |
There was a problem hiding this comment.
The same swipeItems collection is being assigned to LeftItems, RightItems, TopItems, and BottomItems. This could cause issues since collections should not be shared between multiple properties. Consider creating separate SwipeItems instances for each direction.
| var swipeItems = CreateSwipeItems(swipeItemType); | |
| var swipeView = new SwipeView | |
| { | |
| Content = itemLabel, | |
| LeftItems = swipeItems, | |
| RightItems = swipeItems, | |
| TopItems = swipeItems, | |
| BottomItems = swipeItems, | |
| var leftSwipeItems = CreateSwipeItems(swipeItemType); | |
| var rightSwipeItems = CreateSwipeItems(swipeItemType); | |
| var topSwipeItems = CreateSwipeItems(swipeItemType); | |
| var bottomSwipeItems = CreateSwipeItems(swipeItemType); | |
| var swipeView = new SwipeView | |
| { | |
| Content = itemLabel, | |
| LeftItems = leftSwipeItems, | |
| RightItems = rightSwipeItems, | |
| TopItems = topSwipeItems, | |
| BottomItems = bottomSwipeItems, |
There was a problem hiding this comment.
I have made the changes based on your valid suggestion and committed the latest updates.
| var swipeItems = CreateSwipeItems(swipeItemType); | ||
|
|
||
| var swipeView = new SwipeView | ||
| { | ||
| Content = contentView, | ||
| LeftItems = swipeItems, | ||
| RightItems = swipeItems, | ||
| TopItems = swipeItems, | ||
| BottomItems = swipeItems, |
There was a problem hiding this comment.
Same issue as in the CollectionView template - the same swipeItems collection is being reused for all directions. Each SwipeView direction should have its own SwipeItems instance to prevent potential binding and state conflicts.
| var swipeItems = CreateSwipeItems(swipeItemType); | |
| var swipeView = new SwipeView | |
| { | |
| Content = contentView, | |
| LeftItems = swipeItems, | |
| RightItems = swipeItems, | |
| TopItems = swipeItems, | |
| BottomItems = swipeItems, | |
| var leftItems = CreateSwipeItems(swipeItemType); | |
| var rightItems = CreateSwipeItems(swipeItemType); | |
| var topItems = CreateSwipeItems(swipeItemType); | |
| var bottomItems = CreateSwipeItems(swipeItemType); | |
| var swipeView = new SwipeView | |
| { | |
| Content = contentView, | |
| LeftItems = leftItems, | |
| RightItems = rightItems, | |
| TopItems = topItems, | |
| BottomItems = bottomItems, |
There was a problem hiding this comment.
I have made the changes based on your valid suggestion and committed the latest updates.
|
/rebase |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
jsuarezruiz
left a comment
There was a problem hiding this comment.
The test VerifyImageWithSwipeRevealAndSwipeBehaviorOnInvokedAuto is failing on Mac:
at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2530
at UITest.Appium.HelperExtensions.WaitForNone(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2554
at UITest.Appium.HelperExtensions.WaitForNoElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 816
at Microsoft.Maui.TestCases.Tests.SwipeViewFeatureTests.VerifyImageWithSwipeRevealAndSwipeBehaviorOnInvokedAuto() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/SwipeViewFeatureTests.cs:line 503
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
@jsuarezruiz Modified the test to ensure it runs on Mac and committed the code changes. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
* added the sample and test class files * added snapshot for iOS and android * added FailsOn attributes * updated * test case modified * changes updated * revert this changes * added snapshot from CI * update copilot suggestion * update test case --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
* added the sample and test class files * added snapshot for iOS and android * added FailsOn attributes * updated * test case modified * changes updated * revert this changes * added snapshot from CI * update copilot suggestion * update test case --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
* added the sample and test class files * added snapshot for iOS and android * added FailsOn attributes * updated * test case modified * changes updated * revert this changes * added snapshot from CI * update copilot suggestion * update test case --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
* added the sample and test class files * added snapshot for iOS and android * added FailsOn attributes * updated * test case modified * changes updated * revert this changes * added snapshot from CI * update copilot suggestion * update test case --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
* added the sample and test class files * added snapshot for iOS and android * added FailsOn attributes * updated * test case modified * changes updated * revert this changes * added snapshot from CI * update copilot suggestion * update test case --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
This PR includes a comprehensive set of UI test cases for the SwipeView control. The tests validate the SwipeView control’s behavior across a wide range of properties and interaction scenarios. This includes verifying SwipeItems for all supported directions—LeftItems, RightItems, TopItems, and BottomItems—to ensure they are correctly displayed and invoked. Event validation covers key swipe lifecycle events such as SwipeStarted, SwipeChanging, SwipeEnded, and SwipeItem.Invoked, confirming their correct firing during user interactions. The tests also assess various SwipeView properties like IsEnabled, IsVisible, BackgroundColor, HeightRequest, and WidthRequest, ensuring they update the control as expected. Additionally, support for programmatic control using OpenRequested and CloseRequested is validated. Finally, the tests confirm consistent swipe gesture handling across all platforms.
SwipeView Control Feature Matrix
Gallery Page Addition
Options Page Implementation
Main Page Implementation
Issues Identified
Screen.Recording.2025-07-02.at.3.50.54.PM.mov