Skip to content

Commit 235cf04

Browse files
Anandhan RajagopalPureWeen
authored andcommitted
[Testing] Feature Matrix UITest Cases for CheckBox Control (#29739)
* added sample and test class files * Added android snap * Updated images for android and ios * Update CorePageView.cs * updated base images for windows and catalyst platform * removed unused references
1 parent 805346d commit 235cf04

File tree

13 files changed

+434
-0
lines changed

13 files changed

+434
-0
lines changed
55.6 KB
Loading
65.7 KB
Loading

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public override string ToString()
7979
new GalleryPageFactory(() => new TimePickerCoreGalleryPage(), "Time Picker Gallery"),
8080
new GalleryPageFactory(() => new WebViewCoreGalleryPage(), "WebView Gallery"),
8181
new GalleryPageFactory(() => new SliderControlPage(), "Slider Feature Matrix"),
82+
new GalleryPageFactory(() => new CheckBoxControlPage(), "CheckBox Feature Matrix"),
8283
new GalleryPageFactory(() => new CollectionViewFeaturePage(), "CollectionView Feature Matrix"),
8384
new GalleryPageFactory(() => new LabelControlPage(), "Label Feature Matrix"),
8485
new GalleryPageFactory(() => new CarouselViewFeaturePage(), "CarouselView Feature Matrix"),
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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.CheckBoxControlPage"
6+
x:DataType="local:CheckBoxFeatureMatrixViewModel"
7+
Title="CheckBoxFeature">
8+
9+
<Grid Padding="20"
10+
RowDefinitions="*, Auto, Auto, Auto"
11+
ColumnDefinitions="0.5*, 0.5*"
12+
RowSpacing="10">
13+
<!-- CheckBox Control -->
14+
15+
<CheckBox IsChecked="{Binding IsChecked}"
16+
Color="{Binding Color}"
17+
Grid.ColumnSpan="2"
18+
HorizontalOptions="Center"
19+
VerticalOptions="Center"
20+
IsEnabled="{Binding IsEnabled}"
21+
IsVisible="{Binding IsVisible}"
22+
CheckedChanged="OnCheckBoxCheckedChanged"
23+
AutomationId="CheckBoxControl"/>
24+
25+
26+
<!-- IsChecked Value -->
27+
<Label Grid.Row="1"
28+
Grid.Column="0"
29+
Text="IsChecked:"
30+
FontSize="16"
31+
VerticalTextAlignment="Start"
32+
HorizontalTextAlignment="Start"
33+
Margin="65,0,10,10"/>
34+
<Label Grid.Row="1"
35+
Grid.Column="1"
36+
Text="{Binding IsChecked}"
37+
FontSize="16"
38+
VerticalTextAlignment="Start"
39+
HorizontalTextAlignment="Start"
40+
AutomationId="IsCheckedLabel"/>
41+
42+
<!-- Event Status -->
43+
<Label Grid.Row="2"
44+
Grid.Column="0"
45+
FontSize="16"
46+
Text="Triggered Events:"
47+
IsVisible="{Binding IsEventStatusLabelVisible}"
48+
VerticalTextAlignment="Start"
49+
HorizontalTextAlignment="Start"
50+
Margin="80,0,10,10"/>
51+
<Label Grid.Row="2"
52+
Grid.Column="1"
53+
Text="{Binding CheckedChangedStatus}"
54+
FontSize="16"
55+
VerticalTextAlignment="Start"
56+
HorizontalTextAlignment="Start"
57+
AutomationId="CheckedChangedStatusLabel"
58+
Margin="0,0,10,10"/>
59+
60+
<StackLayout Spacing="10"
61+
Padding="10"
62+
Grid.Row="3"
63+
Grid.ColumnSpan="2">
64+
65+
<Label Text="CheckBox Properties"
66+
FontAttributes="Bold"
67+
FontSize="14"
68+
Margin="0,0,0,10"/>
69+
70+
<StackLayout Orientation="Vertical">
71+
<StackLayout Orientation="Horizontal">
72+
<Label Text="IsChecked"
73+
FontAttributes="Bold"
74+
Margin="0,15,0,0"/>
75+
<Switch IsToggled="{Binding IsChecked}"
76+
AutomationId="IsCheckedSwitch"/>
77+
78+
</StackLayout>
79+
<StackLayout Orientation="Horizontal">
80+
<Label Text="IsEnabled"
81+
FontAttributes="Bold"
82+
Margin="0,15,0,0"/>
83+
<Switch IsToggled="{Binding IsEnabled}"
84+
AutomationId="IsEnabledSwitch"/>
85+
</StackLayout>
86+
<StackLayout Orientation="Horizontal">
87+
<Label Text="IsVisible"
88+
FontAttributes="Bold"
89+
Margin="0,15,0,0"/>
90+
<Switch IsToggled="{Binding IsVisible}"
91+
AutomationId="IsVisibleSwitch"/>
92+
</StackLayout>
93+
</StackLayout>
94+
95+
<!-- Color -->
96+
97+
<Grid ColumnDefinitions="*,0.3*,0.3*,0.3*"
98+
ColumnSpacing="15"
99+
HorizontalOptions="Start">
100+
<Label Text="Color"
101+
FontAttributes="Bold"
102+
VerticalOptions="Center"/>
103+
<Button BackgroundColor="Blue"
104+
Grid.Column="1"
105+
Command="{Binding SetColorCommand}"
106+
CommandParameter="Blue"
107+
AutomationId="BlueColorButton"/>
108+
<Button BackgroundColor="Green"
109+
Grid.Column="2"
110+
Command="{Binding SetColorCommand}"
111+
CommandParameter="Green"
112+
AutomationId="GreenColorButton"/>
113+
<Button BackgroundColor="Gray"
114+
Grid.Column="3"
115+
Command="{Binding SetColorCommand}"
116+
AutomationId="DefaultColorButton"/>
117+
</Grid>
118+
119+
<Button Text="Reset Changes"
120+
Clicked="NavigateToOptionsPage_Clicked"
121+
AutomationId="ResetButton"/>
122+
</StackLayout>
123+
</Grid>
124+
</ContentPage>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Windows.Input;
3+
using Microsoft.Maui.Controls;
4+
5+
namespace Maui.Controls.Sample;
6+
7+
public partial class CheckBoxControlPage : ContentPage
8+
{
9+
private CheckBoxFeatureMatrixViewModel _viewModel;
10+
11+
public CheckBoxControlPage()
12+
{
13+
InitializeComponent();
14+
_viewModel = new CheckBoxFeatureMatrixViewModel();
15+
_viewModel.SetColorCommand = new Command<string>(OnSetColor);
16+
BindingContext = _viewModel;
17+
}
18+
19+
private void OnSetColor(string colorName)
20+
{
21+
switch (colorName)
22+
{
23+
case "Blue":
24+
_viewModel.Color = Colors.Blue;
25+
break;
26+
case "Green":
27+
_viewModel.Color = Colors.Green;
28+
break;
29+
case "Default":
30+
default:
31+
_viewModel.Color = null;
32+
break;
33+
}
34+
}
35+
36+
private void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
37+
{
38+
_viewModel = new CheckBoxFeatureMatrixViewModel();
39+
_viewModel.SetColorCommand = new Command<string>(OnSetColor);
40+
BindingContext = _viewModel;
41+
}
42+
43+
private void OnCheckBoxCheckedChanged(object sender, CheckedChangedEventArgs e)
44+
{
45+
_viewModel.CheckedChangedCommand.Execute(null);
46+
}
47+
48+
}
49+
50+
51+
// Extension of the CheckBoxFeatureMatrixViewModel to add commands for the options page
52+
public partial class CheckBoxFeatureMatrixViewModel
53+
{
54+
public ICommand SetColorCommand { get; set; }
55+
}
56+
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Runtime.CompilerServices;
4+
using System.Windows.Input;
5+
using Microsoft.Maui.Controls;
6+
7+
namespace Maui.Controls.Sample;
8+
9+
public partial class CheckBoxFeatureMatrixViewModel : INotifyPropertyChanged
10+
{
11+
private bool _isChecked = true;
12+
private Color _color = null;
13+
private bool _isEnabled = true;
14+
private bool _isVisible = true;
15+
private string _checkedChangedStatus = string.Empty;
16+
private bool _isEventStatusLabelVisible = false;
17+
18+
public event PropertyChangedEventHandler PropertyChanged;
19+
20+
public CheckBoxFeatureMatrixViewModel()
21+
{
22+
CheckedChangedCommand = new Command(OnCheckedChanged);
23+
}
24+
25+
public bool IsChecked
26+
{
27+
get => _isChecked;
28+
set
29+
{
30+
if (_isChecked != value)
31+
{
32+
_isChecked = value;
33+
OnPropertyChanged();
34+
}
35+
}
36+
}
37+
38+
public Color Color
39+
{
40+
get => _color;
41+
set
42+
{
43+
if (_color != value)
44+
{
45+
_color = value;
46+
OnPropertyChanged();
47+
}
48+
}
49+
}
50+
51+
public bool IsEnabled
52+
{
53+
get => _isEnabled;
54+
set
55+
{
56+
if (_isEnabled != value)
57+
{
58+
_isEnabled = value;
59+
OnPropertyChanged();
60+
}
61+
}
62+
}
63+
64+
public bool IsVisible
65+
{
66+
get => _isVisible;
67+
set
68+
{
69+
if (_isVisible != value)
70+
{
71+
_isVisible = value;
72+
OnPropertyChanged();
73+
}
74+
}
75+
}
76+
77+
public string CheckedChangedStatus
78+
{
79+
get => _checkedChangedStatus;
80+
set
81+
{
82+
if (_checkedChangedStatus != value)
83+
{
84+
if (!string.IsNullOrEmpty(value))
85+
{
86+
IsEventStatusLabelVisible = true;
87+
}
88+
_checkedChangedStatus = value;
89+
OnPropertyChanged();
90+
}
91+
}
92+
}
93+
94+
public bool IsEventStatusLabelVisible
95+
{
96+
get => _isEventStatusLabelVisible;
97+
set
98+
{
99+
if (_isEventStatusLabelVisible != value)
100+
{
101+
_isEventStatusLabelVisible = value;
102+
OnPropertyChanged();
103+
}
104+
}
105+
}
106+
107+
public ICommand CheckedChangedCommand { get; }
108+
109+
private void OnCheckedChanged()
110+
{
111+
CheckedChangedStatus = "CheckedChanged Triggered";
112+
}
113+
114+
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
115+
{
116+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
117+
}
118+
}
21.4 KB
Loading
28 KB
Loading

0 commit comments

Comments
 (0)