[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:
Shane Neuville 2019-08-09 11:56:00 -06:00 коммит произвёл Rui Marinho
Родитель d75fa4fa92
Коммит a46dcefc3c
7 изменённых файлов: 126 добавлений и 80 удалений

Просмотреть файл

@ -25,10 +25,12 @@ namespace Xamarin.Forms.Controls.Issues
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>"
}
};
@ -78,7 +80,8 @@ namespace Xamarin.Forms.Controls.Issues
"",
};
Content = new StackLayout {
Content = new StackLayout
{
Children = {
new ListView {
RowHeight = 300,
@ -105,7 +108,7 @@ namespace Xamarin.Forms.Controls.Issues
RunningApp.WaitForNoElement(q => q.WebView(0).Css("#LinkID0"));
UITest.Queries.AppWebResult[] newElem =
RunningApp.RetryUntilPresent(()=> RunningApp.Query (q => q.WebView (0).Css ("h1")));
RunningApp.QueryUntilPresent(() => RunningApp.Query(q => q.WebView(0).Css("h1")));
Assert.AreEqual("#LocalHtmlPage", newElem[0].Id);

Просмотреть файл

@ -123,7 +123,7 @@ namespace Xamarin.Forms.Controls.Issues
AppResult[] lastCellResults = null;
RunningApp.RetryUntilPresent(() =>
RunningApp.QueryUntilPresent(() =>
{
RunningApp.DragCoordinates(colView.Rect.CenterX, colView.Rect.Y + colView.Rect.Height - 50, colView.Rect.CenterX, colView.Rect.Y + 5);

Просмотреть файл

@ -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
@ -65,9 +67,12 @@ namespace Xamarin.Forms.Controls.Issues
void OnItemTapped(MyItemViewModel model)
{
if (model.IsStarted) {
if (model.IsStarted)
{
Items.Remove(model);
} else {
}
else
{
model.IsStarted = true;
}
}
@ -80,9 +85,11 @@ namespace Xamarin.Forms.Controls.Issues
string _name;
public string Name {
public string Name
{
get { return _name; }
set {
set
{
_name = value;
OnPropertyChanged("Name");
}
@ -90,9 +97,11 @@ namespace Xamarin.Forms.Controls.Issues
bool _isStarted;
public bool IsStarted {
public bool IsStarted
{
get { return _isStarted; }
set {
set
{
_isStarted = value;
OnPropertyChanged("IsStarted");
}
@ -100,7 +109,8 @@ namespace Xamarin.Forms.Controls.Issues
void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null) {
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
@ -112,14 +122,41 @@ namespace Xamarin.Forms.Controls.Issues
{
RunningApp.WaitForElement("Ready");
var bt = RunningApp.WaitForElement(c => c.Marked("btnChangeStatus"));
var buttons = RunningApp.Query (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.Query (c => c.Marked ("btnChangeStatus"));
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.Query (c => c.Marked ("btnChangeStatus"));
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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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");

Просмотреть файл

@ -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;