From e94ead0ca02fec3f72d35f296a5b80262fc3fabf Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 29 Nov 2024 17:24:47 +0530 Subject: [PATCH] Enabled 25th set of XamarinUITest into Appium (#23) * Migrated Xamarin to Appium for Issue15542 and Issue15565 * Updated migrated code changes * fixed the failure on windows platform * Updated the comments --------- Co-authored-by: Harish --- .../Issues/XFIssue/Issue15565.cs | 2 +- .../Tests/Issues/XFIssue/Issue15542.cs | 32 ++++--- .../Tests/Issues/XFIssue/Issue15565.cs | 87 ++++++++++++------- 3 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue15565.cs b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue15565.cs index e26f2ae998ff..62dfa4a9f0e2 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue15565.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue15565.cs @@ -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 } } }); } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15542.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15542.cs index e0c6b7c12fe6..efaa0c89781a 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15542.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15542.cs @@ -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"); - // } -} \ No newline at end of file + Assert.That(topTabTop, Is.GreaterThanOrEqualTo(titleViewBottom), "Title View is incorrectly positioned in iOS 16"); + } +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15565.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15565.cs index 656bcd9d6d68..8bea4badf204 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15565.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue15565.cs @@ -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); - // } } \ No newline at end of file