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

Automate more CollectionView tests #13032

Merged
merged 14 commits into from
Jun 29, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.CollectionView)]
[Category(UITestCategories.UwpIgnore)] // CollectionView contents aren't currently visible to test automation
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 10110, "CollectionView EmptyView doesn't show up on UWP HorizontalList", PlatformAffected.UWP)]
public class Issue10110 : TestContentPage
{
const string VerticalEmptyView = "Empty Vertical List as String";
const string HorizontalEmptyView = "Empty Horizontal List as String";

public Issue10110()
{
Title = "Issue 10110";
Expand All @@ -31,14 +35,14 @@ public Issue10110()
var verticalCollectionView = new CollectionView
{
BackgroundColor = Color.LightBlue,
EmptyView = "Empty Vertical List as String"
EmptyView = VerticalEmptyView
};

var horizontalCollectionView = new CollectionView
{
BackgroundColor = Color.LightCoral,
ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal),
EmptyView = "Empty Horizontal List as String"
EmptyView = HorizontalEmptyView
};

layout.Children.Add(verticalCollectionView);
Expand All @@ -54,5 +58,14 @@ protected override void Init()
{

}

#if UITEST
[Test]
public void EmptyViewShowsUpInHorizontalAndVerticalList()
{
RunningApp.WaitForElement(HorizontalEmptyView);
RunningApp.WaitForElement(VerticalEmptyView);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Xamarin.Forms.Controls.Issue10735"
x:Class="Xamarin.Forms.Controls.Issues.Issue10735"
Title="Issue 10735">
<StackLayout>
<Label
Padding="12"
BackgroundColor="Black"
TextColor="White"
Text="If this sample works without exceptions, the test has passed."/>
<Label
x:Name="Result"
Padding="12"
Text="running..."/>
<CollectionView
x:Name="_collectionView"
ItemsSource="{Binding Items}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System;

#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.CollectionView)]
Expand All @@ -18,12 +19,14 @@ namespace Xamarin.Forms.Controls
[Issue(IssueTracker.Github, 10735, "[Bug] [Fatal] [Android] CollectionView Causes Application Crash When Keyboard Opens", PlatformAffected.Android)]
public partial class Issue10735 : TestContentPage
{
#if APP
readonly int _addItemDelay = 300;
int _item = 0;
#if APP
readonly int _changeFocusDelay = 1000;
View _lastFocus;
#endif
#endif

const string Success = "Success";

public Issue10735()
{
Expand All @@ -41,21 +44,26 @@ protected override void Init()

}

#if APP
void StartAddingMessages()
{
Task.Run(async () =>
{
while (true)
while (_item < 30)
{
await Task.Delay(_addItemDelay);
Items.Add(_item.ToString());
_item++;
}

Device.BeginInvokeOnMainThread(() => {
Result.Text = Success;
});
});
#if APP

Task.Run(async () =>
{
while (true)
while (_item < 30)
{
await Task.Delay(_changeFocusDelay);
Device.BeginInvokeOnMainThread(() =>
Expand All @@ -71,7 +79,15 @@ void StartAddingMessages()
});
}
});
}
#endif

#if UITEST
[Test]
public void KeyboardOpeningDuringCollectionViewAnimationShouldNotCrash()
{
RunningApp.WaitForElement(Success, timeout: TimeSpan.FromSeconds(15));
}
#endif
}
}
Loading