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

Commit

Permalink
Automated test for INCC Reset
Browse files Browse the repository at this point in the history
  • Loading branch information
hartez committed May 6, 2019
1 parent 806a6d3 commit 71862b5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
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

0 comments on commit 71862b5

Please sign in to comment.