From 806a6d3ac0d0b9f93ac959588a7258f208bea3df Mon Sep 17 00:00:00 2001 From: "E.Z. Hart" Date: Sat, 4 May 2019 10:44:11 -0600 Subject: [PATCH 1/2] Add missing call to ReloadData on INCC Reset; fixes #5793 --- .../CollectionView/ObservableItemsSource.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs b/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs index 6abdfcef6d7..2cb64ccd26f 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/ObservableItemsSource.cs @@ -59,6 +59,7 @@ void CollectionChanged(object sender, NotifyCollectionChangedEventArgs args) Move(args); break; case NotifyCollectionChangedAction.Reset: + _collectionView.ReloadData(); break; default: throw new ArgumentOutOfRangeException(); From 71862b530182477b1ec274d0d14efb7f39882de4 Mon Sep 17 00:00:00 2001 From: "E.Z. Hart" Date: Sat, 4 May 2019 12:53:19 -0600 Subject: [PATCH 2/2] Automated test for INCC Reset --- .../Issue5793.cs | 50 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 1 + .../MultiTestObservableCollection.cs | 5 -- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5793.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5793.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5793.cs new file mode 100644 index 00000000000..daa6f899963 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5793.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.Forms.Core.UITests; +using Xamarin.UITest; +using NUnit.Framework; +#endif + + +namespace Xamarin.Forms.Controls.Issues +{ +#if UITEST + [Category(UITestCategories.CollectionView)] +#endif + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 5793, "[CollectionView/ListView] Not listening for Reset command", + PlatformAffected.iOS | PlatformAffected.Android)] + class Issue5793 : TestNavigationPage + { + protected override void Init() + { +#if APP + Device.SetFlags(new List(Device.Flags ?? new List()) { "CollectionView_Experimental" }); + + PushAsync(new GalleryPages.CollectionViewGalleries.ObservableCollectionResetGallery()); +#endif + } + +#if UITEST + [Test] + public void Reset() + { + RunningApp.WaitForElement("Reset"); + + // Verify the item is there + RunningApp.WaitForElement("cover1.jpg, 0"); + + // Clear the collection + RunningApp.Tap("Reset"); + + // Verify the item is gone + RunningApp.WaitForNoElement("cover1.jpg, 0"); + } +#endif + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index c5bee2d94d2..dca848dbeb7 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -458,6 +458,7 @@ Code + diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/MultiTestObservableCollection.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/MultiTestObservableCollection.cs index 8c9b0ef8f8f..511a2578886 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/MultiTestObservableCollection.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/MultiTestObservableCollection.cs @@ -77,12 +77,7 @@ public void TestReplaceWithListAndIndex(int index, int count, IEnumerable new public void TestReset() { - var random = new Random(); - var randomized = GetRange(0, Count).Select(item => new { Item = item, Index = random.Next(100000) }) - .OrderBy(x => x.Index).Select(x => x.Item).ToList(); - RemoveRange(0, Count); - InsertRange(0, randomized); var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); OnNotifyCollectionChanged(this, args);