Skip to content

Commit

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

* Updated Bugzilla and XFIssues Cases

* Modified the enabled tests

* Migrated the Bugzilla 35733 and 57674 (#54)

Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com>

* Resolved CI failure

---------

Co-authored-by: HarishKumarSF4517 <harish.kumar@syncfusion.com>
Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com>
  • Loading branch information
3 people authored Dec 25, 2024
1 parent 9797865 commit 8c70cc5
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{

[Issue(IssueTracker.Bugzilla, 35733, "iOS WebView crashes when loading an URL with encoded parameters", PlatformAffected.iOS)]
public class Bugzilla35733 : TestContentPage // or TestFlyoutPage, etc ...
public class Bugzilla35733 : TestNavigationPage // or TestFlyoutPage, etc ...
{
protected override void Init()
{
Expand All @@ -14,15 +14,18 @@ protected override void Init()
};
thisDoesNotWorkButton.Clicked += async (object sender, EventArgs e) => await ShowLocation("KÅRA");

Content = new StackLayout
Navigation.PushAsync(new ContentPage()
{
VerticalOptions = LayoutOptions.Center,
Children = {
thisDoesNotWorkButton
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
thisDoesNotWorkButton
}
}
};
}

});
}
async Task ShowLocation(string locationString)
{
var stringUri = $"https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/README.md?l=en&px_location={Uri.EscapeDataString(locationString)}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Maui.Controls.Sample.Issues
using Microsoft.Maui.Layouts;

namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Bugzilla, 36009, "Children of Layouts with data bound IsVisible are not displayed")]
Expand Down Expand Up @@ -29,7 +31,8 @@ protected override void Init()
{
Children = { contentView }
};

AbsoluteLayout.SetLayoutBounds(contentView, new Rect(0,0,1,1));
AbsoluteLayout.SetLayoutFlags(contentView, AbsoluteLayoutFlags.All);
Content = layout;

var vm = new SampleViewModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,42 @@ protected override void Init()
{
ItemsSource = items
};
Content = new StackLayout
{
Children =
{
listView,
new Button
var firstbutton = new Button
{
AutomationId = _btnScrollToNonExistentItem,
Text = "Click for ScrollTo (should do nothing)",
Command = new Command(() =>
{
listView.ScrollTo("Hello", ScrollToPosition.Start, true);
})
},
new Button
};
var secondbutton = new Button
{
AutomationId = _btnScrollToExistentItem,
Text = "Click for ScrollTo (should go to 15)",
Command = new Command(() =>
{
listView.ScrollTo(_middleListItem, ScrollToPosition.Start, false);
})
}
};

Grid.SetRow(listView, 2);
Grid.SetRow(firstbutton, 0);
Grid.SetRow(secondbutton, 1);

Content = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Star },
},
Children =
{
firstbutton,
secondbutton,
listView
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public IEnumerator<string> GetEnumerator()
public void AddNewItem()
{
int index = _internalList.Count;
string item = Guid.NewGuid().ToString();
string item = "Hello World!";
_internalList.Add(item);
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS // Fails on windows, More information :https://github.com/dotnet/maui/issues/24243
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -15,26 +16,22 @@ public Bugzilla31366(TestDevice testDevice) : base(testDevice)
[Test]
[Category(UITestCategories.Navigation)]
[Category(UITestCategories.Compatibility)]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnMacWhenRunningOnXamarinUITest]
public void Issue31366PushingAndPoppingModallyCausesArgumentOutOfRangeException()
{
App.WaitForElement("StartPopOnAppearingTest");
App.Tap("StartPopOnAppearingTest");
App.WaitForNoElement("If this is visible, the PopOnAppearing test has passed.");
App.WaitForElement("If this is visible, the PopOnAppearing test has passed.");
}

[Test]
[Category(UITestCategories.Navigation)]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnMacWhenRunningOnXamarinUITest]
[FailsOnWindowsWhenRunningOnXamarinUITest("Suddenly failing. https://github.com/dotnet/maui/issues/24243")]
public void Issue31366PushingWithModalStackCausesIncorrectStackOrder()
{
App.WaitForElement("StartModalStackTest");
App.Tap("StartModalStackTest");
App.WaitForNoElement("If this is visible, the modal stack test has passed.");
App.WaitForElement("If this is visible, the modal stack test has passed.");
App.Back();
}
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ public Bugzilla35733(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.WebView)]
[Category(UITestCategories.Compatibility)]
[FailsOnAllPlatformsWhenRunningOnXamarinUITest]
public void Bugzilla35733Test()
{
App.WaitForElement("btnGo");
App.Tap("btnGo");
App.WaitForElement("WebViewTest");
App.Screenshot("I didn't crash");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if IOS
#if TEST_FAILS_ON_WINDOWS // BoxView automation is not supported in windows.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand All @@ -11,17 +11,14 @@ public Bugzilla36009(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Bug] Exception Ancestor must be provided for all pushes except first";
public override string Issue => "Children of Layouts with data bound IsVisible are not displayed";

[Test]
[Category(UITestCategories.BoxView)]
[Category(UITestCategories.Compatibility)]
[FailsOnAndroidWhenRunningOnXamarinUITest("The content is not visible. The test is failing.")]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnMacWhenRunningOnXamarinUITest]
public void Bugzilla36009Test()
{
App.WaitForElement("Victory");
App.WaitForElementTillPageNavigationSettled("Victory");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if ANDROID
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -20,8 +19,7 @@ public Bugzilla38989(TestDevice testDevice) : base(testDevice)
[Category(UITestCategories.Compatibility)]
public void Bugzilla38989Test()
{
App.WaitForNoElement(Success);
App.WaitForElement(Success);
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if ANDROID
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand Down Expand Up @@ -27,11 +26,10 @@ public void Bugzilla41600Test()
App.WaitForElement(BtnScrollToExistentItem);

App.Tap(BtnScrollToNonExistentItem);
App.WaitForNoElement(FirstListItem);
App.WaitForElement(FirstListItem);

App.Tap(BtnScrollToExistentItem);
App.WaitForNoElement(MiddleListItem);
App.WaitForElementTillPageNavigationSettled(MiddleListItem);
}
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ public Bugzilla44476(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Bug] Exception Ancestor must be provided for all pushes except first";
public override string Issue => "[Android] Unwanted margin at top of details page when nested in a NavigationPage";

[Test]
[Category(UITestCategories.Navigation)]
[Category(UITestCategories.Compatibility)]
[FailsOnAndroidWhenRunningOnXamarinUITest]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnMacWhenRunningOnXamarinUITest]

public void Issue44476TestUnwantedMargin()
{
App.WaitForNoElement("This should be visible.");
App.WaitForElement("This should be visible.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ public Bugzilla57674(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.ListView)]
[Category(UITestCategories.Compatibility)]
[FailsOnAndroidWhenRunningOnXamarinUITest]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnMacWhenRunningOnXamarinUITest]
public void Bugzilla57674Test()
{
App.Screenshot("Initial Status");
App.WaitForElement("IssueListView");
App.WaitForNoElement("Hello World!");
App.Tap("IssueButton");
App.Screenshot("Element Added to List");
App.WaitForElement("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if TEST_FAILS_ON_WINDOWS
using NUnit.Framework;
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
using UITest.Core;
Expand Down Expand Up @@ -39,33 +38,32 @@ public void SafeAreaInsetsBreaksAndroidPadding()
if (element.ReadText() != "25, 25, 25, 25")
usesSafeAreaInsets = true;

ClassicAssert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
Assert.That(element.ReadText(), Is.Not.EqualTo("0, 0, 0, 0"));
if (!usesSafeAreaInsets)
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");
Assert.That(element.ReadText(), Is.EqualTo("25, 25, 25, 25"));

// Disable Safe Area Insets
App.Tap(SafeAreaAutomationId);
AssertSafeAreaText($"{SafeAreaText}{false}");
element = App.WaitForFirstElement(PaddingLabel);

ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");
Assert.That(element.ReadText(), Is.EqualTo("25, 25, 25, 25"));

// Enable Safe Area insets
App.Tap(SafeAreaAutomationId);
AssertSafeAreaText($"{SafeAreaText}{true}");
element = App.WaitForFirstElement(PaddingLabel);
ClassicAssert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
Assert.That(element.ReadText(), Is.Not.EqualTo("0, 0, 0, 0"));

if (!usesSafeAreaInsets)
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");
Assert.That(element.ReadText(), Is.EqualTo("25, 25, 25, 25"));

// Set Padding and then disable safe area insets
App.Tap(SetPagePadding);
App.Tap(SafeAreaAutomationId);
AssertSafeAreaText($"{SafeAreaText}{false}");
element = App.WaitForFirstElement(PaddingLabel);
ClassicAssert.AreEqual(element.ReadText(), "25, 25, 25, 25");
Assert.That(element.ReadText(), Is.EqualTo("25, 25, 25, 25"));
}
}
}
#endif

0 comments on commit 8c70cc5

Please sign in to comment.