Skip to content

[Testing] Feature Matrix UITest Cases for CollectionView Grouping Feature #29002

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
HorizontalOptions="Center"
AutomationId="EmptyViewButton"
WidthRequest="400"/>
<Button Text="CollectionViewGrouping"
Clicked="OnGroupingButtonClicked"
HorizontalOptions="Center"
AutomationId="GroupingButton"
WidthRequest="400"/>
<Button Text="Header/FooterViewTemplate"
Clicked="OnHeaderFooterViewButtonClicked"
HorizontalOptions="Center"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
using System;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample
namespace Maui.Controls.Sample;
public class CollectionViewFeaturePage : NavigationPage
{
public class CollectionViewFeaturePage : NavigationPage
public CollectionViewFeaturePage()
{
public CollectionViewFeaturePage()
{
PushAsync(new CollectionViewFeatureMainPage());
}
PushAsync(new CollectionViewFeatureMainPage());
}
}

public partial class CollectionViewFeatureMainPage : ContentPage
public partial class CollectionViewFeatureMainPage : ContentPage
{
public CollectionViewFeatureMainPage()
{
public CollectionViewFeatureMainPage()
{
InitializeComponent();
}
InitializeComponent();
}

private async void OnEmptyViewButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CollectionViewEmptyViewPage());
}
private async void OnEmptyViewButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CollectionViewEmptyViewPage());
}

private async void OnHeaderFooterViewButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CollectionViewHeaderPage());
}
private async void OnHeaderFooterViewButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CollectionViewHeaderPage());
}

private async void OnGroupingButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CollectionViewGroupingPage());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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.CollectionViewGroupingPage"
Title="CollectionViewControlPage">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Options"
Clicked="NavigateToOptionsPage_Clicked"
AutomationId="Options"/>
</ContentPage.ToolbarItems>

<local:CollectionView2
x:Name="collectionView"
ItemsSource="{Binding ItemsSource}"
Header="{Binding Header}"
Footer="{Binding Footer}"
GroupHeaderTemplate="{Binding GroupHeaderTemplate}"
GroupFooterTemplate="{Binding GroupFooterTemplate}"
ItemTemplate="{Binding ItemTemplate}"
IsGrouped="{Binding IsGrouped}"
CanMixGroups="{Binding CanMixGroups}"
CanReorderItems="{Binding CanReorderItems}"
ItemsLayout="{Binding ItemsLayout}"
AutomationId="CollectionViewControl">
</local:CollectionView2>

</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Microsoft.Maui.Controls;
using System.Collections.ObjectModel;

namespace Maui.Controls.Sample;

public partial class CollectionViewGroupingPage : ContentPage
{
private CollectionViewViewModel _viewModel;

public CollectionViewGroupingPage()
{
InitializeComponent();
_viewModel = new CollectionViewViewModel();
_viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT;
BindingContext = _viewModel;
}

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new CollectionViewViewModel();
_viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT;
await Navigation.PushAsync(new GroupingOptionsPage(_viewModel));
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
using System;
using Microsoft.Maui.Controls;
using System.Collections.ObjectModel;
using Maui.Controls.Sample.CollectionViewGalleries;

namespace Maui.Controls.Sample;

public partial class GroupingOptionsPage : ContentPage
{
private CollectionViewViewModel _viewModel;
public GroupingOptionsPage(CollectionViewViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}
private void ApplyButton_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}

private void OnHeaderChanged(object sender, CheckedChangedEventArgs e)
{
if (HeaderNone.IsChecked)
{
_viewModel.Header = null;
}
else if (HeaderString.IsChecked)
{
_viewModel.Header = "CollectionView Header(String)";
}
}

private void OnFooterChanged(object sender, CheckedChangedEventArgs e)
{
if (FooterNone.IsChecked)
{
_viewModel.Footer = null;
}
else if (FooterString.IsChecked)
{
_viewModel.Footer = "CollectionView Footer(String)";
}
}

private void OnGroupHeaderTemplateChanged(object sender, CheckedChangedEventArgs e)
{
if (GroupHeaderTemplateNone.IsChecked)
{
_viewModel.GroupHeaderTemplate = null;
}
else if (GroupHeaderTemplateGrid.IsChecked)
{
_viewModel.GroupHeaderTemplate = new DataTemplate(() =>
{
Grid grid = new Grid
{
BackgroundColor = Colors.LightGray,
Padding = new Thickness(10)
};
grid.Children.Add(new Label
{
Text = "GroupHeaderTemplate",
FontSize = 18,
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
TextColor = Colors.Green
});
return grid;
});
}
}

private void OnGroupFooterTemplateChanged(object sender, CheckedChangedEventArgs e)
{
if (GroupFooterTemplateNone.IsChecked)
{
_viewModel.GroupFooterTemplate = null;
}
else if (GroupFooterTemplateGrid.IsChecked)
{
_viewModel.GroupFooterTemplate = new DataTemplate(() =>
{
Grid grid = new Grid
{
BackgroundColor = Colors.LightGray,
Padding = new Thickness(10)
};
grid.Children.Add(new Label
{
Text = "GroupFooterTemplate",
FontSize = 18,
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
TextColor = Colors.Red
});
return grid;
});
}
}

private void OnIsGroupedChanged(object sender, CheckedChangedEventArgs e)
{
if (IsGroupedFalse.IsChecked)
{
_viewModel.IsGrouped = false;
}
else if (IsGroupedTrue.IsChecked)
{
_viewModel.IsGrouped = true;
}
}

private void OnItemTemplateChanged(object sender, CheckedChangedEventArgs e)
{
if (ItemTemplateNone.IsChecked)
{
_viewModel.ItemTemplate = null;
}
else if (ItemTemplateBasic.IsChecked)
{
_viewModel.ItemTemplate = new DataTemplate(() =>
{
var label = new Label();
label.SetBinding(Label.TextProperty, new Binding("Caption"));
return label;
});
}
}

private void OnItemsSourceChanged(object sender, CheckedChangedEventArgs e)
{
if (!(sender is RadioButton radioButton) || !e.Value)
return;
if (radioButton == ItemsSourceObservableCollection)
_viewModel.ItemsSourceType = ItemsSourceType.ObservableCollectionT;
else if (radioButton == ItemsSourceGroupedList)
_viewModel.ItemsSourceType = ItemsSourceType.GroupedListT;
else if (radioButton == ItemsSourceNone)
_viewModel.ItemsSourceType = ItemsSourceType.None;
}

private void OnCanMixGroupsChanged(object sender, CheckedChangedEventArgs e)
{
if (CanMixGroupsTrue.IsChecked)
{
_viewModel.CanMixGroups = true;
}
else if (CanMixGroupsFalse.IsChecked)
{
_viewModel.CanMixGroups = false;
}
}

private void OnCanReorderItemsChanged(object sender, CheckedChangedEventArgs e)
{
if (CanReorderItemsTrue.IsChecked)
{
_viewModel.CanReorderItems = true;
}
else if (CanReorderItemsFalse.IsChecked)
{
_viewModel.CanReorderItems = false;
}
}

private void OnItemsLayoutChanged(object sender, CheckedChangedEventArgs e)
{
if (ItemsLayoutVerticalList.IsChecked)
{
_viewModel.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Vertical);
}
else if (ItemsLayoutHorizontalList.IsChecked)
{
_viewModel.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal);
}
else if (ItemsLayoutVerticalGrid.IsChecked)
{
_viewModel.ItemsLayout = new GridItemsLayout(2, ItemsLayoutOrientation.Vertical); // 2 columns
}
else if (ItemsLayoutHorizontalGrid.IsChecked)
{
_viewModel.ItemsLayout = new GridItemsLayout(2, ItemsLayoutOrientation.Horizontal); // 2 rows
}
}
}
Loading