-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios,tests] Fix iOS Header with Group (#25157)
* [tests] Add CV header/footer tests * Update more tests * Fixes * [iOS] Make sure to distinguish between group header and global header on CV2 * [iOS] Porting fix #24830 * [tests] Add test for issue 20443 * [testing] run these tests on iOS for now Fix build Add missing usings * Fix #12429 * Update StructuredItemsViewController.cs * [iOS] CV2 fix footer * [iOS] Make sure to handle also the header or footer template * Fix images * [tests] This is a bug on CV2 --------- Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
- Loading branch information
Showing
17 changed files
with
322 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
44 changes: 44 additions & 0 deletions
44
src/Controls/tests/TestCases.HostApp/Issues/Issue20443.xaml
This file contains 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,44 @@ | ||
<?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" | ||
x:Class="Controls.TestCases.HostApp.Issues.Issue20443" | ||
xmlns:local="clr-namespace:Controls.TestCases.HostApp.Issues" | ||
x:DataType="local:Issue20443ViewModel" | ||
Title="Issue20443"> | ||
<ContentPage.BindingContext> | ||
<local:Issue20443ViewModel/> | ||
</ContentPage.BindingContext> | ||
<Grid> | ||
<RefreshView | ||
IsRefreshing="{Binding IsRefreshing}" | ||
Command="{Binding RefreshCommand}"> | ||
<CollectionView | ||
ItemSizingStrategy="MeasureAllItems" | ||
ItemsSource="{Binding Items}"> | ||
<CollectionView.ItemTemplate> | ||
<local:Issue20443TemplateSelector> | ||
<local:Issue20443TemplateSelector.ItemATemplate> | ||
<DataTemplate> | ||
<Grid | ||
HeightRequest="20" | ||
BackgroundColor="Aqua"> | ||
<Label Text="20"/> | ||
</Grid> | ||
</DataTemplate> | ||
</local:Issue20443TemplateSelector.ItemATemplate> | ||
<local:Issue20443TemplateSelector.ItemBTemplate> | ||
<DataTemplate> | ||
<Grid | ||
HeightRequest="100" | ||
BackgroundColor="Pink"> | ||
<Label Text="100"/> | ||
</Grid> | ||
</DataTemplate> | ||
</local:Issue20443TemplateSelector.ItemBTemplate> | ||
</local:Issue20443TemplateSelector> | ||
</CollectionView.ItemTemplate> | ||
|
||
</CollectionView> | ||
</RefreshView> | ||
</Grid> | ||
</ContentPage> |
90 changes: 90 additions & 0 deletions
90
src/Controls/tests/TestCases.HostApp/Issues/Issue20443.xaml.cs
This file contains 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,90 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Controls.TestCases.HostApp.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 20443, "CollectionView item gets wrong size after refresh", PlatformAffected.iOS)] | ||
|
||
public partial class Issue20443 : ContentPage | ||
{ | ||
public Issue20443() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
public class Issue20443ViewModel : INotifyPropertyChanged | ||
{ | ||
public IList<object> Items { get; set; } | ||
|
||
private bool _isRefreshing; | ||
|
||
public bool IsRefreshing | ||
{ | ||
get => _isRefreshing; | ||
set | ||
{ | ||
_isRefreshing = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public Command RefreshCommand { get; set; } | ||
|
||
public Issue20443ViewModel() | ||
{ | ||
RefreshCommand = new Command( | ||
async () => | ||
{ | ||
await Task.Delay(2000); | ||
IsRefreshing = false; | ||
}); | ||
|
||
Items = new List<object>(); | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
Items.Add(new Issue20443ItemA()); | ||
Items.Add(new Issue20443ItemB()); | ||
Items.Add(new Issue20443ItemB()); | ||
Items.Add(new Issue20443ItemB()); | ||
Items.Add(new Issue20443ItemB()); | ||
} | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
|
||
public class Issue20443ItemA | ||
{ | ||
|
||
} | ||
|
||
public class Issue20443ItemB | ||
{ | ||
|
||
} | ||
|
||
public class Issue20443TemplateSelector : DataTemplateSelector | ||
{ | ||
public DataTemplate ItemATemplate { get; set; } | ||
public DataTemplate ItemBTemplate { get; set; } | ||
|
||
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) | ||
{ | ||
if (item is Issue20443ItemA) | ||
{ | ||
return ItemATemplate; | ||
} | ||
|
||
return ItemBTemplate; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...trols/tests/TestCases.Shared.Tests/Tests/CollectionView/CollectionViewUITests.Grouping.cs
This file contains 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,34 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests | ||
{ | ||
#if IOS | ||
public class CollectionViewGroupingTests : CollectionViewUITests | ||
{ | ||
protected override bool ResetAfterEachTest => true; | ||
|
||
public CollectionViewGroupingTests(TestDevice device) | ||
: base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.CollectionView)] | ||
public void GroupingAndHeaderWorks() | ||
{ | ||
VisitInitialGallery("Grouping"); | ||
|
||
VisitSubGallery("Basic Grouping"); | ||
|
||
// header | ||
App.WaitForElement("This is a header"); | ||
// group header | ||
App.WaitForElement("Avengers"); | ||
// group footer | ||
App.WaitForElement("Total members: 12"); | ||
} | ||
} | ||
#endif | ||
} |
Oops, something went wrong.