Skip to content

Commit

Permalink
[Testing] Enabling ported UITests from Xamarin.UITests to Appium #1 (d…
Browse files Browse the repository at this point in the history
…otnet#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]>
  • Loading branch information
jsuarezruiz and PureWeen authored Oct 29, 2024
1 parent 8f0e4d1 commit 734c3d2
Show file tree
Hide file tree
Showing 33 changed files with 556 additions and 442 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<IsTestProject>true</IsTestProject>
<RootNamespace>Microsoft.Maui.TestCases.Tests</RootNamespace>
<DefineConstants>$(DefineConstants);ANDROID</DefineConstants>
<DefineConstants>$(DefineConstants);ANDROID;TEST_FAILS_ON_IOS;TEST_FAILS_ON_CATALYST;TEST_FAILS_ON_WINDOWS</DefineConstants>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if IOS
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Bugzilla, 21177, "Using a UICollectionView in a ViewRenderer results in issues with selection")]
Expand Down Expand Up @@ -28,3 +29,4 @@ private void View_ItemSelected(object sender, int e)
DisplayAlert("Success", "Success", "Cancel");
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
namespace Maui.Controls.Sample.Issues;

public class Bugzilla25979 : TestNavigationPage
[Issue(IssueTracker.Bugzilla, 25979, "https://bugzilla.xamarin.com/show_bug.cgi?id=25979")]
public class Bugzilla25979 : NavigationPage
{
public Bugzilla25979()
{
// Initialize ui here instead of ctor
Navigation.PushAsync(new MyPage());
}

internal sealed class MyPage : ContentPage
{
public MyPage()
Expand Down Expand Up @@ -103,10 +110,4 @@ public MyPage3()
};
}
}

protected override void Init()
{
// Initialize ui here instead of ctor
Navigation.PushAsync(new MyPage() { Title = "Navigation Stack" });
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Bugzilla, 26233, "Windows phone crashing when going back to page containing listview with Frame inside ViewCell")]
public class Bugzilla26233 : TestContentPage
public class Bugzilla26233 : NavigationPage
{
protected override void Init()
public Bugzilla26233()
{
var listview = new ListView();
listview.ItemTemplate = new DataTemplate(typeof(ItemTemplate));
listview.ItemsSource = new string[] { "item1", "item2", "item3", "item4", "item5", null, null };
var btnBack = new Button { Text = "back", Command = new Command(() => Navigation.PopAsync()) };
listview.ItemSelected += (s, e) => Navigation.PushAsync(new ContentPage { Content = btnBack });
var btnPush = new Button
Navigation.PushAsync(new MainPage());
}

public class MainPage : ContentPage
{
public MainPage()
{
Text = "Next",
AutomationId = "btnPush",
Command = new Command(() => Navigation.PushAsync(new ContentPage { Content = btnBack }))
};
var listview = new ListView();
listview.ItemTemplate = new DataTemplate(typeof(ItemTemplate));
listview.ItemsSource = new string[] { "item1", "item2", "item3", "item4", "item5", null, null };
var btnBack = new Button { Text = "back", AutomationId = "btnBack", Command = new Command(() => Navigation.PopAsync()) };
listview.ItemSelected += (s, e) => Navigation.PushAsync(new ContentPage { Content = btnBack });
var btnPush = new Button
{
Text = "Next",
AutomationId = "btnPush",
Command = new Command(() => Navigation.PushAsync(new ContentPage { Content = btnBack }))
};

Content = new StackLayout { Children = { btnPush, listview } };
Content = new StackLayout { Children = { btnPush, listview } };
}
}

internal class ItemTemplate : ViewCell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
#if ANDROID
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Bugzilla, 27731, "[Android] Action Bar can not be controlled reliably on FlyoutPage", PlatformAffected.Android)]
public class Bugzilla27731 : TestFlyoutPage
public class Bugzilla27731 : NavigationPage
{
string _pageTitle = "PageTitle";
protected override void Init()
public Bugzilla27731()
{
// Initialize ui here instead of ctor
Flyout = new ContentPage { Content = new Label { Text = "Menu Item" }, Title = "Menu" };
Detail = new NavigationPage(new Page2(_pageTitle)
{
AutomationId = _pageTitle
});
Navigation.PushAsync(new MainPage());
}

class Page2 : ContentPage
public class MainPage : TestFlyoutPage
{
static int count;
public Page2(string title)
string _pageTitle = "PageTitle";

protected override void Init()
{
count++;
Title = $"{title}{count}";
NavigationPage.SetHasNavigationBar(this, false);
Content = new StackLayout
// Initialize ui here instead of ctor
Flyout = new ContentPage { Content = new Label { Text = "Menu Item" }, Title = "Menu" };
Detail = new NavigationPage(new Page2(_pageTitle)
{
Children =
AutomationId = _pageTitle
});
}

class Page2 : ContentPage
{
static int count;
public Page2(string title)
{
new Label { Text = $"This is page {count}." },
new Button { Text = "Click", AutomationId = "Click", Command = new Command(() => Navigation.PushAsync(new Page2(title))) }
count++;
Title = $"{title}{count}";
NavigationPage.SetHasNavigationBar(this, false);
Content = new StackLayout
{
Children =
{
new Label { Text = $"This is page {count}." },
new Button { Text = "Click", AutomationId = "Click", Command = new Command(() => Navigation.PushAsync(new Page2(title))) }
}
};
}
};
}
}
}
}
#endif
136 changes: 72 additions & 64 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla28001.cs
Original file line number Diff line number Diff line change
@@ -1,75 +1,82 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Bugzilla, 28001, "[Android] TabbedPage: invisible tabs are not Disposed", PlatformAffected.Android)]
public class Bugzilla28001 : TestContentPage
public class Bugzilla28001 : NavigationPage
{
static int s_disposeCount;
static Label s_lbl;

void HandleDispose(object sender, EventArgs e)
public Bugzilla28001()
{
s_disposeCount++;
s_lbl.Text = string.Format("Dispose {0} pages", s_disposeCount);
Navigation.PushAsync(new MainPage());
}

protected override void Init()
public class MainPage : ContentPage
{
s_disposeCount = 0;
s_lbl = new Label { AutomationId = "lblDisposedCount" };
var tab1 = new DisposePage { Title = "Tab1", AutomationId = "Tab1" };
var tab2 = new DisposePage { Title = "Tab2", AutomationId = "Tab2" };
tab1.RendererDisposed += HandleDispose;
tab2.RendererDisposed += HandleDispose;

tab2.PopAction = tab1.PopAction = async () => await Navigation.PopAsync();
static int s_disposeCount;
static Label s_lbl;

var tabbedPage = new TabbedPage { Children = { tab1, tab2 } };
var btm = new Button { Text = "Push", AutomationId = "Push" };
void HandleDispose(object sender, EventArgs e)
{
s_disposeCount++;
s_lbl.Text = string.Format("Dispose {0} pages", s_disposeCount);
}

btm.Clicked += async (object sender, EventArgs e) =>
public MainPage()
{
await Navigation.PushAsync(tabbedPage);
};
s_disposeCount = 0;
s_lbl = new Label { AutomationId = "lblDisposedCount" };
var tab1 = new DisposePage { Title = "Tab1", AutomationId = "Tab1" };
var tab2 = new DisposePage { Title = "Tab2", AutomationId = "Tab2" };
tab1.RendererDisposed += HandleDispose;
tab2.RendererDisposed += HandleDispose;

Content = new StackLayout { Children = { btm, s_lbl } };
}
}
tab2.PopAction = tab1.PopAction = async () => await Navigation.PopAsync();

public class DisposePage : ContentPage
{
public event EventHandler RendererDisposed;
var tabbedPage = new TabbedPage { Children = { tab1, tab2 } };
var btm = new Button { Text = "Push", AutomationId = "Push" };

public void SendRendererDisposed()
{
var handler = RendererDisposed;
if (handler != null)
handler(this, EventArgs.Empty);
}
btm.Clicked += async (object sender, EventArgs e) =>
{
await Navigation.PushAsync(tabbedPage);
};

public int DisposedLabelCount { get; private set; }
Content = new StackLayout { Children = { btm, s_lbl } };
}
}

public Action PopAction { get; set; }
public DisposePage()
public class DisposePage : ContentPage
{
var popButton = new Button { Text = "Pop", AutomationId = "Pop" };
popButton.Clicked += (sender, args) => PopAction();

var disposeLabel1 = new DisposeLabel { Text = "Label 1" };
var disposeLabel2 = new DisposeLabel { Text = "Label 2" };
var disposeLabel3 = new DisposeLabel { Text = "Label 3" };
var disposeLabel4 = new DisposeLabel { Text = "Label 4" };
var disposeLabel5 = new DisposeLabel { Text = "Label 5" };

EventHandler disposeHandler = (sender, args) => DisposedLabelCount++;
disposeLabel1.RendererDisposed += disposeHandler;
disposeLabel2.RendererDisposed += disposeHandler;
disposeLabel3.RendererDisposed += disposeHandler;
disposeLabel4.RendererDisposed += disposeHandler;
disposeLabel5.RendererDisposed += disposeHandler;

Content = new StackLayout
public event EventHandler RendererDisposed;

public void SendRendererDisposed()
{
Children = {
var handler = RendererDisposed;
if (handler != null)
handler(this, EventArgs.Empty);
}

public int DisposedLabelCount { get; private set; }

public Action PopAction { get; set; }
public DisposePage()
{
var popButton = new Button { Text = "Pop", AutomationId = "Pop" };
popButton.Clicked += (sender, args) => PopAction();

var disposeLabel1 = new DisposeLabel { Text = "Label 1" };
var disposeLabel2 = new DisposeLabel { Text = "Label 2" };
var disposeLabel3 = new DisposeLabel { Text = "Label 3" };
var disposeLabel4 = new DisposeLabel { Text = "Label 4" };
var disposeLabel5 = new DisposeLabel { Text = "Label 5" };

EventHandler disposeHandler = (sender, args) => DisposedLabelCount++;
disposeLabel1.RendererDisposed += disposeHandler;
disposeLabel2.RendererDisposed += disposeHandler;
disposeLabel3.RendererDisposed += disposeHandler;
disposeLabel4.RendererDisposed += disposeHandler;
disposeLabel5.RendererDisposed += disposeHandler;

Content = new StackLayout
{
Children = {
popButton,
disposeLabel1,
disposeLabel2,
Expand All @@ -81,18 +88,19 @@ public DisposePage()
}
}
}
};
};
}
}
}

public class DisposeLabel : Label
{
public event EventHandler RendererDisposed;

public void SendRendererDisposed()
public class DisposeLabel : Label
{
var handler = RendererDisposed;
if (handler != null)
handler(this, EventArgs.Empty);
public event EventHandler RendererDisposed;

public void SendRendererDisposed()
{
var handler = RendererDisposed;
if (handler != null)
handler(this, EventArgs.Empty);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@ namespace Maui.Controls.Sample.Issues;


[Issue(IssueTracker.Bugzilla, 32462, "Crash after a page disappeared if a ScrollView is in the HeaderTemplate property of a ListView", PlatformAffected.Android)]
public class Bugzilla32462 : TestContentPage // or TestFlyoutPage, etc ...
public class Bugzilla32462 : NavigationPage // or TestFlyoutPage, etc ...
{
public Bugzilla32462()
{
Navigation.PushAsync(new MainPage());
}

public class MainPage : ContentPage
{
public MainPage()
{
var button = new Button
{
Text = "Click!",
};
button.Clicked += (object sender, EventArgs e) => Navigation.PushAsync(new ListViewPage());
Content = button;
}
}

public class ListViewPage : ContentPage
{
Expand All @@ -23,14 +40,4 @@ public ListViewPage()
listview.ScrollTo(list[39], ScrollToPosition.Center, false);
}
}

protected override void Init()
{
var button = new Button
{
Text = "Click!",
};
button.Clicked += (object sender, EventArgs e) => Navigation.PushAsync(new ListViewPage());
Content = button;
}
}
}
Loading

0 comments on commit 734c3d2

Please sign in to comment.