Create UI test template for XAML pages (#5853)

* create template for XAML pages

* update existing template

* added BindingContext

* removed whitespace

* move BindingContext

* change class name to Issue

* fixed absolute path
This commit is contained in:
adrianknight89 2019-07-03 23:09:02 -05:00 коммит произвёл Samantha Houts
Родитель 2c9b7fd382
Коммит dd8618e14f
4 изменённых файлов: 107 добавлений и 4 удалений

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

@ -523,6 +523,10 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39458.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39853.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MultipleClipToBounds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_TemplateMarkup.xaml.cs">
<DependentUpon>_TemplateMarkup.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)PerformanceGallery\PerformanceDataManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PerformanceGallery\PerformanceGallery.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PerformanceGallery\PerformanceScenario.cs" />
@ -1230,6 +1234,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)_TemplateMarkup.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue5801.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>

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

@ -21,9 +21,11 @@ namespace Xamarin.Forms.Controls.Issues
// Initialize ui here instead of ctor
Content = new Label
{
AutomationId = "IssuePageLabel",
AutomationId = "Issue1Label",
Text = "See if I'm here"
};
BindingContext = new ViewModelIssue1();
}
#if UITEST
@ -31,10 +33,28 @@ namespace Xamarin.Forms.Controls.Issues
public void Issue1Test()
{
// Delete this and all other UITEST sections if there is no way to automate the test. Otherwise, be sure to rename the test and update the Category attribute on the class. Note that you can add multiple categories.
RunningApp.Screenshot ("I am at Issue 1");
RunningApp.WaitForElement (q => q.Marked ("IssuePageLabel"));
RunningApp.Screenshot ("I see the Label");
RunningApp.Screenshot("I am at Issue1");
RunningApp.WaitForElement(q => q.Marked("Issue1Label"));
RunningApp.Screenshot("I see the Label");
}
#endif
}
[Preserve(AllMembers = true)]
public class ViewModelIssue1
{
public ViewModelIssue1()
{
}
}
[Preserve(AllMembers = true)]
public class ModelIssue1
{
public ModelIssue1()
{
}
}
}

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

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<controls:TestContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
x:Class="Xamarin.Forms.Controls.Issues._TemplateMarkup">
<Grid>
<Label AutomationId="Issue2Label" Text="See if I'm here (Markup)"/>
</Grid>
</controls:TestContentPage>

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

@ -0,0 +1,64 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Xaml;
#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.ManualReview)]
#endif
#if APP
[XamlCompilation(XamlCompilationOptions.Compile)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2, "Issue Description (Markup)", PlatformAffected.Default)]
public partial class _TemplateMarkup : TestContentPage
{
public _TemplateMarkup()
{
#if APP
InitializeComponent();
#endif
}
protected override void Init()
{
BindingContext = new ViewModelIssue2();
}
#if UITEST
[Test]
public void Issue2Test()
{
// Delete this and all other UITEST sections if there is no way to automate the test. Otherwise, be sure to rename the test and update the Category attribute on the class. Note that you can add multiple categories.
RunningApp.Screenshot("I am at Issue2");
RunningApp.WaitForElement(q => q.Marked("Issue2Label"));
RunningApp.Screenshot("I see the Label");
}
#endif
}
[Preserve(AllMembers = true)]
public class ViewModelIssue2
{
public ViewModelIssue2()
{
}
}
[Preserve(AllMembers = true)]
public class ModelIssue2
{
public ModelIssue2()
{
}
}
}