зеркало из https://github.com/DeGsoft/maui-linux.git
[UITest] Fix 2951 and moved extension method to be more visible (#7108)
* [UITest] Fix 2951 and moved extension method to be more visible * fix spacing * tabs
This commit is contained in:
Родитель
d75fa4fa92
Коммит
a46dcefc3c
|
@ -14,28 +14,30 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
#if UITEST
|
||||
[NUnit.Framework.Category(Core.UITests.UITestCategories.UwpIgnore)]
|
||||
#endif
|
||||
[Preserve (AllMembers = true)]
|
||||
[Issue (IssueTracker.Bugzilla, 26993, "https://bugzilla.xamarin.com/show_bug.cgi?id=26993")]
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Bugzilla, 26993, "https://bugzilla.xamarin.com/show_bug.cgi?id=26993")]
|
||||
public class Bugzilla26993 : TestContentPage // or TestMasterDetailPage, etc ...
|
||||
{
|
||||
[Preserve (AllMembers = true)]
|
||||
public class Bz26993ViewCell : ViewCell
|
||||
[Preserve(AllMembers = true)]
|
||||
public class Bz26993ViewCell : ViewCell
|
||||
{
|
||||
public static int s_id = 0;
|
||||
|
||||
public Bz26993ViewCell ()
|
||||
public Bz26993ViewCell()
|
||||
{
|
||||
View = new WebView {
|
||||
View = new WebView
|
||||
{
|
||||
AutomationId = "AutomationId" + s_id,
|
||||
HeightRequest = 300,
|
||||
Source = new HtmlWebViewSource {
|
||||
Source = new HtmlWebViewSource
|
||||
{
|
||||
Html = "<html><head><link rel=\"stylesheet\" href=\"default.css\"></head><body><h1 id=\"CellID" + s_id + "\">Xamarin.Forms " + s_id + "</h1><p>The CSS and image are loaded from local files!</p><img src='WebImages/XamarinLogo.png'/><p><a id=\"LinkID" + s_id++ + "\" href=\"local.html\">next page</a></p></body></html>"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Init ()
|
||||
protected override void Init()
|
||||
{
|
||||
Bz26993ViewCell.s_id = 0;
|
||||
|
||||
|
@ -77,9 +79,10 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
Content = new StackLayout {
|
||||
Children = {
|
||||
|
||||
Content = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new ListView {
|
||||
RowHeight = 300,
|
||||
ItemsSource = itemSource,
|
||||
|
@ -94,22 +97,22 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
#if __MACOS__
|
||||
[Ignore("Webview query is not implemented yet on UITEst desktop")]
|
||||
#endif
|
||||
public void Bugzilla26993Test ()
|
||||
public void Bugzilla26993Test()
|
||||
{
|
||||
RunningApp.Screenshot ("I am at BZ26993");
|
||||
RunningApp.Screenshot("I am at BZ26993");
|
||||
|
||||
RunningApp.WaitForElement (q=>q.WebView(0).Css("#CellID0"));
|
||||
RunningApp.Tap (q=>q.WebView(0).Css("#LinkID0"));
|
||||
RunningApp.WaitForElement(q => q.WebView(0).Css("#CellID0"));
|
||||
RunningApp.Tap(q => q.WebView(0).Css("#LinkID0"));
|
||||
|
||||
RunningApp.Screenshot ("Load local HTML");
|
||||
RunningApp.Screenshot("Load local HTML");
|
||||
|
||||
RunningApp.WaitForNoElement (q=>q.WebView(0).Css("#LinkID0"));
|
||||
UITest.Queries.AppWebResult[] newElem =
|
||||
RunningApp.RetryUntilPresent(()=> RunningApp.Query (q => q.WebView (0).Css ("h1")));
|
||||
RunningApp.WaitForNoElement(q => q.WebView(0).Css("#LinkID0"));
|
||||
UITest.Queries.AppWebResult[] newElem =
|
||||
RunningApp.QueryUntilPresent(() => RunningApp.Query(q => q.WebView(0).Css("h1")));
|
||||
|
||||
Assert.AreEqual ("#LocalHtmlPage", newElem[0].Id);
|
||||
Assert.AreEqual("#LocalHtmlPage", newElem[0].Id);
|
||||
|
||||
RunningApp.Screenshot ("I see the Label");
|
||||
RunningApp.Screenshot("I see the Label");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -117,20 +117,20 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
[Test]
|
||||
public void CollectionViewInfiniteScroll()
|
||||
{
|
||||
RunningApp.WaitForElement ("CollectionView5623");
|
||||
RunningApp.WaitForElement("CollectionView5623");
|
||||
|
||||
var colView = RunningApp.Query("CollectionView5623").Single();
|
||||
|
||||
AppResult[] lastCellResults = null;
|
||||
|
||||
RunningApp.RetryUntilPresent(() =>
|
||||
{
|
||||
RunningApp.DragCoordinates(colView.Rect.CenterX, colView.Rect.Y + colView.Rect.Height - 50, colView.Rect.CenterX, colView.Rect.Y + 5);
|
||||
RunningApp.QueryUntilPresent(() =>
|
||||
{
|
||||
RunningApp.DragCoordinates(colView.Rect.CenterX, colView.Rect.Y + colView.Rect.Height - 50, colView.Rect.CenterX, colView.Rect.Y + 5);
|
||||
|
||||
lastCellResults = RunningApp.Query("99");
|
||||
lastCellResults = RunningApp.Query("99");
|
||||
|
||||
return lastCellResults;
|
||||
}, 100, 1);
|
||||
return lastCellResults;
|
||||
}, 100, 1);
|
||||
|
||||
Assert.IsTrue(lastCellResults?.Any() ?? false);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ using System.Threading.Tasks;
|
|||
|
||||
#if UITEST
|
||||
using Xamarin.UITest.Queries;
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -18,11 +20,11 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
#if UITEST
|
||||
[NUnit.Framework.Category(Core.UITests.UITestCategories.UwpIgnore)]
|
||||
#endif
|
||||
[Preserve (AllMembers = true)]
|
||||
[Issue (IssueTracker.Github, 2951, "On Android, button background is not updated when color changes ")]
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 2951, "On Android, button background is not updated when color changes ")]
|
||||
public partial class Issue2951 : TestContentPage
|
||||
{
|
||||
public Issue2951 ()
|
||||
public Issue2951()
|
||||
{
|
||||
#if APP
|
||||
InitializeComponent ();
|
||||
|
@ -31,7 +33,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
async void ListView_ItemAppearing(object sender, ItemVisibilityEventArgs e)
|
||||
{
|
||||
if(e.ItemIndex == 2)
|
||||
if (e.ItemIndex == 2)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
#if APP
|
||||
|
@ -40,93 +42,128 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
}
|
||||
}
|
||||
|
||||
protected override void Init ()
|
||||
protected override void Init()
|
||||
{
|
||||
BindingContext = new MyViewModel ();
|
||||
BindingContext = new MyViewModel();
|
||||
}
|
||||
|
||||
[Preserve (AllMembers = true)]
|
||||
[Preserve(AllMembers = true)]
|
||||
public class MyViewModel
|
||||
{
|
||||
public ObservableCollection<MyItemViewModel> Items { get; private set; }
|
||||
|
||||
public Command<MyItemViewModel> ButtonTapped { get; private set; }
|
||||
|
||||
public MyViewModel ()
|
||||
public MyViewModel()
|
||||
{
|
||||
ButtonTapped = new Command<MyItemViewModel> (OnItemTapped);
|
||||
ButtonTapped = new Command<MyItemViewModel>(OnItemTapped);
|
||||
|
||||
Items = new ObservableCollection<MyItemViewModel> ();
|
||||
Items = new ObservableCollection<MyItemViewModel>();
|
||||
|
||||
Items.Add (new MyItemViewModel { Name = "A", IsStarted = false });
|
||||
Items.Add (new MyItemViewModel { Name = "B", IsStarted = false });
|
||||
Items.Add (new MyItemViewModel { Name = "C", IsStarted = false });
|
||||
Items.Add(new MyItemViewModel { Name = "A", IsStarted = false });
|
||||
Items.Add(new MyItemViewModel { Name = "B", IsStarted = false });
|
||||
Items.Add(new MyItemViewModel { Name = "C", IsStarted = false });
|
||||
}
|
||||
|
||||
void OnItemTapped (MyItemViewModel model)
|
||||
void OnItemTapped(MyItemViewModel model)
|
||||
{
|
||||
if (model.IsStarted) {
|
||||
Items.Remove (model);
|
||||
} else {
|
||||
if (model.IsStarted)
|
||||
{
|
||||
Items.Remove(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
model.IsStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Preserve (AllMembers = true)]
|
||||
[Preserve(AllMembers = true)]
|
||||
public class MyItemViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
string _name;
|
||||
|
||||
public string Name {
|
||||
get { return _name; }
|
||||
set {
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged ("Name");
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
bool _isStarted;
|
||||
|
||||
public bool IsStarted {
|
||||
get { return _isStarted; }
|
||||
set {
|
||||
public bool IsStarted
|
||||
{
|
||||
get { return _isStarted; }
|
||||
set
|
||||
{
|
||||
_isStarted = value;
|
||||
OnPropertyChanged ("IsStarted");
|
||||
OnPropertyChanged("IsStarted");
|
||||
}
|
||||
}
|
||||
|
||||
void OnPropertyChanged (string propertyName)
|
||||
void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (PropertyChanged != null) {
|
||||
PropertyChanged (this, new PropertyChangedEventArgs (propertyName));
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UITEST
|
||||
[Test]
|
||||
public void Issue2951Test ()
|
||||
public void Issue2951Test()
|
||||
{
|
||||
RunningApp.WaitForElement("Ready");
|
||||
var bt = RunningApp.WaitForElement (c => c.Marked ("btnChangeStatus"));
|
||||
var buttons = RunningApp.Query (c => c.Marked ("btnChangeStatus"));
|
||||
Assert.That (buttons.Length, Is.EqualTo (3));
|
||||
RunningApp.Tap(c => c.Marked ("btnChangeStatus").Index(1));
|
||||
buttons = RunningApp.Query (c => c.Marked ("btnChangeStatus"));
|
||||
var text = buttons [1].Text ?? buttons [1].Label;
|
||||
Assert.That (text, Is.EqualTo ("B"));
|
||||
RunningApp.Tap(c => c.Marked ("btnChangeStatus").Index(1));
|
||||
buttons = RunningApp.Query (c => c.Marked ("btnChangeStatus"));
|
||||
Assert.That (buttons.Length, Is.EqualTo (2));
|
||||
var bt = RunningApp.WaitForElement(c => c.Marked("btnChangeStatus"));
|
||||
|
||||
var buttons = RunningApp.QueryUntilPresent(() =>
|
||||
{
|
||||
var results = RunningApp.Query("btnChangeStatus");
|
||||
if (results.Length == 3)
|
||||
return results;
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
Assert.That(buttons.Length, Is.EqualTo(3));
|
||||
RunningApp.Tap(c => c.Marked("btnChangeStatus").Index(1));
|
||||
|
||||
buttons = RunningApp.QueryUntilPresent(() =>
|
||||
{
|
||||
var results = RunningApp.Query("btnChangeStatus");
|
||||
if ((results[1].Text ?? results[1].Label) == "B")
|
||||
return results;
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
var text = buttons[1].Text ?? buttons[1].Label;
|
||||
Assert.That(text, Is.EqualTo("B"));
|
||||
RunningApp.Tap(c => c.Marked("btnChangeStatus").Index(1));
|
||||
|
||||
buttons = RunningApp.QueryUntilPresent(() =>
|
||||
{
|
||||
var results = RunningApp.Query("btnChangeStatus");
|
||||
if (results.Length == 2)
|
||||
return results;
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
Assert.That(buttons.Length, Is.EqualTo(2));
|
||||
//TODO: we should check the color of the button
|
||||
//var buttonTextColor = GetProperty<Color> ("btnChangeStatus", Button.BackgroundColorProperty);
|
||||
//Assert.AreEqual (Color.Pink, buttonTextColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
};
|
||||
|
||||
|
||||
foreach(var view in imageControls)
|
||||
foreach (var view in imageControls)
|
||||
{
|
||||
view.BackgroundColor = Color.Red;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
{
|
||||
AutomationId = "layoutContainer",
|
||||
Children =
|
||||
{
|
||||
{
|
||||
new StackLayout()
|
||||
{
|
||||
Orientation = StackOrientation.Horizontal,
|
||||
|
@ -137,7 +137,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
{
|
||||
labelActiveTest,
|
||||
switchToUri,
|
||||
sourceLabel
|
||||
sourceLabel
|
||||
}
|
||||
},
|
||||
button,
|
||||
|
@ -228,7 +228,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
SetupTest(nameof(ListView), fileSource);
|
||||
|
||||
var imageVisible =
|
||||
RunningApp.RetryUntilPresent(GetImage, 10, 2000);
|
||||
RunningApp.QueryUntilPresent(GetImage, 10, 2000);
|
||||
|
||||
Assert.AreEqual(1, imageVisible.Length);
|
||||
SetImageSourceToNull();
|
||||
|
@ -261,7 +261,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
UITest.Queries.AppResult TestForImageVisible()
|
||||
{
|
||||
var images = RunningApp.RetryUntilPresent(() =>
|
||||
var images = RunningApp.QueryUntilPresent(() =>
|
||||
{
|
||||
var result = RunningApp.WaitForElement(_fileNameAutomationId);
|
||||
|
||||
|
@ -273,7 +273,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
|
||||
Assert.AreEqual(1, images.Length);
|
||||
var imageVisible = images[0];
|
||||
|
||||
|
||||
Assert.Greater(imageVisible.Rect.Height, 1);
|
||||
Assert.Greater(imageVisible.Rect.Width, 1);
|
||||
return imageVisible;
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
public void LegacyImageSourceProperties()
|
||||
{
|
||||
RunningApp.WaitForElement("Nothing Crashed");
|
||||
RunningApp.RetryUntilPresent(
|
||||
RunningApp.QueryUntilPresent(
|
||||
() =>
|
||||
{
|
||||
var result = RunningApp.WaitForElement("Image1");
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
page1.Content = new Label { Text = "success", AutomationId = "success" };
|
||||
|
||||
}
|
||||
catch(Exception exc)
|
||||
catch (Exception exc)
|
||||
{
|
||||
page1.Content = new Label { Text = $"{exc}", AutomationId = "failure" };
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace Xamarin.Forms.Controls.Issues
|
|||
[Test]
|
||||
public void Issue6286_WebView_Test()
|
||||
{
|
||||
RunningApp.RetryUntilPresent(() => RunningApp.WaitForElement("success"));
|
||||
RunningApp.QueryUntilPresent(() => RunningApp.WaitForElement("success"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ using Xamarin.UITest.Queries;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
|
||||
namespace Xamarin.Forms.Core.UITests
|
||||
namespace Xamarin.UITest
|
||||
{
|
||||
internal static class AppExtensions
|
||||
{
|
||||
public static T[] RetryUntilPresent<T>(
|
||||
public static T[] QueryUntilPresent<T>(
|
||||
this IApp app,
|
||||
Func<T[]> func,
|
||||
int retryCount = 10,
|
||||
|
@ -28,7 +28,13 @@ namespace Xamarin.Forms.Core.UITests
|
|||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Xamarin.Forms.Core.UITests
|
||||
{
|
||||
internal static class AppExtensions
|
||||
{
|
||||
public static AppRect ScreenBounds(this IApp app)
|
||||
{
|
||||
return app.Query(Queries.Root()).First().Rect;
|
||||
|
|
Загрузка…
Ссылка в новой задаче