Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 27 #26333

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public FlyoutPageNavigation()
{
InitPages();

// Set FlyoutBehavior to Popover to ensure consistent behavior across desktop and mobile platforms.
// Windows and Catalyst default (FlyoutLayoutBehavior.Default) uses Split mode, which differs from mobile platforms.
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;

var menuList = new ListView
{
BackgroundColor = Colors.Transparent,
Expand Down Expand Up @@ -118,8 +122,8 @@ public FlyoutPageNavigation()
var page = e.SelectedItem as NavigationPage;
if (page != null)
{
Detail = page;
IsPresented = false;
Detail = page;
IsPresented = false;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ protected override void Init()
#pragma warning disable CS0618 // Type or member is obsolete
var stackLayout = new StackLayout() { VerticalOptions = LayoutOptions.FillAndExpand };
#pragma warning restore CS0618 // Type or member is obsolete
stackLayout.AddLogicalChild(new Label { Text = "Go to the other page via the flyout, then come back. The items in the collection view should look identical when you return to this page." });
stackLayout.AddLogicalChild(collectionView);
stackLayout.Children.Add(new Label { Text = "Go to the other page via the flyout, then come back. The items in the collection view should look identical when you return to this page." });
stackLayout.Children.Add(collectionView);
var collectionViewPage = new ContentPage { Content = stackLayout, BindingContext = this };
mainFlyoutItem.Items.Add(collectionViewPage);

otherFlyoutItem.Items.Add(new ContentPage { Content = new Label { Text = "Go back to main page via the flyout" } });
otherFlyoutItem.Items.Add(new ContentPage { Content = new Label { Text = "Go back to main page via the flyout",AutomationId = "Label" } });

Items.Add(new FlyoutItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ContentPage CreateRoot()

var content = new ContentView { Content = label };

grid.AddLogicalChild(content);
grid.Children.Add(content);

return grid;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected override void Init()
var returnButton = new Button { Text = "Go back to tab 1", AutomationId = returnAutomationId };

returnButton.Clicked += OnReturnTapped;
stackLayout.AddLogicalChild(returnButton);
stackLayout.Children.Add(returnButton);

var tabTwoPage = new ContentPage { Content = stackLayout };
tabOne.Items.Add(tabOnePage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class Issue973 : TestFlyoutPage
{
protected override void Init()
{
// Set FlyoutBehavior to Popover to ensure consistent behavior across desktop and mobile platforms.
// Windows and Catalyst default (FlyoutLayoutBehavior.Default) uses Split mode, which differs from mobile platforms.
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;

var cells = new[] {
new PageNameObject ("Close Flyout"),
new PageNameObject ("Page 1"),
Expand Down Expand Up @@ -45,7 +49,7 @@ protected override void Init()

if (cellName == "Close Flyout")
{
IsPresented = false;
IsPresented = false;
}
else
{
Expand All @@ -56,7 +60,7 @@ protected override void Init()

d.PresentMaster += (s, args) =>
{
IsPresented = true;
IsPresented = true;
};

Detail = d;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_ANDROID // ToolBarItem not shown on FlyoutPage, issue: https://github.com/dotnet/maui/issues/26330
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,23 +13,24 @@ public Issue2266(TestDevice testDevice) : base(testDevice)

public override string Issue => "Setting a different Detail page from a FlyoutPage after 2nd time on MainPage";

// [Test]
// [Category(UITestCategories.Navigation)]
// [FailsOnIOSWhenRunningOnXamarinUITest]
// public void SwapMainPageWithFlyoutPages()
// {
// App.WaitForElement(q => q.Text("FlyoutPage Navigation"));
// App.Tap(q => q.Text("FlyoutPage Navigation"));
// App.Tap(q => q.Marked("OpenMaster"));
// App.Tap(q => q.Text("Page 1"));
// App.Tap(q => q.Text("START"));
// App.Tap(q => q.Text("FlyoutPage Navigation ->> Page 1"));
// App.WaitForElement(q => q.Text("Page 1"));
// App.Tap(q => q.Text("START"));
// App.Tap(q => q.Text("FlyoutPage Navigation ->> Page 2"));
// App.WaitForElement(q => q.Text("Page 2"));
// App.Tap(q => q.Text("START"));
// App.Tap(q => q.Text("FlyoutPage Navigation ->> Page 3"));
// App.WaitForElement(q => q.Text("Page 3"));
// }
[Test]
[Category(UITestCategories.Navigation)]

public void SwapMainPageWithFlyoutPages()
{
App.WaitForElement("FlyoutPage Navigation");
App.Tap("FlyoutPage Navigation");
App.Tap("OpenMaster");
App.Tap("Page 1");
App.Tap("START");
App.Tap("FlyoutPage Navigation ->> Page 1");
App.WaitForElement("Page 1");
App.Tap("START");
App.Tap("FlyoutPage Navigation ->> Page 2");
App.WaitForElement("Page 2");
App.Tap("START");
App.Tap("FlyoutPage Navigation ->> Page 3");
App.WaitForElement("Page 3");
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue5831 : _IssuesUITest
{
const string flyoutMainTitle = "Main";
const string flyoutOtherTitle = "Other Page";
public Issue5831(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Navigating away from CollectionView and coming back leaves weird old items";

// TODO: This test was marked ad manual review, can we somehow automate this?
// TODO: TapInFlyout was some helper method in ControlGallery? Do we have that here?
//[Test]
//[Category(UITestCategories.Shell)]
//public void CollectionViewRenderingWhenLeavingAndReturningViaFlyout()
//{
// TapInFlyout(flyoutOtherTitle);
// TapInFlyout(flyoutMainTitle);
//}
}
[Test]
[Category(UITestCategories.Shell)]
public void CollectionViewRenderingWhenLeavingAndReturningViaFlyout()
{
App.TapInShellFlyout(flyoutOtherTitle);
App.WaitForElementTillPageNavigationSettled("Label");
App.TapInShellFlyout(flyoutMainTitle);
App.WaitForElement("Baboon");
App.WaitForElement("Capuchin Monkey");
App.WaitForElement("Blue Monkey");
App.WaitForElement("Squirrel Monkey");
App.WaitForElement("Golden Lion Tamarin");
App.WaitForElement("Howler Monkey");
App.WaitForElement("Japanese Macaque");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public Issue6077(TestDevice testDevice) : base(testDevice)

public override string Issue => "CollectionView (iOS) using horizontal grid does not display last column of uneven item count";

//[Test]
//[Category(UITestCategories.CollectionView)]
//public void LastColumnShouldBeVisible()
//{
// // If the partial column shows up, then Item 5 will be in it
// App.WaitForElement("Item 5");
//}
[Test]
[Category(UITestCategories.CollectionView)]
public void LastColumnShouldBeVisible()
{
// If the partial column shows up, then Item 5 will be in it
App.WaitForElement("Item 5");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,32 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue6738 : _IssuesUITest
{
const string pushAutomationId = "PushPageButton";
const string insertAutomationId = "InsertPageButton";
const string returnAutomationId = "ReturnPageButton";
const string flyoutMainTitle = "Main";
const string flyoutOtherTitle = "Other Page";
public Issue6738(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Flyout Navigation fails when coupled with tabs that have a stack";

//[Test]
//[Category(UITestCategories.Shell)]
//[FailsOnIOS]
//public void FlyoutNavigationBetweenItemsWithNavigationStacks()
//{
// App.WaitForElement(pushAutomationId);
// App.Tap(pushAutomationId);
// App.WaitForElement(insertAutomationId);
// App.Tap(insertAutomationId);

// TapInFlyout(flyoutOtherTitle, timeoutMessage: flyoutOtherTitle);
// TapInFlyout(flyoutMainTitle, timeoutMessage: flyoutMainTitle);

// App.WaitForElement(returnAutomationId);
// App.Tap(returnAutomationId);
// App.NavigateBack();
// App.NavigateBack();
//}
[Test]
[Category(UITestCategories.Shell)]
public void FlyoutNavigationBetweenItemsWithNavigationStacks()
{
App.WaitForElement(pushAutomationId);
App.Tap(pushAutomationId);
App.WaitForElement(insertAutomationId);
App.Tap(insertAutomationId);
App.TapInShellFlyout(flyoutOtherTitle);
App.WaitForElement("Go back to main page via the flyout");
App.TapInShellFlyout(flyoutMainTitle);
App.WaitForElement(returnAutomationId);
App.Tap(returnAutomationId);
App.TapBackArrow();
App.WaitForElementTillPageNavigationSettled("This is an extra page");
App.TapBackArrow();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS //DoubleTap not performing by appium, using DoubleClick also not working for windows getting "OpenQA.Selenium.WebDriverException : Currently only pen and touch pointer input source types are supported" exception. But in manual testing more tap closes the flyout.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -12,12 +13,20 @@ public Issue9440(TestDevice testDevice) : base(testDevice)

public override string Issue => "Flyout closes with two or more taps";

//[Test]
//[Category(UITestCategories.Shell)]
//public void GitHubIssue9440()
//{
// DoubleTapInFlyout(Test1);
// App.WaitForElement(q => q.Marked(Test1));
// Assert.AreEqual(false, FlyoutIsPresented);
//}
}
[Test]
[Category(UITestCategories.Shell)]
public void GitHubIssue9440()
{
App.TapShellFlyoutIcon();
App.WaitForElement("Test 1");
#if ANDROID // In Android Double Tap does not performs in Appium, which does not closes the flyout, but in manual testing it closes. So, we are using DoubleClick instead of DoubleTap as make this test run.
App.DoubleClick("Test 1");
#else
App.DoubleTap("Test 1");
#endif

App.WaitForElement("Test 1");
App.WaitForElement("False");
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_ANDROID // IsPresented value is not reflected when change this on list view item tapped in flyout. Issue: https://github.com/dotnet/maui/issues/26324
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -9,34 +10,31 @@ public class Issue973 : _IssuesUITest
public Issue973(TestDevice testDevice) : base(testDevice)
{
}

#if ANDROID
const string Tab1 = "TAB 1";
const string Tab2 = "TAB 2";
#else
const string Tab1 = "Tab 1";
const string Tab2 = "Tab 2";
#endif
public override string Issue => "ActionBar doesn't immediately update when nested TabbedPage is changed";

//[Test]
//[Category(UITestCategories.TabbedPage)]
//[FailsOnAndroidWhenRunningOnXamarinUITest]
//[Description("Test tab reset when swapping out detail")]
//public void Issue973TestsTabResetAfterDetailSwap()
//{
// App.WaitForElement(q => q.Marked("Initial Page Left aligned"));
// App.WaitForElement(q => q.Marked("Tab 1"));

// App.Tap(q => q.Marked("Tab 2"));
// App.WaitForElement(q => q.Marked("Initial Page Right aligned"));
// App.Screenshot("Tab 2 showing");

// App.Tap(q => q.Marked("Present Flyout"));

// App.Tap(q => q.Marked("Page 4"));
// App.Screenshot("Change detail page");

// App.Tap(q => q.Marked("Close Flyout"));

// App.WaitForElement(q => q.Marked("Page 4 Left aligned"));
// App.Screenshot("Tab 1 Showing and tab 1 should be selected");

// App.Tap(q => q.Marked("Tab 2"));
// App.WaitForElement(q => q.Marked("Page 4 Right aligned"));
// App.Screenshot("Tab 2 showing");
//}
}
[Test]
[Category(UITestCategories.TabbedPage)]
[Description("Test tab reset when swapping out detail")]
public void Issue973TestsTabResetAfterDetailSwap()
{
App.WaitForElement("Initial Page Left aligned");
App.WaitForElement(Tab1);
App.Tap(Tab2);
App.WaitForElement("Initial Page Right aligned");
App.Tap("Present Flyout");
App.Tap("Page 4");
App.WaitForElement("Close Flyout");
App.Tap("Close Flyout");
App.WaitForElement("Page 4 Left aligned");
App.Tap(Tab2);
App.WaitForElement("Page 4 Right aligned");
}
}
#endif
Loading
Loading