-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Testing] Feature Matrix UITest Cases for Switch Control #29950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
PureWeen
merged 6 commits into
dotnet:inflight/current
from
anandhan-rajagopal:feature-matrix-switch
Jun 26, 2025
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4405046
added test cases
TamilarasanSF4853 eeac349
added new test cases
TamilarasanSF4853 95eedf6
added new test cases
TamilarasanSF4853 1efab95
added android and iOS snapshots
TamilarasanSF4853 fca5dfc
modified test case and added snapshots
TamilarasanSF4853 b97b08c
added failing condition
TamilarasanSF4853 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+34 KB
...ts/TestCases.Android.Tests/snapshots/android/Switch_Click_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.9 KB
...Cases.Android.Tests/snapshots/android/Switch_InitialState_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34 KB
...Tests/snapshots/android/Switch_SetFlowDirectionAndToggled_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.5 KB
...id.Tests/snapshots/android/Switch_SetOnColorAndThumbColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.5 KB
...ndroid.Tests/snapshots/android/Switch_SetShadowAndOnColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.5 KB
...oid.Tests/snapshots/android/Switch_SetShadowAndThumbColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.1 KB
...Tests/snapshots/android/Switch_SetShadowOpacityAndToggled_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.9 KB
...id.Tests/snapshots/android/Switch_SetThumbColorAndOnColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.2 KB
...droid.Tests/snapshots/android/Switch_SetToggledAndOnColor_VerifyVisualState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Controls/tests/TestCases.HostApp/FeatureMatrix/Switch/SwitchControlPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample" | ||
| x:Class="Maui.Controls.Sample.SwitchControlMainPage" | ||
| x:DataType="local:SwitchViewModel" | ||
| Title="SwitchControlPage"> | ||
| <ContentPage.ToolbarItems> | ||
| <ToolbarItem Text="Options" | ||
| Clicked="NavigateToOptionsPage_Clicked" | ||
| AutomationId="Options"/> | ||
| </ContentPage.ToolbarItems> | ||
|
|
||
| <Grid RowDefinitions="*,Auto"> | ||
| <Grid x:Name="SwitchGrid" | ||
| Grid.Row="0"> | ||
| <Switch AutomationId="SwitchControl" | ||
| FlowDirection="{Binding FlowDirection}" | ||
| IsEnabled="{Binding IsEnabled}" | ||
| IsVisible="{Binding IsVisible}" | ||
| IsToggled="{Binding IsToggled}" | ||
| OnColor="{Binding OnColor}" | ||
| Shadow="{Binding Shadow}" | ||
| ThumbColor="{Binding ThumbColor}" | ||
| HorizontalOptions="Center" | ||
| VerticalOptions="Center" | ||
| Toggled="Switch_Toggled"> | ||
| </Switch> | ||
| </Grid> | ||
| <HorizontalStackLayout Grid.Row="1" | ||
| HorizontalOptions="Center" | ||
| Padding="0,0,0,40" | ||
| Spacing="10"> | ||
| <Label Text="Toggled Event: "/> | ||
| <Label x:Name="EventLabel" | ||
| AutomationId="ToggledEventLabel" | ||
| Text="False"/> | ||
| </HorizontalStackLayout> | ||
| </Grid> | ||
| </ContentPage> |
57 changes: 57 additions & 0 deletions
57
src/Controls/tests/TestCases.HostApp/FeatureMatrix/Switch/SwitchControlPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| namespace Maui.Controls.Sample; | ||
|
|
||
| public class SwitchControlPage : NavigationPage | ||
| { | ||
| private SwitchViewModel _viewModel; | ||
| public SwitchControlPage() | ||
| { | ||
| _viewModel = new SwitchViewModel(); | ||
| PushAsync(new SwitchControlMainPage(_viewModel)); | ||
| } | ||
| } | ||
|
|
||
| public partial class SwitchControlMainPage : ContentPage | ||
| { | ||
| private SwitchViewModel _viewModel; | ||
|
|
||
| public SwitchControlMainPage(SwitchViewModel viewModel) | ||
| { | ||
| InitializeComponent(); | ||
| _viewModel = viewModel; | ||
| BindingContext = _viewModel; | ||
| } | ||
|
|
||
| private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e) | ||
| { | ||
| BindingContext = _viewModel = new SwitchViewModel(); | ||
| ReinitializeSwitch(); | ||
| await Navigation.PushAsync(new SwitchOptionsPage(_viewModel)); | ||
| } | ||
|
|
||
| private void Switch_Toggled(object sender, ToggledEventArgs e) | ||
| { | ||
| EventLabel.Text = $"{e.Value}"; | ||
| } | ||
|
|
||
| private void ReinitializeSwitch() | ||
| { | ||
| SwitchGrid.Children.Clear(); | ||
| var switchControl = new Switch | ||
| { | ||
| AutomationId = "SwitchControl", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| switchControl.Toggled += Switch_Toggled; | ||
|
|
||
| switchControl.SetBinding(Switch.FlowDirectionProperty, new Binding(nameof(SwitchViewModel.FlowDirection))); | ||
| switchControl.SetBinding(Switch.IsEnabledProperty, new Binding(nameof(SwitchViewModel.IsEnabled))); | ||
| switchControl.SetBinding(Switch.IsVisibleProperty, new Binding(nameof(SwitchViewModel.IsVisible))); | ||
| switchControl.SetBinding(Switch.IsToggledProperty, new Binding(nameof(SwitchViewModel.IsToggled))); | ||
| switchControl.SetBinding(Switch.OnColorProperty, new Binding(nameof(SwitchViewModel.OnColor))); | ||
| switchControl.SetBinding(Switch.ShadowProperty, new Binding(nameof(SwitchViewModel.Shadow))); | ||
| switchControl.SetBinding(Switch.ThumbColorProperty, new Binding(nameof(SwitchViewModel.ThumbColor))); | ||
| SwitchGrid.Children.Add(switchControl); | ||
| } | ||
| } |
142 changes: 142 additions & 0 deletions
142
src/Controls/tests/TestCases.HostApp/FeatureMatrix/Switch/SwitchOptionsPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample" | ||
| x:Class="Maui.Controls.Sample.SwitchOptionsPage" | ||
| x:DataType="local:SwitchViewModel" | ||
| Title="SwitchOptionsPage"> | ||
| <ContentPage.ToolbarItems> | ||
| <ToolbarItem Text="Apply" | ||
| Clicked="ApplyButton_Clicked" | ||
| AutomationId="Apply"/> | ||
| </ContentPage.ToolbarItems> | ||
|
|
||
| <Grid ColumnSpacing="10" | ||
| RowSpacing="10" | ||
| RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto" | ||
| ColumnDefinitions="Auto,Auto" | ||
| HorizontalOptions="Center" | ||
| VerticalOptions="Center"> | ||
|
|
||
| <!-- FlowDirection --> | ||
| <Label Grid.Row="0" | ||
| Grid.Column="0" | ||
| Text="FlowDirection:" | ||
| VerticalOptions="Center"/> | ||
| <StackLayout Grid.Row="0" | ||
| Grid.Column="1" | ||
| Orientation="Horizontal" | ||
| Spacing="5" | ||
| VerticalOptions="Center"> | ||
| <CheckBox x:Name="FlowDirectionLeftToRightCheckBox" | ||
| AutomationId="FlowDirectionLeftToRightCheckBox" | ||
| IsChecked="True" | ||
| CheckedChanged="OnFlowDirectionCheckBoxCheckedChanged"/> | ||
| <Label Text="LeftToRight" | ||
| VerticalOptions="Center"/> | ||
| <CheckBox x:Name="FlowDirectionRightToLeftCheckBox" | ||
| AutomationId="FlowDirectionRightToLeftCheckBox" | ||
| CheckedChanged="OnFlowDirectionCheckBoxCheckedChanged"/> | ||
| <Label Text="RightToLeft" | ||
| VerticalOptions="Center"/> | ||
| </StackLayout> | ||
|
|
||
| <!-- IsEnabled --> | ||
| <Label Grid.Row="1" | ||
| Grid.Column="0" | ||
| Text="IsEnabled:" | ||
| VerticalOptions="Center"/> | ||
| <StackLayout Grid.Row="1" | ||
| Grid.Column="1" | ||
| Orientation="Horizontal" | ||
| Spacing="10" | ||
| VerticalOptions="Center"> | ||
| <CheckBox AutomationId="IsEnabledFalseCheckBox" | ||
| CheckedChanged="OnEnabledCheckBoxCheckedChanged"/> | ||
| </StackLayout> | ||
|
|
||
| <!-- IsVisible --> | ||
| <Label Grid.Row="2" | ||
| Grid.Column="0" | ||
| Text="IsVisible:" | ||
| VerticalOptions="Center"/> | ||
| <StackLayout Grid.Row="2" | ||
| Grid.Column="1" | ||
| Orientation="Horizontal" | ||
| Spacing="10" | ||
| VerticalOptions="Center"> | ||
| <CheckBox AutomationId="IsVisibleFalseCheckBox" | ||
| CheckedChanged="OnVisibleCheckBoxCheckedChanged"/> | ||
| </StackLayout> | ||
|
|
||
| <!-- IsToggled --> | ||
| <Label Grid.Row="3" | ||
| Grid.Column="0" | ||
| Text="IsToggled:" | ||
| VerticalOptions="Center"/> | ||
| <StackLayout Grid.Row="3" | ||
| Grid.Column="1" | ||
| Orientation="Horizontal" | ||
| Spacing="10" | ||
| VerticalOptions="Center"> | ||
| <CheckBox AutomationId="IsToggledTrueCheckBox" | ||
| CheckedChanged="OnToggledCheckBoxCheckedChanged"/> | ||
| </StackLayout> | ||
|
|
||
| <!-- OnColor --> | ||
| <Label Grid.Row="4" | ||
| Grid.Column="0" | ||
| Text="OnColor:" | ||
| VerticalOptions="Center"/> | ||
| <StackLayout Grid.Row="4" | ||
| Grid.Column="1" | ||
| Orientation="Horizontal" | ||
| Spacing="5" | ||
| VerticalOptions="Center"> | ||
| <CheckBox x:Name="OnColorRedCheckBox" | ||
| AutomationId="OnColorRedCheckBox" | ||
| CheckedChanged="OnOnColorCheckBoxCheckedChanged"/> | ||
| <Label Text="Red" | ||
| VerticalOptions="Center"/> | ||
| <CheckBox x:Name="OnColorGreenCheckBox" | ||
| AutomationId="OnColorGreenCheckBox" | ||
| CheckedChanged="OnOnColorCheckBoxCheckedChanged"/> | ||
| <Label Text="Green" | ||
| VerticalOptions="Center"/> | ||
| </StackLayout> | ||
|
|
||
| <!-- Shadow --> | ||
| <Label Grid.Row="5" | ||
| Grid.Column="0" | ||
| Text="Shadow:" | ||
| VerticalOptions="Center"/> | ||
| <HorizontalStackLayout Grid.Row="5" | ||
| Grid.Column="1" | ||
| VerticalOptions="Center"> | ||
| <CheckBox AutomationId="ShadowTrueCheckBox" | ||
| CheckedChanged="OnShadowCheckBoxCheckedChanged"/> | ||
| </HorizontalStackLayout> | ||
|
|
||
| <!-- ThumbColor --> | ||
| <Label Grid.Row="6" | ||
| Grid.Column="0" | ||
| Text="ThumbColor:" | ||
| VerticalOptions="Center"/> | ||
| <StackLayout Grid.Row="6" | ||
| Grid.Column="1" | ||
| Orientation="Horizontal" | ||
| Spacing="5" | ||
| VerticalOptions="Center"> | ||
| <CheckBox x:Name="ThumbColorRedCheckBox" | ||
| AutomationId="ThumbColorRedCheckBox" | ||
| CheckedChanged="OnThumbColorCheckBoxCheckedChanged"/> | ||
| <Label Text="Red" | ||
| VerticalOptions="Center"/> | ||
| <CheckBox x:Name="ThumbColorGreenCheckBox" | ||
| AutomationId="ThumbColorGreenCheckBox" | ||
| CheckedChanged="OnThumbColorCheckBoxCheckedChanged"/> | ||
| <Label Text="Green" | ||
| VerticalOptions="Center"/> | ||
| </StackLayout> | ||
| </Grid> | ||
| </ContentPage> |
115 changes: 115 additions & 0 deletions
115
src/Controls/tests/TestCases.HostApp/FeatureMatrix/Switch/SwitchOptionsPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| using Maui.Controls.Sample; | ||
|
|
||
| namespace Maui.Controls.Sample; | ||
|
|
||
| public partial class SwitchOptionsPage : ContentPage | ||
| { | ||
| private SwitchViewModel _viewModel; | ||
| public SwitchOptionsPage(SwitchViewModel viewModel) | ||
| { | ||
| InitializeComponent(); | ||
| _viewModel = viewModel; | ||
| BindingContext = _viewModel; | ||
| } | ||
| private void ApplyButton_Clicked(object sender, EventArgs e) | ||
| { | ||
| Navigation.PopAsync(); | ||
| } | ||
|
|
||
| private void OnFlowDirectionCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
| if (!(sender is CheckBox changedBox) || !changedBox.IsChecked) | ||
| return; | ||
| if (changedBox == FlowDirectionLeftToRightCheckBox) | ||
| { | ||
| FlowDirectionRightToLeftCheckBox.IsChecked = false; | ||
| _viewModel.FlowDirection = FlowDirection.LeftToRight; | ||
| } | ||
| else if (changedBox == FlowDirectionRightToLeftCheckBox) | ||
| { | ||
| FlowDirectionLeftToRightCheckBox.IsChecked = false; | ||
| _viewModel.FlowDirection = FlowDirection.RightToLeft; | ||
| } | ||
| } | ||
|
|
||
| private void OnEnabledCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
| if (e.Value) | ||
| { | ||
| _viewModel.IsEnabled = false; | ||
| } | ||
| else | ||
| { | ||
| _viewModel.IsEnabled = true; | ||
| } | ||
| } | ||
|
|
||
| private void OnVisibleCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
|
|
||
| if (e.Value) | ||
| { | ||
| _viewModel.IsVisible = false; | ||
| } | ||
| else | ||
| { | ||
| _viewModel.IsVisible = true; | ||
| } | ||
| } | ||
|
|
||
| private void OnToggledCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
| if (e.Value) | ||
| { | ||
| _viewModel.IsToggled = true; | ||
| } | ||
| else | ||
| { | ||
| _viewModel.IsToggled = false; | ||
| } | ||
| } | ||
|
|
||
| private void OnOnColorCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
| if (!(sender is CheckBox changedBox) || !changedBox.IsChecked) | ||
| return; | ||
| if (changedBox == OnColorRedCheckBox) | ||
| { | ||
| OnColorGreenCheckBox.IsChecked = false; | ||
| _viewModel.OnColor = Colors.Red; | ||
| } | ||
| else if (changedBox == OnColorGreenCheckBox) | ||
| { | ||
| OnColorRedCheckBox.IsChecked = false; | ||
| _viewModel.OnColor = Colors.Green; | ||
| } | ||
| } | ||
|
|
||
| private void OnShadowCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
| if (e.Value) | ||
| { | ||
| _viewModel.Shadow = new Shadow { Brush = Colors.Violet, Radius = 20, Offset = new Point(0, 0), Opacity = 1f }; | ||
| } | ||
| else | ||
| { | ||
| _viewModel.Shadow = null; | ||
| } | ||
| } | ||
|
|
||
| private void OnThumbColorCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e) | ||
| { | ||
| if (!(sender is CheckBox changedBox) || !changedBox.IsChecked) | ||
| return; | ||
| if (changedBox == ThumbColorRedCheckBox) | ||
| { | ||
| ThumbColorGreenCheckBox.IsChecked = false; | ||
| _viewModel.ThumbColor = Colors.Red; | ||
| } | ||
| else if (changedBox == ThumbColorGreenCheckBox) | ||
| { | ||
| ThumbColorRedCheckBox.IsChecked = false; | ||
| _viewModel.ThumbColor = Colors.Green; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there's a bug here based on the snapshot. The shadow appears to reflect the off state and doesn't update when the Switch state changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you verify? If is a bug, could you create a new bug and add the link to it in the test with a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz I have added the failing condition to the test case, created a bug issue, and included the bug link in the test case as a comment.