test: Add comprehensive tests for VisualState transition selection #21614
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds comprehensive unit tests for the VisualState transition selection logic as requested in issue #17436. The tests validate the
FindTransitionmethod inVisualStateGroup.cswhich determines which transition to apply when changing between visual states.Changes
Added 9 new test methods to
src/Uno.UI.Tests/Windows_UI_Xaml/VisualStateManagerTests/Given_VisualStateManager.csthat comprehensively cover the transition selection algorithm.Transition Selection Algorithm
The
FindTransitionmethod implements a priority-based selection algorithm:FromandTomatching the state changeFrommatching (andTois null/empty)Tomatching (andFromis null/empty)When multiple transitions match at the same priority level, the first declared transition wins.
Test Coverage
Basic Matching Scenarios
When_Transition_With_Both_From_And_To_Matches- Validates perfect match selectionWhen_Transition_With_Only_From_Matches- Validates From-only matchingWhen_Transition_With_Only_To_Matches- Validates To-only matchingPrecedence Rules
When_Multiple_Transitions_PerfectMatch_Takes_Precedence- Validates that perfect match has highest priorityWhen_Multiple_Transitions_From_Takes_Precedence_Over_To- Validates that From-only beats To-onlyWhen_First_Matching_Transition_Is_Selected- Validates first-declared wins when multiple matchEdge Cases
When_No_Transition_Matches- Validates behavior when no transition matchesWhen_Transition_From_Initial_To_State1- Validates transitions from initial stateWhen_UseTransitions_False_No_Transition_Applied- Validates theuseTransitionsflagImplementation Details
All tests follow the existing patterns in the file:
Setup(),Transition(),AnimateTag())Control.Tagproperty changes throughRegisterPropertyChangedCallbackSequenceEqualto verify the exact sequence of state changesExample Test
Related
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.mscurl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED(dns block)crl.godaddy.com/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf(dns block)/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf --force(dns block)imzvsblobprodcus368.vsblob.vsassets.io/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf(dns block)/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf --force(dns block)m8dvsblobprodcus37.vsblob.vsassets.io/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf(dns block)ocsp.godaddy.com/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf(dns block)/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf --force(dns block)u3hvsblobprodcus371.vsblob.vsassets.io/home/REDACTED/.dotnet/dotnet restore Uno.UI-UnitTests-only.slnf(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #17564
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.