diff options
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests')
6 files changed, 75 insertions, 48 deletions
diff --git a/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs b/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs index b2f98e24..78fa2e3d 100644 --- a/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs +++ b/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs @@ -16,67 +16,90 @@ namespace Xamarin.Forms.Core.UITests { // TODO: Landscape tests - public static IApp App { get; private set; } + public static IApp App { get; set; } public string PlatformViewType { get; protected set; } - public bool ShouldResetPerFixture { get; protected set; } - public AppRect ScreenBounds { get; private set; } + public static AppRect ScreenBounds { get; set; } - protected BaseTestFixture() + [TestFixtureTearDown] + protected virtual void FixtureTeardown() { - ShouldResetPerFixture = true; } - protected abstract void NavigateToGallery(); + static int s_testsrun; + const int ConsecutiveTestLimit = 40; -#pragma warning disable 618 - [TestFixtureSetUp] -#pragma warning restore 618 - protected virtual void FixtureSetup() + // Until we get more of our memory leak issues worked out, restart the app + // after a specified number of tests so we don't get bogged down in GC + public void EnsureMemory() { - try - { - if (ShouldResetPerFixture) - { - RelaunchApp(); - } - } - catch (Exception ex) + s_testsrun += 1; + + if (s_testsrun >= ConsecutiveTestLimit) { - Debug.WriteLine(ex); - throw; - } - } + s_testsrun = 0; -#pragma warning disable 618 - [TestFixtureTearDown] -#pragma warning restore 618 - protected virtual void FixtureTeardown() - { + CoreUITestsSetup.LaunchApp(); + + FixtureSetup(); + } } [SetUp] protected virtual void TestSetup() { - if (!ShouldResetPerFixture) - { - - RelaunchApp(); - } + EnsureMemory(); } [TearDown] protected virtual void TestTearDown() { - } - void RelaunchApp() + protected abstract void NavigateToGallery(); + +#pragma warning disable 618 + [TestFixtureSetUp] +#pragma warning restore 618 + protected virtual void FixtureSetup() { - App = null; - App = AppSetup.Setup(); - App.SetOrientationPortrait(); - ScreenBounds = App.RootViewRect(); + ResetApp(); NavigateToGallery(); } + + protected void ResetApp() + { +#if __IOS__ + App.Invoke("reset:", string.Empty); +#endif +#if __ANDROID__ + App.Invoke("Reset"); +#endif + } + } +} + +#if UITEST +namespace Xamarin.Forms.Core.UITests +{ + using NUnit.Framework; + + [SetUpFixture] + public class CoreUITestsSetup + { + [SetUp] + public void RunBeforeAnyTests() + { + LaunchApp(); + } + + public static void LaunchApp() + { + BaseTestFixture.App = null; + BaseTestFixture.App = AppSetup.Setup(); + + BaseTestFixture.App.SetOrientationPortrait(); + BaseTestFixture.ScreenBounds = BaseTestFixture.App.RootViewRect(); + } } } +#endif diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs index 4b37ea9f..1e624611 100644 --- a/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs @@ -6,9 +6,8 @@ namespace Xamarin.Forms.Core.UITests [Category(UITestCategories.LifeCycle)] internal class AppearingUITests : BaseTestFixture { - public AppearingUITests () + public AppearingUITests() { - ShouldResetPerFixture = false; } protected override void NavigateToGallery () @@ -16,6 +15,13 @@ namespace Xamarin.Forms.Core.UITests App.NavigateToGallery (GalleryQueries.AppearingGallery); } + protected override void TestTearDown() + { + base.TestTearDown(); + ResetApp(); + NavigateToGallery(); + } + [Test] public void AppearingNavigationPage () { diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs index a3ae1063..d681d476 100644 --- a/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs @@ -16,7 +16,6 @@ namespace Xamarin.Forms.Core.UITests public ContextActionsListUITests () { - ShouldResetPerFixture = false; } protected override void NavigateToGallery () @@ -46,12 +45,12 @@ namespace Xamarin.Forms.Core.UITests public void ContextActionsDelete () { // mark is an icon on android - App.TouchAndHold (q => q.Marked (cell0)); + App.TouchAndHold (q => q.Marked (cell1)); App.WaitForElement (q => q.Marked (delete)); App.Screenshot ("I have actions!"); App.Tap (q => q.Marked (delete)); - App.WaitForNoElement (q => q.Marked (cell0)); + App.WaitForNoElement (q => q.Marked (cell1)); App.Screenshot ("Deleted cell 0"); } #endif @@ -89,7 +88,6 @@ namespace Xamarin.Forms.Core.UITests { public ContextActionsTableUITests () { - ShouldResetPerFixture = false; } protected override void NavigateToGallery () diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs index 86a39ad3..7e0cebf1 100644 --- a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs @@ -10,7 +10,6 @@ namespace Xamarin.Forms.Core.UITests { public UnevenListTests () { - ShouldResetPerFixture = false; } protected override void NavigateToGallery () diff --git a/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj b/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj index 42ac29ec..e71867c4 100644 --- a/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj +++ b/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj @@ -58,8 +58,9 @@ <Reference Include="nunit.framework"> <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> </Reference> - <Reference Include="Xamarin.UITest"> - <HintPath>..\packages\Xamarin.UITest.2.0.0-beta05\lib\Xamarin.UITest.dll</HintPath> + <Reference Include="Xamarin.UITest, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\Xamarin.UITest.2.0.0\lib\Xamarin.UITest.dll</HintPath> + <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> diff --git a/Xamarin.Forms.Core.iOS.UITests/packages.config b/Xamarin.Forms.Core.iOS.UITests/packages.config index 2f9ba9ce..6b16f369 100644 --- a/Xamarin.Forms.Core.iOS.UITests/packages.config +++ b/Xamarin.Forms.Core.iOS.UITests/packages.config @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="NUnit" version="2.6.4" targetFramework="net45" /> - <package id="Xamarin.UITest" version="2.0.0-beta05" targetFramework="net45" /> + <package id="Xamarin.UITest" version="2.0.0" targetFramework="net45" /> </packages>
\ No newline at end of file |