Skip to content

Commit 2f51dd9

Browse files
Anandhan RajagopalLogishaSelvarajSF4525nivetha-nagalingam
authored
[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 65 (#26873)
* migrated issue fron xamarian uitest into appium * migrated issue * Migrated the Bugzilla37625 (#56) Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com> * Updated Enabled UITests * Fixed flaky tests Issue1414 * Update Issue7290.cs * Update Issue5412.cs * Update Bugzilla30317.cs --------- Co-authored-by: LogishaSelvarajSF4525 <logisha.selvaraj@syncfusion.com> Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com>
1 parent 07cc973 commit 2f51dd9

File tree

9 files changed

+148
-163
lines changed

9 files changed

+148
-163
lines changed

src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla37625.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ protected override async void Init()
99
int retry = 5;
1010
while (retry-- >= 0)
1111
{
12-
var imageUri = new Uri("https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Microsoft.Maui.Controls.ControlGallery.Android/Assets/WebImages/XamarinLogo.png");
13-
Content = new Image() { Source = new UriImageSource() { Uri = imageUri }, BackgroundColor = Colors.Black, AutomationId = "success" };
12+
var imageUri = new Uri("https://raw.githubusercontent.com/dotnet/maui/main/src/Compatibility/ControlGallery/src/Android/Resources/drawable/coffee.png");
13+
Content = new Image() { Source = new UriImageSource() { Uri = imageUri }, BackgroundColor = Colors.Beige, AutomationId = "success" };
1414

1515
await Task.Delay(50);
1616
}

src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla45125.cs

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,16 @@ public class Bugzilla45125 : TestContentPage
1313
const string DisappearingLabelId = "disappearing";
1414
const string TestButtonId = "TestButtonId";
1515

16-
static int _Appearing = 0;
17-
static int _Disappearing = 0;
16+
int _Appearing = 0;
17+
int _Disappearing = 0;
1818

19-
static Label _status = new Label
20-
{
21-
TextColor = Colors.White,
22-
//TODO: NoWrap causes the Label to be missing from the Horizontal StackLayout
23-
//LineBreakMode = LineBreakMode.NoWrap
24-
};
25-
26-
static Label _groupsAppearing = new Label
27-
{
28-
TextColor = Colors.Green,
29-
AutomationId = AppearingLabelId
30-
};
19+
Label _status;
3120

32-
static Label _groupsDisappearing = new Label
33-
{
34-
TextColor = Colors.Blue,
35-
AutomationId = DisappearingLabelId
36-
};
21+
Label _groupsAppearing;
3722

38-
static ScrollView _scroll = new ScrollView
39-
{
40-
BackgroundColor = Colors.Black,
41-
Content = _status,
42-
MinimumWidthRequest = 200
43-
};
23+
Label _groupsDisappearing;
4424

25+
ScrollView _scroll;
4526

4627
class GroupItem
4728
{
@@ -78,13 +59,43 @@ public HeaderCell()
7859

7960
protected override void Init()
8061
{
62+
InitializeControls();
63+
8164
_status.Text = _groupsAppearing.Text = _groupsDisappearing.Text = "";
8265
_Appearing = _Disappearing = 0;
8366
_scroll.SetScrolledPosition(0, 0);
8467

8568
InitTest(ListViewCachingStrategy.RecycleElement, true);
8669
}
8770

71+
void InitializeControls(){
72+
73+
_status = new Label
74+
{
75+
TextColor = Colors.White
76+
};
77+
78+
_groupsAppearing = new Label
79+
{
80+
TextColor = Colors.Green,
81+
AutomationId = AppearingLabelId
82+
};
83+
84+
_groupsDisappearing = new Label
85+
{
86+
TextColor = Colors.Blue,
87+
AutomationId = DisappearingLabelId
88+
};
89+
90+
_scroll = new ScrollView
91+
{
92+
BackgroundColor = Colors.Black,
93+
Content = _status,
94+
WidthRequest = 200,
95+
HeightRequest = 500
96+
};
97+
}
98+
8899
void InitTest(ListViewCachingStrategy cachingStrategy, bool useTemplate)
89100
{
90101
List<GroupedData> groups = GetGroups();
@@ -94,6 +105,8 @@ void InitTest(ListViewCachingStrategy cachingStrategy, bool useTemplate)
94105
ItemsSource = groups,
95106
ItemTemplate = new DataTemplate(typeof(MyCell)),
96107
HasUnevenRows = true,
108+
HeightRequest = 500,
109+
WidthRequest = 200,
97110

98111
// Must be grouped to repro
99112
IsGroupingEnabled = true
@@ -108,16 +121,18 @@ void InitTest(ListViewCachingStrategy cachingStrategy, bool useTemplate)
108121
listView.ItemAppearing += ListView_ItemAppearing;
109122
listView.ItemDisappearing += ListView_ItemDisappearing;
110123

111-
var horStack = new StackLayout
124+
InitializeControls();
125+
126+
var horStack = new HorizontalStackLayout
112127
{
113-
Orientation = StackOrientation.Horizontal,
114-
Children = { _scroll, listView },
115-
HeightRequest = 300
128+
HeightRequest = 500
116129
};
130+
horStack.Children.Add(_scroll);
131+
horStack.Children.Add(listView);
117132

118133
Button nextButton = new Button { Text = "Next", AutomationId = TestButtonId };
119134
nextButton.Clicked += NextButton_Clicked;
120-
StackLayout stack = new StackLayout
135+
VerticalStackLayout stack = new VerticalStackLayout
121136
{
122137
Children = { new Label { Text = Instructions }, _groupsAppearing, _groupsDisappearing, horStack, nextButton }
123138
};
Lines changed: 26 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Microsoft.Maui.Controls.Internals;
2-
31
namespace Maui.Controls.Sample.Issues;
42

53
[Issue(IssueTracker.Github, 5412, "5412 - (NavigationBar disappears on FlyoutPage)", PlatformAffected.UWP)]
@@ -40,78 +38,47 @@ public class Issue5412SettingPage : ContentPage
4038
{
4139
public Issue5412SettingPage()
4240
{
43-
#pragma warning disable CS0618 // Type or member is obsolete
44-
#pragma warning disable CS0618 // Type or member is obsolete
45-
#pragma warning disable CS0612 // Type or member is obsolete
46-
#pragma warning disable CS0612 // Type or member is obsolete
47-
#pragma warning disable CS0612 // Type or member is obsolete
48-
#pragma warning disable CS0612 // Type or member is obsolete
49-
#pragma warning disable CS0612 // Type or member is obsolete
50-
#pragma warning disable CS0612 // Type or member is obsolete
41+
5142
Content = new StackLayout
5243
{
53-
HorizontalOptions = LayoutOptions.CenterAndExpand,
54-
VerticalOptions = LayoutOptions.CenterAndExpand,
44+
HorizontalOptions = LayoutOptions.Center,
45+
VerticalOptions = LayoutOptions.Center,
5546
Children = {
56-
//new Label
57-
//{
58-
// Text = "Settings Page",
59-
// FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label))
60-
//},
61-
//new Label
62-
//{
63-
// Text = "Navigate back and check the navbar & menu are still visible.",
64-
// FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label))
65-
//},
47+
new Label
48+
{
49+
Text = "Settings Page",
50+
FontSize = 22
51+
},
52+
new Label
53+
{
54+
Text = "Navigate back and check the navbar & menu are still visible.",
55+
FontSize = 16
56+
},
6657
}
6758
};
68-
#pragma warning restore CS0612 // Type or member is obsolete
69-
#pragma warning restore CS0612 // Type or member is obsolete
70-
#pragma warning restore CS0612 // Type or member is obsolete
71-
#pragma warning restore CS0612 // Type or member is obsolete
72-
#pragma warning restore CS0612 // Type or member is obsolete
73-
#pragma warning restore CS0612 // Type or member is obsolete
74-
#pragma warning restore CS0618 // Type or member is obsolete
75-
#pragma warning restore CS0618 // Type or member is obsolete
7659
}
7760
};
7861

7962
public class Issue5412IndexPage : ContentPage
8063
{
8164
public Issue5412IndexPage()
8265
{
83-
#pragma warning disable CS0618 // Type or member is obsolete
84-
#pragma warning disable CS0618 // Type or member is obsolete
85-
#pragma warning disable CS0612 // Type or member is obsolete
86-
#pragma warning disable CS0612 // Type or member is obsolete
87-
#pragma warning disable CS0612 // Type or member is obsolete
88-
#pragma warning disable CS0612 // Type or member is obsolete
89-
#pragma warning disable CS0612 // Type or member is obsolete
90-
#pragma warning disable CS0612 // Type or member is obsolete
9166
Content = new StackLayout
9267
{
93-
HorizontalOptions = LayoutOptions.CenterAndExpand,
94-
VerticalOptions = LayoutOptions.CenterAndExpand,
68+
HorizontalOptions = LayoutOptions.Center,
69+
VerticalOptions = LayoutOptions.Center,
9570
Children = {
96-
//new Label
97-
//{
98-
// Text = "Index Page",
99-
// FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label))
100-
//},
101-
//new Label
102-
//{
103-
// Text = "Open the hamburger menu and navigate to settings page",
104-
// FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label))
105-
//},
71+
new Label
72+
{
73+
Text = "Index Page",
74+
FontSize = 22
75+
},
76+
new Label
77+
{
78+
Text = "Open the hamburger menu and navigate to settings page",
79+
FontSize = 16
80+
},
10681
}
10782
};
108-
#pragma warning restore CS0612 // Type or member is obsolete
109-
#pragma warning restore CS0612 // Type or member is obsolete
110-
#pragma warning restore CS0612 // Type or member is obsolete
111-
#pragma warning restore CS0612 // Type or member is obsolete
112-
#pragma warning restore CS0612 // Type or member is obsolete
113-
#pragma warning restore CS0612 // Type or member is obsolete
114-
#pragma warning restore CS0618 // Type or member is obsolete
115-
#pragma warning restore CS0618 // Type or member is obsolete
11683
}
117-
}
84+
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla30317.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ public Bugzilla30317(TestDevice testDevice) : base(testDevice)
4242
{
4343
}
4444

45+
protected override bool ResetAfterEachTest => true;
46+
4547
public override string Issue => "https://bugzilla.xamarin.com/show_bug.cgi?id=30137";
4648

47-
[Test, Order(1)]
49+
[Test]
4850
public void Bugzilla30317ItemSourceOnAppearingContentPage()
4951
{
5052
App.WaitForElement(PageOne);
@@ -56,12 +58,12 @@ public void Bugzilla30317ItemSourceOnAppearingContentPage()
5658
TouchAndHold(PageOneItem5);
5759
}
5860

59-
[Test, Order(2)]
61+
[Test]
6062
public void Bugzilla30317ItemSourceCtorContentPage()
6163
{
6264
App.WaitForElement(PageTwoButton);
6365
App.Tap(PageTwoButton);
64-
App.WaitForElement(PageTwo);
66+
App.WaitForElementTillPageNavigationSettled(PageTwo);
6567

6668
App.WaitForElement(PageTwoItem1);
6769
TouchAndHold(PageTwoItem1);
@@ -70,18 +72,21 @@ public void Bugzilla30317ItemSourceCtorContentPage()
7072
TouchAndHold(PageTwoItem5);
7173
}
7274

73-
[Test, Order(3)]
75+
[Test]
7476
public void Bugzilla30317ItemSourceTabbedPage()
7577
{
78+
79+
App.WaitForElement(PageTwoButton);
80+
App.Tap(PageTwoButton);
81+
App.WaitForElementTillPageNavigationSettled(PageTwo);
7682

77-
App.WaitForElement(PageTwo);
7883
App.WaitForElement(PageThreeButton);
7984
App.Tap(PageThreeButton);
8085

81-
App.WaitForElement(TabTwo);
86+
App.WaitForElementTillPageNavigationSettled(TabTwo);
8287
App.Tap(TabTwo);
8388

84-
App.WaitForElement(TabTwoItem1);
89+
App.WaitForElementTillPageNavigationSettled(TabTwoItem1);
8590
TouchAndHold(TabTwoItem1);
8691
App.WaitForElement(TabTwoItem1);
8792

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla37625.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if WINDOWS
2-
using NUnit.Framework;
1+
using NUnit.Framework;
32
using UITest.Appium;
43
using UITest.Core;
54

@@ -15,11 +14,9 @@ public Bugzilla37625(TestDevice testDevice) : base(testDevice)
1514

1615
[Test]
1716
[Category(UITestCategories.Image)]
18-
[Category(UITestCategories.Compatibility)]
1917
public void Bugzilla37625Test()
2018
{
2119
App.WaitForElement("success");
2220
}
2321
}
24-
}
25-
#endif
22+
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla45125.cs

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,38 @@ public class Bugzilla45125 : _IssuesUITest
77
{
88
const string AppearingLabelId = "appearing";
99
const string DisappearingLabelId = "disappearing";
10-
const string TestButtonId = "TestButtonId";
10+
const string TestButtonId = "Next";
1111

1212
public Bugzilla45125(TestDevice testDevice) : base(testDevice)
1313
{
1414
}
1515

1616
public override string Issue => "ListView lacks a way to get information about visible elements (such as FirstVisibleItem) to restore visual positions of elements";
1717

18-
// TODO From Xamarin.UITest migration: test references variable in UI, needs to be refactored
19-
// [FailsOnAndroidWhenRunningOnXamarinUITest]
20-
// [FailsOnIOSWhenRunningOnXamarinUITest]
21-
// [Test]
22-
// public void Bugzilla45125Test()
23-
// {
24-
// RunTest();
25-
26-
// App.Tap(TestButtonId);
27-
// RunTest();
18+
[Test]
19+
[Category(UITestCategories.ListView)]
20+
public void Bugzilla45125Test()
21+
{
22+
RunTest();
2823

29-
// App.Tap(TestButtonId);
30-
// RunTest();
24+
App.Tap(TestButtonId);
25+
RunTest();
3126

32-
// App.Tap(TestButtonId);
33-
// RunTest();
34-
// }
27+
App.Tap(TestButtonId);
28+
RunTest();
3529

36-
// void RunTest()
37-
// {
38-
// App.WaitForElement(AppearingLabelId);
39-
// App.WaitForElement(DisappearingLabelId);
30+
App.Tap(TestButtonId);
31+
RunTest();
32+
}
4033

41-
// App.Screenshot("There should be appearing and disappearing events for the Groups and Items.");
42-
// var appearing = int.Parse(App.FindElement(AppearingLabelId)?.GetText() ?? "0");
43-
// var disappearing = int.Parse(App.FindElement(DisappearingLabelId)?.GetText() ?? "0");
34+
void RunTest()
35+
{
36+
App.WaitForElementTillPageNavigationSettled(AppearingLabelId);
37+
App.WaitForElementTillPageNavigationSettled(DisappearingLabelId);
38+
var appearing = int.Parse(App.FindElement(AppearingLabelId)?.GetText() ?? "0");
39+
var disappearing = int.Parse(App.FindElement(DisappearingLabelId)?.GetText() ?? "0");
4440

45-
// Assert.That(appearing, Is.GreaterThan(0), $"Test {_TestNumber}: No appearing events for groups found.");
46-
// Assert.That(disappearing, Is.GreaterThan(0), $"Test {_TestNumber}: No disappearing events for groups found.");
47-
// }
41+
Assert.That(appearing, Is.GreaterThan(0));
42+
Assert.That(disappearing, Is.GreaterThan(0));
43+
}
4844
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue1414.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public void InvalidCastExceptionWhenScrollingAndRefreshingTableView()
1919
{
2020
App.WaitForElement("TableView");
2121
App.ScrollDown("TableView", ScrollStrategy.Gesture, 1.0, 50);
22-
App.WaitForElement("Cell 4-24");
22+
App.WaitForAnyElement(["Cell 4-24","Cell 0-24"]);
2323
App.ScrollUp("TableView", ScrollStrategy.Gesture, 1.0, 30);
24-
App.WaitForElement("Cell 0-0");
24+
App.WaitForAnyElement(["Cell 0-0","Cell 3-24"]);
2525
}
2626
}
2727
#endif

0 commit comments

Comments
 (0)