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 - 33 #26402

Merged
merged 1 commit into from
Dec 6, 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 @@ -6,29 +6,41 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue12652 : _IssuesUITest
{
public Issue12652(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Bug] NullReferenceException in the Shell on UWP when navigating back to Shell Section with multiple content items";

// [Test]
// [Category(UITestCategories.Shell)]
// public void NavigatingBackToAlreadySelectedTopTabDoesntCrash()
// {
// var location = App.WaitForElement("Top 3")[0];
// App.TapCoordinates(location.Rect.CenterX, location.Rect.CenterY);
// App.WaitForElement("TopTabPage3");
// App.Tap("Main 2");
// App.WaitForElement("TopTabPage2");
// App.Tap("Main 1");

// App.TapCoordinates(location.Rect.CenterX, location.Rect.CenterY);
// App.WaitForElement("TopTabPage3");
// App.Tap("Main 2");
// App.WaitForElement("TopTabPage2");
// App.Tap("Main 1");
// App.TapCoordinates(location.Rect.CenterX, location.Rect.CenterY);
// App.WaitForElement("TopTabPage3");
// }
#if ANDROID
const string Top3 = "TOP 3";
#else
const string Top3 = "Top 3";
#endif
public Issue12652(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Bug] NullReferenceException in the Shell on UWP when navigating back to Shell Section with multiple content items";

[Test]
[Category(UITestCategories.Shell)]
public void NavigatingBackToAlreadySelectedTopTabDoesntCrash()
{
// On the Windows platform, there is a dropdown menu that has to be accessed to view the "TopTab" choices.
// The "navViewItem" tap emulates user actions to open the dropdown and display the TopTab for navigation.
#if WINDOWS
App.Tap("navViewItem");
#endif
App.Tap(Top3);
App.WaitForElement("TopTabPage3");
App.Tap("Main 2");
App.WaitForElement("TopTabPage2");
App.Tap("Main 1");
App.WaitForElement("TopTabPage3");

// Once the actions are completed, the dropdown is closed to restore the original view.
// Tapping at coordinates (50, 50) simulates a click outside the dropdown, triggering it to close.
#if WINDOWS
App.TapCoordinates(50, 50);
#endif
App.Tap("Main 2");
App.WaitForElement("TopTabPage2");
App.Tap("Main 1");
App.WaitForElement("TopTabPage3");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_CATALYST // The Programmatic Focus doesn't open the dialog for picker controls. Issue: https://github.com/dotnet/maui/issues/8946
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -7,54 +8,39 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
[Category(UITestCategories.Picker)]
public class Issue5159 : _IssuesUITest
{
const string DatePickerButton = "DatePickerButton";
const string TimePickerButton = "TimePickerButton";
const string PickerButton = "PickerButton";
public Issue5159(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Android] Calling Focus on all Pickers running an API 28 devices no longer opens Picker";

//[Test]
//public void InvisibleDatepickerShowsDialogOnFocus()
//{
// App.WaitForElement(DatePickerButton);
// App.Screenshot("Issue 5159 page is showing in all it's glory");
// App.Tap(DatePickerButton);

// App.WaitForElement(x => x.Class("DatePicker"));

// App.Screenshot("DatePicker is shown");
// App.TapCoordinates(5, 100);
//}

//[Microsoft.Maui.Controls.Compatibility.UITests.FailsOnAndroid]
//[Test]
//public void InvisibleTimepickerShowsDialogOnFocus()
//{
// App.WaitForElement(TimePickerButton);
// App.Screenshot("Issue 5159 page is showing in all it's glory");
// App.Tap(TimePickerButton);

// App.WaitForElement(x => x.Class("timePicker"));

// App.Screenshot("TimePicker is shown");
// App.TapCoordinates(5, 100);
//}

//[FailsOnAndroidWhenRunningOnXamarinUITest]
//[Test]
//public void InvisiblePickerShowsDialogOnFocus()
//{
// App.WaitForElement(PickerButton);
// App.Screenshot("Issue 5159 page is showing in all it's glory");
// App.Tap(PickerButton);

// App.WaitForElement("Foo");

// App.Screenshot("Picker is shown");

// App.Tap("Foo");
[Test]
public void InvisibleDatepickerShowsDialogOnFocus()
{
App.WaitForElement("DatePickerButton");
App.Tap(DatePickerButton);
App.WaitForElement("Done");
App.TapCoordinates(5, 100);
}

// App.WaitForNoElement("Foo");
[Test]
public void InvisibleTimepickerShowsDialogOnFocus()
{
App.WaitForElement(TimePickerButton);
App.Tap(TimePickerButton);
App.WaitForElement("Done");
App.TapCoordinates(5, 100);
}

//}
}
[Test]
public void InvisiblePickerShowsDialogOnFocus()
{
App.WaitForElement(PickerButton);
App.Tap(PickerButton);
App.WaitForElement("Done");
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,33 @@ public Issue8741(TestDevice testDevice) : base(testDevice)
}

public override string Issue => "[Bug] [Shell] [Android] ToolbarItem Enabled/Disabled behavior does not work for Shell apps";

//[Test]
//[Category(UITestCategories.Shell)]
//[FailsOnAndroidWhenRunningOnXamarinUITest]
//public void Issue8741Test()
//{
// App.WaitForElement("Add");
// App.Tap("Add");

// var toolbarItemColorValue = GetToolbarItemColorValue();
// int disabledAlpha = GetAlphaValue(toolbarItemColorValue);

// Assert.AreEqual("0", App.WaitForElement("ClickCount")[0].ReadText());

// App.Tap("ToggleEnabled");
// App.Tap("Add");

// toolbarItemColorValue = GetToolbarItemColorValue();
// int enabledAlpha = GetAlphaValue(toolbarItemColorValue);
// Assert.Less(disabledAlpha, enabledAlpha);

// Assert.AreEqual("1", App.WaitForElement("ClickCount")[0].ReadText());

// App.Tap("ToggleEnabled");
// App.Tap("Add");

// Assert.AreEqual("1", App.WaitForElement("ClickCount")[0].ReadText());
//}

//private object GetToolbarItemColorValue()
//{
// return App.Query(x => x.Text("Add").Invoke("getCurrentTextColor"))[0];
//}

//private int GetAlphaValue(object toolbarItemColorValue)
//{
// int color = Convert.ToInt32(toolbarItemColorValue);
// int a = (color >> 24) & 0xff;
// return a;
//}

[Test]
[Category(UITestCategories.Shell)]
public void Issue8741Test()
{
App.WaitForElement("Add");
App.Tap("Add");

// Note: These methods were commented out because Appium does not offer a consistent way to retrieve precise color values of UI elements across various platforms and devices.
// Additionally, the test scenario has already been validated through tap actions, so the color comparison was deemed unnecessary.
//var toolbarItemColorValue = GetToolbarItemColorValue();
//int disabledAlpha = GetAlphaValue(toolbarItemColorValue);

Assert.That(App.WaitForElement("ClickCount").ReadText(), Is.EqualTo("0"));

App.Tap("ToggleEnabled");
App.Tap("Add");

//toolbarItemColorValue = GetToolbarItemColorValue();
//int enabledAlpha = GetAlphaValue(toolbarItemColorValue);
//Assert.That(disabledAlpha, Is.LessThan(enabledAlpha));

Assert.That(App.WaitForElement("ClickCount").ReadText(), Is.EqualTo("1"));

App.Tap("ToggleEnabled");
App.Tap("Add");

Assert.That(App.WaitForElement("ClickCount").ReadText(), Is.EqualTo("1"));
}
}
Loading