diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-11-16 14:07:30 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-11-16 13:07:30 -0800 |
commit | 122f0e3e6060711d6c3b2b8523236b8a057434df (patch) | |
tree | 719b2a3f4a3146602e764ebeca3939b8788db1a8 /Xamarin.Forms.Core.iOS.UITests | |
parent | acc6efb3d7d502d0a40020ec86eaff4d018de8be (diff) | |
download | xamarin-forms-122f0e3e6060711d6c3b2b8523236b8a057434df.tar.gz xamarin-forms-122f0e3e6060711d6c3b2b8523236b8a057434df.tar.bz2 xamarin-forms-122f0e3e6060711d6c3b2b8523236b8a057434df.zip |
Run multiple UI tests without restarting ControlGallery (#539)
* Allow UI tests to bypass "manual" navigation to isses pages
* Add missing Preserve attribute
* Make Issue198 test work with direct navigation
* Remove empty UI tests
* Fix error handling for iOS
* Use navigation which works for subsequent TestNavigationPages on iOS
* Fix race condition in 39530 test
Remove master page nesting when doing direct nav for UI tests
* Set up and run a single instance of Control Gallery for UI tests
* Force NavigateToIssue to wait for main page appearing to deal with iOS timing
* Move remaining UI tests into Issues namespace
* Change the connection check URL so it'll work on iOS
* Make Appearing Gallery tests work without restarting app
* Prevent ContextActions tests from stepping on each other
* Make context menu test more robust
* Move ButtonExtensions back to Controls namespace
* Have test 774 dismiss the action sheet before ending
* Update UITest package to 2.0.0 stable
* Make 2948 restore orientation when it's done
* Null check on PageController before calling SendDisappearing
* Adding a wait for the root page in the core tests
* Add consecutive tests reset to prevent memory slog on older iOS devices
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 |