Skip to content

Commit

Permalink
[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 36 (
Browse files Browse the repository at this point in the history
…#26436)

* Enabled 36th set of Migrated UITests from XamarinUITest to Appium (#35)

* Migrated Issues for Issue8964 , Issue7329, Issue6932_emptyviewstring, Issue6932_emptyviewstring

* Updated modified tests

* Modified the enabled tests

* Updated 6932

* Removed unwanted spaces

---------

Co-authored-by: HarishKumarSF4517 <[email protected]>

* Resolved CI failure on iOS

---------

Co-authored-by: HarishKumarSF4517 <[email protected]>
  • Loading branch information
anandhan-rajagopal and HarishKumarSF4517 authored Dec 10, 2024
1 parent e8524a3 commit ba3aec2
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,45 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
[Category(UITestCategories.Layout)]
public class Issue6932_emptyviewstring : _IssuesUITest
{
const int Count = 10;
const string LayoutAutomationId = "1";
const string AddAutomationId = "Add";
const string RemoveAutomationId = "Remove";
const string ClearAutomationId = "Clear";
const string EmptyViewStringDescription = "Nothing to see here";

public Issue6932_emptyviewstring(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "EmptyView for BindableLayout (string)";

[Test]
public void BEmptyViewStringBecomesVisibleWhenItemsSourceIsCleared()
{
App.WaitForElement(AddAutomationId);
for (var i = 0; i < Count/2; i++)
App.Tap(AddAutomationId);
App.Tap(ClearAutomationId);
App.WaitForElement(EmptyViewStringDescription);
}

[Test]
public void AEmptyViewStringBecomesVisibleWhenItemsSourceIsEmptiedOneByOne()
{
App.WaitForElement(LayoutAutomationId);

//[Test]
//[FailsOnMauiIOS]
//public void EmptyViewStringBecomesVisibleWhenItemsSourceIsCleared()
//{
// App.Screenshot("Screen opens, items are shown");

// App.WaitForElement(_viewModel.LayoutAutomationId);
// App.Tap(_viewModel.ClearAutomationId);
// App.WaitForElement(_viewModel.EmptyViewStringDescription);

// App.Screenshot("Empty view is visible");
//}

//[Test]
//[FailsOnMauiIOS]
//public void EmptyViewStringBecomesVisibleWhenItemsSourceIsEmptiedOneByOne()
//{
// App.Screenshot("Screen opens, items are shown");

// App.WaitForElement(_viewModel.LayoutAutomationId);

// for (var i = 0; i < _viewModel.ItemsSource.Count; i++)
// App.Tap(_viewModel.RemoveAutomationId);

// App.WaitForElement(_viewModel.EmptyViewStringDescription);

// App.Screenshot("Empty view is visible");
//}

//[Test]
//[FailsOnMauiIOS]
//public void EmptyViewStringHidesWhenItemsSourceIsFilled()
//{
// App.Screenshot("Screen opens, items are shown");

// App.WaitForElement(_viewModel.LayoutAutomationId);
// App.Tap(_viewModel.ClearAutomationId);
// App.WaitForElement(_viewModel.EmptyViewStringDescription);

// App.Screenshot("Items are cleared, empty view visible");

// App.Tap(_viewModel.AddAutomationId);
// App.WaitForNoElement(_viewModel.EmptyViewStringDescription);

// App.Screenshot("Item is added, empty view is not visible");
//}
for (var i = 0; i < Count; i++)
App.Tap(RemoveAutomationId);

App.WaitForElement(EmptyViewStringDescription);
}

[Test]
public void CEmptyViewStringHidesWhenItemsSourceIsFilled()
{
App.WaitForElement(EmptyViewStringDescription);
App.Tap(AddAutomationId);
App.WaitForNoElement(EmptyViewStringDescription);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,46 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
[Category(UITestCategories.Layout)]
public class Issue6932_emptyviewtemplate : _IssuesUITest
{
const int Count = 10;
const string LayoutAutomationId = "1";
const string AddAutomationId = "Add";
const string RemoveAutomationId = "Remove";
const string ClearAutomationId = "Clear";
const string EmptyTemplateAutomationId = "No items here";
public Issue6932_emptyviewtemplate(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "EmptyView for BindableLayout (template)";

//[Test]
//[FailsOnMauiIOS]
//public void EmptyViewTemplateBecomesVisibleWhenItemsSourceIsCleared()
//{
// App.Screenshot("Screen opens, items are shown");

// App.WaitForElement(_viewModel.LayoutAutomationId);
// App.Tap(_viewModel.ClearAutomationId);
// App.WaitForElement(_viewModel.EmptyTemplateAutomationId);

// App.Screenshot("Empty view is visible");
//}

//[Test]
//[FailsOnMauiIOS]
//public void EmptyViewTemplateBecomesVisibleWhenItemsSourceIsEmptiedOneByOne()
//{
// App.Screenshot("Screen opens, items are shown");

// App.WaitForElement(_viewModel.LayoutAutomationId);

// for (var i = 0; i < _viewModel.ItemsSource.Count; i++)
// App.Tap(_viewModel.RemoveAutomationId);

// App.WaitForElement(_viewModel.EmptyTemplateAutomationId);

// App.Screenshot("Empty view is visible");
//}

//[Test]
//[FailsOnMauiIOS]
//public void EmptyViewTemplateHidesWhenItemsSourceIsFilled()
//{
// App.Screenshot("Screen opens, items are shown");

// App.WaitForElement(_viewModel.LayoutAutomationId);
// App.Tap(_viewModel.ClearAutomationId);
// App.WaitForElement(_viewModel.EmptyTemplateAutomationId);

// App.Screenshot("Items are cleared, empty view visible");
[Test]
public void BEmptyViewTemplateBecomesVisibleWhenItemsSourceIsCleared()
{
App.WaitForElement(AddAutomationId);

// App.Tap(_viewModel.AddAutomationId);
// App.WaitForNoElement(_viewModel.EmptyTemplateAutomationId);
for (var i = 0; i < Count / 2; i++)
App.Tap(AddAutomationId);

// App.Screenshot("Item is added, empty view is not visible");
//}
App.Tap(ClearAutomationId);
App.WaitForElement(EmptyTemplateAutomationId);
}

[Test]
public void AEmptyViewTemplateBecomesVisibleWhenItemsSourceIsEmptiedOneByOne()
{
App.WaitForElement(LayoutAutomationId);

for (var i = 0; i < Count; i++)
App.Tap(RemoveAutomationId);

App.WaitForElement(EmptyTemplateAutomationId);
}

[Test]
public void CEmptyViewTemplateHidesWhenItemsSourceIsFilled()
{
App.WaitForElement(EmptyTemplateAutomationId);
App.Tap(AddAutomationId);
App.WaitForNoElement(EmptyTemplateAutomationId);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_CATALYST //In Catalyst, `ScrollDown` isn't functioning correctly with Appium.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,34 +13,22 @@ public Issue7329(TestDevice testDevice) : base(testDevice)

public override string Issue => "[Android] ListView scroll not working when inside a ScrollView";

//[Test]
//[Category(UITestCategories.ScrollView)]

//[FailsOnAndroid]
//[FailsOnIOS]
//public void ScrollListViewInsideScrollView()
//{
// if (!OperatingSystem.IsAndroidVersionAtLeast(21))
// {
// return;
// }

// App.WaitForElement("1");

// App.QueryUntilPresent(() =>
// {
// try
// {
// App.ScrollDownTo("30", strategy: ScrollStrategy.Gesture, swipeSpeed: 100);
// }
// catch
// {
// // just ignore if it fails so it can keep trying to scroll
// }

// return App.Query("30");
// });

// App.Query("30");
//}
}
[Test]
[Category(UITestCategories.ScrollView)]
public void ScrollListViewInsideScrollView()
{
App.WaitForElement("1");

App.ScrollDown("NestedListView");

#if IOS
// In iOS, WaitForNoElement throws a timeout exception eventhough the text is not visible on the screen. So using the ListView Items to ensure scroll.
App.WaitForElement("80");
#else
// App.QueryUntilPresent isn't functioning correctly; it throws a timeout exception immediately after the first try.
// Verifying that instructions label is not visible also confirms that the ListView has scrolled.
App.WaitForNoElement("If the List View can scroll the test has passed");
#endif
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID //The Position property now functions correctly on Android and Windows, issue: https://github.com/dotnet/maui/issues/15443. Note that on Catalyst, swipe and drag options are not supported in Appium.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,34 +13,32 @@ public Issue8964(TestDevice testDevice) : base(testDevice)

public override string Issue => "Adding an item to the beginning of the bound ItemSource causes the carousel to skip sometimes";

//[Test]
//[Category(UITestCategories.CarouselView)]
// [FailsOnAndroid]
// [FailsOnIOS]
// public void Issue8964Test()
// {
// App.WaitForElement(q => q.Marked($"Item Position - 4"));
// var rect = App.Query("carouseView")[0].Rect;
// SwipePreviousItem(rect);
// App.WaitForElement(q => q.Marked($"Item Position - 4"));
// SwipePreviousItem(rect);
// App.WaitForElement(q => q.Marked($"Item Position - 4"));
// SwipePreviousItem(rect);
// App.WaitForElement(q => q.Marked($"Item Position - 4"));
// SwipePreviousItem(rect);
// App.WaitForElement(q => q.Marked($"Item Position - 4"));
// SwipePreviousItem(rect);
// App.WaitForElement(q => q.Marked($"Item Position - 4"));
// App.WaitForElement(q => q.Marked($"Counter 6"));

// }

// void SwipePreviousItem(Xamarin.UITest.Queries.AppRect rect)
// {
//#if ANDROID
// App.DragCoordinates(rect.X + 10, rect.Y, rect.X + rect.Width - 10, rect.Y);
//#else
// App.SwipeLeftToRight("carouseView");
//#endif
// }
}
[Test]
[Category(UITestCategories.CarouselView)]
public void Issue8964Test()
{
App.WaitForElement($"Item Position - 4");
var rect = App.WaitForElement("carouseView").GetRect();
SwipePreviousItem(rect);
App.WaitForElement($"Item Position - 4");
SwipePreviousItem(rect);
App.WaitForElement($"Item Position - 4");
SwipePreviousItem(rect);
App.WaitForElement($"Item Position - 4");
SwipePreviousItem(rect);
App.WaitForElement($"Item Position - 4");
SwipePreviousItem(rect);
App.WaitForElement( $"Item Position - 4");
App.WaitForElement($"Counter 6");
}

void SwipePreviousItem(System.Drawing.Rectangle rect)
{
#if ANDROID
App.DragCoordinates(rect.X + 10, rect.Y, rect.X + rect.Width - 10, rect.Y);
#else
App.SwipeLeftToRight("carouseView");
#endif
}
}
#endif

0 comments on commit ba3aec2

Please sign in to comment.