Skip to content

Commit 7be53bd

Browse files
nivetha-nagalingamPureWeen
authored andcommitted
[Testing] Feature Matrix UITest Cases for Stepper (#29731)
* FeatureMatrix for stepper control * Added the snapshot for windows platform * Updated StepperFeatureTests.cs * Updated StepperControlPage.xaml
1 parent f66aecf commit 7be53bd

File tree

9 files changed

+750
-0
lines changed

9 files changed

+750
-0
lines changed
34.3 KB
Loading

src/Controls/tests/TestCases.HostApp/CoreViews/CorePageView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public override string ToString()
7373
new GalleryPageFactory(() => new ShadowFeaturePage(), "Shadow Feature Matrix"),
7474
new GalleryPageFactory(() => new SearchBarCoreGalleryPage(), "Search Bar Gallery"),
7575
new GalleryPageFactory(() => new SliderCoreGalleryPage(), "Slider Gallery"),
76+
new GalleryPageFactory(() => new StepperControlPage(), "Stepper Feature Matrix"),
7677
new GalleryPageFactory(() => new StepperCoreGalleryPage(), "Stepper Gallery"),
7778
new GalleryPageFactory(() => new SwitchCoreGalleryPage(), "Switch Gallery"),
7879
new GalleryPageFactory(() => new SwipeViewCoreGalleryPage(), "SwipeView Gallery"),
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Maui.Controls.Sample"
5+
x:Class="Maui.Controls.Sample.StepperControlMainPage"
6+
x:DataType="local:StepperViewModel"
7+
Title="StepperFeature">
8+
9+
<ContentPage.ToolbarItems>
10+
<ToolbarItem Text="Options"
11+
Clicked="NavigateToOptionsPage_Clicked"
12+
AutomationId="Options"/>
13+
</ContentPage.ToolbarItems>
14+
15+
<Grid Padding="20"
16+
RowDefinitions="*, Auto, Auto, Auto"
17+
ColumnDefinitions="*,*"
18+
RowSpacing="10"
19+
ColumnSpacing="10"
20+
HorizontalOptions="Center"
21+
VerticalOptions="Center">
22+
23+
<!-- Stepper Control -->
24+
<Stepper Grid.Row="0"
25+
Grid.Column="0"
26+
Grid.ColumnSpan="2"
27+
Minimum="{Binding Minimum}"
28+
Maximum="{Binding Maximum}"
29+
Increment="{Binding Increment}"
30+
Value="{Binding Value}"
31+
IsEnabled="{Binding IsEnabled}"
32+
IsVisible="{Binding IsVisible}"
33+
FlowDirection="{Binding FlowDirection}"
34+
AutomationId="StepperControl"/>
35+
36+
<!-- Minimum Value -->
37+
<Label Grid.Row="1"
38+
Grid.Column="0"
39+
Text="Minimum:"
40+
FontSize="16"
41+
VerticalTextAlignment="Center"
42+
HorizontalTextAlignment="Start"/>
43+
<Label Grid.Row="1"
44+
Grid.Column="1"
45+
AutomationId="MinimumLabel"
46+
Text="{Binding Minimum, StringFormat='{0:F2}'}"
47+
FontSize="16"
48+
VerticalTextAlignment="Center"
49+
HorizontalTextAlignment="End"/>
50+
51+
52+
<!-- Maximum Value -->
53+
<Label Grid.Row="2"
54+
Grid.Column="0"
55+
Text="Maximum:"
56+
FontSize="16"
57+
VerticalTextAlignment="Center"
58+
HorizontalTextAlignment="Start"/>
59+
<Label Grid.Row="2"
60+
Grid.Column="1"
61+
AutomationId="MaximumLabel"
62+
Text="{Binding Maximum, StringFormat='{0:F2}'}"
63+
FontSize="16"
64+
VerticalTextAlignment="Center"
65+
HorizontalTextAlignment="End"/>
66+
67+
<!-- Current Value -->
68+
<Label Grid.Row="3"
69+
Grid.Column="0"
70+
Text="Value:"
71+
FontSize="16"
72+
VerticalTextAlignment="Center"
73+
HorizontalTextAlignment="Start"/>
74+
<Label Grid.Row="3"
75+
Grid.Column="1"
76+
AutomationId="ValueLabel"
77+
Text="{Binding Value, StringFormat='{0:F2}'}"
78+
FontSize="16"
79+
VerticalTextAlignment="Center"
80+
HorizontalTextAlignment="End"/>
81+
</Grid>
82+
</ContentPage>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using Microsoft.Maui.Controls;
3+
4+
namespace Maui.Controls.Sample;
5+
6+
public class StepperControlPage : NavigationPage
7+
{
8+
9+
public StepperControlPage()
10+
{
11+
PushAsync(new StepperControlMainPage());
12+
}
13+
}
14+
public partial class StepperControlMainPage : ContentPage
15+
{
16+
private StepperViewModel _viewModel;
17+
18+
public StepperControlMainPage()
19+
{
20+
InitializeComponent();
21+
BindingContext = _viewModel = new StepperViewModel();
22+
}
23+
24+
private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
25+
{
26+
BindingContext = _viewModel = new StepperViewModel();
27+
await Navigation.PushAsync(new StepperFeaturePage(_viewModel));
28+
}
29+
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Maui.Controls.Sample"
5+
x:Class="Maui.Controls.Sample.StepperFeaturePage"
6+
Title="StepperFeature">
7+
8+
<ContentPage.ToolbarItems>
9+
<ToolbarItem Text="Apply"
10+
Clicked="ApplyButton_Clicked"
11+
AutomationId="Apply"/>
12+
</ContentPage.ToolbarItems>
13+
14+
<Grid Padding="10"
15+
ColumnDefinitions="Auto, *"
16+
RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto"
17+
RowSpacing="10"
18+
ColumnSpacing="15">
19+
<!-- Minimum Value -->
20+
<Label Grid.Row="0"
21+
Grid.Column="0"
22+
Text="Minimum:"
23+
FontSize="15"
24+
VerticalTextAlignment="Center"/>
25+
<Entry Grid.Row="0"
26+
Grid.Column="1"
27+
x:Name="MinimumEntry"
28+
AutomationId="MinimumEntry"
29+
TextChanged="OnMinimumChanged"
30+
Keyboard="Numeric"
31+
HorizontalOptions="Start"
32+
WidthRequest="100"/>
33+
34+
<!-- Maximum Value -->
35+
<Label Grid.Row="1"
36+
Grid.Column="0"
37+
Text="Maximum:"
38+
FontSize="15"
39+
VerticalTextAlignment="Center"/>
40+
<Entry Grid.Row="1"
41+
Grid.Column="1"
42+
x:Name="MaximumEntry"
43+
AutomationId="MaximumEntry"
44+
TextChanged="OnMaximumChanged"
45+
Keyboard="Numeric"
46+
HorizontalOptions="Start"
47+
WidthRequest="100"/>
48+
49+
<!-- Increment -->
50+
<Label Grid.Row="2"
51+
Grid.Column="0"
52+
Text="Increment:"
53+
FontSize="15"
54+
VerticalTextAlignment="Center"/>
55+
<Entry Grid.Row="2"
56+
Grid.Column="1"
57+
x:Name="IncrementEntry"
58+
AutomationId="IncrementEntry"
59+
TextChanged="OnIncrementChanged"
60+
Keyboard="Numeric"
61+
HorizontalOptions="Start"
62+
WidthRequest="100"/>
63+
64+
<!-- Current Value -->
65+
<Label Grid.Row="3"
66+
Grid.Column="0"
67+
Text="Value:"
68+
FontSize="15"
69+
VerticalTextAlignment="Center"/>
70+
<Entry Grid.Row="3"
71+
Grid.Column="1"
72+
x:Name="ValueEntry"
73+
AutomationId="ValueEntry"
74+
TextChanged="OnValueChanged"
75+
Keyboard="Numeric"
76+
HorizontalOptions="Start"
77+
WidthRequest="100"/>
78+
79+
<!-- Is Enabled -->
80+
<Label Grid.Row="4"
81+
Grid.Column="0"
82+
Text="Is Enabled:"
83+
FontSize="15"
84+
VerticalTextAlignment="Center"/>
85+
<StackLayout Grid.Row="4"
86+
Grid.Column="1"
87+
Orientation="Horizontal"
88+
Spacing="10">
89+
<RadioButton x:Name="IsEnabledTrueRadio"
90+
AutomationId="IsEnabledTrueRadio"
91+
GroupName="IsEnabled"
92+
Content="True"
93+
IsChecked="True"
94+
FontSize="14"
95+
CheckedChanged="OnIsEnabledCheckedChanged"/>
96+
<RadioButton x:Name="IsEnabledFalseRadio"
97+
AutomationId="IsEnabledFalseRadio"
98+
GroupName="IsEnabled"
99+
Content="False"
100+
FontSize="14"
101+
CheckedChanged="OnIsEnabledCheckedChanged"/>
102+
</StackLayout>
103+
104+
<!-- Is Visible -->
105+
<Label Grid.Row="5"
106+
Grid.Column="0"
107+
Text="Is Visible:"
108+
FontSize="15"
109+
VerticalTextAlignment="Center"/>
110+
<StackLayout Grid.Row="5"
111+
Grid.Column="1"
112+
Orientation="Horizontal"
113+
Spacing="10">
114+
<RadioButton x:Name="IsVisibleTrueRadio"
115+
AutomationId="IsVisibleTrueRadio"
116+
GroupName="IsVisible"
117+
Content="True"
118+
IsChecked="True"
119+
FontSize="14"
120+
CheckedChanged="OnIsVisibleCheckedChanged"/>
121+
<RadioButton x:Name="IsVisibleFalseRadio"
122+
AutomationId="IsVisibleFalseRadio"
123+
GroupName="IsVisible"
124+
Content="False"
125+
FontSize="14"
126+
CheckedChanged="OnIsVisibleCheckedChanged"/>
127+
</StackLayout>
128+
129+
<!-- Flow Direction -->
130+
<Label Grid.Row="8"
131+
Grid.Column="0"
132+
Text="Flow Direction:"
133+
FontSize="15"
134+
VerticalTextAlignment="Center"/>
135+
<StackLayout Grid.Row="8"
136+
Grid.Column="1"
137+
Orientation="Horizontal"
138+
Spacing="10">
139+
<RadioButton x:Name="FlowDirectionLTRRadio"
140+
AutomationId="FlowDirectionLTRRadio"
141+
GroupName="FlowDirection"
142+
Content="LeftToRight"
143+
IsChecked="True"
144+
FontSize="14"
145+
CheckedChanged="OnFlowDirectionChanged"/>
146+
<RadioButton x:Name="FlowDirectionRTLRadio"
147+
AutomationId="FlowDirectionRTLRadio"
148+
GroupName="FlowDirection"
149+
Content="RightToLeft"
150+
FontSize="14"
151+
CheckedChanged="OnFlowDirectionChanged"/>
152+
</StackLayout>
153+
</Grid>
154+
</ContentPage>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using Microsoft.Maui.Controls;
3+
4+
namespace Maui.Controls.Sample;
5+
6+
public partial class StepperFeaturePage : ContentPage
7+
{
8+
private StepperViewModel _viewModel;
9+
10+
public StepperFeaturePage(StepperViewModel viewModel)
11+
{
12+
InitializeComponent();
13+
_viewModel = viewModel;
14+
BindingContext = _viewModel;
15+
}
16+
17+
private void ApplyButton_Clicked(object sender, EventArgs e)
18+
{
19+
Navigation.PopAsync();
20+
}
21+
22+
private void OnMinimumChanged(object sender, TextChangedEventArgs e)
23+
{
24+
if (double.TryParse(MinimumEntry.Text, out double min))
25+
{
26+
_viewModel.Minimum = min;
27+
}
28+
}
29+
30+
private void OnMaximumChanged(object sender, TextChangedEventArgs e)
31+
{
32+
if (double.TryParse(MaximumEntry.Text, out double max))
33+
{
34+
_viewModel.Maximum = max;
35+
}
36+
}
37+
38+
private void OnIncrementChanged(object sender, TextChangedEventArgs e)
39+
{
40+
if (double.TryParse(IncrementEntry.Text, out double increment))
41+
{
42+
_viewModel.Increment = increment;
43+
}
44+
}
45+
46+
private void OnValueChanged(object sender, TextChangedEventArgs e)
47+
{
48+
if (double.TryParse(ValueEntry.Text, out double value))
49+
{
50+
_viewModel.Value = value;
51+
}
52+
}
53+
54+
private void OnIsEnabledCheckedChanged(object sender, CheckedChangedEventArgs e)
55+
{
56+
_viewModel.IsEnabled = IsEnabledTrueRadio.IsChecked;
57+
}
58+
59+
private void OnIsVisibleCheckedChanged(object sender, CheckedChangedEventArgs e)
60+
{
61+
_viewModel.IsVisible = IsVisibleTrueRadio.IsChecked;
62+
}
63+
64+
private void OnFlowDirectionChanged(object sender, CheckedChangedEventArgs e)
65+
{
66+
_viewModel.FlowDirection = FlowDirectionLTRRadio.IsChecked ? FlowDirection.LeftToRight : FlowDirection.RightToLeft;
67+
}
68+
}

0 commit comments

Comments
 (0)