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 - 25 #26255

Merged
merged 1 commit into from
Dec 3, 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 @@ -40,7 +40,7 @@ static ContentPage createContentPage(string titleView)
{
BackgroundColor = Colors.Red,
AutomationId = "TitleViewId",
Children = { new Label() { Text = titleView, VerticalTextAlignment = TextAlignment.End } }
Children = { new Label() { Text = titleView, AutomationId = titleView, VerticalTextAlignment = TextAlignment.End } }
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue15542 : _IssuesUITest
{

#if ANDROID
const string Page1 = "PAGE 1";
#else
const string Page1 = "page 1";
#endif

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

public override string Issue => "[Bug] Shell.TitleView does not render on iOS 16";

// [Test]
// [Category(UITestCategories.TitleView)]
// public void TitleViewHeightDoesntOverflow()
// {
// var titleView = App.WaitForElement("TitleViewId")[0].Rect;
// var topTab = App.WaitForElement("page 1")[0].Rect;
[Test]
[Category(UITestCategories.TitleView)]
public void TitleViewHeightDoesntOverflow()
{
var titleView = App.WaitForElement("title 1").GetRect();
#if WINDOWS // In Windows the Page 1 items are inside the root navViewItem which in popup we neet top it once.
App.Tap("navViewItem");
#endif
var topTab = App.WaitForElement(Page1).GetRect();

// var titleViewBottom = titleView.Y + titleView.Height;
// var topTabTop = topTab.Y;
var titleViewBottom = titleView.Y + titleView.Height;
var topTabTop = topTab.Y;

// Assert.GreaterOrEqual(topTabTop, titleViewBottom, "Title View is incorrectly positioned in iOS 16");
// }
}
Assert.That(topTabTop, Is.GreaterThanOrEqualTo(titleViewBottom), "Title View is incorrectly positioned in iOS 16");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,71 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
[Category(UITestCategories.TitleView)]
public class Issue15565 : _IssuesUITest
{
#if ANDROID
const string Page1 = "PAGE 1";
const string Page2 = "PAGE 2";
const string Page3 = "PAGE 3";
#else
const string Page1 = "page 1";
const string Page2 = "page 2";
const string Page3 = "page 3";
#endif

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

public override string Issue => "[Bug] Shell TitleView and ToolBarItems rendering strange display on iOS 16";

// [Test]
// public void TitleViewHeightIsNotZero()
// {
// var titleView = App.WaitForElement("TitleViewId")[0].Rect;
// var topTab = App.WaitForElement("page 1")[0].Rect;

// var titleViewBottom = titleView.Y + titleView.Height;
// var topTabTop = topTab.Y;

// Assert.GreaterOrEqual(topTabTop, titleViewBottom, "Title View is incorrectly positioned in iOS 16");
// }

// [FailsOnAndroid]
// [FailsOnIOS]
// [Test]
// public void ToolbarItemsWithTitleViewAreRendering()
// {
// App.WaitForElement("Item 1");
// App.WaitForElement("Item 3");
// }
[Test]
public void TitleViewHeightIsNotZero()
{
TapTopTab(Page1);
#if WINDOWS // In Windows the Page 1 items are inside the root navViewItem which shows in popup, so we need to tap it once to make them visible..
App.Tap("navViewItem");
#endif
var titleView = App.WaitForElement("title 1").GetRect();
var topTab = App.WaitForElement(Page1).GetRect();

var titleViewBottom = titleView.Y + titleView.Height;
var topTabTop = topTab.Y;

Assert.That(topTabTop, Is.GreaterThanOrEqualTo(titleViewBottom), "Title View is incorrectly positioned in iOS 16");
}

// [Test]
// public void NoDuplicateTitleViews()
// {
// var titleView = App.WaitForElement("TitleViewId");

// Assert.AreEqual(1, titleView.Length);
[Test]
public void ToolbarItemsWithTitleViewAreRendering()
{
App.WaitForElement("Item 1");
App.WaitForElement("Item 2");
}

// App.Tap("page 1");
// App.Tap("page 2");
// App.Tap("page 3");
[Test]
public void NoDuplicateTitleViews()
{
App.WaitForElement("title 1");
ValidateElementsCount("title 1");
TapTopTab(Page1);
TapTopTab(Page2);
TapTopTab(Page3);
ValidateElementsCount("title 3");
}

// titleView = App.WaitForElement("TitleViewId");
void TapTopTab(string tab)
{
#if WINDOWS
App.Tap("navViewItem");
#endif
App.Tap(tab);
}
void ValidateElementsCount(string element)
{
#if WINDOWS // FindElements without query fails on Mac, with query fails on Windows; below condition ensures cross-platform compatibility
Assert.That(App.FindElements(element).Count, Is.EqualTo(1));
#else
Assert.That(App.FindElements(AppiumQuery.ById(element)).Count, Is.EqualTo(1));
#endif
}

// Assert.AreEqual(1, titleView.Length);
// }
}
Loading