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

Commit

Permalink
Automate more CollectionView tests (#13032)
Browse files Browse the repository at this point in the history
* Automate test for issue 10110

* Automate issue 10735 test

* Automate issue 7789 test

* Automate issue 7510 test

* Automate issue 7943 test

* Automated issue 8326 test

* Automate issue 8200 test

* Automate issue 9833 test

* Automate issue 8672 test

* Automate issue 8647 test

* Clean up 6889 test

* Disable automation of tests on UWP because the test runner can't see stuff inside of CollectionView yet

* Make CarouselView on UWP display strings (ala test for 7789)

* Remove unnecessary delay
  • Loading branch information
hartez authored Jun 29, 2021
1 parent b1b13f5 commit 37c7405
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 297 deletions.
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

0 comments on commit 37c7405

Please sign in to comment.