Skip to content

Commit 1cdb0aa

Browse files
NafeelaNazhiranandhan-rajagopal
authored andcommitted
[Testing] Feature Matrix UITest Cases for CollectionView Grouping Feature (dotnet#29002)
* Added GroupingFeature tests * updated changes * updated changes * Added test fails attribute * Corrected Mistakes * Updated Images * Corrected mistakes * Changes updated * Modified changes * Resolved Conflicts
1 parent 0d52e90 commit 1cdb0aa

File tree

10 files changed

+2839
-1488
lines changed

10 files changed

+2839
-1488
lines changed

src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/CollectionViewFeaturePage.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
HorizontalOptions="Center"
1313
AutomationId="EmptyViewButton"
1414
WidthRequest="400"/>
15+
<Button Text="CollectionViewGrouping"
16+
Clicked="OnGroupingButtonClicked"
17+
HorizontalOptions="Center"
18+
AutomationId="GroupingButton"
19+
WidthRequest="400"/>
1520
<Button Text="Header/FooterViewTemplate"
1621
Clicked="OnHeaderFooterViewButtonClicked"
1722
HorizontalOptions="Center"
Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
using System;
22
using Microsoft.Maui.Controls;
33

4-
namespace Maui.Controls.Sample
4+
namespace Maui.Controls.Sample;
5+
public class CollectionViewFeaturePage : NavigationPage
56
{
6-
public class CollectionViewFeaturePage : NavigationPage
7+
public CollectionViewFeaturePage()
78
{
8-
public CollectionViewFeaturePage()
9-
{
10-
PushAsync(new CollectionViewFeatureMainPage());
11-
}
9+
PushAsync(new CollectionViewFeatureMainPage());
1210
}
11+
}
1312

14-
public partial class CollectionViewFeatureMainPage : ContentPage
13+
public partial class CollectionViewFeatureMainPage : ContentPage
14+
{
15+
public CollectionViewFeatureMainPage()
1516
{
16-
public CollectionViewFeatureMainPage()
17-
{
18-
InitializeComponent();
19-
}
17+
InitializeComponent();
18+
}
2019

21-
private async void OnEmptyViewButtonClicked(object sender, EventArgs e)
22-
{
23-
await Navigation.PushAsync(new CollectionViewEmptyViewPage());
24-
}
20+
private async void OnEmptyViewButtonClicked(object sender, EventArgs e)
21+
{
22+
await Navigation.PushAsync(new CollectionViewEmptyViewPage());
23+
}
2524

26-
private async void OnHeaderFooterViewButtonClicked(object sender, EventArgs e)
27-
{
28-
await Navigation.PushAsync(new CollectionViewHeaderPage());
29-
}
25+
private async void OnHeaderFooterViewButtonClicked(object sender, EventArgs e)
26+
{
27+
await Navigation.PushAsync(new CollectionViewHeaderPage());
28+
}
3029

31-
private async void OnScrollingButtonClicked(object sender, EventArgs e)
32-
{
33-
await Navigation.PushAsync(new CollectionViewScrollPage());
34-
}
30+
private async void OnGroupingButtonClicked(object sender, EventArgs e)
31+
{
32+
await Navigation.PushAsync(new CollectionViewGroupingPage());
3533
}
34+
35+
private async void OnScrollingButtonClicked(object sender, EventArgs e)
36+
{
37+
await Navigation.PushAsync(new CollectionViewScrollPage());
38+
}
39+
3640
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.CollectionViewGroupingPage"
6+
Title="CollectionViewControlPage">
7+
<ContentPage.ToolbarItems>
8+
<ToolbarItem Text="Options"
9+
Clicked="NavigateToOptionsPage_Clicked"
10+
AutomationId="Options"/>
11+
</ContentPage.ToolbarItems>
12+
13+
<local:CollectionView2
14+
x:Name="collectionView"
15+
ItemsSource="{Binding ItemsSource}"
16+
Header="{Binding Header}"
17+
Footer="{Binding Footer}"
18+
GroupHeaderTemplate="{Binding GroupHeaderTemplate}"
19+
GroupFooterTemplate="{Binding GroupFooterTemplate}"
20+
ItemTemplate="{Binding ItemTemplate}"
21+
IsGrouped="{Binding IsGrouped}"
22+
CanMixGroups="{Binding CanMixGroups}"
23+
CanReorderItems="{Binding CanReorderItems}"
24+
ItemsLayout="{Binding ItemsLayout}"
25+
AutomationId="CollectionViewControl">
26+
</local:CollectionView2>
27+
28+
</ContentPage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using Microsoft.Maui.Controls;
3+
using System.Collections.ObjectModel;
4+
5+
namespace Maui.Controls.Sample;
6+
7+
public partial class CollectionViewGroupingPage : ContentPage
8+
{
9+
private CollectionViewViewModel _viewModel;
10+
11+
public CollectionViewGroupingPage()
12+
{
13+
InitializeComponent();
14+
_viewModel = new CollectionViewViewModel();
15+
_viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT;
16+
BindingContext = _viewModel;
17+
}
18+
19+
private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
20+
{
21+
BindingContext = _viewModel = new CollectionViewViewModel();
22+
_viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT;
23+
await Navigation.PushAsync(new GroupingOptionsPage(_viewModel));
24+
}
25+
}

src/Controls/tests/TestCases.HostApp/FeatureMatrix/CollectionView/CollectionViewGrouping/GroupingOptionsPage.xaml

Lines changed: 240 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
using System;
2+
using Microsoft.Maui.Controls;
3+
using System.Collections.ObjectModel;
4+
using Maui.Controls.Sample.CollectionViewGalleries;
5+
6+
namespace Maui.Controls.Sample;
7+
8+
public partial class GroupingOptionsPage : ContentPage
9+
{
10+
private CollectionViewViewModel _viewModel;
11+
public GroupingOptionsPage(CollectionViewViewModel viewModel)
12+
{
13+
InitializeComponent();
14+
_viewModel = viewModel;
15+
BindingContext = _viewModel;
16+
}
17+
private void ApplyButton_Clicked(object sender, EventArgs e)
18+
{
19+
Navigation.PopAsync();
20+
}
21+
22+
private void OnHeaderChanged(object sender, CheckedChangedEventArgs e)
23+
{
24+
if (HeaderNone.IsChecked)
25+
{
26+
_viewModel.Header = null;
27+
}
28+
else if (HeaderString.IsChecked)
29+
{
30+
_viewModel.Header = "CollectionView Header(String)";
31+
}
32+
}
33+
34+
private void OnFooterChanged(object sender, CheckedChangedEventArgs e)
35+
{
36+
if (FooterNone.IsChecked)
37+
{
38+
_viewModel.Footer = null;
39+
}
40+
else if (FooterString.IsChecked)
41+
{
42+
_viewModel.Footer = "CollectionView Footer(String)";
43+
}
44+
}
45+
46+
private void OnGroupHeaderTemplateChanged(object sender, CheckedChangedEventArgs e)
47+
{
48+
if (GroupHeaderTemplateNone.IsChecked)
49+
{
50+
_viewModel.GroupHeaderTemplate = null;
51+
}
52+
else if (GroupHeaderTemplateGrid.IsChecked)
53+
{
54+
_viewModel.GroupHeaderTemplate = new DataTemplate(() =>
55+
{
56+
Grid grid = new Grid
57+
{
58+
BackgroundColor = Colors.LightGray,
59+
Padding = new Thickness(10)
60+
};
61+
grid.Children.Add(new Label
62+
{
63+
Text = "GroupHeaderTemplate",
64+
FontSize = 18,
65+
FontAttributes = FontAttributes.Bold,
66+
HorizontalOptions = LayoutOptions.Center,
67+
VerticalOptions = LayoutOptions.Center,
68+
TextColor = Colors.Green
69+
});
70+
return grid;
71+
});
72+
}
73+
}
74+
75+
private void OnGroupFooterTemplateChanged(object sender, CheckedChangedEventArgs e)
76+
{
77+
if (GroupFooterTemplateNone.IsChecked)
78+
{
79+
_viewModel.GroupFooterTemplate = null;
80+
}
81+
else if (GroupFooterTemplateGrid.IsChecked)
82+
{
83+
_viewModel.GroupFooterTemplate = new DataTemplate(() =>
84+
{
85+
Grid grid = new Grid
86+
{
87+
BackgroundColor = Colors.LightGray,
88+
Padding = new Thickness(10)
89+
};
90+
grid.Children.Add(new Label
91+
{
92+
Text = "GroupFooterTemplate",
93+
FontSize = 18,
94+
FontAttributes = FontAttributes.Bold,
95+
HorizontalOptions = LayoutOptions.Center,
96+
VerticalOptions = LayoutOptions.Center,
97+
TextColor = Colors.Red
98+
});
99+
return grid;
100+
});
101+
}
102+
}
103+
104+
private void OnIsGroupedChanged(object sender, CheckedChangedEventArgs e)
105+
{
106+
if (IsGroupedFalse.IsChecked)
107+
{
108+
_viewModel.IsGrouped = false;
109+
}
110+
else if (IsGroupedTrue.IsChecked)
111+
{
112+
_viewModel.IsGrouped = true;
113+
}
114+
}
115+
116+
private void OnItemTemplateChanged(object sender, CheckedChangedEventArgs e)
117+
{
118+
if (ItemTemplateNone.IsChecked)
119+
{
120+
_viewModel.ItemTemplate = null;
121+
}
122+
else if (ItemTemplateBasic.IsChecked)
123+
{
124+
_viewModel.ItemTemplate = new DataTemplate(() =>
125+
{
126+
var label = new Label();
127+
label.SetBinding(Label.TextProperty, new Binding("Caption"));
128+
return label;
129+
});
130+
}
131+
}
132+
133+
private void OnItemsSourceChanged(object sender, CheckedChangedEventArgs e)
134+
{
135+
if (!(sender is RadioButton radioButton) || !e.Value)
136+
return;
137+
if (radioButton == ItemsSourceObservableCollection)
138+
_viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT;
139+
else if (radioButton == ItemsSourceGroupedList)
140+
_viewModel.ItemsSourceType = ItemsSourceType.GroupedListT;
141+
else if (radioButton == ItemsSourceNone)
142+
_viewModel.ItemsSourceType = ItemsSourceType.None;
143+
}
144+
145+
private void OnCanMixGroupsChanged(object sender, CheckedChangedEventArgs e)
146+
{
147+
if (CanMixGroupsTrue.IsChecked)
148+
{
149+
_viewModel.CanMixGroups = true;
150+
}
151+
else if (CanMixGroupsFalse.IsChecked)
152+
{
153+
_viewModel.CanMixGroups = false;
154+
}
155+
}
156+
157+
private void OnCanReorderItemsChanged(object sender, CheckedChangedEventArgs e)
158+
{
159+
if (CanReorderItemsTrue.IsChecked)
160+
{
161+
_viewModel.CanReorderItems = true;
162+
}
163+
else if (CanReorderItemsFalse.IsChecked)
164+
{
165+
_viewModel.CanReorderItems = false;
166+
}
167+
}
168+
169+
private void OnItemsLayoutChanged(object sender, CheckedChangedEventArgs e)
170+
{
171+
if (ItemsLayoutVerticalList.IsChecked)
172+
{
173+
_viewModel.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Vertical);
174+
}
175+
else if (ItemsLayoutHorizontalList.IsChecked)
176+
{
177+
_viewModel.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal);
178+
}
179+
else if (ItemsLayoutVerticalGrid.IsChecked)
180+
{
181+
_viewModel.ItemsLayout = new GridItemsLayout(2, ItemsLayoutOrientation.Vertical); // 2 columns
182+
}
183+
else if (ItemsLayoutHorizontalGrid.IsChecked)
184+
{
185+
_viewModel.ItemsLayout = new GridItemsLayout(2, ItemsLayoutOrientation.Horizontal); // 2 rows
186+
}
187+
}
188+
}

0 commit comments

Comments
 (0)