Skip to content

Commit 734c3d2

Browse files
[Testing] Enabling ported UITests from Xamarin.UITests to Appium #1 (dotnet#25178)
* Enabling ported ui tests from Xamarin.UITests to appium * Build fixes * Update Bugzilla32040.cs * Update Bugzilla32148.cs * Removed unnecessary code * Update Bugzilla25662.cs * Update Bugzilla26171.cs * Update Bugzilla26501.cs * Update Bugzilla28001.cs * Update Bugzilla30317.cs * Update Bugzilla32462.cs * Update Bugzilla33870.cs * Some fixes * More changes * More changes * Simplified more tests * Fix build * Simplified tests * Fixed test * Added new project constants * More changes * More fixes --------- Co-authored-by: Shane Neuville <[email protected]>
1 parent 8f0e4d1 commit 734c3d2

33 files changed

+556
-442
lines changed

src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<IsTestProject>true</IsTestProject>
88
<RootNamespace>Microsoft.Maui.TestCases.Tests</RootNamespace>
9-
<DefineConstants>$(DefineConstants);ANDROID</DefineConstants>
9+
<DefineConstants>$(DefineConstants);ANDROID;TEST_FAILS_ON_IOS;TEST_FAILS_ON_CATALYST;TEST_FAILS_ON_WINDOWS</DefineConstants>
1010
</PropertyGroup>
1111

1212
<ItemGroup>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if IOS
12
namespace Maui.Controls.Sample.Issues;
23

34
[Issue(IssueTracker.Bugzilla, 21177, "Using a UICollectionView in a ViewRenderer results in issues with selection")]
@@ -28,3 +29,4 @@ private void View_ItemSelected(object sender, int e)
2829
DisplayAlert("Success", "Success", "Cancel");
2930
}
3031
}
32+
#endif

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
namespace Maui.Controls.Sample.Issues;
22

3-
public class Bugzilla25979 : TestNavigationPage
3+
[Issue(IssueTracker.Bugzilla, 25979, "https://bugzilla.xamarin.com/show_bug.cgi?id=25979")]
4+
public class Bugzilla25979 : NavigationPage
45
{
6+
public Bugzilla25979()
7+
{
8+
// Initialize ui here instead of ctor
9+
Navigation.PushAsync(new MyPage());
10+
}
11+
512
internal sealed class MyPage : ContentPage
613
{
714
public MyPage()
@@ -103,10 +110,4 @@ public MyPage3()
103110
};
104111
}
105112
}
106-
107-
protected override void Init()
108-
{
109-
// Initialize ui here instead of ctor
110-
Navigation.PushAsync(new MyPage() { Title = "Navigation Stack" });
111-
}
112-
}
113+
}

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
namespace Maui.Controls.Sample.Issues;
22

33
[Issue(IssueTracker.Bugzilla, 26233, "Windows phone crashing when going back to page containing listview with Frame inside ViewCell")]
4-
public class Bugzilla26233 : TestContentPage
4+
public class Bugzilla26233 : NavigationPage
55
{
6-
protected override void Init()
6+
public Bugzilla26233()
77
{
8-
var listview = new ListView();
9-
listview.ItemTemplate = new DataTemplate(typeof(ItemTemplate));
10-
listview.ItemsSource = new string[] { "item1", "item2", "item3", "item4", "item5", null, null };
11-
var btnBack = new Button { Text = "back", Command = new Command(() => Navigation.PopAsync()) };
12-
listview.ItemSelected += (s, e) => Navigation.PushAsync(new ContentPage { Content = btnBack });
13-
var btnPush = new Button
8+
Navigation.PushAsync(new MainPage());
9+
}
10+
11+
public class MainPage : ContentPage
12+
{
13+
public MainPage()
1414
{
15-
Text = "Next",
16-
AutomationId = "btnPush",
17-
Command = new Command(() => Navigation.PushAsync(new ContentPage { Content = btnBack }))
18-
};
15+
var listview = new ListView();
16+
listview.ItemTemplate = new DataTemplate(typeof(ItemTemplate));
17+
listview.ItemsSource = new string[] { "item1", "item2", "item3", "item4", "item5", null, null };
18+
var btnBack = new Button { Text = "back", AutomationId = "btnBack", Command = new Command(() => Navigation.PopAsync()) };
19+
listview.ItemSelected += (s, e) => Navigation.PushAsync(new ContentPage { Content = btnBack });
20+
var btnPush = new Button
21+
{
22+
Text = "Next",
23+
AutomationId = "btnPush",
24+
Command = new Command(() => Navigation.PushAsync(new ContentPage { Content = btnBack }))
25+
};
1926

20-
Content = new StackLayout { Children = { btnPush, listview } };
27+
Content = new StackLayout { Children = { btnPush, listview } };
28+
}
2129
}
2230

2331
internal class ItemTemplate : ViewCell
Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
1+
#if ANDROID
12
namespace Maui.Controls.Sample.Issues;
23

34
[Issue(IssueTracker.Bugzilla, 27731, "[Android] Action Bar can not be controlled reliably on FlyoutPage", PlatformAffected.Android)]
4-
public class Bugzilla27731 : TestFlyoutPage
5+
public class Bugzilla27731 : NavigationPage
56
{
6-
string _pageTitle = "PageTitle";
7-
protected override void Init()
7+
public Bugzilla27731()
88
{
9-
// Initialize ui here instead of ctor
10-
Flyout = new ContentPage { Content = new Label { Text = "Menu Item" }, Title = "Menu" };
11-
Detail = new NavigationPage(new Page2(_pageTitle)
12-
{
13-
AutomationId = _pageTitle
14-
});
9+
Navigation.PushAsync(new MainPage());
1510
}
1611

17-
class Page2 : ContentPage
12+
public class MainPage : TestFlyoutPage
1813
{
19-
static int count;
20-
public Page2(string title)
14+
string _pageTitle = "PageTitle";
15+
16+
protected override void Init()
2117
{
22-
count++;
23-
Title = $"{title}{count}";
24-
NavigationPage.SetHasNavigationBar(this, false);
25-
Content = new StackLayout
18+
// Initialize ui here instead of ctor
19+
Flyout = new ContentPage { Content = new Label { Text = "Menu Item" }, Title = "Menu" };
20+
Detail = new NavigationPage(new Page2(_pageTitle)
2621
{
27-
Children =
22+
AutomationId = _pageTitle
23+
});
24+
}
25+
26+
class Page2 : ContentPage
27+
{
28+
static int count;
29+
public Page2(string title)
2830
{
29-
new Label { Text = $"This is page {count}." },
30-
new Button { Text = "Click", AutomationId = "Click", Command = new Command(() => Navigation.PushAsync(new Page2(title))) }
31+
count++;
32+
Title = $"{title}{count}";
33+
NavigationPage.SetHasNavigationBar(this, false);
34+
Content = new StackLayout
35+
{
36+
Children =
37+
{
38+
new Label { Text = $"This is page {count}." },
39+
new Button { Text = "Click", AutomationId = "Click", Command = new Command(() => Navigation.PushAsync(new Page2(title))) }
40+
}
41+
};
3142
}
32-
};
3343
}
3444
}
35-
}
45+
}
46+
#endif
Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,82 @@
11
namespace Maui.Controls.Sample.Issues;
22

33
[Issue(IssueTracker.Bugzilla, 28001, "[Android] TabbedPage: invisible tabs are not Disposed", PlatformAffected.Android)]
4-
public class Bugzilla28001 : TestContentPage
4+
public class Bugzilla28001 : NavigationPage
55
{
6-
static int s_disposeCount;
7-
static Label s_lbl;
8-
9-
void HandleDispose(object sender, EventArgs e)
6+
public Bugzilla28001()
107
{
11-
s_disposeCount++;
12-
s_lbl.Text = string.Format("Dispose {0} pages", s_disposeCount);
8+
Navigation.PushAsync(new MainPage());
139
}
1410

15-
protected override void Init()
11+
public class MainPage : ContentPage
1612
{
17-
s_disposeCount = 0;
18-
s_lbl = new Label { AutomationId = "lblDisposedCount" };
19-
var tab1 = new DisposePage { Title = "Tab1", AutomationId = "Tab1" };
20-
var tab2 = new DisposePage { Title = "Tab2", AutomationId = "Tab2" };
21-
tab1.RendererDisposed += HandleDispose;
22-
tab2.RendererDisposed += HandleDispose;
23-
24-
tab2.PopAction = tab1.PopAction = async () => await Navigation.PopAsync();
13+
static int s_disposeCount;
14+
static Label s_lbl;
2515

26-
var tabbedPage = new TabbedPage { Children = { tab1, tab2 } };
27-
var btm = new Button { Text = "Push", AutomationId = "Push" };
16+
void HandleDispose(object sender, EventArgs e)
17+
{
18+
s_disposeCount++;
19+
s_lbl.Text = string.Format("Dispose {0} pages", s_disposeCount);
20+
}
2821

29-
btm.Clicked += async (object sender, EventArgs e) =>
22+
public MainPage()
3023
{
31-
await Navigation.PushAsync(tabbedPage);
32-
};
24+
s_disposeCount = 0;
25+
s_lbl = new Label { AutomationId = "lblDisposedCount" };
26+
var tab1 = new DisposePage { Title = "Tab1", AutomationId = "Tab1" };
27+
var tab2 = new DisposePage { Title = "Tab2", AutomationId = "Tab2" };
28+
tab1.RendererDisposed += HandleDispose;
29+
tab2.RendererDisposed += HandleDispose;
3330

34-
Content = new StackLayout { Children = { btm, s_lbl } };
35-
}
36-
}
31+
tab2.PopAction = tab1.PopAction = async () => await Navigation.PopAsync();
3732

38-
public class DisposePage : ContentPage
39-
{
40-
public event EventHandler RendererDisposed;
33+
var tabbedPage = new TabbedPage { Children = { tab1, tab2 } };
34+
var btm = new Button { Text = "Push", AutomationId = "Push" };
4135

42-
public void SendRendererDisposed()
43-
{
44-
var handler = RendererDisposed;
45-
if (handler != null)
46-
handler(this, EventArgs.Empty);
47-
}
36+
btm.Clicked += async (object sender, EventArgs e) =>
37+
{
38+
await Navigation.PushAsync(tabbedPage);
39+
};
4840

49-
public int DisposedLabelCount { get; private set; }
41+
Content = new StackLayout { Children = { btm, s_lbl } };
42+
}
43+
}
5044

51-
public Action PopAction { get; set; }
52-
public DisposePage()
45+
public class DisposePage : ContentPage
5346
{
54-
var popButton = new Button { Text = "Pop", AutomationId = "Pop" };
55-
popButton.Clicked += (sender, args) => PopAction();
56-
57-
var disposeLabel1 = new DisposeLabel { Text = "Label 1" };
58-
var disposeLabel2 = new DisposeLabel { Text = "Label 2" };
59-
var disposeLabel3 = new DisposeLabel { Text = "Label 3" };
60-
var disposeLabel4 = new DisposeLabel { Text = "Label 4" };
61-
var disposeLabel5 = new DisposeLabel { Text = "Label 5" };
62-
63-
EventHandler disposeHandler = (sender, args) => DisposedLabelCount++;
64-
disposeLabel1.RendererDisposed += disposeHandler;
65-
disposeLabel2.RendererDisposed += disposeHandler;
66-
disposeLabel3.RendererDisposed += disposeHandler;
67-
disposeLabel4.RendererDisposed += disposeHandler;
68-
disposeLabel5.RendererDisposed += disposeHandler;
69-
70-
Content = new StackLayout
47+
public event EventHandler RendererDisposed;
48+
49+
public void SendRendererDisposed()
7150
{
72-
Children = {
51+
var handler = RendererDisposed;
52+
if (handler != null)
53+
handler(this, EventArgs.Empty);
54+
}
55+
56+
public int DisposedLabelCount { get; private set; }
57+
58+
public Action PopAction { get; set; }
59+
public DisposePage()
60+
{
61+
var popButton = new Button { Text = "Pop", AutomationId = "Pop" };
62+
popButton.Clicked += (sender, args) => PopAction();
63+
64+
var disposeLabel1 = new DisposeLabel { Text = "Label 1" };
65+
var disposeLabel2 = new DisposeLabel { Text = "Label 2" };
66+
var disposeLabel3 = new DisposeLabel { Text = "Label 3" };
67+
var disposeLabel4 = new DisposeLabel { Text = "Label 4" };
68+
var disposeLabel5 = new DisposeLabel { Text = "Label 5" };
69+
70+
EventHandler disposeHandler = (sender, args) => DisposedLabelCount++;
71+
disposeLabel1.RendererDisposed += disposeHandler;
72+
disposeLabel2.RendererDisposed += disposeHandler;
73+
disposeLabel3.RendererDisposed += disposeHandler;
74+
disposeLabel4.RendererDisposed += disposeHandler;
75+
disposeLabel5.RendererDisposed += disposeHandler;
76+
77+
Content = new StackLayout
78+
{
79+
Children = {
7380
popButton,
7481
disposeLabel1,
7582
disposeLabel2,
@@ -81,18 +88,19 @@ public DisposePage()
8188
}
8289
}
8390
}
84-
};
91+
};
92+
}
8593
}
86-
}
8794

88-
public class DisposeLabel : Label
89-
{
90-
public event EventHandler RendererDisposed;
91-
92-
public void SendRendererDisposed()
95+
public class DisposeLabel : Label
9396
{
94-
var handler = RendererDisposed;
95-
if (handler != null)
96-
handler(this, EventArgs.Empty);
97+
public event EventHandler RendererDisposed;
98+
99+
public void SendRendererDisposed()
100+
{
101+
var handler = RendererDisposed;
102+
if (handler != null)
103+
handler(this, EventArgs.Empty);
104+
}
97105
}
98106
}

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@ namespace Maui.Controls.Sample.Issues;
22

33

44
[Issue(IssueTracker.Bugzilla, 32462, "Crash after a page disappeared if a ScrollView is in the HeaderTemplate property of a ListView", PlatformAffected.Android)]
5-
public class Bugzilla32462 : TestContentPage // or TestFlyoutPage, etc ...
5+
public class Bugzilla32462 : NavigationPage // or TestFlyoutPage, etc ...
66
{
7+
public Bugzilla32462()
8+
{
9+
Navigation.PushAsync(new MainPage());
10+
}
11+
12+
public class MainPage : ContentPage
13+
{
14+
public MainPage()
15+
{
16+
var button = new Button
17+
{
18+
Text = "Click!",
19+
};
20+
button.Clicked += (object sender, EventArgs e) => Navigation.PushAsync(new ListViewPage());
21+
Content = button;
22+
}
23+
}
724

825
public class ListViewPage : ContentPage
926
{
@@ -23,14 +40,4 @@ public ListViewPage()
2340
listview.ScrollTo(list[39], ScrollToPosition.Center, false);
2441
}
2542
}
26-
27-
protected override void Init()
28-
{
29-
var button = new Button
30-
{
31-
Text = "Click!",
32-
};
33-
button.Clicked += (object sender, EventArgs e) => Navigation.PushAsync(new ListViewPage());
34-
Content = button;
35-
}
36-
}
43+
}

0 commit comments

Comments
 (0)