Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Add missing call to ReloadData on NotifyCollectionChangedAction.Reset #6089

Merged
merged 3 commits into from
May 8, 2019
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
@@ -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<string>(Device.Flags ?? new List<string>()) { "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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue5535.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue5793.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LegacyComponents\NonAppCompatSwitch.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MapsModalCrash.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ModalActivityIndicatorTest.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ public void TestReplaceWithListAndIndex(int index, int count, IEnumerable<T> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void CollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
Move(args);
break;
case NotifyCollectionChangedAction.Reset:
_collectionView.ReloadData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failing on IOS10 :(

Copy link

@abdul-wasey abdul-wasey Jan 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not working..
XF Version = 4.8.0.1687

break;
default:
throw new ArgumentOutOfRangeException();
Expand Down