summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-05-11 14:21:41 (GMT)
committerkingces95 <kingces95@users.noreply.github.com>2016-05-11 14:21:41 (GMT)
commit846c1dc0ecb70920f15f4884b69396cc52ba3e96 (patch)
tree5c99c116418e36ada4c72cdc8ee9cc0ac1fad9c1 /Xamarin.Forms.Core.iOS.UITests/Tests
parentad3a6f68f009555387847efc37b324187b24212a (diff)
downloadxamarin-forms-846c1dc0ecb70920f15f4884b69396cc52ba3e96.zip
xamarin-forms-846c1dc0ecb70920f15f4884b69396cc52ba3e96.tar.gz
xamarin-forms-846c1dc0ecb70920f15f4884b69396cc52ba3e96.tar.bz2
Make RunningApp.Screenshot do nothing unless SCREENSHOTS symbol defined (#169)
* Make RunningApp.Screenshot do nothing unless SCREENSHOTS symbol is defined * Replace IApp casts with conditional compilation directives * Fix warning * Remove EnableLocalScreenshots * Add Ignore attributes to keep tests from "failing" in Test Cloud
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests/Tests')
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs46
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs91
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs6
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs7
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs9
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs41
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs83
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs8
8 files changed, 138 insertions, 153 deletions
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs
index 5ae8f50..47bb45c 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs
@@ -64,11 +64,11 @@ namespace Xamarin.Forms.Core.UITests
var remote = new ViewContainerRemote (App, Test.Button.BorderRadius, PlatformViewType);
remote.GoTo ();
- if (App is iOSApp) {
- var borderRadius = remote.GetProperty<float> (Button.BorderRadiusProperty);
- Assert.AreEqual (20.0f, borderRadius);
- }
-
+#if __IOS__
+ var borderRadius = remote.GetProperty<float> (Button.BorderRadiusProperty);
+ Assert.AreEqual (20.0f, borderRadius);
+#endif
+
}
[Test]
@@ -79,10 +79,10 @@ namespace Xamarin.Forms.Core.UITests
var remote = new ViewContainerRemote (App, Test.Button.BorderWidth, PlatformViewType);
remote.GoTo ();
- if (App is iOSApp) {
- var borderWidth = remote.GetProperty<float> (Button.BorderWidthProperty);
+#if __IOS__
+ var borderWidth = remote.GetProperty<float> (Button.BorderWidthProperty);
Assert.AreEqual (15.0f, borderWidth);
- }
+#endif
}
@@ -124,14 +124,13 @@ namespace Xamarin.Forms.Core.UITests
var remote = new ViewContainerRemote (App, Test.Button.Font, PlatformViewType);
remote.GoTo ();
- if (App is AndroidApp) {
- var isBold = remote.GetProperty<bool> (Button.FontProperty);
- Assert.True (isBold);
- } else {
- var font = remote.GetProperty<Font> (Button.FontProperty);
- Assert.True (font.FontAttributes.HasFlag (FontAttributes.Bold));
- }
-
+#if __ANDROID__
+ var isBold = remote.GetProperty<bool> (Button.FontProperty);
+ Assert.True (isBold);
+#else
+ var font = remote.GetProperty<Font> (Button.FontProperty);
+ Assert.True (font.FontAttributes.HasFlag (FontAttributes.Bold));
+#endif
}
[Test]
@@ -155,19 +154,20 @@ namespace Xamarin.Forms.Core.UITests
Assert.AreEqual ("Text", buttonText);
}
+ //TODO iOS
+
+#if __ANDROID__
[Test]
[UiTest (typeof (Button), "TextColor")]
public void TextColor ()
{
- //TODO iOS
- if (App is AndroidApp) {
- var remote = new ViewContainerRemote (App, Test.Button.TextColor, PlatformViewType);
- remote.GoTo ();
+ var remote = new ViewContainerRemote (App, Test.Button.TextColor, PlatformViewType);
+ remote.GoTo ();
- var buttonTextColor = remote.GetProperty<Color> (Button.TextColorProperty);
- Assert.AreEqual (Color.Pink, buttonTextColor);
- }
+ var buttonTextColor = remote.GetProperty<Color> (Button.TextColorProperty);
+ Assert.AreEqual (Color.Pink, buttonTextColor);
}
+#endif
protected override void FixtureTeardown ()
{
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs
index 7691dd4..fc80937 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs
@@ -31,58 +31,56 @@ namespace Xamarin.Forms.Core.UITests
const string clear = "Clear Items";
const string mark = "Mark";
+
+#if __ANDROID__
[Test]
public void ContextActionsShow ()
{
- if (App is AndroidApp) {
- // mark is an icon on android
- App.TouchAndHold (q => q.Marked (cell0));
- App.WaitForElement (q => q.Marked (delete));
- App.Screenshot ("I have actions!");
- } else if (App is iOSApp) {
- Assert.Inconclusive ("Not tested on iOS yet");
- }
+ // mark is an icon on android
+ App.TouchAndHold (q => q.Marked (cell0));
+ App.WaitForElement (q => q.Marked (delete));
+ App.Screenshot ("I have actions!");
}
[Test]
public void ContextActionsDelete ()
{
- if (App is AndroidApp) {
- // mark is an icon on android
- App.TouchAndHold (q => q.Marked (cell0));
- App.WaitForElement (q => q.Marked (delete));
- App.Screenshot ("I have actions!");
-
- App.Tap (q => q.Marked (delete));
- App.WaitForNoElement (q => q.Marked (cell0));
- App.Screenshot ("Deleted cell 0");
-
- } else if (App is iOSApp) {
- Assert.Inconclusive ("Not tested on iOS yet");
- }
+ // mark is an icon on android
+ App.TouchAndHold (q => q.Marked (cell0));
+ App.WaitForElement (q => q.Marked (delete));
+ App.Screenshot ("I have actions!");
+
+ App.Tap (q => q.Marked (delete));
+ App.WaitForNoElement (q => q.Marked (cell0));
+ App.Screenshot ("Deleted cell 0");
}
+#endif
+#if __IOS__
[Test]
public void PopoverDismiss()
{
- if (App is iOSApp) {
- var app = ((iOSApp)App);
- if (app.Device.IsTablet) {
- var screenBounds = App.Query (PlatformQueries.Root)[0].Rect;
- var cellBounds = App.Query (q => q.Marked (cell0))[0].Rect;
- App.DragCoordinates (screenBounds.Width - 10, cellBounds.CenterY, 10, cellBounds.CenterY);
- App.Screenshot("I see context actions");
- App.Tap (q => q.Marked ("More"));
- App.Screenshot ("Should see Popover");
- App.TapCoordinates (50, 50);
- App.Screenshot ("I should not crash");
- } else {
- Assert.Inconclusive("Not testing iOS Phone");
- }
+ var device = App.Device as iOSDevice;
+
+ if (device == null)
+ {
+ return;
+ }
+
+ if (device.IsTablet) {
+ var screenBounds = App.Query (PlatformQueries.Root)[0].Rect;
+ var cellBounds = App.Query (q => q.Marked (cell0))[0].Rect;
+ App.DragCoordinates (screenBounds.Width - 10, cellBounds.CenterY, 10, cellBounds.CenterY);
+ App.Screenshot("I see context actions");
+ App.Tap (q => q.Marked ("More"));
+ App.Screenshot ("Should see Popover");
+ App.TapCoordinates (50, 50);
+ App.Screenshot ("I should not crash");
} else {
- Assert.Inconclusive ("Not testing on Android");
+ Assert.Inconclusive("Not testing iOS Phone");
}
}
+#endif
}
[TestFixture]
@@ -107,23 +105,20 @@ namespace Xamarin.Forms.Core.UITests
const string mark = "Mark";
const string cellWithNoContextActions = "I have no ContextActions";
+#if __ANDROID__
[Test]
public void ContextActionsShowAndReset ()
{
- if (App is AndroidApp) {
- // mark is an icon on android
- App.TouchAndHold (q => q.Marked (cell0));
- App.WaitForElement (q => q.Marked (delete));
- App.Screenshot ("I have actions!");
+ // mark is an icon on android
+ App.TouchAndHold (q => q.Marked (cell0));
+ App.WaitForElement (q => q.Marked (delete));
+ App.Screenshot ("I have actions!");
- App.Tap (q => q.Marked (cellWithNoContextActions));
- App.WaitForNoElement (q => q.Marked (delete));
- App.Screenshot ("Actions should be gone");
-
- } else if (App is iOSApp) {
- Assert.Inconclusive ("Not tested on iOS yet");
- }
+ App.Tap (q => q.Marked (cellWithNoContextActions));
+ App.WaitForNoElement (q => q.Marked (delete));
+ App.Screenshot ("Actions should be gone");
}
+#endif
}
}
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs
index 45b7337..6d498b5 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs
@@ -53,11 +53,7 @@ namespace Xamarin.Forms.Core.UITests
App.EnterText (q=> q.Raw (remote.ViewQuery), "Test");
- if (App is AndroidApp) {
- ((AndroidApp)App).PressUserAction (UserAction.Done);
- } else {
- App.PressEnter ();
- }
+ App.PressEnter ();
var eventLabelText = remote.GetEventLabel ().Text;
Assert.AreEqual (eventLabelText, "Event: Completed (fired 1)");
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs
index 77daff1..d143b41 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs
@@ -248,11 +248,8 @@ namespace Xamarin.Forms.Core.UITests
App.Tap (PlatformQueries.EntryCellWithPlaceholder ("I am a placeholder"));
App.EnterText (PlatformQueries.EntryCellWithPlaceholder ("I am a placeholder"), "Hi");
App.Screenshot ("Entered Text");
- if (App is AndroidApp) {
- ((AndroidApp)App).PressUserAction (UserAction.Done);
- } else {
- App.PressEnter ();
- }
+ App.PressEnter ();
+
App.WaitForElement (q => q.Marked ("Entered: 1"));
App.Screenshot ("Completed should have changed label's text");
}
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs
index 764c3a6..e597809 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs
@@ -78,8 +78,15 @@ namespace Xamarin.Forms.Core.UITests
var scrollViewArea = App.Query (q => q.Marked ("ChoosePageScrollView")).First ().Rect;
App.ScrollForElement (string.Format("* marked:'{0}'", page.ButtonId), new Drag (scrollViewArea, Drag.Direction.BottomToTop, Drag.DragLength.Long));
App.Tap (q => q.Marked (page.ButtonId));
- if(!page.IsModal || App is iOSApp)
+
+ var ios = false;
+#if __IOS__
+ ios = true;
+#endif
+
+ if (!page.IsModal || ios)
App.WaitForElement (q => q.Marked (page.PageId));
+
App.Screenshot ("Page: " + page.PageId);
}
}
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs
index 522cd4b..eddc20c 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs
@@ -12,32 +12,35 @@ namespace Xamarin.Forms.Core.UITests
{
string btn1Id = "tb1";
string btn4Id = "tb4";
-
+#if __ANDROID__
static bool isSecondaryMenuOpen = false;
+#endif
static void ShouldShowMenu ()
{
- if (App is AndroidApp) {
- isSecondaryMenuOpen = true;
- //show secondary menu
- App.Tap (c => c.Class ("android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton"));
- }
+#if __ANDROID__
+ isSecondaryMenuOpen = true;
+ //show secondary menu
+ App.Tap (c => c.Class ("android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton"));
+#endif
}
static void ShouldHideMenu ()
{
- if (App is AndroidApp && isSecondaryMenuOpen) {
+#if __ANDROID__
+ if (isSecondaryMenuOpen) {
isSecondaryMenuOpen = false;
App.Back ();
}
+#endif
}
protected override void NavigateToGallery ()
{
App.NavigateToGallery (GalleryQueries.ToolbarItemGallery);
- if (App is iOSApp) {
- btn1Id = "menuIcon";
- btn4Id = "tb4";
- }
+#if __IOS__
+ btn1Id = "menuIcon";
+ btn4Id = "tb4";
+#endif
}
[Test]
@@ -51,12 +54,11 @@ namespace Xamarin.Forms.Core.UITests
public void ToolbarButtonsCommand ()
{
ShouldShowMenu ();
- if (App is AndroidApp) {
- //App.Query (c => c.Marked (btn4Id))[0];
- }
- else {
- App.Tap (c => c.Marked (btn4Id));
- }
+#if __ANDROID__
+ //App.Query (c => c.Marked (btn4Id))[0];
+#else
+ App.Tap (c => c.Marked (btn4Id));
+#endif
}
[Test]
@@ -93,8 +95,9 @@ namespace Xamarin.Forms.Core.UITests
var btn1 = App.Query (c => c.Marked (btn1Id)) [0];
ShouldShowMenu ();
var btn2 = App.Query (c => c.Marked ("tb4")) [0];
- if(App is iOSApp)
- Assert.True (btn1.Rect.CenterY < btn2.Rect.CenterY);
+#if __IOS__
+ Assert.True (btn1.Rect.CenterY < btn2.Rect.CenterY);
+#endif
}
}
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs
index 9d6f08f..7cfbe55 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs
@@ -20,20 +20,7 @@ namespace Xamarin.Forms.Core.UITests
//[UiTest (Test.VisualElement.AnchorX)]
public virtual void _AnchorX ()
{
- //var remote = RemoteFactory.CreateRemote<StateViewContainerRemote> (App, "AnchorX", PlatformViewType);
- //remote.GoTo ();
-
- ////App.LogPropertiesForView (remote.ViewQuery, true);
-
- //if (App is AndroidApp) {
- // var anchorX = remote.GetProperty<float> (View.AnchorXProperty);
- // var viewWidth = remote.GetView ().Rect.Width;
- // Assert.AreEqual (anchorX, 0.25 * viewWidth);
- //} else if (App is iOSApp) {
- // var anchorXMatrix = remote.GetProperty<Matrix> (View.AnchorXProperty);
- // var viewWidth = remote.GetView ().Rect.Width;
- // Assert.AreEqual (anchorXMatrix.M30, 0 - (viewWidth * 0.25f));
- //}
+
}
// [Test]
@@ -41,18 +28,7 @@ namespace Xamarin.Forms.Core.UITests
// TODO: working on some views, others not
public virtual void _AnchorY ()
{
- //var remote = RemoteFactory.CreateRemote<StateViewContainerRemote> (App, "AnchorY", PlatformViewType);
- //remote.GoTo ();
-
- //if (App is AndroidApp) {
- // var anchorY = remote.GetProperty<float> (View.AnchorYProperty);
- // var viewHeight = remote.GetView ().Rect.Height;
- // Assert.AreEqual (anchorY, viewHeight);
- //} else if (App is iOSApp) {
- // var anchorYMatrix = remote.GetProperty<Matrix> (View.AnchorYProperty);
- // var viewHeight = remote.GetView ().Rect.Height;
- // Assert.AreEqual (anchorYMatrix.M31, viewHeight / 2.0f);
- //}
+
}
// [Test]
@@ -175,16 +151,17 @@ namespace Xamarin.Forms.Core.UITests
{
var remote = new ViewContainerRemote (App, Test.VisualElement.Rotation, PlatformViewType);
remote.GoTo ();
-
- if (App is AndroidApp) {
- var rotation = remote.GetProperty<float> (View.RotationProperty);
- Assert.AreEqual (10.0f, rotation);
- } else if (App is iOSApp) {
- var rotationMatrix = remote.GetProperty<Matrix> (View.RotationProperty);
- Matrix generatedMatrix = NumericExtensions.CalculateRotationMatrixForDegrees (10, Axis.Z);
- Assert.AreEqual (generatedMatrix, rotationMatrix);
- }
- }
+
+#if __ANDROID__
+ var rotation = remote.GetProperty<float> (View.RotationProperty);
+ Assert.AreEqual (10.0f, rotation);
+#endif
+#if __IOS__
+ var rotationMatrix = remote.GetProperty<Matrix> (View.RotationProperty);
+ Matrix generatedMatrix = NumericExtensions.CalculateRotationMatrixForDegrees (10, Axis.Z);
+ Assert.AreEqual (generatedMatrix, rotationMatrix);
+#endif
+}
[Test]
[UiTest (typeof (VisualElement), "RotationX")]
@@ -193,14 +170,15 @@ namespace Xamarin.Forms.Core.UITests
var remote = new ViewContainerRemote (App, Test.VisualElement.RotationX, PlatformViewType);
remote.GoTo ();
- if (App is AndroidApp) {
- var rotationX = remote.GetProperty<float> (View.RotationXProperty);
- Assert.AreEqual (33.0f, rotationX);
- } else if (App is iOSApp) {
- var rotationXMatrix = remote.GetProperty<Matrix> (View.RotationXProperty);
- Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (33.0f, Axis.X);
- Assert.AreEqual (matrix, rotationXMatrix);
- }
+#if __ANDROID__
+ var rotationX = remote.GetProperty<float> (View.RotationXProperty);
+ Assert.AreEqual (33.0f, rotationX);
+#endif
+#if __IOS__
+ var rotationXMatrix = remote.GetProperty<Matrix> (View.RotationXProperty);
+ Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (33.0f, Axis.X);
+ Assert.AreEqual (matrix, rotationXMatrix);
+#endif
}
[Test]
@@ -210,14 +188,15 @@ namespace Xamarin.Forms.Core.UITests
var remote = new ViewContainerRemote (App, Test.VisualElement.RotationY, PlatformViewType);
remote.GoTo ();
- if (App is AndroidApp) {
- var rotationY = remote.GetProperty<float> (View.RotationYProperty);
- Assert.AreEqual (10.0f, rotationY);
- } else if (App is iOSApp) {
- var rotationYMatrix = remote.GetProperty<Matrix> (View.RotationYProperty);
- Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (10.0f, Axis.Y);
- Assert.AreEqual (matrix, rotationYMatrix);
- }
+#if __ANDROID__
+ var rotationY = remote.GetProperty<float> (View.RotationYProperty);
+ Assert.AreEqual (10.0f, rotationY);
+#endif
+#if __IOS__
+ var rotationYMatrix = remote.GetProperty<Matrix> (View.RotationYProperty);
+ Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (10.0f, Axis.Y);
+ Assert.AreEqual (matrix, rotationYMatrix);
+#endif
}
[Test]
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs
index d4233cb..c52693a 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs
@@ -38,6 +38,7 @@ namespace Xamarin.Forms.Core.UITests
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _IsVisible () {}
[UiTestExempt (ExemptReason.CannotTest, "Invalid interaction with Label")]
@@ -51,31 +52,38 @@ namespace Xamarin.Forms.Core.UITests
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _Opacity () {}
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _Rotation () {}
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _RotationX () {}
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _RotationY () {}
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _TranslationX () {}
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _TranslationY () {}
[Test]
[Category ("ManualReview")]
+ [Ignore("Keep empty test from failing in Test Cloud")]
public override void _Scale () {}
[UiTestExempt (ExemptReason.CannotTest, "Invalid interaction with Label")]