summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs')
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs b/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs
new file mode 100644
index 00000000..a92d357c
--- /dev/null
+++ b/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using NUnit.Framework;
+
+using Xamarin.UITest;
+using Xamarin.UITest.Queries;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ internal abstract class BaseTestFixture
+ {
+ // TODO: Landscape tests
+
+ public static IApp App { get; private set; }
+ public string PlatformViewType { get; protected set; }
+ public bool ShouldResetPerFixture { get; protected set; }
+ public AppRect ScreenBounds { get; private set; }
+
+ protected BaseTestFixture ()
+ {
+ ShouldResetPerFixture = true;
+ }
+
+ protected abstract void NavigateToGallery ();
+
+ [TestFixtureSetUp]
+ protected virtual void FixtureSetup ()
+ {
+ if (ShouldResetPerFixture) {
+ RelaunchApp ();
+ }
+ }
+
+ [TestFixtureTearDown]
+ protected virtual void FixtureTeardown ()
+ {
+ }
+
+ [SetUp]
+ protected virtual void TestSetup ()
+ {
+ if (!ShouldResetPerFixture) {
+ RelaunchApp ();
+ }
+ App.Screenshot ("Begin Test");
+ }
+
+ [TearDown]
+ protected virtual void TestTearDown ()
+ {
+ App.Screenshot ("Test complete");
+ }
+
+ void RelaunchApp ()
+ {
+ App = null;
+ RunningApp.App = null;
+
+ try {
+ RunningApp.Restart ();
+ } catch (Exception ex) {
+ // if at first you dont succeed
+ RunningApp.Restart ();
+ }
+ App = RunningApp.App;
+
+ App.SetOrientationPortrait ();
+ ScreenBounds = App.RootViewRect ();
+ NavigateToGallery ();
+ }
+ }
+}