Add UI Test. Add instructions. Move to correct namespace (#4170) fixes #2251

This commit is contained in:
mikescandy 2018-10-25 00:39:36 +01:00 коммит произвёл Rui Marinho
Родитель 2b370fc402
Коммит 27acd4d02d
1 изменённых файлов: 33 добавлений и 5 удалений

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

@ -7,20 +7,35 @@ using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.TestCasesPages
#if UITEST
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve (AllMembers=true)]
[Issue (IssueTracker.Github, 1777, "Adding picker items when picker is in a ViewCell breaks", PlatformAffected.WinPhone)]
public class Issue1777 : ContentPage
public class Issue1777 : TestContentPage
{
Picker _pickerTable = null;
Picker _pickerNormal = null;
string _pickerTableId = "pickerTableId";
string _btnText = "do magic";
public Issue1777 ()
protected override void Init ()
{
StackLayout stackLayout = new StackLayout();
Content = stackLayout;
var instructions = new Label
{
Text = $@"Tap the ""{_btnText}"" button. Then click on the picker inside the Table. The picker should display ""test 0"". If not, the test failed."
};
stackLayout.Children.Add(instructions);
TableView tableView = new TableView();
stackLayout.Children.Add( tableView);
@ -38,6 +53,7 @@ namespace Xamarin.Forms.Controls.TestCasesPages
viewCell.View = contentView;
_pickerTable = new Picker ();
_pickerTable.AutomationId = _pickerTableId;
_pickerTable.HorizontalOptions = LayoutOptions.FillAndExpand;
contentView.Content = _pickerTable;
@ -50,7 +66,7 @@ namespace Xamarin.Forms.Controls.TestCasesPages
Button button = new Button ();
button.Clicked += button_Clicked;
button.Text = "do magic";
button.Text = _btnText;
stackLayout.Children.Add (button);
//button_Clicked(button, EventArgs.Empty);
@ -63,5 +79,17 @@ namespace Xamarin.Forms.Controls.TestCasesPages
_pickerTable.Items.Add ("test " + _pickerTable.Items.Count);
_pickerNormal.Items.Add ("test " + _pickerNormal.Items.Count);
}
}
#if UITEST && __WINDOWS__
[Test]
public void Issue1777Test()
{
RunningApp.WaitForElement(q => q.Button(_btnText));
RunningApp.Tap(q => q.Button(_btnText));
RunningApp.Tap(q => q.Marked(_pickerTableId));
RunningApp.WaitForElement(q => q.Marked("test 0"));
RunningApp.Screenshot("Picker is displayed correctly in the ViewCell");
}
#endif
}
}