[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 8 (#25814)
* Migrated the Issue2740 and ListViewNRE (#1) * Migrated the Issue2740 and ListViewNRE * Migrated the Issue1355 and Issue2923 * Feedback addressed --------- Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com> * optimized the test code changes --------- Co-authored-by: nivetha-nagalingam <nivetha.nagalingam@syncfusion.com>
This commit is contained in:
Родитель
353f1a3064
Коммит
0af4a9a882
|
@ -23,7 +23,7 @@
|
|||
{
|
||||
var page = new ContentPage
|
||||
{
|
||||
Content = new Label { Text = Success },
|
||||
Content = new Label { AutomationId = Success , Text = Success },
|
||||
Title = $"CreatePage Iteration: {_runCount}"
|
||||
};
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
namespace Maui.Controls.Sample.Issues;
|
||||
|
||||
|
||||
[Issue(IssueTracker.Github, 1355, "Setting Main Page in quick succession causes crash on Android", PlatformAffected.Android, issueTestNumber: 1)]
|
||||
public class Issue1355_Forms : TestContentPage
|
||||
{
|
||||
int _runCount = 0;
|
||||
int _maxRunCount = 2;
|
||||
const string Success = "Success";
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
Appearing += OnAppearing;
|
||||
}
|
||||
|
||||
private void OnAppearing(object o, EventArgs eventArgs)
|
||||
{
|
||||
Application.Current.MainPage = CreatePage();
|
||||
}
|
||||
|
||||
ContentPage CreatePage()
|
||||
{
|
||||
var page = new ContentPage
|
||||
{
|
||||
Content = new Label { Text = Success, AutomationId = Success },
|
||||
Title = $"CreatePage Iteration: {_runCount}"
|
||||
};
|
||||
|
||||
page.Appearing += (sender, args) =>
|
||||
{
|
||||
_runCount += 1;
|
||||
if (_runCount <= _maxRunCount)
|
||||
{
|
||||
Application.Current.MainPage = new NavigationPage(CreatePage());
|
||||
}
|
||||
};
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
|
@ -27,6 +27,20 @@ public class Issue2740 : TestFlyoutPage
|
|||
{
|
||||
var listview = new ListView();
|
||||
listview.ItemsSource = new List<string> { "1", "2" };
|
||||
|
||||
listview.ItemTemplate = new DataTemplate(() =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.SetBinding(Label.TextProperty, ".");
|
||||
label.SetBinding(Label.AutomationIdProperty, new Binding("."));
|
||||
var viewCell = new ViewCell
|
||||
{
|
||||
View = label
|
||||
};
|
||||
|
||||
return viewCell;
|
||||
});
|
||||
|
||||
listview.ItemTapped += OnItemTapped;
|
||||
Content = listview;
|
||||
Title = "Unit List";
|
||||
|
|
|
@ -12,6 +12,20 @@ public class ListViewNRE : TestContentPage
|
|||
ItemsSource = Enumerable.Range(0, 10)
|
||||
};
|
||||
|
||||
listView.ItemTemplate = new DataTemplate(() =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.SetBinding(Label.TextProperty, ".");
|
||||
label.SetBinding(Label.AutomationIdProperty, new Binding("."));
|
||||
|
||||
var viewCell = new ViewCell
|
||||
{
|
||||
View = label
|
||||
};
|
||||
|
||||
return viewCell;
|
||||
});
|
||||
|
||||
listView.ItemSelected += ListView_ItemSelected;
|
||||
|
||||
Content = listView;
|
||||
|
@ -19,6 +33,6 @@ public class ListViewNRE : TestContentPage
|
|||
|
||||
void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
Content = new Label { Text = Success };
|
||||
Content = new Label { AutomationId = Success , Text = Success };
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
#if ANDROID
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using UITest.Appium;
|
||||
using UITest.Core;
|
||||
|
||||
|
@ -7,7 +6,6 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
|
|||
|
||||
public class Issue1355 : _IssuesUITest
|
||||
{
|
||||
const string Success = "Success";
|
||||
|
||||
public Issue1355(TestDevice testDevice) : base(testDevice)
|
||||
{
|
||||
|
@ -18,11 +16,9 @@ public class Issue1355 : _IssuesUITest
|
|||
[Test]
|
||||
[Category(UITestCategories.LifeCycle)]
|
||||
[Category(UITestCategories.Compatibility)]
|
||||
[FailsOnAndroidWhenRunningOnXamarinUITest]
|
||||
public void SwitchMainPageOnAppearing()
|
||||
{
|
||||
// Without the fix, this would crash. If we're here at all, the test passed.
|
||||
App.WaitForNoElement(Success);
|
||||
App.WaitForElement("Success");
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,22 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using UITest.Appium;
|
||||
using UITest.Core;
|
||||
|
||||
namespace Microsoft.Maui.TestCases.Tests.Issues;
|
||||
|
||||
public class GitHub1355_Forms : _IssuesUITest
|
||||
{
|
||||
public GitHub1355_Forms(TestDevice testDevice) : base(testDevice)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Issue => "[Android] ViewCell shows ContextActions on tap instead of long press";
|
||||
|
||||
// [Test]
|
||||
// [Category(UITestCategories.Navigation)]
|
||||
// public void SwitchMainPageOnAppearing()
|
||||
// {
|
||||
// // Without the fix, this would crash. If we're here at all, the test passed.
|
||||
// App.WaitForElement(Success);
|
||||
// }
|
||||
}
|
|
@ -6,20 +6,24 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
|
|||
|
||||
public class Issue2740 : _IssuesUITest
|
||||
{
|
||||
const string Switch = "Switch";
|
||||
|
||||
const string ListItem = "1";
|
||||
|
||||
public Issue2740(TestDevice testDevice) : base(testDevice)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Issue => "System.NotSupportedException: Unable to activate instance of type Microsoft.Maui.Controls.Platform.Android.PageContainer from native handle";
|
||||
|
||||
// [Test]
|
||||
// [Category(UITestCategories.LifeCycle)]
|
||||
// public void Issue2740Test()
|
||||
// {
|
||||
// App.WaitForElement(q => q.Marked("1"));
|
||||
// App.Tap(q => q.Marked("1"));
|
||||
// App.WaitForElement(q => q.Marked("Switch"));
|
||||
// App.Tap(q => q.Marked("Switch"));
|
||||
// App.WaitForElement(q => q.Marked("1"));
|
||||
// }
|
||||
[Test]
|
||||
[Category(UITestCategories.LifeCycle)]
|
||||
public void Issue2740Test()
|
||||
{
|
||||
App.WaitForElement(ListItem);
|
||||
App.Tap(ListItem);
|
||||
App.WaitForElement(Switch);
|
||||
App.Tap(Switch);
|
||||
App.WaitForElement(ListItem);
|
||||
}
|
||||
}
|
|
@ -13,18 +13,11 @@ public class Issue2923 : _IssuesUITest
|
|||
|
||||
public override string Issue => "First tab does not load until navigating";
|
||||
|
||||
// [Test]
|
||||
// public void Issue2923TestOne()
|
||||
// {
|
||||
// App.WaitForElement(q => q.Marked("FirstPageLabel"));
|
||||
// App.Screenshot("First Tab is showing");
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void Issue2923TestTwo()
|
||||
// {
|
||||
// App.Tap(q => q.Marked("ResetButton"));
|
||||
// App.Screenshot("Tabs Reset");
|
||||
// App.WaitForElement(q => q.Marked("ResetPageLabel"));
|
||||
// }
|
||||
[Test]
|
||||
public void Issue2923TestOne()
|
||||
{
|
||||
App.WaitForElement("FirstPageLabel");
|
||||
App.Tap("ResetButton");
|
||||
App.WaitForElement("ResetPageLabel");
|
||||
}
|
||||
}
|
|
@ -12,13 +12,12 @@ public class ListViewNRE : _IssuesUITest
|
|||
|
||||
public override string Issue => "ListView crashes when disposed on ItemSelected";
|
||||
|
||||
//[Test]
|
||||
//[Category(UITestCategories.ListView)]
|
||||
//[FailsOnIOS]
|
||||
//public void ListViewNRETest()
|
||||
//{
|
||||
// App.WaitForElement(q => q.Marked("1"));
|
||||
// App.Tap(q => q.Marked("1"));
|
||||
// App.WaitForElement(q => q.Marked(Success));
|
||||
//}
|
||||
[Test]
|
||||
[Category(UITestCategories.ListView)]
|
||||
public void ListViewNRETest()
|
||||
{
|
||||
App.WaitForElement("1");
|
||||
App.Tap("1");
|
||||
App.WaitForElement("Success");
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче