Skip to content

[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 22 #26193

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

Merged
merged 6 commits into from
Dec 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ protected override void Init()
#pragma warning restore CS0618 // Type or member is obsolete
var btn = new Button()
{
Text = "Toggle"
Text = "DetailToggle"
};
var btn1 = new Button()
{
Text = "Toggle"
Text = "FlyoutToggle"
};

btn.Clicked += (object sender, EventArgs e) => IsPresented = !IsPresented;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ public class Bugzilla41038 : TestFlyoutPage
protected override void Init()
{
Title = "Main";


// 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 btnViewA = new Button() { Text = "ViewA", AutomationId = "ViewA" };
btnViewA.Clicked += Button_Clicked;

Expand Down Expand Up @@ -46,7 +49,7 @@ private async void Button_Clicked(object sender, EventArgs e)

await _navPage.Navigation.PushAsync(newRoot);
_navPage.Navigation.RemovePage(root);
IsPresented = false;
IsPresented = false;
}

public class ViewA : ContentPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ protected override void Init()
{
var rootPage = new RootPage();
Flyout = rootPage;

// 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;
rootPage.ListView.ItemSelected += (sender, e) =>
{
var item = e.SelectedItem as RootPageItem;
Expand Down Expand Up @@ -174,9 +178,7 @@ public _42329_Page3()
otherLabel = new Label
{
HorizontalOptions = LayoutOptions.Center,
FontAttributes = FontAttributes.Bold,
AutomationId = Success

FontAttributes = FontAttributes.Bold
};
Content = new StackLayout
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void BlowUp()
protected override void Init()
{
Title = "Test";

Flyout = new ContentPage
{
Title = "Flyout",
Expand All @@ -68,6 +67,7 @@ protected override void Init()
Command = new Command(() =>
{
Detail = new Page1();
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;
IsPresented = false;
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !WINDOWS // Setting orientation is not supported on Windows
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST // Setting orientation is not supported on Windows and mac
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand All @@ -7,45 +7,39 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Bugzilla30353 : _IssuesUITest
{
const string DetailToggle = "DetailToggle";
const string FlyoutToggle = "FlyoutToggle";
const string FlyoutVisibleText = "The Flyout is now visible";
const string FlyoutInvisibleText = "The Flyout is now invisible";

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

public override string Issue => "FlyoutPage.IsPresentedChanged is not raised";

// There is 2 "Toggle" in the UI, which is which? They also need AutomationIds
// [Test]
// [FailsOnMacWhenRunningOnXamarinUITest]
// [FailsOnIOSWhenRunningOnXamarinUITest]
// [Category(UITestCategories.FlyoutPage)]
// public void FlyoutPageIsPresentedChangedRaised()
// {
// App.SetOrientationPortrait();
// App.Screenshot("Portrait");
// App.Tap("Toggle");
// App.Screenshot("Portrait Visible");
// App.WaitForElement("The Flyout is now visible");
// App.Back();
// App.Screenshot("Portrait Invisible");
// App.WaitForElement("The Flyout is now invisible");
// App.SetOrientationLandscape();
// App.Screenshot("Landscape Invisible");
// App.WaitForElement("The Flyout is now invisible");
// App.Tap("Toggle");
// App.Screenshot("Landscape Visible");
// App.WaitForElement("The Flyout is now visible");
// App.Back();
// App.Screenshot("Landscape InVisible");
// App.WaitForElement("The Flyout is now invisible");
// App.SetOrientationPortrait();
// App.Tap("Toggle");
// App.Screenshot("Portrait Visible");
// App.WaitForElement("The Flyout is now visible");
// App.Back();
// App.Screenshot("Portrait Invisible");
// App.WaitForElement("The Flyout is now invisible");
// App.SetOrientationLandscape();
// }
[Test]
[Category(UITestCategories.FlyoutPage)]
public void FlyoutPageIsPresentedChangedRaised()
{
App.SetOrientationPortrait();
App.WaitForElement(DetailToggle);
App.Tap(DetailToggle);
App.WaitForElement(FlyoutVisibleText);
App.Tap(FlyoutToggle);
App.WaitForElement(FlyoutInvisibleText);
App.SetOrientationLandscape();
App.WaitForElement(FlyoutInvisibleText);
App.Tap(DetailToggle);
App.WaitForElement(FlyoutVisibleText);
App.Tap(FlyoutToggle);
App.WaitForElement(FlyoutInvisibleText);
App.SetOrientationPortrait();
App.Tap(DetailToggle);
App.WaitForElement(FlyoutVisibleText);
App.Tap(FlyoutToggle);
App.WaitForElement(FlyoutInvisibleText);
App.SetOrientationLandscape();
}

[TearDown]
public void TearDown()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !IOS && !WINDOWS // Setting orientation is not supported on Windows
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST // Orientation not support in Windows and Catalyst.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand All @@ -13,35 +13,31 @@ public Bugzilla34632(TestDevice testDevice) : base(testDevice)

public override string Issue => "Can't change IsPresented when setting SplitOnLandscape ";

// [Test]
// [Category(UITestCategories.FlyoutPage)]
// public void Bugzilla34632Test()
// {
// if (Devices.DeviceInfo.Idiom == Devices.DeviceIdiom.Tablet)
// {
// App.SetOrientationPortrait();
// App.Tap("btnModal");
// App.SetOrientationLandscape();
// App.Tap("btnDismissModal");
// App.Tap("btnModal");
// App.SetOrientationPortrait();
// App.Tap("btnDismissModal");
// App.Tap("Main Page");
// App.Tap("btnFlyout");
// App.WaitForNoElement("btnFlyout");
// }
// else
// {
// // Wait for the test to finish loading before exiting otherwise
// // the next UI test might start running while this is still loading
// App.WaitForElement("btnModal");
// }
// }

// [TearDown]
// public void TearDown()
// {
// App.SetOrientationPortrait();
// }
[Test]
[Category(UITestCategories.FlyoutPage)]
public void Bugzilla34632Test()
{
App.SetOrientationPortrait();
App.WaitForElement("btnModal");
App.Tap("btnModal");
App.SetOrientationLandscape();
App.WaitForElement("btnDismissModal");
App.Tap("btnDismissModal");
App.WaitForElement("btnModal");
App.Tap("btnModal");
App.SetOrientationPortrait();
App.Tap("btnDismissModal");
App.TapFlyoutPageIcon("Main Page");
App.WaitForElement("btnFlyout");
App.Tap("btnFlyout");
App.WaitForNoElement("btnFlyout");
}

[TearDown]
public void TearDown()
{
App.SetOrientationPortrait();
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ public Bugzilla41038(TestDevice testDevice) : base(testDevice)

public override string Issue => "FlyoutPage loses menu icon on iOS after reusing NavigationPage as Detail";

// TODO Xamarin.UITest migration how do we open flyout menu?!
// [Test]
// [Category(UITestCategories.FlyoutPage)]
// public void Bugzilla41038Test()
// {
// App.WaitForElement("ViewA");
// App.Tap("Flyout");
// App.WaitForElement("ViewB");
// App.Tap("ViewB");
// App.WaitForElement("Flyout");
// App.Screenshot("I see the flyout toggle");
// }
[Test]
[Category(UITestCategories.FlyoutPage)]
public void Bugzilla41038Test()
{
App.WaitForElement("ViewA");

App.TapFlyoutPageIcon("Flyout");

App.WaitForElement("ViewB");
App.Tap("ViewB");

#if ANDROID || WINDOWS // On Android and Windows, the hamburger icon was displayed, while on iOS and Catalyst, the title text was shown.
App.TapFlyoutPageIcon("Flyout");
#else
App.WaitForElementTillPageNavigationSettled("Flyout");
#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 All @@ -19,20 +18,25 @@ public Bugzilla42329(TestDevice testDevice) : base(testDevice)

public override string Issue => "ListView in Frame and FormsAppCompatActivity Memory Leak";

// TODO From Xamarin.UITest migration: test fails, so disabled for now
// [Test]
// [Category(UITestCategories.ListView)]
// public void MemoryLeakB42329()
// {
// App.WaitForElement(Page1Title);
// App.Tap(LabelPage1);
// App.WaitForElement(Page1Title);
// App.Tap(Page2Title);
// App.WaitForElement(LabelPage2);
// App.Tap(LabelPage2);
// App.WaitForElement(Page2Title);
// App.Tap(Page3Title);
// App.WaitForElement("Destructor called");
// }
}
#endif
[Test]
[Category(UITestCategories.ListView)]
public void MemoryLeakB42329()
{
App.WaitForElement(LabelPage1);
App.Tap(LabelPage1);

App.WaitForElement(Page2Title);
App.Tap(Page2Title);

App.WaitForElement(LabelPage2);
App.Tap(LabelPage2);

App.WaitForElement(Page3Title);
App.Tap(Page3Title);
#if ANDROID || WINDOWS //In random scenario, the destructor called upon the fourth navigation. So added one more navigation for Android and Windows to make this test work.
App.TapInFlyoutPageFlyout(Page2Title);
App.TapInFlyoutPageFlyout(Page3Title);
#endif
App.WaitForElement("Destructor called");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@ public Issue2964(TestDevice testDevice) : base(testDevice)

public override string Issue => "TabbedPage toolbar item crash";

// [Test]
// [Category(UITestCategories.ToolbarItem)]
// public void Issue2964Test()
// {
// App.Screenshot("I am at Issue 2964");

// App.Tap(q => q.Marked("FlyoutButton"));
// App.Screenshot("Create new Detail instance");

// App.Tap(q => q.Marked("Page1PushModalButton"));
// App.Screenshot("Modal is pushed");

// App.Tap(q => q.Marked("ModalPagePopButton"));
// App.Screenshot("Modal is popped");

// App.WaitForElement(q => q.Marked("Page1Label"));
// App.Screenshot("Didn't blow up! :)");
// }
[Test]
[Category(UITestCategories.ToolbarItem)]
public void Issue2964Test()
{
App.WaitForElement("FlyoutButton");
App.Tap("FlyoutButton");
App.WaitForElement("Page1PushModalButton");
App.Tap("Page1PushModalButton");
App.WaitForElement("ModalPagePopButton");
App.Tap("ModalPagePopButton");
App.WaitForElement("Page1Label");

}
}
Loading
Loading