summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UITests.Shared/Tests
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2017-03-23 11:03:48 +0000
committerGitHub <noreply@github.com>2017-03-23 11:03:48 +0000
commit2be80a55a514a050ab5ab07a201d13c111f49f63 (patch)
treea9cc64903a830e4b754ae6eee3fcc2ebb3ba200d /Xamarin.Forms.Core.UITests.Shared/Tests
parent16fcac8cf52ab960e7354a52864b0a72aefdfc1f (diff)
downloadxamarin-forms-2be80a55a514a050ab5ab07a201d13c111f49f63.tar.gz
xamarin-forms-2be80a55a514a050ab5ab07a201d13c111f49f63.tar.bz2
xamarin-forms-2be80a55a514a050ab5ab07a201d13c111f49f63.zip
[UITests]Add Xamarin.Forms.Core.UITests.Shared (#711)
* [UITests]Add Xamarin.Forms.Core.UITests.Shared * fix * [UITests]Use shared UITest project on macOS * [UITests] Add correct platform queries * [Controls] Add missing Preserve
Diffstat (limited to 'Xamarin.Forms.Core.UITests.Shared/Tests')
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ActionSheetUITests.cs167
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ActivityIndicatorUITests.cs69
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/AppearingUITests.cs66
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/AutomationIDUITests.cs76
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/BoxViewUITests.cs57
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ButtonUITests.cs172
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ContextActionsUITests.cs121
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/DatePickerUITests.cs50
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/DisplayAlertUITests.cs58
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/EditorUITests.cs50
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/EntryUITests.cs63
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/FrameUITests.cs57
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ImageUITests.cs61
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/LabelUITests.cs54
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-CellsUITests.cs290
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-UnevenListTests.cs37
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/PickerUITests.cs42
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ProgressBarUITests.cs54
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/RootGalleryUITests.cs93
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ScrollViewUITests.cs67
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/SearchBarUITests.cs40
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/SliderUITests.cs48
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/StepperUITests.cs48
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/SwitchUITests.cs48
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/TimePickerUITests.cs51
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs151
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/ViewUITests.cs247
-rw-r--r--Xamarin.Forms.Core.UITests.Shared/Tests/WebViewUITests.cs111
28 files changed, 2448 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ActionSheetUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ActionSheetUITests.cs
new file mode 100644
index 00000000..88d280e5
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ActionSheetUITests.cs
@@ -0,0 +1,167 @@
+using NUnit.Framework;
+using Xamarin.UITest.Queries;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.ActionSheet)]
+ internal class ActionSheetUITests : BaseTestFixture
+ {
+ AppRect screenSize;
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.ActionSheetGallery);
+ }
+
+ static void CheckExtras()
+ {
+ App.WaitForElement(c => c.Marked("Extra One"));
+ App.WaitForElement(c => c.Marked("Extra Six"));
+ }
+
+ protected override void TestSetup()
+ {
+ base.TestSetup();
+#if !__MACOS__
+ screenSize = App.Query(q => q.Marked("ActionSheetPage"))[0].Rect;
+#endif
+ }
+
+ [Test]
+ public void TestDisplayActionSheet()
+ {
+ ScrollAndTap("ActionSheet Extras");
+ CheckExtras();
+ App.Tap(c => c.Marked("Extra One"));
+ }
+
+ [Test]
+ public void TestDisplayActionSheetCancel()
+ {
+ ScrollAndTap("ActionSheet Cancel");
+ // iPad does not have a Cancel button for action sheet
+ if (App.Query(q => q.Marked("Cancel")).Length > 0)
+ App.Tap(c => c.Marked("Cancel"));
+ else
+ App.TapCoordinates(20, screenSize.Height / 2);
+ }
+
+ [Test]
+ public void TestDisplayActionSheetCancelDestruction()
+ {
+ ScrollAndTap("ActionSheet Cancel Destruction");
+ App.WaitForNoElement(c => c.Marked("Extra One"));
+ App.WaitForElement(c => c.Marked("Destruction"));
+ if (App.Query(q => q.Marked("Cancel")).Length > 0)
+ App.Tap(c => c.Marked("Cancel"));
+ else
+ App.TapCoordinates(20, screenSize.Height / 2);
+ }
+
+ [Test]
+ public void TestDisplayActionSheetCancelExtras()
+ {
+ ScrollAndTap("ActionSheet Cancel Extras");
+ CheckExtras();
+ if (App.Query(q => q.Marked("Cancel")).Length > 0)
+ App.Tap(c => c.Marked("Cancel"));
+ else
+ App.TapCoordinates(20, screenSize.Height / 2);
+ }
+
+ [Test]
+ public void TestDisplayActionSheetCancelExtrasDestruction()
+ {
+ ScrollAndTap("ActionSheet Cancel Destruction Extras");
+ CheckExtras();
+ App.WaitForElement(c => c.Marked("Destruction"));
+ if (App.Query(q => q.Marked("Cancel")).Length > 0)
+ App.Tap(c => c.Marked("Cancel"));
+ else
+ App.TapCoordinates(20, screenSize.Height / 2);
+ }
+
+ [Test]
+ public void TestDisplayActionSheetDestruction()
+ {
+ ScrollAndTap("ActionSheet Destruction");
+ App.WaitForNoElement(c => c.Marked("Extra One"));
+ App.Tap(c => c.Marked("Destruction"));
+ }
+
+ [Test]
+ public void TestDisplayActionSheetDestructionExtras()
+ {
+ ScrollAndTap("ActionSheet Destruction Extras");
+ CheckExtras();
+ App.Tap(c => c.Marked("Extra One"));
+ }
+
+ [Test]
+ public void TestDisplayActionSheetTitleCancel()
+ {
+ ScrollAndTap("ActionSheet Title Cancel");
+ App.WaitForElement(c => c.Marked("Title"));
+ if (App.Query(q => q.Marked("Cancel")).Length > 0)
+ App.Tap(c => c.Marked("Cancel"));
+ else
+ App.TapCoordinates(20, screenSize.Height / 2);
+ }
+
+ [Test]
+ public void TestDisplayActionSheetTitleCancelDestruction()
+ {
+ ScrollAndTap("ActionSheet Title Cancel Destruction");
+ App.WaitForElement(c => c.Marked("Title"));
+ App.WaitForNoElement(c => c.Marked("Extra One"));
+ App.Tap(c => c.Marked("Destruction"));
+ }
+
+ [Test]
+ public void TestDisplayActionSheetTitleCancelDestructionExtras()
+ {
+ ScrollAndTap("ActionSheet Title Cancel Destruction Extras");
+ App.WaitForElement(c => c.Marked("Title"));
+ CheckExtras();
+ App.Tap(c => c.Marked("Destruction"));
+ }
+
+ [Test]
+ public void TestDisplayActionSheetTitleDestruction()
+ {
+ ScrollAndTap("ActionSheet Title Destruction");
+ App.WaitForElement(c => c.Marked("Title"));
+ App.WaitForNoElement(c => c.Marked("Extra One"));
+ App.Tap(c => c.Marked("Destruction"));
+ }
+
+ [Test]
+ public void TestDisplayActionSheetTitleDestructionExtras()
+ {
+ ScrollAndTap("ActionSheet Title Destruction Extras");
+ App.WaitForElement(c => c.Marked("Title"));
+ CheckExtras();
+ App.Tap(c => c.Marked("Destruction"));
+ }
+
+
+ [Test]
+ public void TestDisplayActionSheetTitleExtras()
+ {
+ ScrollAndTap("ActionSheet Title Extras");
+ CheckExtras();
+ App.Tap(c => c.Marked("Extra One"));
+ }
+
+ void ScrollAndTap(string actionSheet)
+ {
+#if !__MACOS__
+ App.ScrollForElement(string.Format("* text:'{0}'", actionSheet), new Drag(App.Query(q => q.Marked("ActionSheetPage"))[0].Rect, Drag.Direction.BottomToTop, Drag.DragLength.Long));
+#endif
+ App.Tap(q => q.Raw(string.Format("* text:'{0}'", actionSheet)));
+ }
+
+ }
+}
+
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ActivityIndicatorUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ActivityIndicatorUITests.cs
new file mode 100644
index 00000000..1667aa34
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ActivityIndicatorUITests.cs
@@ -0,0 +1,69 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.ActivityIndicator)]
+ internal class ActivityIndicatorUITests : _ViewUITests
+ {
+ public ActivityIndicatorUITests()
+ {
+ PlatformViewType = Views.ActivityIndicator;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.ActivityIndicatorGallery);
+ }
+
+ // View tests
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ public override void _GestureRecognizers()
+ {
+ // TODO Can implement this
+ var remote = new ViewContainerRemote(App, Test.View.GestureRecognizers, PlatformViewType);
+ remote.GoTo();
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsEnabled()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // ActivityIndicator tests
+ [Test]
+ [UiTest(typeof(ActivityIndicator), "IsRunning")]
+ public void IsRunning()
+ {
+ var remote = new ViewContainerRemote(App, Test.ActivityIndicator.IsRunning, PlatformViewType);
+ remote.GoTo();
+#if __MACOS__
+ Assert.Inconclusive("Not tested yet");
+#else
+ var isRunning = remote.GetProperty<bool> (ActivityIndicator.IsRunningProperty);
+ Assert.IsTrue (isRunning);
+#endif
+ }
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/AppearingUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/AppearingUITests.cs
new file mode 100644
index 00000000..b38fd418
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/AppearingUITests.cs
@@ -0,0 +1,66 @@
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Core.UITests
+{
+#if __MACOS__
+ [Ignore("Not tested on the MAC")]
+#endif
+ [Category(UITestCategories.LifeCycle)]
+ internal class AppearingUITests : BaseTestFixture
+ {
+ public AppearingUITests()
+ {
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.AppearingGallery);
+ }
+
+ protected override void TestTearDown()
+ {
+ base.TestTearDown();
+ ResetApp();
+ NavigateToGallery();
+ }
+
+ [Test]
+ public void AppearingNavigationPage()
+ {
+ App.Tap(t => t.Marked("NavAppearingPage"));
+ App.WaitForElement("Appearing NavAppearingPage");
+ App.WaitForElement("Appearing Page 1");
+ App.Tap(t => t.Marked("Push new Page"));
+ App.WaitForElement("Disappearing Page 1");
+ App.WaitForElement("Appearing Page 2");
+ App.Tap(t => t.Marked("Change Main Page"));
+ App.WaitForElement("Disappearing Page 2");
+ App.WaitForElement("Disappearing NavAppearingPage");
+ App.WaitForElement("Appearing Page 3");
+ }
+
+ [Test]
+ public void AppearingCarouselPage()
+ {
+ App.Tap(t => t.Marked("CarouselAppearingPage"));
+ App.WaitForElement("Appearing CarouselAppearingPage");
+ App.WaitForElement("Appearing Page 1");
+ }
+
+ [Test]
+ public void AppearingTabbedPage()
+ {
+ App.Tap(t => t.Marked("TabbedAppearingPage"));
+ App.WaitForElement("Appearing TabbedAppearingPage");
+ App.WaitForElement("Appearing Page 1");
+ }
+
+ [Test]
+ public void AppearingMasterDetailPage()
+ {
+ App.Tap(t => t.Marked("MasterAppearingPage"));
+ App.WaitForElement("Appearing MasterAppearingPage");
+ App.WaitForElement("Appearing Page 1");
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/AutomationIDUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/AutomationIDUITests.cs
new file mode 100644
index 00000000..9b814a92
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/AutomationIDUITests.cs
@@ -0,0 +1,76 @@
+using NUnit.Framework;
+using Xamarin.UITest;
+using System;
+using System.Threading;
+using Xamarin.UITest.Queries;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.AutomationId)]
+ internal class AutomationIDUITests : BaseTestFixture
+ {
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.AutomationIDGallery);
+ }
+
+ [Test]
+ public void Test1 ()
+ {
+ App.WaitForElement(c => c.Marked("btnTest1"));
+ App.Tap (c => c.Marked ("btnTest1"));
+ App.WaitForElement (c => c.Marked ("stckMain"));
+ App.WaitForElement (c => c.Marked ("actHello"));
+ App.WaitForElement (c => c.Marked ("bxvHello"));
+ App.Tap (c => c.Marked ("btnHello"));
+ App.WaitForElement (c => c.Marked ("dtPicker"));
+ App.WaitForElement (c => c.Marked ("tPicker"));
+
+ var label = App.Query ("lblHello") [0];
+ Assert.AreEqual (label.Text, "Hello Label");
+
+ var editor = App.Query ("editorHello") [0];
+ Assert.AreEqual (editor.Text, "Hello Editor");
+
+ var entry = App.Query ("entryHello") [0];
+ Assert.AreEqual (entry.Text, "Hello Entry");
+
+ App.Tap (c => c.Marked ("popModal"));
+ }
+
+
+ [Test]
+ public async void Test2()
+ {
+ await Task.Delay(1000);
+ App.WaitForElement(c => c.Marked("btnTest2"));
+ App.Tap (c => c.Marked ("btnTest2"));
+ App.WaitForElement (c => c.Marked ("imgHello"));
+ App.WaitForElement (c => c.Marked ("lstView"));
+ App.WaitForElement (c => c.Marked ("pickerHello"));
+ App.WaitForElement (c => c.Marked ("progressHello"));
+ App.ScrollDownTo (c => c.Marked ("progressHello"));
+ App.WaitForElement (c => c.Marked ("srbHello"));
+ App.WaitForElement (c => c.Marked ("sliHello"));
+ App.WaitForElement (c => c.Marked ("stepperHello"));
+ App.WaitForElement (c => c.Marked ("switchHello"));
+ //App.WaitForElement (c => c.Marked ("webviewHello"));
+ App.Tap (c => c.Marked ("popModal"));
+ }
+
+ [Test]
+ [Ignore("only works on ios")]
+ public void TestToolbarItem ()
+ {
+ App.Tap (c => c.Marked ("tbItemHello"));
+ App.WaitForElement (x => x.Marked ("Hello"));
+ App.Tap (c => c.Marked ("ok"));
+ App.Tap (c => c.Marked ("tbItemHello2"));
+ App.WaitForElement (x => x.Marked ("Hello2"));
+ App.Tap (c => c.Marked ("ok"));
+ }
+ }
+}
+
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/BoxViewUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/BoxViewUITests.cs
new file mode 100644
index 00000000..a99363dc
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/BoxViewUITests.cs
@@ -0,0 +1,57 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+#if __MACOS__
+ [Ignore("Not tested on the MAC")]
+#endif
+ [Category(UITestCategories.BoxView)]
+ internal class BoxViewUITests : _ViewUITests
+ {
+ public BoxViewUITests()
+ {
+ PlatformViewType = Views.BoxView;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.BoxViewGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsEnabled()
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ButtonUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ButtonUITests.cs
new file mode 100644
index 00000000..83dff100
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ButtonUITests.cs
@@ -0,0 +1,172 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Button)]
+ internal class ButtonUITests : _ViewUITests
+ {
+ public ButtonUITests()
+ {
+ PlatformViewType = Views.Button;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.ButtonGallery);
+ }
+
+ // View Tests
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // Button Tests
+ [Test]
+ [UiTest(typeof(Button), "BorderColor")]
+ [UiTestBroken(BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")]
+ [UiTestBroken(BrokenReason.CalabashiOSUnsupported, "iOS nil result")]
+ public void BorderColor()
+ {
+ //TODO iOS
+ var remote = new ViewContainerRemote(App, Test.Button.BorderColor, PlatformViewType);
+ remote.GoTo();
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "BorderRadius")]
+ [UiTestBroken(BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")]
+ public void BorderRadius()
+ {
+ var remote = new ViewContainerRemote(App, Test.Button.BorderRadius, PlatformViewType);
+ remote.GoTo();
+
+#if __IOS__
+ var borderRadius = remote.GetProperty<float>(Button.BorderRadiusProperty);
+ Assert.AreEqual(20.0f, borderRadius);
+#endif
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "BorderWidth")]
+ [UiTestBroken(BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")]
+ public void BorderWidth()
+ {
+ var remote = new ViewContainerRemote(App, Test.Button.BorderWidth, PlatformViewType);
+ remote.GoTo();
+
+#if __IOS__
+ var borderWidth = remote.GetProperty<float>(Button.BorderWidthProperty);
+ Assert.AreEqual(15.0f, borderWidth);
+#endif
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "Clicked")]
+ public void Clicked()
+ {
+ var remote = new EventViewContainerRemote(App, Test.Button.Clicked, PlatformViewType);
+ remote.GoTo();
+
+ var textBeforeClick = remote.GetEventLabel().Text;
+ Assert.AreEqual("Event: Clicked (none)", textBeforeClick);
+
+ // Click Button
+ remote.TapView();
+
+ var textAfterClick = remote.GetEventLabel().Text;
+ Assert.AreEqual("Event: Clicked (fired 1)", textAfterClick);
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "Command")]
+ public void Command()
+ {
+ var remote = new ViewContainerRemote(App, Test.Button.Command, PlatformViewType);
+ remote.GoTo();
+
+ remote.TapView();
+
+ App.WaitForElement(q => q.Marked("Hello Command"));
+ App.Tap(q => q.Marked("Destroy"));
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "Font")]
+ public void Font()
+ {
+ //TODO iOS
+ var remote = new ViewContainerRemote(App, Test.Button.Font, PlatformViewType);
+ remote.GoTo();
+
+#if __ANDROID__
+ var isBold = remote.GetProperty<bool> (Button.FontProperty);
+ Assert.True (isBold);
+#elif __MACOS__
+ Assert.Inconclusive("needs testing");
+#else
+ var font = remote.GetProperty<Font>(Button.FontProperty);
+ Assert.True(font.FontAttributes.HasFlag(FontAttributes.Bold));
+#endif
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "Image")]
+ [UiTestExempt(ExemptReason.TimeConsuming, "Need way to check Android resources")]
+ public void Image()
+ {
+ //TODO iOS
+ var remote = new ViewContainerRemote(App, Test.Button.Image, PlatformViewType);
+ remote.GoTo();
+ }
+
+ [Test]
+ [UiTest(typeof(Button), "Text")]
+ public void Text()
+ {
+ var remote = new ViewContainerRemote(App, Test.Button.Text, PlatformViewType);
+ remote.GoTo();
+
+ var buttonText = remote.GetProperty<string>(Button.TextProperty);
+ Assert.AreEqual("Text", buttonText);
+ }
+
+ //TODO iOS
+
+#if __ANDROID__
+ [Test]
+ [UiTest (typeof (Button), "TextColor")]
+ public void TextColor ()
+ {
+ var remote = new ViewContainerRemote (App, Test.Button.TextColor, PlatformViewType);
+ remote.GoTo ();
+
+ var buttonTextColor = remote.GetProperty<Color> (Button.TextColorProperty);
+ Assert.AreEqual (Color.Pink, buttonTextColor);
+ }
+#endif
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ContextActionsUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ContextActionsUITests.cs
new file mode 100644
index 00000000..cd0b3643
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ContextActionsUITests.cs
@@ -0,0 +1,121 @@
+using NUnit.Framework;
+using Xamarin.UITest;
+using System;
+using System.Threading;
+
+using Xamarin.UITest.Android;
+using Xamarin.UITest.iOS;
+using Xamarin.UITest.Queries;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Cells)]
+ internal class ContextActionsListUITests : BaseTestFixture
+ {
+
+ public ContextActionsListUITests ()
+ {
+ }
+
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.ContextActionsListGallery);
+ }
+
+ const string cell0 = "Subject Line 0";
+ const string cell1 = "Subject Line 1";
+ const string move = "Move";
+ const string delete = "Delete";
+ const string clear = "Clear Items";
+ const string mark = "Mark";
+
+
+#if __ANDROID__ || __MACOS__
+ [Test]
+ public void ContextActionsShow ()
+ {
+ // 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 ()
+ {
+ // mark is an icon on android
+ 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 (cell1));
+ App.Screenshot ("Deleted cell 0");
+ }
+#endif
+
+#if __IOS__
+ [Test]
+ public void PopoverDismiss()
+ {
+ 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 iOS Phone");
+ }
+ }
+#endif
+ }
+ [TestFixture]
+ [Category(UITestCategories.Cells)]
+ internal class ContextActionsTableUITests : BaseTestFixture
+ {
+ public ContextActionsTableUITests ()
+ {
+ }
+
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.ContextActionsTableGallery);
+ }
+
+ const string cell0 = "Subject Line 0";
+ const string cell1 = "Subject Line 1";
+ const string move = "Move";
+ const string delete = "Delete";
+ const string clear = "Clear Items";
+ const string mark = "Mark";
+ const string cellWithNoContextActions = "I have no ContextActions";
+
+#if __ANDROID__ || __MACOS__
+ [Test]
+ public void ContextActionsShowAndReset ()
+ {
+ // 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");
+ }
+#endif
+ }
+}
+
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/DatePickerUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/DatePickerUITests.cs
new file mode 100644
index 00000000..4e176df2
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/DatePickerUITests.cs
@@ -0,0 +1,50 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.DatePicker)]
+ internal class DatePickerUITests : _ViewUITests
+ {
+ public DatePickerUITests()
+ {
+ PlatformViewType = Views.DatePicker;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.DatePickerGallery);
+ }
+
+ // View Tests
+ // TODO
+ public override void _Focus()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers()
+ {
+ }
+
+ // TODO
+ public override void _IsFocused()
+ {
+ }
+
+ // TODO
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/DisplayAlertUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/DisplayAlertUITests.cs
new file mode 100644
index 00000000..ce935dc9
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/DisplayAlertUITests.cs
@@ -0,0 +1,58 @@
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.DisplayAlert)]
+ internal class DisplayAlertUITests : BaseTestFixture
+ {
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.DisplayAlertGallery);
+ }
+
+ [Test]
+ public void TestWithCancelButton()
+ {
+ App.Tap(c => c.Marked("Alert Override1"));
+ App.Screenshot("Display Alert");
+ App.WaitForElement(c => c.Marked("TheAlertTitle"));
+ App.WaitForElement(c => c.Marked("TheAlertMessage"));
+ App.WaitForElement(c => c.Marked("TheCancelButton"));
+ App.Screenshot("Display Alert Closed");
+ App.Tap(c => c.Marked("TheCancelButton"));
+ App.WaitForNoElement(c => c.Marked("TheAlertTitle"));
+ }
+
+ [Test]
+ public void TestWithCancelAndOkButton()
+ {
+ App.Tap(c => c.Marked("Alert Override2"));
+ App.Screenshot("Display Alert");
+ App.WaitForElement(c => c.Marked("TheAlertTitle"));
+ App.WaitForElement(c => c.Marked("TheAlertMessage"));
+ App.WaitForElement(c => c.Marked("TheAcceptButton"));
+ App.WaitForElement(c => c.Marked("TheCancelButton"));
+ App.Tap(c => c.Marked("TheCancelButton"));
+ App.Screenshot("Display Alert Closed");
+ App.WaitForNoElement(c => c.Marked("TheAlertTitle"));
+ }
+
+ [Test]
+ public void TestOkAndCancelResults()
+ {
+ App.Tap(c => c.Marked("Alert Override2"));
+ App.Screenshot("Display Alert");
+ App.WaitForElement(c => c.Marked("TheCancelButton"));
+ App.Tap(c => c.Marked("TheCancelButton"));
+ App.Screenshot("Display Alert Closed with cancel");
+ App.WaitForElement(c => c.Marked("Result: False"));
+ App.Tap(c => c.Marked("test2"));
+ App.Screenshot("Display Alert");
+ App.WaitForElement(c => c.Marked("TheAcceptButton"));
+ App.Tap(c => c.Marked("TheAcceptButton"));
+ App.Screenshot("Display Alert Closed with True");
+ App.WaitForElement(c => c.Marked("Result: True"));
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/EditorUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/EditorUITests.cs
new file mode 100644
index 00000000..b2739b5c
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/EditorUITests.cs
@@ -0,0 +1,50 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Editor)]
+ internal class EditorUITests : _ViewUITests
+ {
+ public EditorUITests()
+ {
+ PlatformViewType = Views.Editor;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.EditorGallery);
+ }
+
+ // View Tests
+ // TODO
+ public override void _Focus()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers()
+ {
+ }
+
+ // TODO
+ public override void _IsFocused()
+ {
+ }
+
+ // TODO
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/EntryUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/EntryUITests.cs
new file mode 100644
index 00000000..80d2095f
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/EntryUITests.cs
@@ -0,0 +1,63 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Entry)]
+ internal class EntryUITests : _ViewUITests
+ {
+ public EntryUITests()
+ {
+ PlatformViewType = Views.Entry;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.EntryGallery);
+ }
+
+ // TODO
+ public override void _Focus()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers()
+ {
+ }
+
+ // TODO
+ public override void _IsFocused()
+ {
+ }
+
+ // TODO
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+ [Test]
+ [UiTest(typeof(Entry), "Completed")]
+ public void Completed()
+ {
+ var remote = new EventViewContainerRemote(App, Test.Entry.Completed, PlatformViewType);
+ remote.GoTo();
+
+ App.EnterText(q => q.Raw(remote.ViewQuery), "Test");
+
+ App.PressEnter();
+
+ var eventLabelText = remote.GetEventLabel().Text;
+ Assert.AreEqual(eventLabelText, "Event: Completed (fired 1)");
+ }
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/FrameUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/FrameUITests.cs
new file mode 100644
index 00000000..469c8a5a
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/FrameUITests.cs
@@ -0,0 +1,57 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+#if __MACOS__
+ [Ignore("Not tested on the MAC")]
+#endif
+ [TestFixture]
+ [Category(UITestCategories.Frame)]
+ internal class FrameUITests : _ViewUITests
+ {
+ public FrameUITests()
+ {
+ PlatformViewType = Views.Frame;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.FrameGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsEnabled()
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ImageUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ImageUITests.cs
new file mode 100644
index 00000000..0b2aa849
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ImageUITests.cs
@@ -0,0 +1,61 @@
+using System.Threading;
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Image)]
+ internal class ImageUITests : _ViewUITests
+ {
+ public ImageUITests()
+ {
+ PlatformViewType = Views.Image;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.ImageGallery);
+
+ // let remote images load
+ Thread.Sleep(2000);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsEnabled()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ // TODO
+ // Tests for remote images
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/LabelUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/LabelUITests.cs
new file mode 100644
index 00000000..8b0dd311
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/LabelUITests.cs
@@ -0,0 +1,54 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Label)]
+ internal class LabelUITests : _ViewUITests
+ {
+ public LabelUITests()
+ {
+ PlatformViewType = Views.Label;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.LabelGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsEnabled()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-CellsUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-CellsUITests.cs
new file mode 100644
index 00000000..45b3436c
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-CellsUITests.cs
@@ -0,0 +1,290 @@
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+#if __MACOS__
+ [Ignore("Not tested on the MAC")]
+#endif
+ [TestFixture]
+ [Category(UITestCategories.Cells)]
+ internal class CellsGalleryTests : BaseTestFixture
+ {
+ // TODO find a way to test individula elements of cells
+ // TODO port to new framework
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.CellsGalleryLegacy);
+ }
+
+ [Test]
+ [Description("ListView with TextCells, all are present")]
+ [UiTest(typeof(ListView))]
+ [UiTest(typeof(TextCell))]
+ public void CellsGalleryTextCellList()
+ {
+ App.ScrollForElement("* marked:'TextCell List'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+ App.Tap(q => q.Marked("TextCell List"));
+ App.WaitForElement(q => q.Marked("Text 0"), "Timeout : Text 0");
+
+ App.Screenshot("At TextCell List Gallery");
+
+ App.ScrollForElement("* marked:'Detail 99'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.WaitForElement(q => q.Marked("Detail 99"), "Timeout : Detail 99");
+
+ App.Screenshot("All TextCells are present");
+ }
+
+ [Test]
+ [Description("TableView with TextCells, all are present")]
+ [UiTest(typeof(TableView))]
+ [UiTest(typeof(TextCell))]
+ public void CellsGalleryTextCellTable()
+ {
+ App.ScrollForElement("* marked:'TextCell Table'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("TextCell Table"));
+ App.WaitForElement(q => q.Marked("Text 1"), "Timeout : Text 1");
+
+ App.Screenshot("At TextCell Table Gallery");
+
+ App.ScrollForElement("* marked:'Detail 12'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.WaitForElement(q => q.Marked("Detail 12"), "Timeout : Detail 12");
+
+ App.Screenshot("All TextCells are present");
+ }
+
+ [Test]
+ [Description("ListView with ImageCells, all are present")]
+ [UiTest(typeof(ListView))]
+ [UiTest(typeof(ImageCell))]
+ public void CellsGalleryImageCellList()
+ {
+ Thread.Sleep(2000);
+
+ App.ScrollForElement("* marked:'ImageCell List'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ Thread.Sleep(2000);
+
+ App.Tap(q => q.Marked("ImageCell List"));
+ App.WaitForElement(q => q.Marked("Text 0"), "Timeout : Text 0");
+
+ App.Screenshot("At ImageCell List Gallery");
+
+ var scollBounds = App.Query(q => q.Marked("ImageCellListView")).First().Rect;
+ App.ScrollForElement("* marked:'Detail 99'",
+ new Drag(scollBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.WaitForElement(q => q.Marked("Detail 99"), "Timeout : Detail 99");
+
+ App.Screenshot("All ImageCells are present");
+
+ var numberOfImages = App.Query(q => q.Raw(PlatformViews.Image)).Length;
+ // Check that there are images present. In Android,
+ // have to make sure that there are more than 2 for navigation.
+ Assert.IsTrue(numberOfImages > 2);
+
+ App.Screenshot("Images are present");
+ }
+
+ [Test]
+ [Ignore("Ignore because is only failing on iOS10 at XTC")]
+ [Description("ListView with ImageCells, file access problems")]
+ [UiTest(typeof(ListView))]
+ [UiTest(typeof(ImageCell))]
+ public async Task CellsGalleryImageUrlCellList()
+ {
+ App.ScrollForElement("* marked:'ImageCell Url List'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("ImageCell Url List"));
+
+ //var scollBounds = App.Query(q => q.Marked("ImageUrlCellListView")).First().Rect;
+ //App.ScrollForElement("* marked:'Detail 200'", new Drag(scollBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+ //App.ScrollUp();
+ //App.WaitForElement(q => q.Marked("Detail 200"), "Timeout : Detail 200");
+
+ App.Screenshot("All ImageCells are present");
+
+ int numberOfImages = 0;
+
+ // Most of the time, 1 second is long enough to wait for the images to load, but depending on network conditions
+ // it may take longer
+ for (int n = 0; n < 30; n++)
+ {
+ await Task.Delay(1000);
+ numberOfImages = App.Query(q => q.Raw(PlatformViews.Image)).Length;
+ if (numberOfImages > 2)
+ {
+ break;
+ }
+ }
+
+ // Check that there are images present. In Android,
+ // have to make sure that there are more than 2 for navigation.
+ Assert.IsTrue(numberOfImages > 2);
+
+ App.Screenshot("Images are present");
+ }
+
+ [Test]
+ [Description("TableView with ImageCells, all are present")]
+ [UiTest(typeof(TableView))]
+ [UiTest(typeof(ImageCell))]
+ public void CellsGalleryImageCellTable()
+ {
+ App.ScrollForElement("* marked:'ImageCell Table'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("ImageCell Table"));
+ App.WaitForElement(q => q.Marked("Text 1"), "Timeout : Text 1");
+
+ App.Screenshot("At ImageCell Table Gallery");
+
+ App.ScrollForElement("* marked:'Detail 12'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.WaitForElement(q => q.Marked("Detail 12"), "Timeout : Detail 12");
+
+ App.Screenshot("All ImageCells are present");
+
+ var numberOfImages = App.Query(q => q.Raw(PlatformViews.Image)).Length;
+ // Check that there are images present. In Android,
+ // have to make sure that there are more than 2 for navigation.
+ Assert.IsTrue(numberOfImages > 2);
+
+ App.Screenshot("Images are present");
+ }
+
+ [Test]
+ [Description("ListView with SwitchCells, all are present")]
+ [UiTest(typeof(ListView))]
+ [UiTest(typeof(SwitchCell))]
+ public void CellsGallerySwitchCellList()
+ {
+ App.ScrollForElement("* marked:'SwitchCell List'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("SwitchCell List"));
+ App.WaitForElement(q => q.Marked("Label 0"), "Timeout : Label 0");
+
+ App.Screenshot("At SwitchCell List Gallery");
+
+ App.ScrollForElement("* marked:'Label 99'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ var numberOfSwitches = App.Query(q => q.Raw(PlatformViews.Switch)).Length;
+ Assert.IsTrue(numberOfSwitches > 2);
+
+ App.Screenshot("Switches are present");
+ }
+
+ [Test]
+ [Description("TableView with SwitchCells, all are present")]
+ [UiTest(typeof(TableView))]
+ [UiTest(typeof(SwitchCell))]
+ public void CellsGallerySwitchCellTable()
+ {
+ App.ScrollForElement("* marked:'SwitchCell Table'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("SwitchCell Table"));
+ App.WaitForElement(q => q.Marked("text 1"), "Timeout : text 1");
+
+ App.Screenshot("At SwitchCell Table Gallery");
+
+ App.ScrollForElement("* marked:'text 32'", new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ var numberOfSwitches = App.Query(q => q.Raw(PlatformViews.Switch)).Length;
+ Assert.IsTrue(numberOfSwitches > 2);
+
+ App.Screenshot("Switches are present");
+ }
+
+ [Test]
+ [Description("ListView with EntryCells, all are present")]
+ [UiTest(typeof(ListView))]
+ [UiTest(typeof(EntryCell))]
+ public void CellsGalleryEntryCellList()
+ {
+ App.ScrollForElement("* marked:'EntryCell List'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("EntryCell List"));
+ App.WaitForElement(q => q.Marked("Label 0"), "Timeout : Label 0");
+
+ App.Screenshot("At EntryCell List Gallery");
+
+ App.ScrollForElement("* marked:'Label 99'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Screenshot("All EntryCells are present");
+ }
+
+ [Test]
+ [Description("TableView with EntryCells, all are present")]
+ [UiTest(typeof(TableView))]
+ [UiTest(typeof(EntryCell))]
+ public void CellsGalleryEntryCellTable()
+ {
+ App.ScrollForElement("* marked:'EntryCell Table'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("EntryCell Table"));
+ App.WaitForElement(q => q.Marked("Text 2"), "Timeout : Text 2");
+
+ App.Screenshot("At EntryCell Table Gallery");
+
+ App.ScrollForElement("* marked:'Text 32'", new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Screenshot("All EntryCells are present");
+ }
+
+ [Test]
+ [Category("EntryCell")]
+ [Description("EntryCell fires .Completed event")]
+ [UiTest(typeof(EntryCell), "Completed")]
+ public void CellsGalleryEntryCellCompleted()
+ {
+ App.ScrollForElement("* marked:'EntryCell Table'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Tap(q => q.Marked("EntryCell Table"));
+ App.WaitForElement(q => q.Marked("Text 2"), "Timeout : Text 2");
+
+ App.Screenshot("At EntryCell Table Gallery");
+ App.ScrollForElement("* marked:'Enter text'",
+ new Drag(ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium));
+
+ App.Screenshot("Before clicking Entry");
+
+#if !__IOS__
+ App.Tap(PlatformQueries.EntryCellWithPlaceholder("I am a placeholder"));
+ App.EnterText(PlatformQueries.EntryCellWithPlaceholder("I am a placeholder"), "Hi");
+ App.Screenshot("Entered Text");
+ App.PressEnter();
+
+ App.WaitForElement(q => q.Marked("Entered: 1"));
+ App.Screenshot("Completed should have changed label's text");
+
+#endif
+ }
+
+ protected override void TestTearDown()
+ {
+ App.NavigateBack();
+ base.TestTearDown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-UnevenListTests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-UnevenListTests.cs
new file mode 100644
index 00000000..34ca2a9a
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/Legacy-UnevenListTests.cs
@@ -0,0 +1,37 @@
+using NUnit.Framework;
+using Xamarin.UITest;
+using Xamarin.UITest.iOS;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category("Cells")]
+ internal class UnevenListTests : BaseTestFixture
+ {
+ public UnevenListTests()
+ {
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.UnevenListGalleryLegacy);
+ }
+
+ [Test]
+ public void UnevenListCellTest()
+ {
+ if (UnevenListTests.ShouldRunTest(App))
+ {
+ var element = App.Query(q => q.Marked("unevenCellListGalleryDynamic").Descendant(("UITableViewCellContentView")))[0];
+
+ Assert.GreaterOrEqual(element.Rect.Height, 100);
+ }
+ }
+
+ public static bool ShouldRunTest(IApp app)
+ {
+ var appAs = app as iOSApp;
+ return (appAs != null && appAs.Device.IsPhone);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/PickerUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/PickerUITests.cs
new file mode 100644
index 00000000..9628c4a0
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/PickerUITests.cs
@@ -0,0 +1,42 @@
+using NUnit.Framework;
+
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Picker)]
+ internal class PickerUITests : _ViewUITests
+ {
+ public PickerUITests ()
+ {
+ PlatformViewType = Views.Picker;
+ }
+
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.PickerGallery);
+ }
+
+ // TODO
+ public override void _Focus () {}
+
+ [UiTestExempt (ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers () {}
+
+ // TODO
+ public override void _IsFocused () {}
+
+ // TODO
+ public override void _UnFocus () {}
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown ()
+ {
+ App.NavigateBack ();
+ base.FixtureTeardown ();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ProgressBarUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ProgressBarUITests.cs
new file mode 100644
index 00000000..63eceb60
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ProgressBarUITests.cs
@@ -0,0 +1,54 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.ProgressBar)]
+ internal class ProgressBarUITests : _ViewUITests
+ {
+ public ProgressBarUITests()
+ {
+ PlatformViewType = Views.ProgressBar;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.ProgressBarGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsEnabled()
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/RootGalleryUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/RootGalleryUITests.cs
new file mode 100644
index 00000000..b55fc23e
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/RootGalleryUITests.cs
@@ -0,0 +1,93 @@
+using NUnit.Framework;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ internal sealed class RootPageModel
+ {
+ public string ButtonId { get; private set; }
+
+ public string PageId { get; private set; }
+
+ public bool IsModal { get; private set; }
+
+ public RootPageModel(string buttonId, string pageId, bool isModal = false)
+ {
+ ButtonId = buttonId;
+ PageId = pageId;
+ IsModal = isModal;
+ }
+ }
+
+ [TestFixture]
+ [Category(UITestCategories.RootGallery)]
+ internal class RootGalleryUITests : BaseTestFixture
+ {
+ readonly IEnumerable<RootPageModel> rootPages;
+
+ public RootGalleryUITests()
+ {
+ string[] ids =
+ {
+ "Content",
+ "Nav->Content",
+ "MDP->Nav->Content",
+ "Tab->Content",
+ "Tab->MDP->Nav->Content",
+ "Tab->Nav->Content",
+ "Tab(Many)->Nav->Content",
+ "Nav->Tab->Content(BAD IDEA)",
+ "Nav->Tab(Many)->Content(BAD IDEA)",
+ "MDP->Nav->Tab->Content(BAD IDEA)"
+ };
+ string[] modalIds =
+ {
+ "(Modal)Content",
+ "(Modal)Nav->Content",
+ "(Modal)MDP->Nav->Content",
+ "(Modal)Tab->Content",
+ "(Modal)Tab->MDP->Nav->Content",
+ "(Modal)Tab->Nav->Content",
+ "(Modal)Tab(Many)->Nav->Content",
+ "(Modal)Nav->Tab->Content(BAD IDEA)",
+ "(Modal)Nav->Tab(Many)->Content(BAD IDEA)",
+ "(Modal)MDP->Nav->Tab->Content(BAD IDEA)",
+ };
+
+ rootPages =
+ (from id in ids
+ select new RootPageModel(id + "ButtonId", id + "PageId")).Union(
+ from id in modalIds
+ select new RootPageModel(id + "ButtonId", id + "PageId", true));
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.RootPagesGallery);
+ }
+
+ [Test]
+ [Ignore("Ignore while we dont't have a response from XTC team why this fails some times")]
+ public void VisitEachPage()
+ {
+ foreach (var page in rootPages)
+ {
+ 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));
+
+ bool ios = false;
+#if __IOS__
+ ios = true;
+#endif
+
+ if (!page.IsModal || ios)
+ App.WaitForElement(q => q.Marked(page.PageId));
+
+ App.Screenshot("Page: " + page.PageId);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ScrollViewUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ScrollViewUITests.cs
new file mode 100644
index 00000000..fa057636
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ScrollViewUITests.cs
@@ -0,0 +1,67 @@
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.ScrollView)]
+ internal class ScrollViewGalleryTests : BaseTestFixture
+ {
+ public ScrollViewGalleryTests ()
+ {
+ }
+
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.ScrollViewGallery);
+ }
+
+ [Test]
+ [Description ("Scroll element to the start")]
+ public void ScrollToElement1Start ()
+ {
+ //var scroller = App.Query (c => c.Marked ("thescroller"))[0];
+ //need to extract the contentOffset on iOS
+ App.Tap(c=> c.Marked("Start"));
+ App.WaitForElement (c => c.Marked ("the scrollto button"));
+ //Assert.Equals (App.Query (c => c.Marked ("the before")).Length, 0);
+ App.Screenshot ("Element is on the top");
+ }
+
+ [Test]
+ [Description ("Scroll element to the center")]
+ public void ScrollToElement2Center ()
+ {
+ App.Tap(c=> c.Marked("Center"));
+ App.WaitForElement (c => c.Marked ("the scrollto button"));
+ App.WaitForElement (c => c.Marked ("the before"));
+ App.WaitForElement (c => c.Marked ("the after"));
+ App.Screenshot ("Element is in the center");
+ }
+
+ [Test]
+ [Description ("Scroll element to the end")]
+ public void ScrollToElement3End ()
+ {
+ App.Tap(c=> c.Marked("End"));
+ App.WaitForElement (c => c.Marked ("the scrollto button"));
+ //Assert.Equals (App.Query (c => c.Marked ("the after")).Length, 0);
+ App.Screenshot ("Element is in the end");
+ }
+
+ [Test]
+ [Description ("ScrollTo Y = 100")]
+ public void ScrollToY ()
+ {
+ App.Tap(c=> c.Marked("Scroll to 100"));
+ }
+
+ [Test]
+ [Description ("ScrollTo Y = 100 no animation")]
+ public void ScrollToYNoAnim ()
+ {
+ App.ScrollDown ();
+ App.ScrollDown ();
+ App.Tap (c => c.Marked ("Scroll to 100 no anim"));
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/SearchBarUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/SearchBarUITests.cs
new file mode 100644
index 00000000..2b25d275
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/SearchBarUITests.cs
@@ -0,0 +1,40 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.SearchBar)]
+ internal class SearchBarUITests : _ViewUITests
+ {
+ public SearchBarUITests ()
+ {
+ PlatformViewType = Views.SearchBar;
+ }
+
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.SearchBarGallery);
+ }
+
+ // TODO
+ public override void _Focus () {}
+
+ [UiTestExempt (ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers () {}
+
+ // TODO
+ public override void _IsFocused () {}
+
+ // TODO
+ public override void _UnFocus () {}
+
+ // TODO
+ // Implement control specific ui tests
+ protected override void FixtureTeardown ()
+ {
+ App.NavigateBack ();
+ base.FixtureTeardown ();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/SliderUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/SliderUITests.cs
new file mode 100644
index 00000000..eceed80b
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/SliderUITests.cs
@@ -0,0 +1,48 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Slider)]
+ internal class SliderUITests : _ViewUITests
+ {
+ public SliderUITests()
+ {
+ PlatformViewType = Views.Slider;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.SliderGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/StepperUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/StepperUITests.cs
new file mode 100644
index 00000000..1aa69af8
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/StepperUITests.cs
@@ -0,0 +1,48 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Stepper)]
+ internal class StepperUITests : _ViewUITests
+ {
+ public StepperUITests()
+ {
+ PlatformViewType = Views.Stepper;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.StepperGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/SwitchUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/SwitchUITests.cs
new file mode 100644
index 00000000..f2e1fe25
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/SwitchUITests.cs
@@ -0,0 +1,48 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.Switch)]
+ internal class SwitchUITests : _ViewUITests
+ {
+ public SwitchUITests()
+ {
+ PlatformViewType = Views.Switch;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.SwitchGallery);
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/TimePickerUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/TimePickerUITests.cs
new file mode 100644
index 00000000..db093dc8
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/TimePickerUITests.cs
@@ -0,0 +1,51 @@
+using System.Threading;
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.TimePicker)]
+ internal class TimePickerUITests : _ViewUITests
+ {
+ public TimePickerUITests()
+ {
+ PlatformViewType = Views.TimePicker;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.TimePickerGallery);
+
+ Thread.Sleep(4000);
+ }
+
+ // TODO
+ public override void _Focus()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers()
+ {
+ }
+
+ // TODO
+ public override void _IsFocused()
+ {
+ }
+
+ // TODO
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs
new file mode 100644
index 00000000..0231ca57
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ToolbarItemTests.cs
@@ -0,0 +1,151 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+using Xamarin.UITest.Queries;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.ToolbarItem)]
+ internal class ToolbarItemTests : BaseTestFixture
+ {
+ string btn1Id = "tb1";
+ string btn4Id = "tb4";
+#if __ANDROID__
+ static bool isSecondaryMenuOpen = false;
+#endif
+ static void ShouldShowMenu()
+ {
+#if __ANDROID__
+ isSecondaryMenuOpen = true;
+ //show secondary menu
+ App.Tap(c => c.Class("android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton"));
+#endif
+ }
+
+ static void ShouldHideMenu()
+ {
+#if __ANDROID__
+ if (isSecondaryMenuOpen)
+ {
+ isSecondaryMenuOpen = false;
+ App.Back();
+ }
+#endif
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.ToolbarItemGallery);
+#if __IOS__
+ btn1Id = "menuIcon";
+ btn4Id = "tb4";
+#endif
+ }
+
+ [Test]
+ public void ToolbarButtonsClick()
+ {
+ ShouldHideMenu();
+#if __MACOS__
+ App.Tap(c => c.Button().Index(4));
+#else
+ App.Tap(c => c.Marked(btn1Id));
+#endif
+ var textLabel = App.Query((arg) => arg.Marked("label_id"))[0];
+ Assert.False(textLabel.Text == "tb1");
+ Assert.True(textLabel.Text == "Hello ContentPage");
+ }
+
+ [Test]
+ public void ToolbarButtonsCommand()
+ {
+ ShouldShowMenu();
+#if __ANDROID__
+ //App.Query (c => c.Marked (btn4Id))[0];
+#else
+ App.Tap(c => c.Marked(btn4Id));
+ var textLabel = App.Query((arg) => arg.Marked("label_id"))[0];
+ Assert.False(textLabel.Text == "tb4");
+#if __MACOS__
+ App.Tap(c => c.Button().Index(6));
+#else
+ App.Tap(c => c.Marked("tb3"));
+#endif
+ App.Tap(c => c.Marked(btn4Id));
+ textLabel = App.Query((arg) => arg.Marked("label_id"))[0];
+ Assert.IsTrue(textLabel.Text == "tb4");
+#if __MACOS__
+ App.Tap(c => c.Button().Index(6));
+#else
+ App.Tap(c => c.Marked("tb3"));
+#endif
+#endif
+ }
+
+ [Test]
+ public void ToolbarButtonsDisable()
+ {
+ ShouldHideMenu();
+#if __MACOS__
+ var result = App.Query(c => c.Button());
+ var btn1 = result[4];
+ var btn2 = App.Query(c => c.Marked(btn4Id))[0];
+ Assert.False(btn2.Enabled, "Toolbar Item should be disable");
+#else
+ var btn1 = App.Query(c => c.Marked(btn1Id))[0];
+ ShouldShowMenu();
+ //var btn2 = App.Query (c => c.Marked (btn4Id)) [0];
+ //TODO: how to check Enable for the textview
+ //Assert.False (btn2.Enabled, "Toolbar Item should be disable");
+#endif
+ Assert.False(btn1.Enabled, "Toolbar Item should be disable");
+ }
+
+ [Test]
+ public void ToolbarButtonsExist()
+ {
+ ShouldHideMenu();
+#if __MACOS__
+ var existsPrimary = App.Query(c => c.Button())[4];
+ Assert.True(existsPrimary != null, "Toolbar Item 1 no name, not found");
+#else
+ var existsPrimary = App.Query(c => c.Marked(btn1Id)).Length;
+ Assert.True(existsPrimary > 0, "Toolbar Item 1 no name, not found");
+#endif
+ var existsPrimary2 = App.Query(c => c.Marked("tb2")).Length;
+ Assert.True(existsPrimary2 > 0, "Toolbar Item 2, not found");
+ ShouldShowMenu();
+
+#if __MACOS__
+ var existsSecondary = App.Query(c => c.Button())[7];
+ Assert.True(existsSecondary != null, "Toolbar Item 3 no name, not found");
+#else
+ var existsSecondary = App.Query(c => c.Marked("tb3")).Length;
+ Assert.True(existsSecondary > 0, "Toolbar Item 1 no name, not found");
+#endif
+ var existsSecondary2 = App.Query(c => c.Marked(btn4Id)).Length;
+ Assert.True(existsSecondary2 > 0, "Toolbar Item 4, not found");
+ }
+
+ [Test]
+ public void ToolbarButtonsOrder()
+ {
+ ShouldHideMenu();
+#if __MACOS__
+ var btn1 = App.Query(c => c.Button())[4];
+#else
+ var btn1 = App.Query(c => c.Marked(btn1Id))[0];
+#endif
+ ShouldShowMenu();
+ var btn2 = App.Query(c => c.Marked("tb4"))[0];
+#if __IOS__
+ Assert.True(btn1.Rect.CenterY < btn2.Rect.CenterY);
+#elif __MACOS__
+ Assert.True(btn1.Rect.CenterX < btn2.Rect.CenterX);
+#endif
+ }
+
+ }
+}
+
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/ViewUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/ViewUITests.cs
new file mode 100644
index 00000000..9029f2aa
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/ViewUITests.cs
@@ -0,0 +1,247 @@
+using System;
+using System.Diagnostics;
+using System.Linq;
+using System.Net.Configuration;
+
+using NUnit.Framework;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.UITest.Android;
+using Xamarin.UITest.iOS;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [Category("ViewBaseTests")]
+ internal abstract class _ViewUITests : BaseTestFixture
+ {
+ /* Under score prefixes ensure inherited properties run first in test suite */
+ //[Test]
+ //[Category ("View")]
+ //[UiTestBroken (BrokenReason.UITestBug, "Issue #115 - when trying to get anchorPoint, iOS")]
+ //[UiTest (Test.VisualElement.AnchorX)]
+ public virtual void _AnchorX ()
+ {
+
+ }
+
+ // [Test]
+ // [UiTest (Test.VisualElement.AnchorY)]
+ // TODO: working on some views, others not
+ public virtual void _AnchorY ()
+ {
+
+ }
+
+ // [Test]
+ // [UiTest (Test.VisualElement.BackgroundColor)]
+ // [UiTestBroken (BrokenReason.UITestBug, "UITest Issue #107")]
+ public virtual void _BackgroundColor ()
+ {
+ //TODO: this was failing and is changing in next version of calabash (UI-Test-pre nuget) to a json rgb
+// var remote = RemoteFactory.CreateRemote<ViewContainerRemote> (App, "BackgroundColor", PlatformViewType);
+// remote.GoTo ();
+// if (App is iOSApp) {
+// var backgroundColor = remote.GetProperty<Color> (View.BackgroundColorProperty);
+// Assert.AreEqual (Color.Blue, backgroundColor);
+// }
+
+ }
+
+ [Test]
+ [UiTest (typeof(VisualElement), "Focus")]
+ public abstract void _Focus ();
+
+ [Test]
+ [UiTest (typeof (VisualElement), "GestureRecognizers")]
+ public abstract void _GestureRecognizers ();
+
+ //[Test]
+ [UiTest (typeof (VisualElement), "InputTransparent")]
+ public virtual void _InputTransparent ()
+ {
+ //var remote = new LayeredViewContainerRemote (App, Test.VisualElement.InputTransparent, PlatformViewType);
+ //remote.GoTo ();
+
+ //var hiddenButtonClickedLabelTextPre = remote.GetLayeredLabel ().Text;
+ //Assert.AreEqual ("Hidden Button (Not Clicked)", hiddenButtonClickedLabelTextPre);
+
+ //remote.TapHiddenButton ();
+
+ //var hiddenButtonClickedLabelTextPost = remote.GetLayeredLabel ().Text;
+ //var hiddenButtonClicked = hiddenButtonClickedLabelTextPost == "Hidden Button (Clicked)";
+
+ //// Allow tests to continue by dismissing DatePicker that should not show
+ //// Remove when InputTransparency works
+ //if (!hiddenButtonClicked && PlatformViewType == PlatformViews.DatePicker)
+ // remote.DismissPopOver ();
+
+ //Assert.True (hiddenButtonClicked);
+ }
+
+ [Test]
+ [UiTest (typeof (VisualElement), "IsEnabled")]
+ public virtual void _IsEnabled ()
+ {
+ //var propName = Test.VisualElement.IsEnabled.ToString ();
+ var remote = new StateViewContainerRemote (App, Test.VisualElement.IsEnabled, PlatformViewType);
+ remote.GoTo ();
+
+ var enabled = remote.GetProperty<bool> (View.IsEnabledProperty);
+ Assert.IsTrue (enabled);
+
+ remote.TapStateButton ();
+
+ enabled = remote.GetProperty<bool> (View.IsEnabledProperty);
+ Assert.IsFalse (enabled);
+
+ remote.TapStateButton ();
+
+ var isEnabled = remote.GetStateLabel ().Text;
+ Assert.AreEqual ("True", isEnabled);
+
+ remote.TapStateButton ();
+
+ var isDisabled = remote.GetStateLabel ().Text;
+ Assert.AreEqual ("False", isDisabled);
+ }
+
+ [Test]
+ [UiTest (typeof (VisualElement), "IsFocused")]
+ public abstract void _IsFocused ();
+
+ [Test]
+ [UiTest (typeof (VisualElement), "IsVisible")]
+ public virtual void _IsVisible ()
+ {
+ var remote = new StateViewContainerRemote (App, Test.VisualElement.IsVisible, PlatformViewType);
+ remote.GoTo ();
+
+ var viewPre = remote.GetViews ();
+
+#if __MACOS__
+ Assert.GreaterOrEqual(viewPre.Length, 1);
+#else
+ Assert.AreEqual (1, viewPre.Length);
+#endif
+
+ remote.TapStateButton ();
+
+ var viewPost = remote.GetViews ();
+
+ Assert.AreEqual (0, viewPost.Length);
+ }
+
+ [UiTestExemptAttribute (ExemptReason.None, "Not sure how to test at the moment")]
+ public virtual void _Layout (){}
+
+ [UiTestExemptAttribute (ExemptReason.None, "Not sure how to test at the moment")]
+ public virtual void _Navigation () {}
+
+ [Test]
+ [UiTest (typeof (VisualElement), "Opacity")]
+ public virtual void _Opacity ()
+ {
+ var remote = new ViewContainerRemote(App, Test.VisualElement.Opacity, PlatformViewType);
+ remote.GoTo();
+#if __MACOS__
+ Assert.Inconclusive("needs testing");
+#else
+ float opacity = -1f;
+ opacity = remote.GetProperty<float> (View.OpacityProperty);
+ Assert.AreEqual (0.5f, opacity);
+#endif
+ }
+
+ [Test]
+ [UiTest (typeof(VisualElement), "Rotation")]
+ [UiTestBroken (BrokenReason.CalabashBug, "Calabash bug")]
+ public virtual void _Rotation ()
+ {
+ var remote = new ViewContainerRemote (App, Test.VisualElement.Rotation, PlatformViewType);
+ remote.GoTo ();
+
+#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")]
+ public virtual void _RotationX ()
+ {
+ var remote = new ViewContainerRemote (App, Test.VisualElement.RotationX, PlatformViewType);
+ remote.GoTo ();
+
+#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]
+ [UiTest (typeof (VisualElement), "RotationY")]
+ public virtual void _RotationY ()
+ {
+ var remote = new ViewContainerRemote (App, Test.VisualElement.RotationY, PlatformViewType);
+ remote.GoTo ();
+
+#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]
+ [UiTest (typeof (VisualElement), "Scale")]
+ public virtual void _Scale ()
+ {
+ var remote = new ViewContainerRemote(App, Test.VisualElement.Scale, PlatformViewType);
+ remote.GoTo();
+#if __MACOS__
+ Assert.Inconclusive("needs testing");
+#else
+ var scaleMatrix = remote.GetProperty<Matrix>(View.ScaleProperty);
+ Matrix generatedMatrix = NumericExtensions.BuildScaleMatrix(0.5f);
+ Assert.AreEqual(generatedMatrix, scaleMatrix);
+#endif
+ }
+
+ [Test]
+ [UiTest (typeof (VisualElement), "TranslationX")]
+ [Category(UITestCategories.ManualReview)]
+ public virtual void _TranslationX ()
+ {
+ var remote = new ViewContainerRemote (App, Test.VisualElement.TranslationX, PlatformViewType);
+ remote.GoTo ();
+ }
+
+ [Test]
+ [UiTest (typeof (VisualElement), "TranslationY")]
+ [Category(UITestCategories.ManualReview)]
+ public virtual void _TranslationY ()
+ {
+ var remote = new ViewContainerRemote (App, Test.VisualElement.TranslationY, PlatformViewType);
+ remote.GoTo ();
+ }
+
+ [Test]
+ [UiTest (typeof (VisualElement), "Unfocus")]
+ public abstract void _UnFocus ();
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core.UITests.Shared/Tests/WebViewUITests.cs b/Xamarin.Forms.Core.UITests.Shared/Tests/WebViewUITests.cs
new file mode 100644
index 00000000..08ff5146
--- /dev/null
+++ b/Xamarin.Forms.Core.UITests.Shared/Tests/WebViewUITests.cs
@@ -0,0 +1,111 @@
+using NUnit.Framework;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category(UITestCategories.WebView)]
+ internal class WebViewUITests : _ViewUITests
+ {
+ public WebViewUITests()
+ {
+ PlatformViewType = Views.WebView;
+ }
+
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.WebViewGallery);
+ }
+
+ [Category(UITestCategories.ManualReview)]
+ public override void _IsEnabled()
+ {
+ Assert.Inconclusive("Does not make sense for WebView");
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _IsVisible()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction with Label")]
+ public override void _Focus()
+ {
+ }
+
+ // TODO
+ public override void _GestureRecognizers()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction with Label")]
+ public override void _IsFocused()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _Opacity()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _Rotation()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _RotationX()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _RotationY()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _TranslationX()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _TranslationY()
+ {
+ }
+
+ [Test]
+ [Category(UITestCategories.ManualReview)]
+ [Ignore("Keep empty test from failing in Test Cloud")]
+ public override void _Scale()
+ {
+ }
+
+ [UiTestExempt(ExemptReason.CannotTest, "Invalid interaction with Label")]
+ public override void _UnFocus()
+ {
+ }
+
+ // TODO
+ // Implement control specific ui tests
+
+ protected override void FixtureTeardown()
+ {
+ App.NavigateBack();
+ base.FixtureTeardown();
+ }
+ }
+} \ No newline at end of file