diff --git a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5354.xaml.cs b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5354.xaml.cs index 85f9bc9e5bb6..c4dcbb46ae16 100644 --- a/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5354.xaml.cs +++ b/src/Compatibility/ControlGallery/src/Issues.Shared/Issue5354.xaml.cs @@ -76,6 +76,7 @@ void ButtonClicked(object sender, EventArgs e) #if UITEST [Test] [Compatibility.UITests.FailsOnMauiIOS] + [Compatibility.UITests.MovedToAppium] public void CollectionViewItemsLayoutUpdate() { RunningApp.WaitForElement("CollectionView5354"); diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21711.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21711.cs new file mode 100644 index 000000000000..d1a12727c2d8 --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue21711.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.Maui; +using Microsoft.Maui.Controls; + +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 21711, "NullReferenceException from FlexLayout.InitItemProperties", PlatformAffected.iOS)] + public class Issue21711 : TestContentPage + { + protected override void Init() + { + FlexLayout flex = null!; + Content = new VerticalStackLayout + { + new Button + { + Text = "Add", + AutomationId = "Add", + Command = new Command(() => + { + flex.Clear(); + flex.Add(NewLabel(0)); + flex.Add(NewLabel(1)); + + flex.Clear(); + flex.Add(NewLabel(2)); + flex.Add(NewLabel(3)); + }) + }, + new Button + { + Text = "Insert", + AutomationId = "Insert", + Command = new Command(() => + { + flex.Clear(); + flex.Insert(0, NewLabel(1)); + flex.Insert(0, NewLabel(0)); + + flex.Clear(); + flex.Insert(0, NewLabel(3)); + flex.Insert(0, NewLabel(2)); + }) + }, + new Button + { + Text = "Update", + AutomationId = "Update", + Command = new Command(() => + { + flex.Clear(); + flex.Add(NewLabel(0)); + flex[0] = NewLabel(1); + + flex.Clear(); + flex.Add(NewLabel(2)); + flex[0] = NewLabel(3); + }) + }, + new Button + { + Text = "Remove", + AutomationId = "Remove", + Command = new Command(() => + { + flex.Clear(); + var label = NewLabel(0); + flex.Add(label); + flex.Remove(label); + + flex.Clear(); + label = NewLabel(1); + flex.Add(label); + flex.Remove(label); + + flex.Add(NewLabel(2)); + }) + }, + (flex = new FlexLayout { }), + }; + } + + Label NewLabel(int count) => + new Label + { + Text = $"Item{count}", + AutomationId = $"Item{count}", + Background = Brush.Yellow, + TextType = TextType.Html + }; + } +} \ No newline at end of file diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue5354.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue5354.xaml new file mode 100644 index 000000000000..3cf3c402e88e --- /dev/null +++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue5354.xaml @@ -0,0 +1,33 @@ + + + + + + + + + +