From 17fdde66d94155fc62a034fa6658995bef6fd6e5 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 22 Mar 2016 13:02:25 -0700 Subject: Initial import --- Xamarin.Forms.Core.iOS.UITests/App.cs | 27 ++ Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs | 76 ++++ Xamarin.Forms.Core.iOS.UITests/Makefile | 2 + Xamarin.Forms.Core.iOS.UITests/PlatformQueries.cs | 136 +++++++ .../Properties/AssemblyInfo.cs | 40 ++ Xamarin.Forms.Core.iOS.UITests/Queries.cs | 165 +++++++++ .../Remotes/BaseViewContainerRemote.cs | 315 ++++++++++++++++ .../Remotes/EventViewContainerRemote.cs | 20 + .../Remotes/LayeredViewContainerRemote.cs | 25 ++ .../Remotes/RemoteFactory.cs | 56 +++ .../Remotes/StateViewContainerRemote.cs | 35 ++ .../Remotes/ViewContainerRemote.cs | 13 + .../Tests/ActionSheetUITests.cs | 171 +++++++++ .../Tests/ActivityIndicatorUITests.cs | 76 ++++ .../Tests/AppearingUITests.cs | 64 ++++ .../Tests/AutomationIDUITests.cs | 73 ++++ .../Tests/BoxViewUITests.cs | 57 +++ .../Tests/ButtonUITests.cs | 178 +++++++++ .../Tests/ContextActionsUITests.cs | 129 +++++++ .../Tests/DatePickerUITests.cs | 55 +++ .../Tests/DisplayAlertUITests.cs | 85 +++++ .../Tests/EditorUITests.cs | 55 +++ .../Tests/EntryUITests.cs | 73 ++++ .../Tests/FrameUITests.cs | 57 +++ .../Tests/ImageUITests.cs | 63 ++++ .../Tests/LabelUITests.cs | 57 +++ .../Tests/Legacy-AbsoluteLayoutGalleryTest.cs | 229 ++++++++++++ .../Tests/Legacy-BoundViewUITest.cs | 96 +++++ .../Tests/Legacy-ButtonUITests.cs | 98 +++++ .../Tests/Legacy-CarouselPageUITests.cs | 63 ++++ .../Tests/Legacy-CellsUITests.cs | 318 ++++++++++++++++ .../Tests/Legacy-ClipToBoundsUITests.cs | 73 ++++ .../Tests/Legacy-EditorUITests.cs | 269 ++++++++++++++ .../Tests/Legacy-EntryUITests.cs | 301 +++++++++++++++ .../Tests/Legacy-GridGalleryUITests.cs | 132 +++++++ .../Tests/Legacy-GroupedListActionsUITests.cs | 277 ++++++++++++++ .../Tests/Legacy-InputIntentUITests.cs | 190 ++++++++++ .../Tests/Legacy-ListUITests.cs | 92 +++++ .../Tests/Legacy-MapUITests.cs | 110 ++++++ .../Tests/Legacy-MinimumSizeUITest.cs | 48 +++ .../Tests/Legacy-NavigationBarUITests.cs | 57 +++ .../Tests/Legacy-RelativeLayoutUITest.cs | 49 +++ .../Tests/Legacy-SearchBarUITests.cs | 163 +++++++++ .../Tests/Legacy-SliderUITests.cs | 94 +++++ .../Tests/Legacy-StackLayoutUITest.cs | 76 ++++ .../Tests/Legacy-StepperUITests.cs | 93 +++++ .../Tests/Legacy-SwitchUITests.cs | 104 ++++++ .../Tests/Legacy-TableViewUITests.cs | 76 ++++ .../Tests/Legacy-TemplatedCarouselPageUITests.cs | 407 +++++++++++++++++++++ .../Tests/Legacy-TemplatedTabPageUITests.cs | 346 ++++++++++++++++++ .../Tests/Legacy-ToolbarGalleryUITests.cs | 51 +++ .../Tests/Legacy-UnevenListTests.cs | 38 ++ .../Tests/Legacy-UnevenViewCellUITests.cs | 94 +++++ .../Tests/Legacy-ViewCellUITests.cs | 66 ++++ .../Tests/PickerUITests.cs | 54 +++ .../Tests/ProgressBarUITests.cs | 56 +++ .../Tests/RootGalleryUITests.cs | 88 +++++ .../Tests/ScrollViewUITests.cs | 68 ++++ .../Tests/SearchBarUITests.cs | 54 +++ .../Tests/SliderUITests.cs | 54 +++ .../Tests/StepperUITests.cs | 54 +++ .../Tests/SwitchUITests.cs | 54 +++ .../Tests/TimePickerUITests.cs | 56 +++ .../Tests/ToolbarItemTests.cs | 102 ++++++ .../Tests/ViewUITests.cs | 257 +++++++++++++ .../Tests/WebViewUITests.cs | 93 +++++ .../Utilities/AppExtensions.cs | 116 ++++++ Xamarin.Forms.Core.iOS.UITests/Utilities/Drag.cs | 173 +++++++++ .../Utilities/Gestures.cs | 114 ++++++ Xamarin.Forms.Core.iOS.UITests/Utilities/Logger.cs | 71 ++++ .../Utilities/NumericExtensions.cs | 126 +++++++ .../Utilities/ParsingUtils.cs | 89 +++++ .../Utilities/UITestCustomExceptions.cs | 101 +++++ .../Utilities/ViewInspector.cs | 342 +++++++++++++++++ .../Xamarin.Forms.Core.iOS.UITests.csproj | 175 +++++++++ Xamarin.Forms.Core.iOS.UITests/packages.config | 5 + 76 files changed, 8415 insertions(+) create mode 100644 Xamarin.Forms.Core.iOS.UITests/App.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Makefile create mode 100644 Xamarin.Forms.Core.iOS.UITests/PlatformQueries.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Properties/AssemblyInfo.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Queries.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Remotes/BaseViewContainerRemote.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Remotes/EventViewContainerRemote.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Remotes/LayeredViewContainerRemote.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Remotes/RemoteFactory.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Remotes/StateViewContainerRemote.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Remotes/ViewContainerRemote.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ActionSheetUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ActivityIndicatorUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/AutomationIDUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/BoxViewUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/DatePickerUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/DisplayAlertUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/EditorUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/FrameUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ImageUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/LabelUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-AbsoluteLayoutGalleryTest.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-BoundViewUITest.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ButtonUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CarouselPageUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ClipToBoundsUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EditorUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EntryUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GridGalleryUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GroupedListActionsUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-InputIntentUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ListUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MapUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MinimumSizeUITest.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-NavigationBarUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-RelativeLayoutUITest.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SearchBarUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SliderUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StackLayoutUITest.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StepperUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SwitchUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TableViewUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedCarouselPageUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedTabPageUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ToolbarGalleryUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenViewCellUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ViewCellUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/PickerUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ProgressBarUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ScrollViewUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/SearchBarUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/SliderUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/StepperUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/SwitchUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/TimePickerUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/Drag.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/Gestures.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/Logger.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/NumericExtensions.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/ParsingUtils.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/UITestCustomExceptions.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Utilities/ViewInspector.cs create mode 100644 Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj create mode 100644 Xamarin.Forms.Core.iOS.UITests/packages.config (limited to 'Xamarin.Forms.Core.iOS.UITests') diff --git a/Xamarin.Forms.Core.iOS.UITests/App.cs b/Xamarin.Forms.Core.iOS.UITests/App.cs new file mode 100644 index 00000000..845bb9a5 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/App.cs @@ -0,0 +1,27 @@ +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.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class RunningApp + { + public static iOSApp App; + + public static void Restart () + { + App = ConfigureApp + .iOS + .Debug () + .InstalledApp ("com.xamarin.quickui.controlgallery") + .StartApp (Xamarin.UITest.Configuration.AppDataMode.Clear); + } + } +} \ No newline at end of file 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 (); + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Makefile b/Xamarin.Forms.Core.iOS.UITests/Makefile new file mode 100644 index 00000000..242ff29b --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Makefile @@ -0,0 +1,2 @@ +console: + DEBUG=1 DEVICE_TARGET=device DEVICE_ENDPOINT=http://10.0.1.159:37265 calabash-ios console diff --git a/Xamarin.Forms.Core.iOS.UITests/PlatformQueries.cs b/Xamarin.Forms.Core.iOS.UITests/PlatformQueries.cs new file mode 100644 index 00000000..4ae2515c --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/PlatformQueries.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.UITest.iOS; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class iOSLoaderIdentifier + { + + } + + internal static class PlatformMethodQueries + { + public static readonly Dictionary> PropertyPlatformMethodDictionary = new Dictionary> { + { ActivityIndicator.ColorProperty, Tuple.Create (new[] { "color" }, false) }, + { ActivityIndicator.IsRunningProperty, Tuple.Create (new[] { "isAnimating" }, false) }, + { Button.BorderRadiusProperty, Tuple.Create (new[] { "layer", "cornerRadius" }, false) }, + { Button.BorderWidthProperty, Tuple.Create (new[] { "layer", "borderWidth" }, false) }, + { Button.FontProperty, Tuple.Create (new[] { "titleLabel", "font" }, false) }, + { Button.TextProperty, Tuple.Create (new[] { "titleLabel", "text" }, false) }, + { Button.TextColorProperty, Tuple.Create (new[] { "titleLabel", "textColor" }, false) }, + { View.AnchorXProperty, Tuple.Create (new[] { "layer", "transform" }, true) }, + { View.AnchorYProperty, Tuple.Create (new[] { "layer", "transform" }, true) }, + { View.BackgroundColorProperty, Tuple.Create (new[] { "backgroundColor" }, false) }, + { View.IsEnabledProperty, Tuple.Create (new[] { "isEnabled" }, false) }, + { View.OpacityProperty, Tuple.Create (new [] { "alpha" }, true) }, + { View.RotationProperty, Tuple.Create (new[] { "layer", "transform" }, true) }, + { View.RotationXProperty, Tuple.Create (new[] { "layer", "transform" }, true) }, + { View.RotationYProperty, Tuple.Create (new[] { "layer", "transform" }, true) }, + { View.ScaleProperty, Tuple.Create (new[] { "layer", "transform" }, true) }, + }; + } + + internal static class PlatformViews + { + public static readonly string ActivityIndicator = "UIActivityIndicatorView"; + public static readonly string BoxView = "Xamarin_Forms_Platform_iOS_BoxRenderer"; + public static readonly string Button = "UIButton"; + public static readonly string DatePicker = "UITextField"; + public static readonly string Editor = "UITextView"; + public static readonly string Entry = "UITextField"; + public static readonly string Frame = "view:'Xamarin_Forms_Platform_iOS_FrameRenderer'"; + public static readonly string Image = "UIImageView"; + public static readonly string Label = "UILabel"; + public static readonly string ListView = "UITableView"; + public static readonly string OpenGLView = "GLKView"; + public static readonly string Picker = "UITextField"; + public static readonly string ProgressBar = "UIProgressView"; + public static readonly string SearchBar = "UISearchBar"; + public static readonly string Slider = "UISlider"; + public static readonly string Stepper = "UIStepper"; + public static readonly string Switch = "UISwitch"; + public static readonly string TableView = "UITableView"; + public static readonly string TimePicker = "UITextField"; + public static readonly string WebView = "UIWebView"; + } + + internal static class PlatformQueries + { + public static readonly Func Root = q => q.Class ("UIWindow"); + public static readonly Func RootPageListView = q => q.Class ("Xamarin_Forms_Platform_iOS_ListViewRenderer index:0"); + public static readonly Func GalleryListView = q => q.Class ("Xamarin_Forms_Platform_iOS_ListViewRenderer index:1"); + public static readonly Func PageWithoutNavigationBar = q => q.Raw ("*").Index (7); + public static readonly Func NavigationBarBackButton = q => q.Class ("UINavigationItemButtonView"); + + // Controls + public static readonly Func ActivityIndicator = q => q.ClassFull (PlatformViews.ActivityIndicator); + public static readonly Func Button = q => q.ClassFull (PlatformViews.Button); + + public static Func EntryWithPlaceholder (string text) { + return q => q.Raw (string.Format ("TextField placeholder:'{0}'", text)); + } + + public static Func EntryWithText (string text) { + return q => q.Raw (string.Format ("TextField text:'{0}'", text)); + } + + public static Func EntryCellWithPlaceholder (string text) { + return q => q.Raw (string.Format ("UITextFieldLabel text:'{0}'", text)); + } + + public static Func EntryCellWithText (string text) { + return q => q.Raw (string.Format ("TextField text:'{0}'", text)); + } + + public static Func EditorsWithText (string text) { + return q => q.Raw (string.Format ("TextView text:'{0}'", text)); + } + + public static Func EntryWithIndex (int index) { + return q => q.Raw (string.Format ("TextField index:{0}", index)); + } + + public static Func SearchBarWithIndex (int index) { + return q => q.Raw (string.Format ("SearchBar index:{0}", index)); + } + + public static Func LabelWithIndex (int index) { + return q => q.Raw (string.Format ("Label index:{0}", index)); + } + + public static Func LabelWithText (string text) { + return q => q.Raw (string.Format ("Label text:'{0}'", text)); + } + + public static Func LabelWithId (string id) { + return q => q.Raw (string.Format ("Label id:'{0}'", id)); + } + + public static Func PickerEntryWithIndex (int index) { + return q => q.Raw (string.Format ("TextField index:{0}", index)); + } + + public static Func PickerEntryWithPlaceholder (string placeholder) { + return q => q.Raw (string.Format ("TextField placeholder:'{0}'", placeholder)); + } + + public static Func PickerEntryWithText (string text) { + return q => q.Raw (string.Format ("TextField text:'{0}'", text)); + } + + public static Func SwitchWithIndex (int index) { + return q => q.Raw (string.Format ("Switch index:{0}", index)); + } + + public static Func StepperWithIndex (int index) { + return q => q.Raw (string.Format ("Stepper index:{0}", index)); + } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Properties/AssemblyInfo.cs b/Xamarin.Forms.Core.iOS.UITests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1246e892 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Properties/AssemblyInfo.cs @@ -0,0 +1,40 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Xamarin.Forms.Core.iOS.UITests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Xamarin.Forms.Core.iOS.UITests")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e3f6d744-9587-4d06-b7eb-5560d847c107")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: InternalsVisibleTo("Xamarin.Forms.Loader")] +[assembly: InternalsVisibleTo("Xamarin.Forms.UITest.Validator")] +[assembly: InternalsVisibleTo("Xamarin.Forms.UITest.TestCloud")] diff --git a/Xamarin.Forms.Core.iOS.UITests/Queries.cs b/Xamarin.Forms.Core.iOS.UITests/Queries.cs new file mode 100644 index 00000000..dbc8ef47 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Queries.cs @@ -0,0 +1,165 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class GalleryQueries + { + public const string AutomationIDGallery = "* marked:'AutomationID Gallery'"; + public const string ActivityIndicatorGallery = "* marked:'ActivityIndicator Gallery'"; + public const string BoxViewGallery = "* marked:'BoxView Gallery'"; + public const string ButtonGallery = "* marked:'Button Gallery'"; + public const string ContextActionsListGallery = "* marked:'ContextActions List Gallery'"; + public const string ContextActionsTableGallery = "* marked:'ContextActions Table Gallery'"; + public const string DatePickerGallery = "* marked:'DatePicker Gallery'"; + public const string EditorGallery = "* marked:'Editor Gallery'"; + public const string EntryGallery = "* marked:'Entry Gallery'"; + public const string FrameGallery = "* marked:'Frame Gallery'"; + public const string ImageGallery = "* marked:'Image Gallery'"; + public const string LabelGallery = "* marked:'Label Gallery'"; + public const string ListViewGallery = "* marked:'ListView Gallery'"; + public const string OpenGLViewGallery = "* marked:'OpenGLView Gallery'"; + public const string PickerGallery = "* marked:'Picker Gallery'"; + public const string ProgressBarGallery = "* marked:'ProgressBar Gallery'"; + public const string ScrollViewGallery = "* marked:'ScrollView Gallery'"; + public const string ScrollViewGalleryHorizontal = "* marked:'ScrollView Gallery Horizontal'"; + public const string SearchBarGallery = "* marked:'SearchBar Gallery'"; + public const string SliderGallery = "* marked:'Slider Gallery'"; + public const string StepperGallery = "* marked:'Stepper Gallery'"; + public const string SwitchGallery = "* marked:'Switch Gallery'"; + public const string TableViewGallery = "* marked:'TableView Gallery'"; + public const string TimePickerGallery = "* marked:'TimePicker Gallery'"; + public const string WebViewGallery = "* marked:'WebView Gallery'"; + public const string ToolbarItemGallery = "* marked:'ToolbarItems Gallery'"; + public const string DisplayAlertGallery = "* marked:'DisplayAlert Gallery'"; + public const string ActionSheetGallery = "* marked:'ActionSheet Gallery'"; + public const string RootPagesGallery = "* marked:'RootPages Gallery'"; + + public const string AppearingGallery = "* marked:'Appearing Gallery'"; + + // Legacy galleries + public const string AbsoluteLayoutGalleryLegacy = "* marked:'AbsoluteLayout Gallery - Legacy'"; + public const string BoundPageGalleryLegacy = "* marked:'BoundPage Gallery - Legacy'"; + public const string ButtonGalleryLegacy = "* marked:'Button Gallery - Legacy'"; + public const string CellsGalleryLegacy = "* marked:'Cells Gallery - Legacy'"; + public const string CarouselPageGalleryLegacy = "* marked:'CarouselPage Gallery - Legacy'"; + public const string ClipToBoundsGalleryLegacy = "* marked:'ClipToBounds Gallery - Legacy'"; + public const string EditorGalleryLegacy = "* marked:'Editor Gallery - Legacy'"; + public const string EntryGalleryLegacy = "* marked:'Entry Gallery - Legacy'"; + public const string GridGalleryLegacy = "* marked:'Grid Gallery - Legacy'"; + public const string GroupedListActionsGalleryLegacy = "* marked:'GroupedListActions Gallery - Legacy'"; + public const string GroupedListGalleryLegacy = "* marked:'GroupedList Gallery - Legacy'"; + public const string InputIntentGalleryLegacy = "* marked:'InputIntent Gallery - Legacy'"; + public const string ListViewGalleryLegacy = "* marked:'ListView Gallery - Legacy'"; + public const string MapGalleryLegacy = "* marked:'Map Gallery - Legacy'"; + public const string MinimumSizeGalleryLegacy = "* marked:'MinimumSize Gallery - Legacy'"; + public const string NavigationBarGalleryLegacy = "* marked:'NavigationBar Gallery - Legacy'"; + public const string RelativeLayoutGalleryLegacy = "* marked:'RelativeLayout Gallery - Legacy'"; + public const string SearchBarGalleryLegacy = "* marked:'SearchBar Gallery - Legacy'"; + public const string SliderGalleryLegacy = "* marked:'Slider Gallery - Legacy'"; + public const string StackLayoutGalleryLegacy = "* marked:'StackLayout Gallery - Legacy'"; + public const string StepperGalleryLegacy = "* marked:'Stepper Gallery - Legacy'"; + public const string SwitchGalleryLegacy = "* marked:'Switch Gallery - Legacy'"; + public const string TableViewGalleryLegacy = "* marked:'TableView Gallery - Legacy'"; + public const string TemplatedCarouselPageGalleryLegacy = "* marked:'TemplatedCarouselPage Gallery - Legacy'"; + public const string TemplatedTabbedPageGalleryLegacy = "* marked:'TemplatedTabbedPage Gallery - Legacy'"; + public const string ToolbarGalleryLegacy = "* marked:'Toolbar Gallery - Legacy'"; + public const string UnevenViewCellGalleryLegacy = "* marked:'UnevenViewCell Gallery - Legacy'"; + public const string UnevenListGalleryLegacy = "* marked:'UnevenList Gallery - Legacy'"; + public const string ViewCellGalleryLegacy = "* marked:'ViewCell Gallery - Legacy'"; + } + + internal static class Queries + { + #region Shared queries + public static Func RootPageListView = PlatformQueries.RootPageListView; + public static Func GalleryListView = PlatformQueries.GalleryListView; + + public static Func ButtonWithText (string text) + { + return q => q.Button (text); + } + + public static Func ElementWithText (string text) + { + return q => q.Marked (text); + } + + public static Func All () + { + return q => q.All (); + } + + #endregion + + #region Platform queries + + public static Func NavigationBarBackButton () + { + return PlatformQueries.NavigationBarBackButton; + } + + public static Func PageWithoutNavigationBar () + { + return PlatformQueries.PageWithoutNavigationBar; + } + + public static Func Root () + { + return PlatformQueries.Root; + } + + public static Func EntryCellWithPlaceholder (string placeholder) + { + return PlatformQueries.EntryCellWithPlaceholder (placeholder); + } + + public static Func EntryCellWithText (string placeholder) + { + return PlatformQueries.EntryCellWithText (placeholder); + } + + #endregion + + } + + internal static class Views + { + public static readonly string ActivityIndicator = PlatformViews.ActivityIndicator; + public static readonly string BoxView = PlatformViews.BoxView; + public static readonly string Button = PlatformViews.Button; + public static readonly string DatePicker = PlatformViews.DatePicker; + public static readonly string Editor = PlatformViews.Editor; + public static readonly string Entry = PlatformViews.Entry; + public static readonly string Frame = PlatformViews.Frame; + public static readonly string Image = PlatformViews.Image; + public static readonly string Label = PlatformViews.Label; + public static readonly string ListView = PlatformViews.ListView; + public static readonly string OpenGLView = PlatformViews.OpenGLView; + public static readonly string Picker = PlatformViews.Picker; + public static readonly string ProgressBar = PlatformViews.ProgressBar; + public static readonly string SearchBar = PlatformViews.SearchBar; + public static readonly string Slider = PlatformViews.Slider; + public static readonly string Stepper = PlatformViews.Stepper; + public static readonly string Switch = PlatformViews.Switch; + public static readonly string TableView = PlatformViews.TableView; + public static readonly string TimePicker = PlatformViews.TimePicker; + public static readonly string WebView = PlatformViews.WebView; + } + + internal static class Rects + { + public static AppRect RootViewRect (this IApp app) + { + return app.Query (q => q.Raw ("* index:0"))[0].Rect; + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Remotes/BaseViewContainerRemote.cs b/Xamarin.Forms.Core.iOS.UITests/Remotes/BaseViewContainerRemote.cs new file mode 100644 index 00000000..f51782ce --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Remotes/BaseViewContainerRemote.cs @@ -0,0 +1,315 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.Remoting.Messaging; +using System.Security.Permissions; + +using NUnit.Framework; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; +using System.Globalization; + + +namespace Xamarin.Forms.Core.UITests +{ + internal abstract class BaseViewContainerRemote + { + bool requiresDismissal; + + protected IApp App { get; private set; } + + public string ViewQuery { get; private set; } + + public string PlatformViewType { get; set; } + + public string ContainerQuery { get; private set; } + public string ContainerDescendents { get; private set; } + + public string EventLabelQuery { get; set; } + + public string StateLabelQuery { get; private set; } + public string StateButtonQuery { get; private set; } + + public string LayeredHiddenButtonQuery { get; private set; } + public string LayeredLabelQuery { get; private set; } + + protected BaseViewContainerRemote (IApp app, Enum formsType, string platformViewType) + { + App = app; + PlatformViewType = platformViewType; + + // Currently tests are failing because the ViewInitilized is setting the renderer and control, fix and then remove index one + + ContainerQuery = string.Format("* marked:'{0}Container'", formsType); + ContainerDescendents = string.Format("* marked:'{0}Container' child *", formsType); + + ViewQuery = string.Format ("* marked:'{0}VisualElement'", formsType); + + EventLabelQuery = string.Format ("* marked:'{0}EventLabel'", formsType); + StateLabelQuery = string.Format ("* marked:'{0}StateLabel'", formsType); + StateButtonQuery = string.Format ("* marked:'{0}StateButton'", formsType); + LayeredHiddenButtonQuery = string.Format ("* marked:'{0}LayeredHiddenButton'", formsType); + LayeredLabelQuery = string.Format ("* marked:'{0}LayeredLabel'", formsType); + + if (platformViewType == PlatformViews.DatePicker) { + requiresDismissal = true; + } + } + + public virtual void GoTo ([CallerMemberName] string callerMemberName = "") + { + var scrollBounds = App.Query (Queries.PageWithoutNavigationBar ()).First ().Rect; + + // Scroll using gutter to the right of view, avoid scrolling inside of WebView + if (PlatformViewType == PlatformViews.WebView) { + scrollBounds = new AppRect { + X = scrollBounds.Width - 20, + CenterX = scrollBounds.Width - 10, + Y = scrollBounds.Y, + CenterY = scrollBounds.CenterY, + Width = 20, + Height = scrollBounds.Height, + }; + } + + + while (true) { + var result = App.Query (o => o.Raw(ContainerQuery)); + if (result.Any ()) + break; + App.Tap (o => o.Raw ("* marked:'MoveNextButton'")); + } + + //Assert.True (App.ScrollForElement ( + // ContainerQuery, new Drag (scrollBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium) + //), "Failed to find element in: " + callerMemberName); + + App.Screenshot ("Go to element"); + } + + public void TapView () + { + App.Tap (q => q.Raw (ViewQuery)); + } + + public void DismissPopOver () + { + App.Screenshot ("About to dismiss pop over"); + App.Tap (q => q.Button ("Done")); + App.Screenshot ("Pop over dismissed"); + } + + public AppResult GetView () + { + return App.Query (q => q.Raw (ViewQuery)).First (); + } + + public AppResult[] GetViews () + { + return App.Query (q => q.Raw (ViewQuery)); + } + + public AppResult[] GetContainerDescendants () + { + return App.Query (q => q.Raw (ContainerDescendents)); + } + + public T GetProperty (BindableProperty formProperty) + { + Tuple property = formProperty.GetPlatformPropertyQuery (); + string[] propertyPath = property.Item1; + bool isOnParentRenderer = property.Item2; + + var query = ViewQuery; + if (isOnParentRenderer && + PlatformViewType != PlatformViews.BoxView && + PlatformViewType != PlatformViews.Frame) { + query = query + " parent * index:0"; + } + + object prop = null; + bool found = false; + + bool isEdgeCase = false; + if (App is AndroidApp && formProperty == View.ScaleProperty) + isEdgeCase = true; + + if (!isEdgeCase) { + found = + MaybeGetProperty (App, query, propertyPath, out prop) || + MaybeGetProperty (App, query, propertyPath, out prop) || + MaybeGetProperty (App, query, propertyPath, out prop) || + MaybeGetProperty (App, query, propertyPath, out prop); + } + + + if (App is AndroidApp && formProperty == View.ScaleProperty) { + var matrix = new Matrix (); + matrix.M00 = App.Query (q => q.Raw (query).Invoke (propertyPath[0]).Value ()).First (); + matrix.M11 = App.Query (q => q.Raw (query).Invoke (propertyPath[1]).Value ()).First (); + matrix.M22 = 0.5f; + matrix.M33 = 1.0f; + return (T)((object)matrix); + } + + if (!found || prop == null) { + throw new NullReferenceException ("null property"); + } + + if (prop.GetType () == typeof(T)) + return (T)prop; + + if (prop.GetType () == typeof(string) && typeof(T) == typeof(Matrix)) { + Matrix matrix = ParsingUtils.ParseCATransform3D ((string)prop); + return (T)((object)matrix); + } + + if (typeof(T) == typeof(Color)) { + if (App is iOSApp) { + Color color = ParsingUtils.ParseUIColor ((string)prop); + return (T)((object)color); + } else { + uint intColor = (uint)((float)prop); + Color color = Color.FromUint (intColor); + return (T)((object)color); + } + } + + if (prop.GetType () == typeof (string) && typeof(T) == typeof(Font)) { + if (App is iOSApp) { + Font font = ParsingUtils.ParseUIFont ((string)prop); + return (T)((object)font); + } else { + + } + } + + T result = default(T); + + var stringToBoolConverter = new StringToBoolConverter (); + var floatToBoolConverter = new FloatToBoolConverter (); + + if (stringToBoolConverter.CanConvertTo (prop, typeof(bool))) { + result = (T)stringToBoolConverter.ConvertTo (prop, typeof(bool)); + } else if (floatToBoolConverter.CanConvertTo (prop, typeof(bool))) { + result = (T)floatToBoolConverter.ConvertTo (prop, typeof(bool)); + } + + return result; + } + + static bool MaybeGetProperty(IApp app, string query, string[] propertyPath, out object result) + { + + try { + switch (propertyPath.Length){ + case 1: + result = app.Query (q => q.Raw (query).Invoke (propertyPath[0]).Value ()).First (); + break; + case 2: + result = app.Query (q => q.Raw (query).Invoke (propertyPath[0]).Invoke (propertyPath[1]).Value ()).First (); + break; + case 3: + result = app.Query (q => q.Raw (query).Invoke (propertyPath[0]).Invoke (propertyPath[1]).Invoke (propertyPath[2]).Value ()).First (); + break; + case 4: + result = app.Query (q => q.Raw (query).Invoke (propertyPath[0]).Invoke (propertyPath[1]).Invoke (propertyPath[2]).Invoke(propertyPath[3]).Value ()).First (); + break; + default: + result = null; + return false; + } + } + catch { + result = null; + return false; + } + + return true; + } + + } + + internal class StringToBoolConverter : TypeConverter + { + public override bool CanConvertTo (object source, Type targetType) + { + if (targetType != typeof(bool) || !(source is string)) + return false; + + var str = (string)source; + str = str.ToLowerInvariant (); + + switch (str) { + case "0": + case "1": + case "false": + case "true": + return true; + default: + return false; + } + } + + public override object ConvertTo (object source, Type targetType) + { + var str = (string)source; + str = str.ToLowerInvariant(); + + switch (str) + { + case "1": + case "true": + return true; + default: + return false; + } + } + } + + internal class FloatToBoolConverter : TypeConverter + { + public override bool CanConvertTo (object source, Type targetType) + { + if (targetType != typeof(bool) || !(source is float)) + return false; + + var flt = (float)source; + var epsilon = 0.0001; + if (Math.Abs (flt - 1.0f) < epsilon || Math.Abs (flt - 0.0f) < epsilon) + return true; + else + return false; + } + + public override object ConvertTo (object source, Type targetType) + { + var flt = (float)source; + var epsilon = 0.0001; + if (Math.Abs (flt - 1.0f) < epsilon) + return true; + else + return false; + } + } + + internal abstract class TypeConverter + { + public abstract bool CanConvertTo (object source, Type targetType); + + public abstract object ConvertTo (object source, Type targetType); + } + + internal static class PlatformMethods + { + public static Tuple GetPlatformPropertyQuery (this BindableProperty bindableProperty) + { + return PlatformMethodQueries.PropertyPlatformMethodDictionary[bindableProperty]; + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Remotes/EventViewContainerRemote.cs b/Xamarin.Forms.Core.iOS.UITests/Remotes/EventViewContainerRemote.cs new file mode 100644 index 00000000..d603974d --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Remotes/EventViewContainerRemote.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal sealed class EventViewContainerRemote : BaseViewContainerRemote + { + public EventViewContainerRemote (IApp app, Enum formsType, string platformViewType) + : base (app, formsType, platformViewType) { } + + public AppResult GetEventLabel () + { + App.WaitForElement (q => q.Raw (EventLabelQuery)); + return App.Query (q => q.Raw (EventLabelQuery)).First (); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Remotes/LayeredViewContainerRemote.cs b/Xamarin.Forms.Core.iOS.UITests/Remotes/LayeredViewContainerRemote.cs new file mode 100644 index 00000000..6f6c1071 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Remotes/LayeredViewContainerRemote.cs @@ -0,0 +1,25 @@ +using System; +using System.Linq; +using System.Security.Cryptography.X509Certificates; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal sealed class LayeredViewContainerRemote : BaseViewContainerRemote + { + public LayeredViewContainerRemote (IApp app, Enum formsType, string platformViewType) + : base (app, formsType, platformViewType) {} + + public AppResult GetLayeredLabel () + { + return App.Query (q => q.Raw (LayeredLabelQuery)).First (); + } + + public void TapHiddenButton () + { + App.Tap (q => q.Raw (LayeredHiddenButtonQuery)); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Remotes/RemoteFactory.cs b/Xamarin.Forms.Core.iOS.UITests/Remotes/RemoteFactory.cs new file mode 100644 index 00000000..ec9757ef --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Remotes/RemoteFactory.cs @@ -0,0 +1,56 @@ +using System; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + +// Potential cleanup of Raw Queries +// public void MyTest(IApp app) +// { +// var viewName = "myView"; +// +// app.Query (x => x.Marked (viewName + " View").Parent ().Index (0).Sibling ().Index (1).Child (0).Child (0)); +// +// app.Query (x => x.Marked (viewName + " View").Parent (0).Sibling (1).Child (0).Child (0)); +// +// app.Query (x => x.LayeredHiddenButton ("mine").LayeredHiddenButton ("yours")); +// +// app.Query (x => x.LayeredHiddenButton (viewName).Parentx(4)); +// +// app.ForAndroid (x => { +// x.Back(); +// }); +// } + + +// Potential cleanup of Raw Queries +// make public or reflection will not pick up in REPL +// internal static class Exts +// { +// public static void ForAndroid(this IApp app, Action action) +// { +// if (app is AndroidApp) +// { +// action (app as AndroidApp); +// } +// } +// +// public static AppQuery LayeredHiddenButton(this AppQuery query, string viewName) +// { +// if(query.QueryPlatform == QueryPlatform.Android) +// { +// return query.Marked (viewName + " Android View").Parent (0).Sibling (1).Child (0).Child (0); +// +// } +// return query.Marked (viewName + " iOS View").Parent (0).Sibling (1).Child (0).Child (0); +// } +// +// public static AppQuery Parentx(this AppQuery query, int index) +// { +// return query.Parent ().Index (index); +// } +// } + +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Remotes/StateViewContainerRemote.cs b/Xamarin.Forms.Core.iOS.UITests/Remotes/StateViewContainerRemote.cs new file mode 100644 index 00000000..2d7a1172 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Remotes/StateViewContainerRemote.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Linq.Expressions; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +using NUnit.Framework; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal sealed class StateViewContainerRemote : BaseViewContainerRemote + { + public StateViewContainerRemote (IApp app, Enum formsType, string platformViewType) + : base(app, formsType, platformViewType) { } + + public void TapStateButton () + { + App.Screenshot ("Before state change"); + App.Tap (q => q.Raw (StateButtonQuery)); + App.Screenshot ("After state change"); + } + + public AppResult GetStateLabel () + { + return App.Query (q => q.Raw (StateLabelQuery)).First (); + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Remotes/ViewContainerRemote.cs b/Xamarin.Forms.Core.iOS.UITests/Remotes/ViewContainerRemote.cs new file mode 100644 index 00000000..f19d3e6b --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Remotes/ViewContainerRemote.cs @@ -0,0 +1,13 @@ +using System; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal sealed class ViewContainerRemote : BaseViewContainerRemote + { + public ViewContainerRemote (IApp app, Enum formsType, string platformViewType) + : base (app, formsType, platformViewType) { } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ActionSheetUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ActionSheetUITests.cs new file mode 100644 index 00000000..9899d024 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ActionSheetUITests.cs @@ -0,0 +1,171 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System; +using System.Threading; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("ActionSheet")] + internal class ActionSheetUITests : BaseTestFixture + { + AppRect screenSize; + + public ActionSheetUITests () + { + + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ActionSheetGallery); + } + + static void CheckExtras () + { + App.WaitForElement (c => c.Marked ("Extra One")); + App.WaitForElement (c => c.Marked ("Extra Eight")); + } + + protected override void TestSetup () + { + base.TestSetup (); + screenSize = App.Query (q => q.Marked ("ActionSheetPage"))[0].Rect; + } + + [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) + { + App.ScrollForElement(string.Format("* text:'{0}'", actionSheet), new Drag(App.Query(q => q.Marked("ActionSheetPage"))[0].Rect, Drag.Direction.BottomToTop, Drag.DragLength.Long)); + App.Tap(q=>q.Raw(string.Format("* text:'{0}'", actionSheet))); + } + + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ActivityIndicatorUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ActivityIndicatorUITests.cs new file mode 100644 index 00000000..325a5682 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ActivityIndicatorUITests.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.Linq; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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 () {} + + //[UiTest (typeof(ActivityIndicator), "Color")] + public void Color () + { + //TODO: this was failing and is changing in next version of calabash (UI-Test-pre nuget) to a json rgb + +// var remote = RemoteFactory.CreateRemote (App, "Color", PlatformViewType); +// remote.GoTo (); +// +// var color = remote.GetProperty (ActivityIndicator.ColorProperty); +// Assert.AreEqual (Forms.Color.Lime, color); + } + + // ActivityIndicator tests + [Test] + [UiTest (typeof(ActivityIndicator), "IsRunning")] + public void IsRunning () + { + var remote = new ViewContainerRemote (App, Test.ActivityIndicator.IsRunning, PlatformViewType); + remote.GoTo (); + + var isRunning = remote.GetProperty (ActivityIndicator.IsRunningProperty); + Assert.IsTrue (isRunning); + } + + protected override void FixtureTeardown () + { + App.NavigateBack (); + base.FixtureTeardown (); + } + + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs new file mode 100644 index 00000000..c346b4fc --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/AppearingUITests.cs @@ -0,0 +1,64 @@ +using System; +using NUnit.Framework; + +namespace Xamarin.Forms.Core.UITests +{ + [Category ("Lifecycle")] + internal class AppearingUITests : BaseTestFixture + { + + public AppearingUITests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.AppearingGallery); + } + + [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"); + + } + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/AutomationIDUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/AutomationIDUITests.cs new file mode 100644 index 00000000..7746bafa --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/AutomationIDUITests.cs @@ -0,0 +1,73 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System; +using System.Threading; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("AutomationID")] + internal class AutomationIDUITests : BaseTestFixture + { + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.AutomationIDGallery); + } + + [Test] + public void Test1 () + { + App.Tap (c => c.Marked ("btnTest1")); + App.WaitForElement (c => c.Marked ("scrollMain")); + 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 void Test2 () + { + 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.iOS.UITests/Tests/BoxViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/BoxViewUITests.cs new file mode 100644 index 00000000..cf542c3e --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/BoxViewUITests.cs @@ -0,0 +1,57 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/ButtonUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs new file mode 100644 index 00000000..5ae8f506 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs @@ -0,0 +1,178 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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 (App is iOSApp) { + var borderRadius = remote.GetProperty (Button.BorderRadiusProperty); + Assert.AreEqual (20.0f, borderRadius); + } + + } + + [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 (App is iOSApp) { + var borderWidth = remote.GetProperty (Button.BorderWidthProperty); + Assert.AreEqual (15.0f, borderWidth); + } + + } + + [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 (App is AndroidApp) { + var isBold = remote.GetProperty (Button.FontProperty); + Assert.True (isBold); + } else { + var font = remote.GetProperty (Button.FontProperty); + Assert.True (font.FontAttributes.HasFlag (FontAttributes.Bold)); + } + + } + + [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 (Button.TextProperty); + Assert.AreEqual ("Text", buttonText); + } + + [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 buttonTextColor = remote.GetProperty (Button.TextColorProperty); + Assert.AreEqual (Color.Pink, buttonTextColor); + } + } + + protected override void FixtureTeardown () + { + App.NavigateBack (); + base.FixtureTeardown (); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs new file mode 100644 index 00000000..7691dd46 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ContextActionsUITests.cs @@ -0,0 +1,129 @@ +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 ("Cells")] + internal class ContextActionsListUITests : BaseTestFixture + { + + public ContextActionsListUITests () + { + ShouldResetPerFixture = false; + } + + 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"; + + [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"); + } + } + + [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"); + } + } + + [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"); + } + } else { + Assert.Inconclusive ("Not testing on Android"); + } + } + } + + [TestFixture] + [Category ("Cells")] + internal class ContextActionsTableUITests : BaseTestFixture + { + public ContextActionsTableUITests () + { + ShouldResetPerFixture = false; + } + + 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"; + + [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!"); + + 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"); + } + } + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/DatePickerUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/DatePickerUITests.cs new file mode 100644 index 00000000..5769f71b --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/DatePickerUITests.cs @@ -0,0 +1,55 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/DisplayAlertUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/DisplayAlertUITests.cs new file mode 100644 index 00000000..be0e4997 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/DisplayAlertUITests.cs @@ -0,0 +1,85 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System; +using System.Threading; + + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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")); + } + +// [Test] +// public void TestRotation () +// { +// App.SetOrientationLandscape (); +// +// //App.Tap (c => c.Marked ("Alert Override1")); +// // 27-01-2015 14:30:02.125 -08:00 - 28524 - Tapping first element (2 total) matching Marked("Alert Override1") at coordinates [ 512, 113 ]. +// +// App.TapCoordinates (665, 512); +// +// App.WaitForElement (c => c.Marked ("TheAlertTitle")); +// +// App.Screenshot ("Display Alert After Rotation"); +// App.WaitForElement (c => c.Marked ("TheAlertTitle")); +// App.Tap (c => c.Marked("TheCancelButton")); +// App.WaitForNoElement (c => c.Marked("TheCancelButton")); +// App.SetOrientationPortrait (); +// +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/EditorUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/EditorUITests.cs new file mode 100644 index 00000000..6701faad --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/EditorUITests.cs @@ -0,0 +1,55 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/EntryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs new file mode 100644 index 00000000..45b73374 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/EntryUITests.cs @@ -0,0 +1,73 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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"); + + if (App is AndroidApp) { + ((AndroidApp)App).PressUserAction (UserAction.Done); + } else { + 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.iOS.UITests/Tests/FrameUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/FrameUITests.cs new file mode 100644 index 00000000..f7a59ed5 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/FrameUITests.cs @@ -0,0 +1,57 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/ImageUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ImageUITests.cs new file mode 100644 index 00000000..5c19d1cb --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ImageUITests.cs @@ -0,0 +1,63 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/LabelUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/LabelUITests.cs new file mode 100644 index 00000000..423774fd --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/LabelUITests.cs @@ -0,0 +1,57 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/Legacy-AbsoluteLayoutGalleryTest.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-AbsoluteLayoutGalleryTest.cs new file mode 100644 index 00000000..c23a0d27 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-AbsoluteLayoutGalleryTest.cs @@ -0,0 +1,229 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System; +using System.Threading; +using Xamarin.UITest.Queries; +using System.Diagnostics; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("AbsoluteLayout")] + internal class AbsoluteLayoutGalleryTests : BaseTestFixture + { + // TODO: Port to new conventions + + public AbsoluteLayoutGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.AbsoluteLayoutGalleryLegacy); + } + + [Test] + public void AbsoluteLayoutGalleryMoveBox () + { + App.Screenshot ("At Gallery"); + + // App.WaitForElement (q => q.Raw (Views.BoxView), "Timeout : Box Renderers"); + // Assert.AreEqual (1, App.Query (q => q.Raw (Views.BoxView)).Length); + + // App.WaitForElement (q => q.Raw (Views.Label), "Timeout : Labels"); + // Assert.AreEqual (4, App.Query(q => q.Raw (Views.Label)).Length); + + // App.WaitForElement (q => q.Raw (Views.Slider), "Timeout : Sliders"); + // Assert.AreEqual (4, App.Query(q => q.Raw (Views.Slider)).Length); + // App.Screenshot ("All elements exist"); + + // App.WaitForElement (q => q.Raw (Views.Slider)); + // // Move green box left + // var sliders = (App.Query (q => q.Raw (Views.Slider))); + // var sliderCenter = (sliders[0]).Rect.CenterX; + // var sliderLeft = (sliders[0]).Rect.X; + // var sliderRight = sliderLeft + (sliders[0]).Rect.Width; + + // var xSlider = (sliders[0]).Rect.CenterY; + // var ySlider = (sliders[1]).Rect.CenterY; + + //var absoluteBounds = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0].Rect; + + //// Move box left + //App.DragFromTo (sliderCenter, xSlider, sliderLeft, xSlider, Speed.Slow); + //Assert.AreEqual (absoluteBounds.X, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.X, 2.0); + //App.Screenshot ("Box moved to left bounds"); + + //// Move box right + //App.DragFromTo (sliderLeft, xSlider, sliderRight, xSlider, Speed.Slow); + //Assert.AreEqual (absoluteBounds.X + absoluteBounds.Width, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.X + (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Width, 2.0); + //App.Screenshot ("Box moved to right bounds"); + + ////Move box up + //var boxContainer = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0]; + //var boxContainerTop = boxContainer.Rect.Y; + //var boxContainerBottom = boxContainer.Rect.Y + boxContainer.Rect.Height; + + //App.DragFromTo (sliderCenter, ySlider, sliderLeft, ySlider, Speed.Slow); + //Assert.AreEqual (boxContainerTop, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Y); + //App.Screenshot ("Box moved to top bounds"); + + //// Move box down + //App.DragFromTo (sliderLeft, ySlider, sliderRight, ySlider, Speed.Slow); + //Assert.AreEqual (boxContainerBottom, (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Y + (App.Query (PlatformQueries.BoxRendererQuery))[0].Rect.Height); + //App.Screenshot ("Box moved to bottom bounds"); + } + + //[Test] + //[Description ("MaxWidth")] + //public void AbsoluteLayoutGalleryResizeToMaximumWidth () + //{ + //App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders"); + + //AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[2].Rect; + //float sliderCenter = widthSlider.CenterX; + //float sliderY = widthSlider.CenterY; + //float sliderRight = widthSlider.X + widthSlider.Width; + + //App.DragFromTo (sliderCenter, sliderY, sliderRight, sliderY, Speed.Slow); + + //AppRect absoluteBounds = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0].Rect; + //AppRect boxBounds = App.Query (PlatformQueries.BoxRendererQuery)[0].Rect; + + //Assert.AreEqual (absoluteBounds.Width, boxBounds.Width, 2.0); + //App.Screenshot ("Box at maximum width"); + //} + + //[Test] + //[Description ("MaxHeight")] + //public void AbsoluteLayoutGalleryResizeToMaximumHeight () + //{ + //App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders"); + + //AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[3].Rect; + //float sliderCenter = widthSlider.CenterX; + //float sliderY = widthSlider.CenterY; + //float sliderRight = widthSlider.X + widthSlider.Width; + + //App.DragFromTo (sliderCenter, sliderY, sliderRight, sliderY, Speed.Slow); + + //AppRect absoluteBounds = App.Query (PlatformQueries.AbsoluteGalleryBackground)[0].Rect; + //AppRect boxBounds = App.Query (PlatformQueries.BoxRendererQuery)[0].Rect; + + //Assert.AreEqual (absoluteBounds.Height, boxBounds.Height, 2.0); + //App.Screenshot ("Box at maximum height"); + //} + + //[Test] + //[Description ("MinWidth")] + //public void AbsoluteLayoutGalleryResizeToMinimumWidth () + //{ + //App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders"); + + //AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[2].Rect; + //float sliderCenter = widthSlider.CenterX; + //float sliderY = widthSlider.CenterY; + //float sliderLeft = widthSlider.X - 20; + + //App.DragFromTo (sliderCenter, sliderY, sliderLeft, sliderY, Speed.Slow); + + //bool isZeroed = false; + //if (App.Query (PlatformQueries.BoxRendererQuery).Length == 0) { + // // Android removes 0 width BoxView + // isZeroed = true; + //} else { + // if (App.Query (PlatformQueries.BoxRendererQuery)[0].Rect.Width <= 4.0) + // isZeroed = true; + //} + + //Assert.IsTrue (isZeroed, "Box is minimum width"); + //App.Screenshot ("Box at minimum width"); + } + + //[Test] + //[Description ("MinHeight")] + //public void AbsoluteLayoutGalleryResizeToMinimumHeight () + //{ + //App.WaitForElement (PlatformQueries.Sliders, "Timeout : Sliders"); + + //AppRect widthSlider = (App.Query (PlatformQueries.Sliders))[3].Rect; + //float sliderCenter = widthSlider.CenterX; + //float sliderY = widthSlider.CenterY; + //float sliderLeft = widthSlider.X - 20; + + //App.DragFromTo (sliderCenter, sliderY, sliderLeft, sliderY, Speed.Slow); + + //bool isZeroed = false; + //if (App.Query (PlatformQueries.BoxRendererQuery).Length == 0) { + // // Android removes 0 height BoxView + // isZeroed = true; + //} else { + // if (App.Query (PlatformQueries.BoxRendererQuery)[0].Rect.Height <= 4.0) + // isZeroed = true; + //} + + //Assert.IsTrue (isZeroed, "Box is minimum height"); + //App.Screenshot ("Box at minimum height"); + //} + +/*******************************************************/ +/**************** Landscape tests **********************/ +/*******************************************************/ + + //[Test] + //[Description ("Move box around with sliders - landscape")] + //public void AbsoluteLayoutGalleryMoveBoxLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // AbsoluteLayoutGalleryMoveBox (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + + //[Test] + //[Description ("Resize to max width with sliders - landscape")] + //public void AbsoluteLayoutGalleryResizeToMaximumWidthLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // AbsoluteLayoutGalleryResizeToMaximumWidth (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + + //[Test] + //[Description ("Resize to max height with sliders - landscape")] + //public void AbsoluteLayoutGalleryResizeToMaximumHeightLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // AbsoluteLayoutGalleryResizeToMaximumHeight (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + + //[Test] + //[Description ("Resize to min height with sliders - landscape")] + //public void AbsoluteLayoutGalleryResizeToMinimumWidthLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // AbsoluteLayoutGalleryResizeToMinimumWidth (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + + //[Test] + //[Description ("Resize to min height with sliders - landscape")] + //public void AbsoluteLayoutGalleryResizeToMinimumHeightLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // AbsoluteLayoutGalleryResizeToMinimumHeight (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + //} +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-BoundViewUITest.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-BoundViewUITest.cs new file mode 100644 index 00000000..625a27ca --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-BoundViewUITest.cs @@ -0,0 +1,96 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System; +using System.Threading; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Templated")] + internal class BoundViewGalleryTests : BaseTestFixture + { + // TODO: Port to new conventions + + public BoundViewGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.BoundPageGalleryLegacy); + } + + //void AllElementsPresent () + //{ + // App.WaitForElement (q => q.Button ("Click Me!")); + // App.Screenshot ("All elements present"); + //} + + [Test] + [Description ("Test bound view navigation")] + public void BoundViewGalleryNavigateToAndBack () + { + App.Screenshot ("At Gallery"); + +// AllElementsPresent (); + +// App.Tap (q => q.Button ("Click Me!")); +// App.WaitForElement (q => q.Marked ("Second Page"), "Timeout : Second Page"); +// App.Screenshot ("Navigation to next page successful"); + +// App.Tap (PlatformQueries.Back); +// App.WaitForElement (q => q.Button ("Click Me!"), "Timeout : Click Me!"); +// App.Screenshot ("Navigation back successful"); + } + +// [Test] +// [Description ("Test button click")] +// public void BoundViewGalleryClickButton () +// { +// App.Tap (q => q.Button ("Click Me!")); +// App.WaitForElement (q => q.Marked ("Second Page"), "Timeout : Second Page"); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Verify all elements are preset - landscape")] +// public void BoundViewGalleryAllElementsPresentLandscape () +// { +// App.SetOrientationLandscape (); +// Thread.Sleep (1000); +// App.Screenshot ("Rotated to Landscape"); +// AllElementsPresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Test bound view navigation- landscape")] +// public void BoundViewGalleryNavigateToAndBackLandscape () +// { +// App.SetOrientationLandscape (); +// Thread.Sleep (1000); +// App.Screenshot ("Rotated to Landscape"); +// BoundViewGalleryNavigateToAndBack (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Test button click - landscape")] +// public void BoundViewGalleryClickButtonLandscape () +// { +// App.SetOrientationLandscape (); +// Thread.Sleep (1000); +// App.Screenshot ("Rotated to Landscape"); +// BoundViewGalleryClickButton (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ButtonUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ButtonUITests.cs new file mode 100644 index 00000000..71443ce2 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ButtonUITests.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Xamarin.Forms.Core.UITests +{ + // Run these to test in CI before full suite + [TestFixture] + [Category ("Button")] + internal class ButtonGalleryTests : BaseTestFixture + { + // TODO: Rotate Button - test rotation + // TODO: Port to new conventions + + public ButtonGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ButtonGalleryLegacy); + } + + [Test] + [Description ("Disabled Button")] + public void ButtonGalleryOnOffDisbledButton () + { + App.Screenshot ("At Gallery"); + + // App.ScrollDownForElement (q => q.Marked ("Cannot Tap"), 3); + // App.Tap (q => q.Button ("Disabled Button")); + // Assert.AreEqual (1, App.Query (q => q.Button ("Disabled Button")).Length); + // App.Screenshot ("Tried to tap disabled button"); + // App.Tap (PlatformQueries.Switch); + // App.Screenshot ("Tapped switch"); + // App.Tap (q => q.Button ("Disabled Button")); + // App.WaitForElement (q => q.Marked ("TAPPED!")); + // App.Screenshot ("Disabled button should not be enabled and change labels text"); + } + + //[Test] + //[UiTest (Test.Device.StartTimer)] + //[Description ("Clicking the 'Timer Button'")] + //public void ButtonGalleryTimerButton () + //{ + // App.ScrollDownForElement (q => q.Marked ("Timer"), 10); + // App.Screenshot ("Press 'Timer' Button"); + + // App.Tap (q => q.Button ("Timer")); + + // App.WaitForElement (q => q.Marked ("Timer Elapsed 3"), "Timeout : Timer Elapsed 3"); + // App.Screenshot ("Timer button elapsed 3"); + //} + + //[Test] + //[UiTest (Test.Page.DisplayAlert)] + //public void ButtonGalleryAlertAccepted () + //{ + // App.ScrollDownForElement (q => q.Marked ("Alert"), 10); + + // App.Screenshot ("Press 'Alert' Button"); + + // App.Tap (q => q.Marked ("Alert")); + // App.WaitForElement (q => q.Marked ("Accept"), "Timeout : Accept"); + + // App.Screenshot ("Press 'Accept' or 'Cancel'"); + + // App.Tap (q => q.Marked ("Accept")); + // App.WaitForElement (q => q.Button ("Accepted"), "Timeout : Accepted"); + + // App.Screenshot ("See 'Accepted' or 'Cancelled'"); + //} + + + //[Test] + //[UiTest (Test.Page.DisplayAlert)] + //public void ButtonGalleryAlertCancelled () + //{ + // App.ScrollDownForElement (q => q.Marked ("Alert"), 10); + + // App.Screenshot ("Press 'Alert' Button"); + + // App.Tap (q => q.Marked ("Alert")); + // App.WaitForElement (q => q.Marked ("Cancel"), "Timeout : Cancel"); + + // App.Screenshot ("Press 'Accept' or 'Cancel'"); + + // App.Tap (q => q.Marked ("Cancel")); + // App.WaitForElement (q => q.Button ("Cancelled"), "Timeout : Cancelled"); + + // App.Screenshot ("See 'Accepted' or 'Cancelled'"); + //} + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CarouselPageUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CarouselPageUITests.cs new file mode 100644 index 00000000..14a6ed4b --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CarouselPageUITests.cs @@ -0,0 +1,63 @@ +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("CarouselPage")] + internal class CarouselPageGalleryTests : BaseTestFixture + { + // TODO: Port to new conventions + + public CarouselPageGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.CarouselPageGalleryLegacy); + } + + [Test] + [Description ("Swiping between screens")] + [UiTest (typeof(CarouselPage))] + public void CarouselPageGallerySwipeScreens () + { + App.Screenshot ("At Gallery"); + + // var rootViewWidth = App.Query (q => q.Raw ("*"))[0].Rect.Width; + // var rootViewHeight = App.Query (q => q.Raw ("*"))[0].Rect.Height; + + // // Verify the elements can be touched + // App.Tap (q => q.Button ("Click me one")); + // App.WaitForNoElement (q => q.Marked ("No click one"), "Timeout : No click one"); + // App.WaitForElement (q => q.Marked ("Clicked one"), "Timeout : Clicked one"); + + // App.Pan (new Drag (ScreenBounds, rootViewWidth - 20, rootViewHeight / 2, 20, rootViewHeight / 2, Drag.Direction.RightToLeft)); + + // App.WaitForElement (q => q.Marked ("No click two"), "Timeout : No click two"); + // App.WaitForElement (q => q.Button ("Click me two"), "Timeout : Click me two"); + // App.Screenshot ("On page two"); + + // // Verify the elements can be touched + // App.Tap (q => q.Button ("Click me two")); + // App.WaitForNoElement (q => q.Marked ("No click two"), "Timeout : No click two"); + // App.WaitForElement (q => q.Marked ("Clicked two"), "Timeout : Clicked two"); + + // App.Pan (new Drag (ScreenBounds, rootViewWidth - 20, rootViewHeight / 2, 20, rootViewHeight / 2, Drag.Direction.RightToLeft)); + + // App.WaitForElement (q => q.Marked ("No click three"), "Timeout : No click three"); + // App.WaitForElement (q => q.Button ("Click me three"), "Timeout : Click me three"); + // App.Screenshot ("On page three"); + + // // Verify the elements can be touched + // App.Tap (q => q.Button ("Click me three")); + // App.WaitForNoElement (q => q.Marked ("No click three"), "Timeout : No click three"); + // App.WaitForElement (q => q.Marked ("Clicked three"), "Clicked three"); + // App.Screenshot ("All screens interacted with"); + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs new file mode 100644 index 00000000..e6efd5f9 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-CellsUITests.cs @@ -0,0 +1,318 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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] + [Description ("ListView with ImageCells, file access problems")] + [UiTest (typeof(ListView))] + [UiTest (typeof(ImageCell))] + public void 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.Long), 40); + + App.WaitForElement (q => q.Marked ("Detail 200"), "Timeout : Detail 200"); + + 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 ("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"); + } + + [Description ("Entered text stays after scrolled out of view")] + [Issue (IssueTracker.Github, 1024, "EntryCell with text set clears after scrolling off screen", PlatformAffected.Android)] + [UiTest (typeof(EntryCell))] + public void CellsGalleryIssue1024 () + { + // TODO fix +// 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.Tap (Queries.EntryCellWithPlaceholder ("Placeholder 1")); +// App.EnterText (Queries.EntryCellWithPlaceholder ("Placeholder 1"), "I am going to be scrolled off screen"); +// +// App.Screenshot ("Dismiss keyboard"); +// +// App.ScrollForElement ("* marked:'Label 40'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); +// App.Screenshot ("Scroll down"); +// +// App.ScrollForElement ("* marked:'Label 0'", new Drag (ScreenBounds, Drag.Direction.TopToBottom, Drag.DragLength.Medium)); +// +// App.WaitForElement (Queries.EntryCellWithText ("I am going to be scrolled off screen"), "Timeout : Scrolled Entry with Text"); +// App.Screenshot ("Scroll back up to cell"); + } + + [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"); + + 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.WaitForElement (q => q.Marked ("Entered: 1")); + App.Screenshot ("Completed should have changed label's text"); + } + + //[Test] + [Description ("Issue 1033 - page does not respect orientation changes")] + public void CellsGalleryIssue1033 () + { +// App.SetOrientationLandscape (); +// App.Tap (q => q.Marked ("TextCell List")); +// App.WaitForElement (q => q.Marked ("Text 2"), "Timeout : Text 2"); +// float listViewHeightLandscape = App.Query (q => q.Raw (Views.ListView))[0].Rect.Height; +// App.Screenshot ("Landscape list"); +// +// +// App.NavigateBack (); +// App.Screenshot ("Navigate back"); +// App.SetOrientationPortrait (); +// App.Screenshot ("Set orientation to portrait"); +// +// App.Tap (q => q.Marked ("TextCell List")); +// App.WaitForElement (q => q.Marked ("Text 2"), "Timeout : Text 2"); +// float listViewHeightPortrait = App.Query (q => q.Raw (Views.ListView))[0].Rect.Height; +// App.Screenshot ("Portrait list"); +// +// // Should be be the same size if the layout is resized +// Assert.AreNotEqual (listViewHeightLandscape, listViewHeightPortrait); + } + + protected override void TestTearDown() + { + App.NavigateBack (); + base.TestTearDown(); + } + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ClipToBoundsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ClipToBoundsUITests.cs new file mode 100644 index 00000000..9dffeaaf --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ClipToBoundsUITests.cs @@ -0,0 +1,73 @@ +using System; +using System.Runtime; +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.Shared; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("AbsoluteLayout")] + internal class ClipToBoundsGalleryTests : BaseTestFixture + { + // TODO detect size before and after clip + // TODO: Port to new conventions + + public ClipToBoundsGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ClipToBoundsGalleryLegacy); + } + [Test] + [Description ("Check all elements exist")] + public void ClipToBoundsGalleryAllElementsExist () + { +// App.WaitForElement (q => q.Button ("Clip"), "Timeout : Clip"); +// var boxes = App.Query (PlatformQueries.BoxRendererQuery); +// Assert.AreEqual (2, boxes.Length); +// App.Screenshot ("2 boxes exist"); + + + } + +// [Test] +// [Description ("Clip boxes")] +// public void ClipToBoundsGalleryClipElements () +// { +// App.Tap (q => q.Button ("Clip")); +// App.Screenshot ("Clip elements"); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Check all elements exist - landscape")] +// public void ClipToBoundsGalleryAllElementsExistLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// ClipToBoundsGalleryAllElementsExist (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Clip boxes - landscape")] +// public void ClipToBoundsGalleryClipElementsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// ClipToBoundsGalleryClipElements (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); + // } + + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EditorUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EditorUITests.cs new file mode 100644 index 00000000..df34deec --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EditorUITests.cs @@ -0,0 +1,269 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Threading; + +using Xamarin.Forms.CustomAttributes; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Editor")] + internal class EditorGalleryTests : BaseTestFixture + { + // TODO: Port to new conventions + + public EditorGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.EditorGalleryLegacy); + } + + [Test] + [Category ("ManualReview")] + [Description ("Try Default keyboard")] + [UiTest (typeof (Editor), "Keyboard")] + [UiTest (typeof (Keyboard), "Default")] + public void EditorGalleryDefaultKeyboardGallery () + { +// App.Tap (q => q.Marked ("Default Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Default Keyboard Gallery"); + +// App.Tap (PlatformQueries.Editors); +// // App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard showing"); + +// var text = "This is some text that I am entering"; +// App.EnterText (PlatformQueries.Editors, text); +// App.WaitForElement (PlatformQueries.EditorsWithText (text), "Timeout : Editor with Text " + text); +// App.Screenshot ("Text Entered"); + +// App.PressEnter (); +// // App.KeyboardIsDismissed (); +// App.Screenshot ("Pressed enter"); + } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Editor.Completed Fires")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.Editor.Completed)] +// public void EditorGalleryDefaultKeyboardGalleryCompletedFires () +// { +// App.Tap (q => q.Marked ("Default Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Default Keyboard Gallery"); + +// App.Tap (PlatformQueries.Editors); +// // App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard showing"); +// App.EnterText (PlatformQueries.Editors, "First Line"); +// App.PressEnter (); + +// App.Screenshot ("Pressed enter"); +// App.EnterText (PlatformQueries.Editors, "Second Line"); +// App.Screenshot ("Entered second line"); +// App.Tap (PlatformQueries.LabelWithText("Nothing entered")); +// App.Screenshot ("Keyboard dismissed"); +//// App.Tap (q => q.Marked ("Done")); + + +// App.WaitForNoElement (q => q.Marked ("Nothing entered")); +// App.Screenshot ("Test complete"); +//// App.WaitForElement (q => q.Marked ("Entered : First Line Second Line")); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Try Chat keyboard")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.InputView.Keyboard)] +// [UiTest (Test.Keyboard.Chat)] +// public void EditorGalleryChatKeyboardGallery () +// { +// App.Tap (q => q.Marked ("Chat Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Chat Keyboard Gallery"); + +// App.Tap (PlatformQueries.Editors); +// // App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard showing"); + +// var text = "This is some text that I am entering"; +// App.EnterText (PlatformQueries.Editors, text); +// App.WaitForElement (PlatformQueries.EditorsWithText (text), "Timeout : Editor with Text " + text); +// App.Screenshot ("Text Entered"); + +// App.PressEnter (); +// // App.KeyboardIsDismissed (); +// App.Screenshot ("Pressed enter"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Try Text keyboard")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.InputView.Keyboard)] +// [UiTest (Test.Keyboard.Text)] +// public void EditorGalleryTextKeyboardGallery () +// { +// App.Tap (q => q.Marked ("Text Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Text Keyboard Gallery"); + +// App.Tap (PlatformQueries.Editors); +// // App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard showing"); + +// var text = "This is some text that I am entering"; +// App.EnterText (PlatformQueries.Editors, text); +// App.WaitForElement (PlatformQueries.EditorsWithText (text), "Timeout : Editor with Text " + text); +// App.Screenshot ("Text Entered"); + +// App.PressEnter (); +// // App.KeyboardIsDismissed (); +// App.Screenshot ("Pressed enter"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Try Url keyboard")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.InputView.Keyboard)] +// [UiTest (Test.Keyboard.Url)] +// public void EditorGalleryUrlKeyboardGallery () +// { +// App.Tap (q => q.Marked ("Url Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Url Keyboard Gallery"); + +// App.Tap (PlatformQueries.Editors); +// // App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard showing"); + +// var text = "https://www.xamarin.com"; +// App.EnterText (PlatformQueries.Editors, text); +// App.WaitForElement (PlatformQueries.EditorsWithText (text), "Timeout : Editor with Text " + text); +// App.Screenshot ("Text Entered"); + +// App.PressEnter (); +// // App.KeyboardIsDismissed (); +// App.Screenshot ("Pressed enter"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Try Numeric keyboard")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.InputView.Keyboard)] +// [UiTest (Test.Keyboard.Numeric)] +// public void EditorGalleryNumericKeyboardGallery () +// { +// App.Tap (q => q.Marked ("Numeric Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Numeric Keyboard Gallery"); + +// App.Tap (PlatformQueries.Editors); +// // App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard showing"); + +// var text = "12345678910"; +// App.EnterText (PlatformQueries.Editors, text); +// App.WaitForElement (PlatformQueries.EditorsWithText (text), "Timeout : Editor with Text " + text); +// App.Screenshot ("Text Entered"); +// } + +// [Test] +// [Description ("TextChanged event")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.Editor.TextChanged)] +// public void EditorGalleryDefaultKeyboardTextChanged () +// { +// App.Tap (q => q.Marked ("Default Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Default Keyboard Gallery"); + +// App.EnterText (PlatformQueries.Editors, "ABC"); +// App.Screenshot ("Entered three characters"); +// App.WaitForElement (PlatformQueries.LabelWithText ("xxx")); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithIndex (1)); +// Assert.AreEqual ("xxx", labelText); +// } + +// [Test] +// [Description ("TextChanged event - Issue #")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.Editor.TextChanged)] +// public void EditorGalleryChatKeyboardTextChanged () +// { +// App.Tap (q => q.Marked ("Chat Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Chat Keyboard Gallery"); + +// App.EnterText (PlatformQueries.Editors, "ABC"); +// App.Screenshot ("Entered three characters"); +// App.WaitForElement (PlatformQueries.LabelWithText ("xxx")); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithIndex (1)); +// Assert.AreEqual ("xxx", labelText); +// } + +// [Test] +// [Description ("TextChanged event")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.Editor.TextChanged)] +// public void EditorGalleryNumericKeyboardTextChanged () +// { +// App.Tap (q => q.Marked ("Numeric Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Numeric Keyboard Gallery"); + +// App.EnterText (PlatformQueries.Editors, "123"); +// App.Screenshot ("Entered three characters"); +// App.WaitForElement (PlatformQueries.LabelWithText ("xxx")); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithIndex (1)); +// Assert.AreEqual ("xxx", labelText); +// } + +// [Test] +// [Description ("TextChanged event")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.Editor.TextChanged)] +// public void EditorGalleryTextKeyboardTextChanged () +// { +// App.Tap (q => q.Marked ("Text Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Text Keyboard Gallery"); + +// App.EnterText (PlatformQueries.Editors, "ABC"); +// App.Screenshot ("Entered three characters"); +// App.WaitForElement (PlatformQueries.LabelWithText ("xxx")); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithIndex (1)); +// Assert.AreEqual ("xxx", labelText); +// } + +// [Test] +// [Description ("TextChanged event")] +// [UiTest (Test.Views.Editor)] +// [UiTest (Test.Editor.TextChanged)] +// public void EditorGalleryUrlKeyboardTextChanged () +// { +// App.Tap (q => q.Marked ("Url Keyboard")); +// App.WaitForElement (PlatformQueries.Editors, "Timeout : Editors"); +// App.Screenshot ("At Url Keyboard Gallery"); + +// App.EnterText (PlatformQueries.Editors, "ABC"); +// App.Screenshot ("Entered three characters"); +// App.WaitForElement (PlatformQueries.LabelWithText ("xxx")); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithIndex (1)); +// Assert.AreEqual ("xxx", labelText); +// } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EntryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EntryUITests.cs new file mode 100644 index 00000000..e88ff6b6 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-EntryUITests.cs @@ -0,0 +1,301 @@ +using System; +using NUnit.Framework; +using System.Collections.Generic; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Entry")] + internal class EntryGalleryTests : BaseTestFixture + { + // TODO: Get Toggle color tests for both iOS and Android, Keyboard dismisses for Enter + // TODO: Port to new conventions + + public EntryGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.EntryGalleryLegacy); + } + [Test] + [Description ("All Entry Gallery elements are present")] + public void EntryGalleryAllElementsPresent () + { + +// var entryElements = new [] { +// q => q.Marked ("Enter something in Normal"), +// q => q.Marked ("No typing has happened in Normal yet"), +// PlatformQueries.EntryWithPlaceholder ("Normal"), +// PlatformQueries.EntryWithPlaceholder ("Password"), +// PlatformQueries.EntryWithPlaceholder ("Numeric Password"), +// q => q.Marked ("Focus an Entry"), +// PlatformQueries.EntryWithPlaceholder ("Disabled"), +// PlatformQueries.EntryWithPlaceholder ("Activation"), +// PlatformQueries.EntryWithPlaceholder ("Transparent"), +// PlatformQueries.EntryWithPlaceholder ("Keyboard.Default") +// }; + +// foreach (var entry in entryElements) +// App.ScrollDownForElement (entry, 10); + +// var buttons = new [] { +// "Toggle Text Color", +// "Toggle Secure", +// "Change Placeholder", +// "Focus First" +// }; + +// foreach (var button in buttons) +// App.ScrollDownForElement (q => q.Button (button), 10); + +// App.Screenshot ("All elements present"); + } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Check that the keyboard shows for each Entry")] +// public void EntryGalleryKeyboardDisplays () +// { +// AppRect windowBounds = App.MainScreenBounds (); + +// var placeHolders = new [] { +// "Normal", +// "Password", +// "Numeric Password", +// "Disabled", +// "Activation", +// "Transparent", +// "Keyboard.Default" +// }; + +// foreach (var placeholder in placeHolders) { +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (placeholder), 3); +// if (placeholder != "Disabled") { +// App.Tap (PlatformQueries.EntryWithPlaceholder (placeholder)); +// //App.KeyboardIsPresent (); +// App.Screenshot ("Keyboard shown: " + placeholder); +// // Tap empty part of screen +// App.TapCoordinates (10, windowBounds.Height / 3); +// } else { // Disabled entry should not show keyboard +// App.Tap (PlatformQueries.EntryWithPlaceholder (placeholder)); +// //App.KeyboardIsDismissed (); +// App.Screenshot ("Keyboard not shown: " + placeholder); +// } +// } + +// App.Screenshot ("Keyboard should be dismissed"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Enter text in each entry")] +// public void EntryGalleryEnterTextInEachFieldAndTapScreenDismiss () +// { +// var entries = new [] { +// new { Placeholder = "Normal", LabelValue = "Normal Focused" }, +// new { Placeholder = "Password", LabelValue = "Password Focused" }, +// new { Placeholder = "Numeric Password", LabelValue = "Numeric Password Focused" }, +// new { Placeholder = "Disabled", LabelValue = "Disabled Focused" }, +// new { Placeholder = "Activation", LabelValue = "Activation Focused" }, +// new { Placeholder = "Transparent", LabelValue = "Transparent Focused" }, +// new { Placeholder = "Keyboard.Default", LabelValue = "Keyboard.Default Focused" }, +// }; + +// AppRect windowBounds = App.MainScreenBounds (); +// int helloNum = 0; + +// foreach (var entry in entries) { +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (entry.Placeholder), 3); +// if (entry.Placeholder == "Disabled") { +// App.Tap (PlatformQueries.EntryWithPlaceholder (entry.Placeholder)); +// // App.KeyboardIsDismissed (); +// } else if (entry.Placeholder == "Numeric Password") { +// App.Tap (PlatformQueries.EntryWithPlaceholder (entry.Placeholder)); +// // App.KeyboardIsPresent (); +// App.EnterText (PlatformQueries.EntryWithPlaceholder (entry.Placeholder), "167728"); +// App.TapCoordinates (10, windowBounds.Height / 3); +// } else { +// App.Tap (PlatformQueries.EntryWithPlaceholder (entry.Placeholder)); +// // App.KeyboardIsPresent (); +// App.EnterText (PlatformQueries.EntryWithPlaceholder (entry.Placeholder), "Hello " + helloNum); +// App.TapCoordinates (10, windowBounds.Height / 3); +// helloNum++; +// } +// } + +// App.Screenshot ("Entered text in each entry, password should be hidden"); +// App.Tap (q => q.Button ("Toggle Secure")); + +// App.ScrollUpForElement (q => q.Marked ("Hello 0"), 5); +// App.ScrollDownForElement (q => q.Marked ("Hello 1"), 5); +// App.ScrollDownForElement (q => q.Marked ("167728"), 5); +// App.ScrollDownForElement (q => q.Marked ("Hello 3"), 5); +// App.ScrollDownForElement (q => q.Marked ("Hello 4"), 5); +// App.ScrollDownForElement (q => q.Marked ("Hello 5"), 5); + +// App.Screenshot ("Entered text in each entry, password should be shown"); +// } + +//// [Test] +//// public void ToggleTextColor () +//// { +//// AllElementsPresent (); +//// +//// var text = "hello"; +//// App.EnterText (PlatformQueries.EntryWithPlaceholder ("Normal"), text); +//// var initialTextColor = App.Query (q => q.Raw (string.Format ("{0} {1}:'{2}', :getCurrentTextColor", PlatformStrings.Entry, PlatformStrings.Text, text))); +//// App.Tap (q => q.Button ("Toggle Text Color")); +//// var secondTextColor = App.Query (q => q.Raw (string.Format ("{0} {1}:'{2}', :getCurrentTextColor", PlatformStrings.Entry, PlatformStrings.Text, text))); +//// Assert.AreNotEqual (initialTextColor, secondTextColor); +//// } + +// [Test] +// [Description ("Change Placeholder in each entry")] +// public void EntryGalleryChangePlaceholder () +// { +// for (var i = 1; i <= 5; i++) { +// App.ScrollDownForElement (q => q.Button ("Change Placeholder"), 5); +// App.Tap (q => q.Button ("Change Placeholder")); +// App.ScrollUpForElement (PlatformQueries.EntryWithPlaceholder ("Placeholder " + i), 5); +// } + +// App.Screenshot ("Changed placeholder 5 times"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Update Keyboard Type - #1307")] +// public void EntryGalleryChangeKeyboardType () +// { +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder ("Keyboard.Default"), 5); +// App.Tap (PlatformQueries.EntryWithPlaceholder ("Keyboard.Default")); +// App.Screenshot ("I should see the default keyboard"); +// App.PressEnter (); +// App.Screenshot ("Keyboard should be dismissed"); +// App.Screenshot ("Manually check that keyboard type is switched"); +//// App.WaitForElement (PlatformQueries.EntryWithPlaceholder ("Keyboard.Numeric")); +//// App.Tap (PlatformQueries.EntryWithPlaceholder ("Keyboard.Numeric")); +// App.Screenshot ("I should see the numeric keyboard"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Completed handler firing, keyboard dismissing - #1308")] +// public void EntryGalleryCheckCompletedKeyboardDismissed () +// { +// App.WaitForElement (q => q.Marked ("Enter something in Normal")); +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder ("Normal"), 5); +// App.Tap (PlatformQueries.EntryWithPlaceholder ("Normal")); +// App.Screenshot ("Tapped Normal"); +// App.EnterText (PlatformQueries.EntryWithPlaceholder ("Normal"), "It has been entered"); +// App.Screenshot ("The keyboard should be shown"); +// // App.PressEnter (); +// App.Screenshot ("Keyboard should be dismissed - Check manually"); +// //App.WaitForNoElement (q => q.Marked ("Enter something in Normal")); +// //App.ScrollUpForElement (q => q.Marked ("It has been entered"), 5); +// App.Screenshot ("Text should have changed"); +// } + +// [Test] +// [Description ("Test the TextChanged event")] +// public void EntryGalleryTextChangedEventTest () +// { +// App.Screenshot ("Waiting for entry gallery"); +// App.WaitForElement (q => q.Marked ("No typing has happened in Normal yet")); +// App.Screenshot ("Entering text in Normal"); +// App.EnterText (PlatformQueries.EntryWithPlaceholder ("Normal"), "a"); +// App.WaitForElement (q => q.Marked ("You typed in normal")); +// App.Screenshot ("Text entered, TextChanged event should have fired"); +// } + + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("All Entry Gallery elements are present - landscape")] +// public void EntryGalleryAllElementsPresentLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryAllElementsPresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Check that the keyboard shows for each Entry - landscape")] +// public void EntryGalleryKeyboardDisplaysLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryKeyboardDisplays (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Enter text in each entry - landscape")] +// public void EntryGalleryEnterTextInEachFieldAndTapScreenDismissLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryEnterTextInEachFieldAndTapScreenDismiss (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Change Placeholder in each entry - landscape")] +// public void EntryGalleryChangePlaceholderLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryChangePlaceholder (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Update Keyboard Type - #1307 - Landscape")] +// public void EntryGalleryChangeKeyboardTypeLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryChangeKeyboardType (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Completed handler firing, keyboard dismissing - #1308 - Landscape")] +// public void EntryGalleryCheckCompletedKeyboardDismissedLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryCheckCompletedKeyboardDismissed (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Test the TextChanged event - Landscape")] +// public void EntryGalleryTextChangedEventTestLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// EntryGalleryTextChangedEventTest (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GridGalleryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GridGalleryUITests.cs new file mode 100644 index 00000000..04b59460 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GridGalleryUITests.cs @@ -0,0 +1,132 @@ +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest; +using Xamarin.UITest.Queries; +using System.Threading; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("GridLayout")] + internal class GridLayoutGalleryTests : BaseTestFixture + { + // TODO - test Absolutes + // TODO: Port to new conventions + + public GridLayoutGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.GridGalleryLegacy); + } + + //void AllElementsPresent () + //{ + // App.ScrollForElement ("* marked:'Column Types:'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Absolute Width'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Auto Width'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Star'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'*'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'**'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'***'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Right'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Center'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Left'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Fill'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Spans:'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Spanning 4 columns'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Spanning 3 rows'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'Spanning 4 columns'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + // App.ScrollForElement ("* marked:'a block 3x3'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + + // App.Screenshot ("All elements present"); + //} + + + [Test] + [Category("ManualReview")] + [Description ("Check Grid Star sizing")] + [UiTest (typeof(Grid))] + public void GridLayoutGalleryStarLayout () + { + // AllElementsPresent (); + + // App.ScrollForElement ("* marked:'*'", new Drag (ScreenBounds, Drag.Direction.TopToBottom, Drag.DragLength.Medium)); + + // var oneStarWidth = App.Query (q => q.Marked ("*"))[0].Rect.Width; + // var twoStarWidth = App.Query (q => q.Marked ("**"))[0].Rect.Width; + // var threeStarWidth = App.Query (q => q.Marked ("***"))[0].Rect.Width; + + // Assert.AreEqual (threeStarWidth, oneStarWidth * 3, 2.0); + // Assert.AreEqual (twoStarWidth, oneStarWidth * 2, 2.0); + + // App.Screenshot ("Star layout correct"); + } + + // TODO port to new framework + //[Test] + //[UiTest (Test.Layouts.Grid)] + //public void GridLayoutGallerySpanSizes () + //{ + // AllElementsPresent (); + + // var unitWidth = App.Query (q => q.Marked ("Unit"))[0].Rect.Width; + // var unitHeight = App.Query (q => q.Marked ("Unit"))[0].Rect.Height; + + // var spanningFourColumnsWidth = App.Query (q => q.Marked ("Spanning 4 columns"))[0].Rect.Width; + // var spanningFourColumnsHeight = App.Query (q => q.Marked ("Spanning 4 columns"))[0].Rect.Height; + + // // platform queries deal with label rendering differences + // var threeXThreeWidth = App.Query (PlatformQueries.ThreeXThreeGridCell) [0].Rect.Width; + // var threeXThreeHeight = App.Query (PlatformQueries.ThreeXThreeGridCell) [0].Rect.Height; + + // var spanningThreeRowsWidth = App.Query (PlatformQueries.SpanningThreeRows)[0].Rect.Width; + // var spanningThreeRowsHeight = App.Query (PlatformQueries.SpanningThreeRows)[0].Rect.Height; + + // Assert.AreEqual (spanningFourColumnsWidth, unitWidth * 4, 2.0); + // Assert.AreEqual (spanningFourColumnsHeight, unitHeight, 2.0); + + // Assert.AreEqual (threeXThreeWidth, unitWidth * 3, 2.0); + // Assert.AreEqual (threeXThreeHeight, unitHeight * 3, 2.0); + + // Assert.AreEqual (spanningThreeRowsWidth, unitWidth, 2.0); + // Assert.AreEqual (spanningThreeRowsHeight, unitHeight * 3, 2.0); + + // App.Screenshot ("Span sizes correct"); + //} + + // TODO port to new framework + //[Test] + //[UiTest (Test.Layouts.Grid)] + //public void GridLayoutGalleryResizesProperlyAfterRotation () + //{ + // // Displays GridLayout bug on rotation (Issue #854) + // AllElementsPresent (); + + // AppRect detailBounds = App.DetailPage ().Rect; + + // var oneStarWidth = App.Query (q => q.Marked ("*"))[0].Rect.Width; + // var twoStarWidth = App.Query (q => q.Marked ("**"))[0].Rect.Width; + // var threeStarWidth = App.Query (q => q.Marked ("***"))[0].Rect.Width; + + // Assert.AreEqual (detailBounds.Width, oneStarWidth + twoStarWidth + threeStarWidth, 1.0); + // App.Screenshot ("All stars fill portrait screen width"); + + // App.SetOrientationLandscape (); + + // AppRect detailBoundsAfterRotation = App.DetailPage ().Rect; + // var oneStarWidthAfterRotation = App.Query (q => q.Marked ("*"))[0].Rect.Width; + // var twoStarWidthAfterRotation = App.Query (q => q.Marked ("**"))[0].Rect.Width; + // var threeStarWidthAfterRotation = App.Query (q => q.Marked ("***"))[0].Rect.Width; + + // Assert.AreEqual (detailBoundsAfterRotation.Width, oneStarWidthAfterRotation + twoStarWidthAfterRotation + threeStarWidthAfterRotation, 1.0); + // App.Screenshot ("Grid stars resized"); + + // App.SetOrientationPortrait (); + //} + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GroupedListActionsUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GroupedListActionsUITests.cs new file mode 100644 index 00000000..289b5389 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-GroupedListActionsUITests.cs @@ -0,0 +1,277 @@ +using NUnit.Framework; +using System.Threading; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("ListView")] + internal class GroupedListActionsGalleryTests : BaseTestFixture + { + // TODO Group item actions, isolate specific indices (iOS is by 1, Android by two for cells) + // TODO: Port to new conventions + + public GroupedListActionsGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.GroupedListActionsGalleryLegacy); + } + + [Test] + [Description ("All of the grouped list actions are displayed")] + public void GroupedListActionsGalleryAllElementsExist () + { +// var actions = new [] { +// "General", +// "Change group name", +// "Change group short name", +// "Child item actions", +// "Clear this group", +// "Insert group item", +// "Insert 2 group items", +// "Remove next item", +// "Dummy item RDI", +// "Remove next 2 dummy items", +// "Dummy item RmDI-1", +// "Dummy item RmDI-2", +// "Replace dummy item", +// "Dummy item RpDI", +// "Replace next two dummy items", +// "Dummy item RpDI-1", +// "Dummy item RpDI-2", +// "Select next dummy item", +// "Dummy item SI", +// "Move dummy above this one", +// "Dummy item MDI", +// "Move last 2 items above this one", +// "Dummy item M2DI-1", +// "Dummy item M2DI-2", +// "Group item actions", +// "Clear all", +// "Insert group", +// "Insert 2 groups", +// "Remove previous dummy group", +// "Remove previous 2 dummy groups", +// "Replace previous dummy group", +// "Replace previous 2 dummy groups", +// "Move next group above", +// "Move next 2 groups above" +// }; + +// foreach (var action in actions) { +// App.ScrollDownForElement (q => q.Marked (action), 40); +// } + +// App.Screenshot ("All actions are preset"); + } + +// [Test] +// [Description ("Change group name")] +// public void GroupedListActionsGalleryChangeGroupName () +// { +// App.ScrollDownForElement (q => q.Marked ("General"), 40); +// App.Screenshot ("Before changing group name"); +// App.Tap (q => q.Marked ("Change group name")); +// App.WaitForElement (q => q.Marked ("General (changed)")); +// App.Screenshot ("After changing group name"); +// } + +// [Test] +// [Description ("Child actions - clear group")] +// public void GroupedListActionsGalleryChildClearGroup () +// { +// App.ScrollDownForElement (q => q.Marked ("Clear this group"), 40); +// App.Screenshot ("Before clearing group"); +// App.Tap (q => q.Marked ("Clear this group")); +// App.WaitForNoElement (q => q.Marked ("Insert group item")); +// App.WaitForNoElement (q => q.Marked ("Insert 2 group items")); +// App.Screenshot ("After clearing the group"); +// } + +// [Test] +// [Description ("Child actions - insert item(s)")] +// public void GroupedListActionsGalleryChildInsertItems () +// { +// App.ScrollDownForElement (q => q.Marked ("Insert group item"), 40); +// App.Screenshot ("Before inserting item"); + +// App.Tap (q => q.Marked ("Insert group item")); +// App.ScrollUpForElement (q => q.Marked ("Inserted item S"), 2); +// App.WaitForElement (q => q.Marked ("Inserted item S")); +// App.Screenshot ("After inserting item"); + +// App.ScrollDownForElement (q => q.Marked ("Insert 2 group items"), 2); +// App.Tap (q => q.Marked ("Insert 2 group items")); +// App.ScrollUpForElement (q => q.Marked ("Inserted item D 0"), 2); +// App.WaitForElement (q => q.Marked ("Inserted item D 0")); +// App.WaitForElement (q => q.Marked ("Inserted item D 1")); +// App.Screenshot ("After inserting 2 items"); +// } + + +// [Test] +// [Description ("Child actions - remove item(s)")] +// public void GroupedListActionsGalleryChildRemoveItems () +// { +// App.ScrollDownForElement (q => q.Marked ("Remove next item"), 40); +// App.Screenshot ("Before removing item"); + +// App.Tap (q => q.Marked ("Remove next item")); +// App.WaitForNoElement (q => q.Marked ("Dummy item RDI")); +// App.Screenshot ("After removing item"); + +// App.ScrollDownForElement (q => q.Marked ("Remove next 2 dummy items"), 40); +// App.Tap (q => q.Marked ("Remove next 2 dummy items")); +// App.WaitForNoElement (q => q.Marked ("Dummy item RmDI-1")); +// App.WaitForNoElement (q => q.Marked ("Dummy item RmDI-2")); +// App.Screenshot ("After removing 2 items"); +// } + +// [Test] +// [Description ("Child actions - replace item(s)")] +// public void GroupedListActionsGalleryChildReplaceItems () +// { +// App.ScrollDownForElement (q => q.Marked ("Replace dummy item"), 40); +// App.Screenshot ("Before replacing item"); + +// App.Tap (q => q.Marked ("Replace dummy item")); +// App.WaitForNoElement (q => q.Marked ("Dummy item RpDI")); +// App.ScrollDownForElement (q => q.Marked ("Replaced item"), 2); +// App.Screenshot ("After replacing item"); + +// App.ScrollDownForElement (q => q.Marked ("Replace next two dummy items"), 40); +// App.Tap (q => q.Marked ("Replace next two dummy items")); +// App.WaitForNoElement (q => q.Marked ("Dummy item RpDI-1")); +// App.WaitForNoElement (q => q.Marked ("Dummy item RpDI-2")); +// App.WaitForElement (q => q.Marked ("Replaced items 0")); +// App.WaitForElement (q => q.Marked ("Replaced items 1")); +// App.Screenshot ("After replacing 2 items"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Child actions - select item(s)")] +// public void GroupedListActionsGalleryChildSelectItems () +// { +// App.ScrollDownForElement (q => q.Marked ("Select next dummy item"), 40); +// App.Screenshot ("Before selecting item"); +// App.Tap (q => q.Marked ("Select next dummy item")); +// App.Screenshot ("After selecting item"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Child actions - move item(s)")] +// public void GroupedListActionsGalleryChildMoveItems () +// { +// App.ScrollDownForElement (q => q.Marked ("Move dummy above this one"), 40); +// App.Screenshot ("Before moving item"); + +// App.Tap (q => q.Marked ("Move dummy above this one")); +// App.Screenshot ("Dummy item MDI should now be above 'Move dummy above this one'"); + +// App.Tap (q => q.Marked ("Move last 2 items above this one")); +// App.Screenshot ("Dummy item M2DI-1 and M2DI-2 should now be above 'Move last 2 items above this one'"); + +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Child item action test - landscape")] +// public void GroupedListActionsGalleryAllElementsExistLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryAllElementsExist (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Change group name - landscape")] +// public void GroupedListActionsGalleryChangeGroupNameLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChangeGroupName (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Child actions - clear group - landscape")] +// public void GroupedListActionsGalleryChildClearGroupLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChildClearGroup (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Child actions - insert item(s) - landscape")] +// public void GroupedListActionsGalleryChildInsertItemsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChildInsertItems (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + + +// [Test] +// [Description ("Child actions - remove item(s) - landscape")] +// public void GroupedListActionsGalleryChildRemoveItemsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChildRemoveItems (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Child actions - replace item(s) - landscape")] +// public void GroupedListActionsGalleryChildReplaceItemsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChildReplaceItems (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Child actions - select item(s) - landscape")] +// public void GroupedListActionsGalleryChildSelectItemsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChildSelectItems (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Child actions - move item(s) - landscape")] +// public void GroupedListActionsGalleryChildMoveItemsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// GroupedListActionsGalleryChildMoveItems (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-InputIntentUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-InputIntentUITests.cs new file mode 100644 index 00000000..10713087 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-InputIntentUITests.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Entry")] + internal class InputIntentGalleryTests : BaseTestFixture + { + // TODO: Detect keyboard types, fix scroll coordinates + // TODO: Port to new conventions + + public InputIntentGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.InputIntentGalleryLegacy); + } + + [Test] + [Description ("All entries are shown")] + public void InputIntentGalleryAllElementsExist () + { +// var inputs = new [] { +// "Default", +// "Email Input", +// "Text Input", +// "Url Input", +// "Numeric Input", +// "Telephone Input", +// "Chat Input", +// "Custom Entry" +// }; + +// foreach (var input in inputs) +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (input), 5); + +// App.Screenshot ("All Entries exist"); + } + +// [Test] +// [Description ("Tap each entry and dismiss keyboard by tapping outside of keyboard")] +// public void InputIntentGalleryTapEachEntry () +// { +// AppRect screenSize = App.MainScreenBounds (); +// var numberOfEntries = App.Query (PlatformQueries.Entrys).Length; +// App.Screenshot ("Tap each entry"); + +// var inputs = new List () { +// "Default", +// "Email Input", +// "Text Input", +// "Url Input", +// "Numeric Input", +// "Telephone Input", +// "Chat Input", +// "Custom Entry" +// }; + +// foreach (var input in inputs) { +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (input), 5); +// App.Tap (PlatformQueries.EntryWithPlaceholder (input)); +// App.Screenshot ("Input Tapped: " + input); +// App.TapCoordinates (5, screenSize.Height / 3); +// App.Screenshot ("Clicked main screen, keyboard should be dismissed"); +// } + +// App.ScrollUpForElement (q => q.Marked ("Custom Focused"), 5); + +// App.Screenshot ("Label should now say 'Custom Focused'"); +// } + +// [Test] +// [Description ("Enter text in each entry")] +// public void InputIntentGalleryEnterTextInEachEnry () +// { + +// AppRect screenSize = App.MainScreenBounds (); + +// var inputs = new Dictionary () { +// { "Default", "abc Quick weee!" }, +// { "Email Input", "s@test.com" }, +// { "Text Input", "Hi, I am text!" }, +// { "Url Input", "https://www.xamarin.com/" }, +// { "Numeric Input", "12345678910" }, +// { "Telephone Input", "0000001234" }, +// { "Chat Input", "Sorry, I wasn\'t paying attention." }, +// { "Custom Entry", "I should be custom" } +// }; + +// App.Screenshot ("Enter text in each input"); + +// foreach (var input in inputs) { +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (input.Key), 5); +// App.Tap (PlatformQueries.EntryWithPlaceholder (input.Key)); +// App.EnterText (PlatformQueries.EntryWithPlaceholder (input.Key), input.Value); +// App.Screenshot ("Text entered"); +// App.TapCoordinates (5, screenSize.Height / 3); +// App.Screenshot ("Clicked main screen, keyboard should be dismissed"); +// } + +// } + +// [Test] +// [Description ("Open keyboard and navigate back without dismissing")] +// public void InputIntentGalleryNavigateBackWithoutDismissingKeyboard () +// { +// // Should catch any regression of Issue #638, #928 +// var inputs = new List () { +// "Default", +// "Email Input", +// "Text Input", +// "Url Input", +// "Numeric Input", +// "Telephone Input", +// "Chat Input", +// "Custom Entry" +// }; + +// foreach (string input in inputs) { +// App.ScrollDownForElement (PlatformQueries.EntryWithPlaceholder (input), 5); +// App.Tap (PlatformQueries.EntryWithPlaceholder (input)); +// App.Screenshot ("Input Tapped"); + +// App.Tap (PlatformQueries.Back); +// App.Screenshot ("Back at Control Gallery"); +// App.ScrollDownForElement (q => q.Button ("InputIntent"), 2); +// App.Tap (q => q.Button ("InputIntent")); +// } +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("All entries are shown - landscape")] +// public void InputIntentGalleryAllElementsExistLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// InputIntentGalleryAllElementsExist (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Tap each entry and dismiss keyboard by tapping outside of keyboard - landscape")] +// public void InputIntentGalleryTapEachEntryLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// InputIntentGalleryTapEachEntry (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Enter text in each entry")] +// public void InputIntentGalleryEnterTextInEachEnryLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// InputIntentGalleryEnterTextInEachEnry (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + +// [Test] +// [Description ("Open keyboard and navigate back without dismissing")] +// public void InputIntentGalleryNavigateBackWithoutDismissingKeyboardLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// InputIntentGalleryNavigateBackWithoutDismissingKeyboard (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to portrait"); +// } + + } +} + + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ListUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ListUITests.cs new file mode 100644 index 00000000..e57ed902 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ListUITests.cs @@ -0,0 +1,92 @@ +using NUnit.Framework; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("ListView")] + internal class ListGalleryTests : BaseTestFixture + { + // TODO + // TODO: Port to new conventions + + public ListGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ListViewGalleryLegacy); + } +// void AllElementsExist () +// { +// for (int i = 0; i < 5; i++) +// App.WaitForElement (q => q.Marked (i.ToString ())); + +// App.Screenshot ("List elements exist"); +// } + + [Test] + [Description ("Click 0 - 5 and reset")] + public void ListGalleryClickElementsAndReset () + { +// AllElementsExist (); + +// for (int i = 0; i < 5; i++) { +// App.Tap (q => q.Raw (string.Format ("{0} index:{1}", PlatformStrings.Cell, i))); +// } + +// App.WaitForNoElement (q => q.Marked ("0"), "Timeout : 0"); +// Assert.AreEqual (2, App.Query (q => q.Marked ("5")).Length); + +// App.Screenshot ("Clicked 0 - 5"); + +// App.Tap (q => q.Raw (PlatformStrings.Cell + " index:5")); + +// App.WaitForElement (q => q.Marked ("0"), "Timeout : 0"); +// Assert.AreEqual (1, App.Query (q => q.Marked ("5")).Length); + +// App.Screenshot ("Reset elements"); + } + +// [Test] +// [Description ("Scroll to the end of the list")] +// public void ListGalleryScrollToEndOfList () +// { +// AllElementsExist (); + +// for (int i = 0; i < 50; i++) +// App.ScrollDownForElement (q => q.Marked (i.ToString ()), 2); + +// App.Screenshot ("At the bottom of the list"); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Click 0 - 5 and reset - Landscape")] +// public void ListGalleryClickElementsAndResetLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// ListGalleryClickElementsAndReset (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Scroll to the end of the list - Landscape")] +// public void ListGalleryScrollToEndOfListLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// ListGalleryScrollToEndOfList (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MapUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MapUITests.cs new file mode 100644 index 00000000..f2d55f3e --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MapUITests.cs @@ -0,0 +1,110 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System.Diagnostics; +using System.Threading; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Map")] + internal class MapGalleryTests : BaseTestFixture + { + // TODO - Figure out how to implement the map stuff for Android, ie query pins etc + // TODO: Port to new conventions + + public MapGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.MapGalleryLegacy); + } + + [Test] + [Description ("Gallery element are present")] + public void MapGalleryAllElementsPresent () + { + // CustomScrollDownToBottomForAllElements (); + // App.Screenshot ("All elements exist"); + } + + //[Test] + //[Description ("Change MapMapType")] + //public void MapGalleryMapType () + //{ + // AppRect screenBounds = App.MainScreenBounds (); + // App.DragFromToForElement (5, q => q.Button ("Map Type"), screenBounds.Width - 15, screenBounds.Height - 100, screenBounds.Width - 15, 15); + // App.Tap (q => q.Button ("Map Type")); + // App.Screenshot ("Selected Map Type"); + // App.Tap (q => q.Button ("Satellite")); + // App.Screenshot ("Satellite MapType selected"); + // App.DragFromToForElement (5, PlatformQueries.SearchBars, screenBounds.Width - 15, 75, screenBounds.Width - 15, screenBounds.Height - 100); + //} + + +// [Test] +// public void PinDetails () +// { +// App.Tap (q => q.Raw(PlatformStrings.MapPin + " index:0")); +// App.WaitForElement (q => q.Marked ("Sistine Chapel")); +// App.WaitForElement (q => q.Marked ("Piazza della Rotunda, 00186 Rome, Province of Rome, Italy")); +// +// App.Screenshot ("First pin"); +// +// App.Tap (q => q.Raw(PlatformStrings.MapPin + " index:1")); +// App.WaitForElement (q => q.Marked ("Pantheon")); +// App.WaitForElement (q => q.Marked ("Piazza del Colosseo, 00186 Rome, Province of Rome, Italy")); +// +// App.Screenshot ("Second pin"); +// +// App.Tap (q => q.Raw(PlatformStrings.MapPin + " index:2")); +// App.WaitForElement (q => q.Marked ("Colosseum")); +// App.WaitForElement (q => q.Marked ("Piazza del Colosseo, 00184 Rome, Province of Rome, Italy")); +// +// App.Screenshot ("Third pin"); +// } + + + //void CustomScrollDownToBottomForAllElements () + //{ + // AppRect screenBounds = App.MainScreenBounds (); + + // App.DragFromToForElement (5, PlatformQueries.SearchBars, screenBounds.Width - 15, screenBounds.Height - 100, screenBounds.Width - 15, 15); + // App.DragFromToForElement (5, PlatformQueries.Map, screenBounds.Width - 15, screenBounds.Height - 100, screenBounds.Width - 15, 15); + + // App.DragFromToForElement (5, q => q.Button ("Map Type"), screenBounds.Width - 15, screenBounds.Height - 100, screenBounds.Width - 15, 15); + // App.DragFromToForElement (5, q => q.Button ("Zoom In"), screenBounds.Width - 15, screenBounds.Height - 100, screenBounds.Width - 15, 15); + // App.DragFromToForElement (5, q => q.Button ("Zoom Out"), 15, screenBounds.Height - 100, 15, 15); + // App.DragFromToForElement (5, q => q.Button ("Address From Position"), screenBounds.Width - 15, screenBounds.Height - 100, screenBounds.Width - 15, 15); + //} + +/*******************************************************/ +/**************** Landscape tests **********************/ +/*******************************************************/ + + //[Test] + //[Description ("Gallery element are present - Landscape")] + //public void MapGalleryAllElementsPresentLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // MapGalleryAllElementsPresent (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + + //[Test] + //[Description ("Change MapMapType - Landscape")] + //public void MapGalleryMapTypeLandscape () + //{ + // App.SetOrientationLandscape (); + // App.Screenshot ("Rotated to Landscape"); + // MapGalleryMapType (); + // App.SetOrientationPortrait (); + // App.Screenshot ("Rotated to Portrait"); + //} + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MinimumSizeUITest.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MinimumSizeUITest.cs new file mode 100644 index 00000000..9de241c0 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-MinimumSizeUITest.cs @@ -0,0 +1,48 @@ +using NUnit.Framework; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("StackLayout")] + internal class MinimumSizeGalleryTests : BaseTestFixture + { + // TODO + // TODO: Port to new conventions + + public MinimumSizeGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.MinimumSizeGalleryLegacy); + } + + + [Test] + [Description ("Scroll to the bottom of the TableView")] + public void MinimumSizeGalleryTableViewElementsAreAccessible () + { + // AllElementsPresent (); + + // var tableView = App.Query (PlatformQueries.Tables) [0]; + + // var tableX = tableView.Rect.X; + // var tableY = tableView.Rect.Y; + // var tableWidth = tableView.Rect.Width; + // var tableHeight = tableView.Rect.Height; + + // var elementFound = App.DragFromToForElement (20, q => q.Marked ("Cell 4 Last"), tableWidth / 2, (tableY + tableHeight) - 70, tableWidth / 2, tableY + 30); + + // Assert.IsTrue (elementFound); + // App.Screenshot ("All table elements exist"); + } + +/*******************************************************/ +/**************** Landscape tests **********************/ +/*******************************************************/ + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-NavigationBarUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-NavigationBarUITests.cs new file mode 100644 index 00000000..5af7751d --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-NavigationBarUITests.cs @@ -0,0 +1,57 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System; +using System.Threading; +using Xamarin.UITest.Queries; +using System.Diagnostics; + +namespace Xamarin.Forms.Core.UITests +{ + //[TestFixture] + //[Category ("NavigationPage")] + internal class NavigationBarGalleryTests : BaseTestFixture + { + // TODO: Port to new conventions + + public NavigationBarGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + //App.NavigateToGallery (GalleryQueries.NavigationBarGalleryLegacy); + } + + //[Test] + //[Category ("ManualReview")] + //[Description ("Change NavigationPage Bar colors")] + public void NavigationBarGalleryTestsChangeColors () + { + // App.Screenshot ("Background should be green, Text and back button / arrow should be yellow"); + + // App.Tap (q => q.Button ("Change BarTextColor")); + // App.Screenshot ("Text / back button / arrow should change to teal"); + // App.Tap (q => q.Button ("Change BarTextColor")); + // App.Screenshot ("Text / back button / arrow should change to Color.Default"); + // App.Tap (q => q.Button ("Change BarTextColor")); + // App.Screenshot ("Text / back button / arrow should change to teal"); + + // App.Tap (q => q.Button ("Change BarBackgroundColor")); + // App.Screenshot ("Background color should change to navy"); + // App.Tap (q => q.Button ("Change BarBackgroundColor")); + // App.Screenshot ("Background color should change to Color.Default"); + // App.Tap (q => q.Button ("Change BarBackgroundColor")); + // App.Screenshot ("Background color should change to navy"); + + // App.Tap (q => q.Button ("Change Both to default")); + // App.Screenshot ("Background color / text / back button / arrow should change to Color.Default"); + + // App.Tap (q => q.Button ("Make sure Tint still works")); + // App.Screenshot ("Background arrow should change to red"); + + // App.Tap (q => q.Button ("Black background, white text")); + // App.Screenshot ("Status bar should be white on iOS"); + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-RelativeLayoutUITest.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-RelativeLayoutUITest.cs new file mode 100644 index 00000000..72171f39 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-RelativeLayoutUITest.cs @@ -0,0 +1,49 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System.Linq; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("RelativeLayout")] + internal class RelativeLayoutGalleryTests : BaseTestFixture + { + // TODO - Add relative layout tests + // TODO: Port to new conventions + + public RelativeLayoutGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.RelativeLayoutGalleryLegacy); + } + + [Test] + [Description ("All elements are present")] + public void RelativeLayoutGalleryAllElementsPresent () + { +// var elements = Enumerable.Range (0, 201).Select (x => x); +// foreach (int element in elements) +// App.ScrollDownForElement (q => q.Marked (element.ToString ()), 10); + } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("All elements are present - Landscape")] +// public void RelativeLayoutGalleryAllElementsPresentLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// RelativeLayoutGalleryAllElementsPresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SearchBarUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SearchBarUITests.cs new file mode 100644 index 00000000..d9461cf6 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SearchBarUITests.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Threading; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("SearchBar")] + internal class SearchBarGalleryTests : BaseTestFixture + { + // TODO: Enter text and try searching + // TODO: Port to new conventions + + public SearchBarGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.SearchBarGalleryLegacy); + } + + [Test] + [Category ("ManualReview")] + [Description ("Enter query into each SearchBar")] + public void SearchBarGalleryEnterSearchText () + { +// SearchBarGalleryAllElementsPresent (); +// for (var i = 0; i < 3; i++) { +// App.ScrollDownForElement (PlatformQueries.SearchBarWithIndex (i), 5); +// App.Tap (PlatformQueries.SearchBarWithIndex (i)); +// App.EnterText (PlatformQueries.SearchBarWithIndex (i), "Search: " + i); +// App.Screenshot ("Keyboard should be shown"); +// App.PressEnter (); +// App.WaitForElement (q => q.Marked ("Search: " + i)); +// App.Screenshot (string.Format("Keyboard should be dismissed - Label should have changed to 'Search: {0}'", i)); +// } + +// App.Tap (q => q.Button ("More SearchBars")); +// App.WaitForElement (q => q.Marked ("Search Query 2")); + +// SearchBarGalleryAllElementsPresentPageTwo (); + +// // Disabled keyboard +// App.Tap (PlatformQueries.SearchBarWithIndex (0)); +// App.Screenshot ("Should not see keyboard for disabled SearchBar"); + +// App.Tap (PlatformQueries.SearchBarWithIndex (1)); +// App.Screenshot ("Should not see keyboard for disabled SearchBar"); +// App.EnterText (PlatformQueries.SearchBarWithIndex (1), "Entered transparent"); +// App.PressEnter (); +// App.WaitForElement (q => q.Marked ("Entered transparent")); +// App.Screenshot ("Entered query for tranparent SearchBar"); + } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Enable disable keyboard, Issues #1182, #1237")] +// public void SearchBarGalleryEnableDisableSearchBar () +// { +// App.Tap (q => q.Button ("More SearchBars")); +// App.WaitForElement (q => q.Marked ("Search Query 2")); + +// SearchBarGalleryAllElementsPresentPageTwo (); + +// App.Tap (PlatformQueries.SearchBarWithIndex (0)); +// App.Screenshot ("SearchBar should not be focused, keyboard should not be shown"); + +// App.Tap (q => q.Button ("Toggle enabled")); +// App.Tap (PlatformQueries.SearchBarWithIndex (0)); +// App.EnterText (PlatformQueries.SearchBarWithIndex (0), "Now Enabled"); +// App.PressEnter (); +// App.ScrollDownForElement (q => q.Marked ("Now Enabled"), 2); +// App.Screenshot ("Enabled and abled to query"); + +// App.Tap (q => q.Button ("Toggle enabled")); +// App.Screenshot ("Disabled again"); + +// App.ScrollUpForElement (PlatformQueries.SearchBarWithIndex (0), 2); +// App.Tap (PlatformQueries.SearchBarWithIndex (0)); +// App.Screenshot ("SearchBar should not be focused, keyboard should not be shown after diabling once again"); +// } + +// [Test] +//// [Category ("Single")] +// [Description ("Test the TextChanged event")] +// public void SearchBarGalleryTextChangedEventTest () +// { +// SearchBarGalleryAllElementsPresent (); + +// App.EnterText (PlatformQueries.SearchBarWithIndex (0), "A"); +// App.Screenshot ("Entered three characters in noPlaceholder search bar"); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ("1")); +// Assert.AreEqual ("1", labelText); + +// App.EnterText (PlatformQueries.SearchBarWithIndex (1), "B"); +// App.Screenshot ("Entered three characters in normal search bar"); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ("2")); +// Assert.AreEqual ("2", labelText); + +// App.EnterText (PlatformQueries.SearchBarWithIndex (2), "C"); +// App.Screenshot ("Entered three characters in activation search bar"); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ("3")); +// Assert.AreEqual ("3", labelText); + +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ +// [Test] +// [Category ("ManualReview")] +// [Description ("Enable disable keyboard, Issues #1182, #1237 - landscape")] +// public void SearchBarGalleryEnableDisableSearchBarLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// SearchBarGalleryEnableDisableSearchBar (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Category ("ManualReview")] +// [Description ("Enter query into each SearchBar - Landscape")] +// public void SearchBarGalleryEnterSearchTextLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// SearchBarGalleryEnterSearchText (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// void SearchBarGalleryAllElementsPresent () +// { +// var searchBars = App.Query (PlatformQueries.SearchBars); +// Assert.AreEqual (3, searchBars.Length); + +// App.ScrollDownForElement (q => q.Marked ("Search Query"), 5); + +// App.ScrollUp (); +// App.Screenshot ("All SearchBars present"); +// } + + + +// void SearchBarGalleryAllElementsPresentPageTwo () +// { +// App.ScrollDownForElement (q => q.Marked ("Search Query 2"), 5); +// App.ScrollDownForElement (q => q.Button ("Toggle enabled"), 5); + +// App.ScrollUp (); +// App.Screenshot ("All SearchBars present - Page 2"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SliderUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SliderUITests.cs new file mode 100644 index 00000000..11c33d7f --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SliderUITests.cs @@ -0,0 +1,94 @@ +using NUnit.Framework; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Slider")] + internal class SliderGalleryTests : BaseTestFixture + { + // TODO: Detect Slider value changes + // TODO: Port to new conventions + + public SliderGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.SliderGalleryLegacy); + } +// void AllElementsPresent () +// { +// var sliders = App.Query (PlatformQueries.Sliders); +// Assert.AreEqual (3, sliders.Length); + +// App.Screenshot ("All Sliders present"); +// } + + [Test] + [Description ("Slide all Sliders, test ValueChanged event")] + public void SliderGallerySlideAllSliders () + { +// AllElementsPresent (); + +// var sliders = App.Query (PlatformQueries.Sliders); +// var sliderLeft = sliders[0].Rect.X; +// var sliderRight = sliderLeft + sliders[0].Rect.Width - 5; // Needed to move 5 pixels left so that the drag would register +// var topSliderY = sliders[0].Rect.CenterY; +// var middleSliderY = sliders[1].Rect.CenterY; +// var bottomSliderY = sliders[2].Rect.CenterY; + +// // Move top slider, numbers should change +// App.DragFromTo (sliderLeft, topSliderY, sliderRight, topSliderY); +// App.WaitForElement (q => q.Marked ("100"), "Timeout : 100"); +// App.Screenshot ("Move first slider right"); + +// App.DragFromTo (sliderRight, topSliderY, sliderLeft, topSliderY); +// App.WaitForElement (q => q.Marked ("20"), "Timeout : 20"); +// App.Screenshot ("Move first slider left"); + +// // Move middle slider, shouldn't move +// App.DragFromTo (sliderLeft, middleSliderY, sliderRight, middleSliderY); +// App.WaitForElement (q => q.Marked ("20"), "Timeout : 20"); +// App.Screenshot ("Tried to move disabled slider"); + +// // Move bottom slider, should move but nothing happens +// App.DragFromTo (sliderLeft, bottomSliderY, sliderRight, bottomSliderY); +// App.WaitForElement (q => q.Marked ("20"), "Timeout : 20"); +// App.Screenshot ("Move third slider right"); + +// App.DragFromTo (sliderRight, bottomSliderY, sliderLeft, bottomSliderY); +// App.WaitForElement (q => q.Marked ("20"), "Timeout : 20"); +// App.Screenshot ("Move first slider left"); + + } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// public void AllElementsPresentLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// AllElementsPresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Slide all Sliders - Landscape")] +// public void SliderGallerySlideAllSlidersLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// SliderGallerySlideAllSliders (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StackLayoutUITest.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StackLayoutUITest.cs new file mode 100644 index 00000000..b17c7ec8 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StackLayoutUITest.cs @@ -0,0 +1,76 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System.Collections.Generic; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("StackLayout")] + internal class StackLayoutGalleryTests : BaseTestFixture + { + // TODO + // TODO: Port to new conventions + + public StackLayoutGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.StackLayoutGalleryLegacy); + } + +// void AllElementsPresent () +// { +// var buttons = new [] { +// "Boring", +// "Exciting!", +// "Amazing!", +// "Meh" +// }; + +// foreach (var button in buttons) { +// App.WaitForElement (q => q.Button (button)); +// } + +// App.Screenshot ("All elements exist"); +// } + + [Test] + [Description ("Check that each button is there and click them")] + public void StackLayoutGalleryClickEachButton () + { +// AllElementsPresent (); + +// App.Tap (q => q.Button ("Boring")); +// App.WaitForElement (q => q.Button ("clicked1"), "Timeout : clicked1"); + +// App.Tap (q => q.Button ("Exciting!")); +// App.WaitForElement (q => q.Button ("clicked2"), "Timeout : clicked2"); + +// App.Tap (q => q.Button ("Amazing!")); +// App.WaitForElement (q => q.Button ("clicked3"), "Timeout : clicked3"); + +// App.Tap (q => q.Button ("Meh")); +// App.WaitForElement (q => q.Button ("clicked4"), "Timeout : clicked4"); + +// App.Screenshot ("All buttons clicked"); + } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ +// [Test] +// [Description ("Check that each button is there and click them - Landscape")] +// public void StackLayoutGalleryClickEachButtonLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// StackLayoutGalleryClickEachButton (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StepperUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StepperUITests.cs new file mode 100644 index 00000000..a468e310 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-StepperUITests.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Diagnostics; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Stepper")] + internal class StepperGalleryTests : BaseTestFixture + { + // TODO: Checking enabled / disabled states + // TODO: Port to new conventions + + public StepperGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.StepperGalleryLegacy); + } + + [Test] + [Description ("Check all elements exist")] + public void StepperGalleryAllElementsPresent () + { +// App.WaitForElement (PlatformQueries.LabelWithText ("0")); +// var labels = App.Query (PlatformQueries.LabelWithText ("0")); +// Assert.AreEqual (2, labels.Length); + +// var steppers = App.Query (PlatformQueries.Steppers); +// Assert.AreEqual (2, steppers.Length); + +// App.Screenshot ("All elements exist"); + } + +// [Test] +// [Description ("Check that value changed event fires")] +// public void StepperGalleryValueChangedEventTest () +// { +// StepperGalleryAllElementsPresent (); +// var labelText = ""; +// for (int i = 1; i <= 5; i++) { +// App.Tap (PlatformQueries.StepperWithIndex (0)); +// App.Screenshot (string.Format ("Tapped first stepper {0} times", i)); +// App.WaitForElement (PlatformQueries.LabelWithText ((i*10).ToString ())); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ((i*10).ToString ())); +// Assert.AreEqual ((i*10).ToString (), labelText); +// } + +// for (int i = 1; i <= 5; i++) { +// App.Tap (PlatformQueries.StepperWithIndex (1)); +// App.Screenshot (string.Format ("Tapped second stepper {0} times", i)); +// App.WaitForElement (PlatformQueries.LabelWithText ((i*.05).ToString ())); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ((i*.05).ToString ())); +// Assert.AreEqual ((i*.05).ToString (), labelText); +// } +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Check all elements exist - Landscape")] +// public void StepperGalleryAllElementsPresetLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// StepperGalleryAllElementsPresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Check that events fire - Landscape")] +//// [Category ("Single")] +// public void StepperGalleryEventTestLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// StepperGalleryValueChangedEventTest (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SwitchUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SwitchUITests.cs new file mode 100644 index 00000000..67a23d88 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-SwitchUITests.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using System.Diagnostics; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Switch")] + internal class SwitchGalleryTests : BaseTestFixture + { + // TODO: Checking enabled / disabled states + // TODO: Port to new conventions + + public SwitchGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.SwitchGalleryLegacy); + } + + [Test] + [Description ("Check all elements exist")] + public void SwitchGalleryAllElementsPresent () + { +// var label = App.Query (PlatformQueries.LabelWithText("Test Label")); +// Assert.AreEqual (1, label.Length); + +// var switches = App.Query (q => q.Raw ("Switch")); +// Assert.AreEqual (3, switches.Length); + +// var steppers = App.Query (PlatformQueries.Steppers); +// Assert.AreEqual (1, steppers.Length); + +// App.Screenshot ("All elements exist"); + } + +// [Test] +// [Description ("Check that events fire")] +//// [Category ("Single")] +// public void SwitchGalleryEventTest () +// { +// App.Tap (PlatformQueries.SwitchWithIndex (0)); +// App.Screenshot ("Toggled normal switch"); +// App.WaitForElement (PlatformQueries.LabelWithText ("Toggled normal switch")); +// var labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ("Toggled normal switch")); +// Assert.AreEqual ("Toggled normal switch", labelText); + +// App.Tap (PlatformQueries.SwitchWithIndex (1)); +// App.Screenshot ("Tried to toggle disabled switch"); +// App.WaitForElement (PlatformQueries.LabelWithText ("Toggled normal switch")); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ("Toggled normal switch")); +// Assert.AreEqual ("Toggled normal switch", labelText); + +// App.Tap (PlatformQueries.SwitchWithIndex (2)); +// App.Screenshot ("Toggled transparent switch"); +// App.WaitForElement (PlatformQueries.LabelWithText ("Toggled transparent switch")); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText ("Toggled transparent switch")); +// Assert.AreEqual ("Toggled transparent switch", labelText); + +// for (int i = 1; i <= 5; i++) { +// App.Tap (PlatformQueries.Steppers); +// App.Screenshot (string.Format ("Tapped stepper {0} times", i)); +// App.WaitForElement (PlatformQueries.LabelWithText (i.ToString ())); +// labelText = App.GetTextForQuery (PlatformQueries.LabelWithText (i.ToString ())); +// Assert.AreEqual (i.ToString (), labelText); +// } +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Check all elements exist - Landscape")] +// public void SwitchGalleryAllElementsPresetLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// SwitchGalleryAllElementsPresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Check that events fire - Landscape")] +//// [Category ("Single")] +// public void SwitchGalleryEventTestLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// SwitchGalleryEventTest (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TableViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TableViewUITests.cs new file mode 100644 index 00000000..5f9bd80c --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TableViewUITests.cs @@ -0,0 +1,76 @@ +using System; +using System.Runtime; +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("TableView")] + internal class TableViewGalleryTests : BaseTestFixture + { + + // TODO: test sizes + // TODO: Port to new conventions + + public TableViewGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.TableViewGalleryLegacy); + } + + [Test] + [Description ("Elements of section header are present")] + public void TableViewGalleryHeader () + { +// App.WaitForElement (q => q.Marked ("Section One"), "Timeout : Section One"); +// App.Screenshot ("Header is present"); + } + +// [Test] +// [Description ("TableCells are present")] +// public void TableViewGalleryTableCellsArePresent () +// { +// var list = App.Query (PlatformQueries.Tables); +// Assert.AreEqual (1, list.Length); +// App.WaitForElement (q => q.Marked ("View Cell 1"), "Timeout : View Cell 1"); +// App.WaitForElement (q => q.Marked ("View Cell 2"), "Timeout : View Cell 2"); + +// App.Screenshot ("TableCells are present"); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Elements of CustomHeader are present - Landscape")] +// public void TableViewGalleryCustomHeaderLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TableViewGalleryHeader (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("TableCells are present - Landscape")] +// public void TableViewGalleryTableCellsArePresentLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TableViewGalleryTableCellsArePresent (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedCarouselPageUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedCarouselPageUITests.cs new file mode 100644 index 00000000..f01641a5 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedCarouselPageUITests.cs @@ -0,0 +1,407 @@ +using NUnit.Framework; +using Xamarin.UITest; +using System.Threading; +using Xamarin.UITest.Queries; +using System; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Templated")] + internal class TemplatedCarouselPageGalleryTests : BaseTestFixture + { + // TODO: Port to new conventions + + public TemplatedCarouselPageGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.TemplatedCarouselPageGalleryLegacy); + } + //AppRect scrollContainerBounds = new AppRect (); + +// void AllElementsPresent () +// { +// AllElementExistForPage (0); + +// App.Screenshot ("All elements found on page 0"); + +// SwipeLeft (); + +// App.Screenshot ("Swiped left"); + +// AllElementExistForPage (1); + +// App.Screenshot ("All elements found on page 1"); +// } + + [Test] + [Description ("Insert page")] + public void TemplatedCarouselPageGalleryInsertPage () + { +// AllElementsPresent (); + +// App.Tap (q => q.Button ("Insert Tab: 1")); + +// SwipeLeft (); + +// AllElementExistForPage (2); +// App.Screenshot ("At page 2"); + +// SwipeRight (); + +// AllElementExistForPage (1); +// App.Screenshot ("At page 1"); + +// SwipeRight (); + +// AllElementExistForPage (0); +// App.Screenshot ("At page 0"); + } + +// [Test] +// [Description ("Remove page")] +// public void TemplatedCarouselPageGalleryRemovePage () +// { +// AllElementsPresent (); + +// App.Tap (q => q.Button ("Remove Tab: 1")); + +// AllElementExistForPage (0); +// App.Screenshot ("Removed page 1"); +// } + +// [Test] +// [Description ("Insert / Remove page")] +// public void TemplatedCarouselPageGalleryAddRemovePage () +// { +// AllElementsPresent (); + +// App.Tap (q => q.Button ("Insert Tab: 1")); + +// SwipeLeft (); + +// AllElementExistForPage (2); +// App.Screenshot ("At page 2"); + +// App.Tap (q => q.Button ("Remove Tab: 2")); +// AllElementExistForPage (0); +// App.Screenshot ("Removed page 2"); + +// SwipeLeft (); + +// App.Tap (q => q.Button ("Remove Tab: 1")); +// AllElementExistForPage (0); +// App.Screenshot ("Removed page 1"); +// } + +// [Test] +// [Description ("Reset pages")] +// public void TemplatedCarouselPageGalleryResetAllPages () +// { +// AllElementsPresent (); + +// App.WaitForElement (q => q.Button ("Insert Tab: 1")); +// App.Tap (q => q.Button ("Insert Tab: 1")); + +// SwipeLeft (); +// AllElementExistForPage (2); +// App.Tap (q => q.Button ("Insert Tab: 2")); + +// SwipeLeft (); +// AllElementExistForPage (3); +// App.Screenshot ("At page 3"); + +// SwipeRight (); +// App.Tap (q => q.Button ("Reset all tabs: 2")); + +// AllElementExistForPage (0); +// App.Screenshot ("Pages reset"); + +// SwipeLeft (); +// AllElementExistForPage (1); +// App.Screenshot ("On Page 1 again"); + +// SwipeLeft (); +// AllElementExistForPage (1); +// App.Screenshot ("On Page 1 again"); +// } + +// [Test] +// [Description ("Insert / go to next pages")] +// public void TemplatedCarouselPageGalleryNextPage () +// { +// TemplatedCarouselPageGalleryInsertPage (); + +// AppRect screenSize = App.MainScreenBounds (); +// ScrollDownForQuery (q => q.Button ("Delayed reset: 0"), scrollContainerBounds); +// App.Tap (q => q.Button ("Next Page: 0")); +// AllElementExistForPage (1); +// App.Screenshot ("At page 1"); + +// ScrollDownForQuery (q => q.Button ("Delayed reset: 1"), scrollContainerBounds); +// App.Tap (q => q.Button ("Next Page: 1")); +// AllElementExistForPage (2); +// App.Screenshot ("At page 2"); + +// ScrollDownForQuery (q => q.Button ("Delayed reset: 2"), scrollContainerBounds); +// App.Tap (q => q.Button ("Next Page: 2")); +// AllElementExistForPage (0); +// App.Screenshot ("At page 0"); +// } + +// [Test] +// [Description ("Reproduction for a crash related to adding / reseting pages")] +// public void TemplatedCarouselPageGalleryAddResetCrash () +// { +// AllElementsPresent (); + +// SwipeRight (); + +// App.Tap (q => q.Button ("Insert Tab: 0")); +// App.Tap (q => q.Button ("Insert Tab: 0")); +// App.Screenshot ("Added two pages from Page 0"); + +// SwipeLeft (); +// App.Tap (q => q.Button ("Insert Tab: 3")); +// App.Tap (q => q.Button ("Insert Tab: 3")); +// App.Screenshot ("Added two pages from Page 3"); + +// App.Tap (q => q.Button ("Reset all tabs: 3")); +// AllElementExistForPage (0); +// App.Screenshot ("Pages reset without crashing"); +// } + +// [Test] +// [Description ("Reproduction for a crash related to adding / reseting pages")] +// public void TemplatedCarouselPageGalleryAnotherAddResetCrash () +// { +// AllElementsPresent (); + +// App.WaitForElement (q => q.Button ("Insert Tab: 1")); +// App.Tap (q => q.Button ("Insert Tab: 1")); + +// SwipeLeft (); + +// AllElementExistForPage (2); +// App.Screenshot ("At page 2"); + +// App.Tap (q => q.Button ("Reset all tabs: 2")); +// App.WaitForElement (q => q.Marked ("Insert Tab: 0")); +// AllElementExistForPage (0); +// } + +// [Test] +// [Description ("Delayed reset of all content")] +// public void TemplatedCarouselPageGalleryDelayResetAllElements () +// { +// AllElementsPresent (); + +// App.ScrollDownForElement (q => q.Button ("Delayed reset: 1"), 2); +// App.Tap (q => q.Button ("Delayed reset: 1")); + +// App.WaitForNoElement (q => q.Marked ("Lorem ipsum dolor sit amet #1")); +// App.WaitForElement (q => q.Marked ("Insert Tab: 0")); +// AllElementExistForPage (0); +// } + +// [Test] +// [Description ("Reproduction for a crash related to removing the first page")] +// public void TemplatedCarouselPageGalleryRemoveFirstPageAndResetCrash () +// { +// AllElementsPresent (); + +// SwipeRight (); +// AllElementExistForPage (0); + +// App.Tap (q => q.Marked ("Remove Tab: 0")); +// App.Screenshot ("Remove first page"); + +// AllElementExistForPage (1); +// App.Tap (q => q.Marked ("Reset all tabs: 1")); + +// AllElementExistForPage (0); +// App.Screenshot ("Reset all pages"); +// } + +// void SwipeLeft () +// { + +// AppRect swipeLabelBounds = App.Query (q => q.Marked ("Swipe Here"))[0].Rect; +// // Account for padded scrollview implementations on the different platforms +// App.DragFromTo ( +// scrollContainerBounds.X + scrollContainerBounds.Width - PlatformValues.OffsetForScrollView, +// swipeLabelBounds.CenterY, +// scrollContainerBounds.X + PlatformValues.OffsetForScrollView, +// swipeLabelBounds.CenterY +// ); +// Thread.Sleep (2000); +// } + +// void SwipeRight () +// { + +// AppRect swipeLabelBounds = App.Query (q => q.Marked ("Swipe Here"))[0].Rect; +// // Account for padded scrollview implementations on the different platforms +// App.DragFromTo ( +// scrollContainerBounds.X + PlatformValues.OffsetForScrollView, +// swipeLabelBounds.CenterY, +// scrollContainerBounds.X + scrollContainerBounds.Width - PlatformValues.OffsetForScrollView, +// swipeLabelBounds.CenterY +// ); +// Thread.Sleep (2000); +// } + +// void ScrollDownForQuery (Func query, AppRect scrollContainer) +// { +// AppRect screenSize = App.MainScreenBounds (); +// float swipeY = scrollContainer.X + 5; +// App.DragFromToForElement (5, query, swipeY, (2 / 3.0f) * screenSize.Height, swipeY, screenSize.Height / 3.0f); +// } + +// void ScrollUpForQuery (Func query, AppRect scrollContainer) +// { +// AppRect screenSize = App.MainScreenBounds (); +// float swipeY = scrollContainer.X + 5; +// App.DragFromToForElement (2, query, swipeY, screenSize.Height / 3.0f, swipeY, (2 / 3.0f) * screenSize.Height); +// } + + +// void AllElementExistForPage (int index) +// { +// var title = "Lorem ipsum dolor sit amet #" + index; +// // Wait for element to load before querying its parent (problem on iOS) +// if (App.Query (q => q.Marked (title)).Length < 1) +// App.ScrollUpForElement (q => q.Marked (title), 3); +// App.WaitForElement (q => q.Marked (title)); +// scrollContainerBounds = App.Query (q => q.Marked (title).Parent ())[2].Rect; + +// ScrollUpForQuery (q => q.Marked (title), scrollContainerBounds); + +// var buttons = new [] { +// "Insert Tab: " + index, +// "Change title: " + index, +// "Remove Tab: " + index, +// "Reset all tabs: " + index, +// "Next Page: " + index, +// "Delayed reset: " + index, +// }; + +// App.WaitForElement (q => q.Marked (title), "Timeout: " + title); + +// foreach (var button in buttons) { +// if (App.Query (q => q.Button (button)).Length < 1) +// ScrollDownForQuery (q=> q.Button (button), scrollContainerBounds); +// App.WaitForElement (q => q.Button (button)); +// } +// ScrollUpForQuery (q => q.Marked (title), scrollContainerBounds); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Insert page - Landscape")] +// public void TemplatedCarouselPageGalleryInsertPageLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryInsertPage (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Remove page - Landscape")] +// public void TemplatedCarouselPageGalleryRemovePageLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryRemovePage (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Insert / Remove page - Landscape")] +// public void TemplatedCarouselPageGalleryAddRemovePageLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryAddRemovePage (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Reset pages - Landscape")] +// public void TemplatedCarouselPageGalleryResetAllPagesLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryResetAllPages (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Insert / go to next pages - Landscape")] +// public void TemplatedCarouselPageGalleryNextPageLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryNextPage (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Reproduction for a crash related to adding / reseting pages - Landscape")] +// public void TemplatedCarouselPageGalleryAddResetCrashLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryAddResetCrash (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Reproduction for a crash related to adding / reseting pages - Landscape")] +// public void TemplatedCarouselPageGalleryAnotherAddResetCrashLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryAnotherAddResetCrash (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Delayed reset of all content - Landscape")] +// public void TemplatedCarouselPageGalleryDelayResetAllElementsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryDelayResetAllElements (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Reproduction for a crash related to removing the first page - Landscape")] +// public void TemplatedCarouselPageGalleryRemoveFirstPageAndResetCrashLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedCarouselPageGalleryRemoveFirstPageAndResetCrash (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedTabPageUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedTabPageUITests.cs new file mode 100644 index 00000000..180c7bff --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-TemplatedTabPageUITests.cs @@ -0,0 +1,346 @@ +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.Queries; +using System; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Templated")] + internal class TemplatedTabPageGalleryTests : BaseTestFixture + { + // TODO + // TODO: Port to new conventions + + public TemplatedTabPageGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.TemplatedTabbedPageGalleryLegacy); + } + +// void AllElementsExist () +// { +// var labels = new [] { +// "Lorem ipsum dolor sit amet #0", +// "Page 0", +// "Page 1", +// }; + +// foreach (var label in labels) +// App.WaitForElement (q => q.Marked (label), "Timeout : " + label); + +// AllElementExistForPage (0); + +// App.Tap (q => q.Marked ("Page 1")); +// AllElementExistForPage (1); + +// App.Screenshot ("All elements exist"); +// } + + [Test] + [Description ("Insert tab")] + public void TemplatedTabPageGalleryInsertTab () + { +// AllElementsExist (); + +// App.Tap (q => q.Button ("Insert Tab: 1")); +// App.WaitForElement (q => q.Marked ("Page 2"), "Timeout : Page 2"); + +// App.Screenshot ("Page 2 added"); + +// App.Tap (q => q.Marked ("Page 2")); +// AllElementExistForPage (2); + +// App.Screenshot ("Page 2 selected"); + } + +// [Test] +// [Description ("Insert tab crash reproduction")] +// public void TemplatedTabPageGalleryInsertTabCrash () +// { +// TemplatedTabPageGalleryInsertTab (); +// App.Tap (q => q.Marked ("Page 1")); +// AllElementExistForPage (1); + +// App.Tap (q => q.Marked ("Page 0")); +// AllElementExistForPage (0); +// } + +// [Test] +// [Description ("Change tab Title")] +// public void TemplatedTabPageGalleryChangeTitles () +// { +// AllElementsExist (); +// App.Tap (q => q.Marked ("Change title: 1")); +// App.WaitForNoElement (q => q.Marked ("Page 1"), "Timeout : Page 1"); + +// // Change Page 1 title +// for (int i = 0; i < 3; i++) { +// App.WaitForElement (q => q.Marked ("Title: " + i), "Timeout : Title " + i); +// App.Tap (q => q.Marked ("Change title: 1")); +// } + +// App.Screenshot ("Page 1 titles changed"); + +// // Change Page 0 title +// App.Tap (q => q.Marked ("Page 0")); +// App.Tap (q => q.Button ("Change title: 0")); +// App.WaitForNoElement (q => q.Marked ("Page 0"), "Timeout : Page 0"); + +// for (int i = 0; i < 3; i++) { +// App.WaitForElement (q => q.Marked ("Title: " + i), "Timeout : Title " + i); +// App.Tap (q => q.Button ("Change title: 0")); +// } + +// App.Screenshot ("Page 0 titles changed"); +// } + +// [Test] +// [Description ("Move tabs")] +// public void TemplatedTabPageGalleryMoveTabs () +// { +// AllElementsExist (); + +// int pageZeroTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 0"); +// int pageOneTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 1"); + +// // Elements found +// Assert.AreNotEqual (-1, pageZeroTabIndex); +// Assert.AreNotEqual (-1, pageOneTabIndex); + +// Assert.Greater (pageOneTabIndex, pageZeroTabIndex); + +// App.Screenshot ("Tabs before move"); + +// App.Tap (q => q.Button ("Move Tab: 1")); + +// int pageZeroMovedTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 0"); +// int pageOneMovedTabIndex = App.IndexForElementWithText (PlatformQueries.Labels, "Page 1"); + +// // Elements found +// Assert.AreNotEqual (-1, pageZeroMovedTabIndex); +// Assert.AreNotEqual (-1, pageOneMovedTabIndex); + +// Assert.Greater (pageZeroMovedTabIndex, pageOneMovedTabIndex); + +// App.Screenshot ("Tabs after move"); +// } + +// [Test] +// [Description ("Remove tabs")] +// public void TemplatedTabPageGalleryRemoveTabs () +// { +// AllElementsExist (); + +// App.Tap (q => q.Button ("Remove Tab: 1")); +// App.WaitForNoElement (q => q.Marked ("Page 1"), "Timeout : Page 1"); + +// App.Screenshot ("Remove Page 1"); +// } + +// [Test] +// [Description ("Add / remove tabs")] +// public void TemplatedTabPageGalleryAddRemoveTabs () +// { +// TemplatedTabPageGalleryInsertTab (); + +// App.Tap (q => q.Button ("Remove Tab: 2")); +// App.WaitForNoElement (q => q.Marked ("Page 2"), "Timeout : Page 2"); + +// App.Screenshot ("Remove Page 2"); + +// App.Tap (q => q.Button ("Remove Tab: 0")); +// App.WaitForNoElement (q => q.Marked ("Page 0"), "Timeout : Page 0"); + +// App.Screenshot ("Remove Page 0"); + +// AllElementExistForPage (1); +// } + +// [Test] +// [Description ("Reset tabs")] +// public void TemplatedTabPageGalleryResetAllTabs () +// { +// TemplatedTabPageGalleryChangeTitles (); + +// App.Tap (q => q.Button ("Insert Tab: 0")); +// App.WaitForElement (q => q.Marked ("Page 2"), "Timeout : Page 2"); + +// App.Screenshot ("Page 2 added"); + +// App.Tap (q => q.Marked ("Page 2")); +// AllElementExistForPage (2); + +// App.Screenshot ("Page 2 selected"); + +// App.ScrollDownForElement (q => q.Button ("Reset all tabs: 2"), 3); +// App.Tap (q => q.Button ("Reset all tabs: 2")); +// App.WaitForElement (q => q.Marked ("Page 0"), "Timeout : Page 0"); +// App.WaitForElement (q => q.Marked ("Page 1"), "Timeout : Page 1"); + +// var numberOfTabs = App.Query (q => q.Raw (PlatformStrings.Label + " {text BEGINSWITH 'Page'}")).Length; +// Assert.AreEqual (2, numberOfTabs); + +// App.Screenshot ("Tabs reset"); +// } + +// [Test] +// [Description ("Go to next tabs")] +// public void TemplatedTabPageGalleryNextPage () +// { +// TemplatedTabPageGalleryInsertTab (); + +// ScrollDownForQuery (q => q.Button ("Next Page: 2")); +// App.Tap (q => q.Button ("Next Page: 2")); +// AllElementExistForPage (0); +// App.Screenshot ("On Page 0"); + +// ScrollDownForQuery (q => q.Button ("Next Page: 0")); +// App.Tap (q => q.Button ("Next Page: 0")); +// AllElementExistForPage (1); +// App.Screenshot ("On Page 1"); + +// ScrollDownForQuery (q => q.Button ("Next Page: 1")); +// App.Tap (q => q.Button ("Next Page: 1")); +// AllElementExistForPage (2); +// App.Screenshot ("On Page 2"); + +// ScrollDownForQuery (q => q.Button ("Next Page: 2")); +// App.Tap (q => q.Button ("Next Page: 2")); +// AllElementExistForPage (0); +// App.Screenshot ("On Page 0"); +// } + +// void AllElementExistForPage (int index) +// { +// var title = "Lorem ipsum dolor sit amet #" + index; + +// ScrollUpForQuery (q => q.Marked (title)); + +// var buttons = new [] { +// "Insert Tab: " + index, +// "Change title: " + index, +// "Move Tab: " + index, +// "Remove Tab: " + index, +// "Reset all tabs: " + index, +// "Next Page: " + index, +// }; + +// App.WaitForElement (q => q.Marked (title)); + +// foreach (var button in buttons) +// ScrollDownForQuery (q => q.Button (button)); + +// ScrollUpForQuery (q => q.Marked (title)); +// } + +// void ScrollDownForQuery (Func query) +// { +// var screenBounds = App.MainScreenBounds (); +// App.DragFromToForElement (2, query, screenBounds.Width - 10, (2 / 3.0f) * screenBounds.Height, screenBounds.Width - 10, screenBounds.Height / 3.0f); +// } + +// void ScrollUpForQuery (Func query) +// { +// var screenBounds = App.MainScreenBounds (); +// App.DragFromToForElement (2, query, screenBounds.Width - 10, screenBounds.Height / 3.0f, screenBounds.Width - 10, (2 / 3.0f) * screenBounds.Height); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("Insert tab - Landscape")] +// public void TemplatedTabPageGalleryInsertTabLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryInsertTab (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Insert tab crash reproduction - Landscape")] +// public void TemplatedTabPageGalleryInsertTabCrashLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryInsertTabCrash (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Change tab Title - Landscape")] +// public void TemplatedTabPageGalleryChangeTitlesLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryChangeTitles (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Move tabs - Landscape")] +// public void TemplatedTabPageGalleryMoveTabsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryMoveTabs (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Remove tabs - Landscape")] +// public void TemplatedTabPageGalleryRemoveTabLandscapes () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryRemoveTabs (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Add / remove tabs - Landscape")] +// public void TemplatedTabPageGalleryAddRemoveTabsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryAddRemoveTabs (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Reset tabs - Landscape")] +// public void TemplatedTabPageGalleryResetAllTabsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryResetAllTabs (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Go to next tabs - Landscape")] +// public void TemplatedTabPageGalleryNextPageLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// TemplatedTabPageGalleryNextPage (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ToolbarGalleryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ToolbarGalleryUITests.cs new file mode 100644 index 00000000..ad00a191 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ToolbarGalleryUITests.cs @@ -0,0 +1,51 @@ +using NUnit.Framework; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("ToolBar")] + internal class ToolbarGalleryTests : BaseTestFixture + { + // TODO - Is there a ToolBar item limit, test image only toolbar item + // TODO: Port to new conventions + + public ToolbarGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ToolbarGalleryLegacy); + } + + //void AllElementsPresent () + //{ + // var elements = new [] { "One", "Two", "Three", "Four", "Click the toolbar" }; + // foreach (var element in elements) + // App.WaitForElement (q => q.Marked (element)); + + // App.Screenshot ("All elements exist"); + //} + + [Test] + public void ToolbarGalleryToolbarAction () + { + // AllElementsPresent (); + + // var elements = new [] { "One", "Two", "Three", "Four" }; + // foreach (var element in elements) { + // App.Tap (q => q.Marked (element)); + // App.WaitForElement (q => q.Marked ("Activated: " + element)); + // } + + // App.Screenshot ("Toolbar commands fire"); + } + +/*******************************************************/ +/**************** Landscape tests **********************/ +/*******************************************************/ + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs new file mode 100644 index 00000000..b425545f --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenListTests.cs @@ -0,0 +1,38 @@ +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Cells")] + internal class UnevenListTests : BaseTestFixture + { + public UnevenListTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.UnevenListGalleryLegacy); + } + + [Test] + public void UnevenListCellTest () + { + if (UnevenListTests.ShouldRunTest(RunningApp.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); + } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenViewCellUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenViewCellUITests.cs new file mode 100644 index 00000000..1b826ec0 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-UnevenViewCellUITests.cs @@ -0,0 +1,94 @@ +using NUnit.Framework; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Cells")] + internal class UnevenViewCellGalleryTests : BaseTestFixture + { + // TODO + // TODO: Port to new conventions + + public UnevenViewCellGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.UnevenViewCellGalleryLegacy); + } +// void AllElementsPresent () +// { +// App.WaitForElement (q => q.Marked ("Testing"), "Timeout : Testing"); +// App.WaitForElement (PlatformQueries.Map, "Timeout : Map"); +// App.Screenshot ("All elements exist"); +// } + + [Test] + [Description ("All views exist")] + public void UnevenViewCellGalleryScrollDownForAllElements () + { +// AllElementsPresent (); + +// var window = App.Query (q => q.Raw ("*")) [0]; +// var windowWidth = window.Rect.Width; +// var windowHeight = window.Rect.Height; + +// App.DragFromToForElement (20, q => q.Marked ("1 day"), windowWidth - 100, windowHeight - 100, windowWidth - 100, windowHeight / 2); +// App.DragFromToForElement (20, q => q.Marked ("2 days"), windowWidth - 100, windowHeight - 100, windowWidth - 100, windowHeight / 2); +// App.DragFromToForElement (20, q => q.Marked ("3 days"), windowWidth - 100, windowHeight - 100, windowWidth - 100, windowHeight / 2); +// App.DragFromToForElement (20, q => q.Marked ("4 days"), windowWidth - 100, windowHeight - 100, windowWidth - 100, windowHeight / 2); +// App.DragFromToForElement (20, q => q.Marked ("5 days"), windowWidth - 100, windowHeight - 100, windowWidth - 100, windowHeight / 2); + +// App.Screenshot ("All views exist"); + } + +// [Test] +// [Description ("Check uneven ViewCell sizes")] +// public void UnevenViewCellGalleryCheckViewCellSizes () +// { +// AllElementsPresent (); + +// var window = App.Query (q => q.Raw ("*")) [0]; +// var windowWidth = window.Rect.Width; +// var windowHeight = window.Rect.Height; + +// var unevenCellHeight = App.Query (PlatformQueries.Map) [0].Rect.Height; + +// App.DragFromToForElement (20, q => q.Marked ("1 day"), windowWidth - 100, windowHeight - 100, windowWidth - 100, windowHeight / 2); + +// var evenCellHeight = App.Query (q => q.Marked ("1 day")) [0].Rect.Height; + +// Assert.Greater (unevenCellHeight, evenCellHeight); +// } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("All views exist - Landscape")] +// public void UnevenViewCellGalleryScrollDownForAllElementsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// UnevenViewCellGalleryScrollDownForAllElements (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + +// [Test] +// [Description ("Check uneven ViewCell sizes - Landscape")] +// public void UnevenViewCellGalleryCheckViewCellSizesLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// UnevenViewCellGalleryCheckViewCellSizes (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ViewCellUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ViewCellUITests.cs new file mode 100644 index 00000000..c6a79e71 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/Legacy-ViewCellUITests.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("Cells")] + internal class ViewCellGalleryTests : BaseTestFixture + { +// // TODO + // TODO: Port to new conventions + + public ViewCellGalleryTests () + { + ShouldResetPerFixture = false; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ViewCellGalleryLegacy); + } + +// public void AllElementsPresent () +// { +// App.WaitForElement (q => q.Marked ("Testing"), "Timeout : Testing"); +// App.WaitForElement (q => q.Marked ("0"), "Timeout : 0"); +// App.WaitForElement (q => q.Marked ("BrandLabel"), "Timeout : BrandLabel"); + +// App.Screenshot ("All elements exist"); +// } + + [Test] + [UiTest (typeof(ViewCell))] + [Description ("All elements exist")] + public void ViewCellGalleryScrollDownForAllElements () + { +// AllElementsPresent (); + +// App.ScrollForElement ("* marked:'0'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); +// App.ScrollForElement ("* marked:'1'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); +// App.ScrollForElement ("* marked:'2'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); +// App.ScrollForElement ("* marked:'3'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); +// App.ScrollForElement ("* marked:'4'", new Drag (ScreenBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)); + +// App.Screenshot ("All ViewCells exist"); + } + +///*******************************************************/ +///**************** Landscape tests **********************/ +///*******************************************************/ + +// [Test] +// [Description ("All elements exist - Landscape")] +// public void ViewCellGalleryScrollDownForAllElementsLandscape () +// { +// App.SetOrientationLandscape (); +// App.Screenshot ("Rotated to Landscape"); +// ViewCellGalleryScrollDownForAllElements (); +// App.SetOrientationPortrait (); +// App.Screenshot ("Rotated to Portrait"); +// } + + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/PickerUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/PickerUITests.cs new file mode 100644 index 00000000..19357fad --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/PickerUITests.cs @@ -0,0 +1,54 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/ProgressBarUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ProgressBarUITests.cs new file mode 100644 index 00000000..5d95145c --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ProgressBarUITests.cs @@ -0,0 +1,56 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/RootGalleryUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs new file mode 100644 index 00000000..764c3a69 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/RootGalleryUITests.cs @@ -0,0 +1,88 @@ +using NUnit.Framework; +using Xamarin.UITest; + +using System; +using System.Threading; +using System.Collections.Generic; +using System.Linq; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +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 ("RootGallery")] + internal class RootGalleryUITests : BaseTestFixture + { + IEnumerable 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)); + if(!page.IsModal || App is iOSApp) + App.WaitForElement (q => q.Marked (page.PageId)); + App.Screenshot ("Page: " + page.PageId); + } + } + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ScrollViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ScrollViewUITests.cs new file mode 100644 index 00000000..ed75fa43 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ScrollViewUITests.cs @@ -0,0 +1,68 @@ +using NUnit.Framework; +using Xamarin.UITest; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/SearchBarUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/SearchBarUITests.cs new file mode 100644 index 00000000..e45ba385 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/SearchBarUITests.cs @@ -0,0 +1,54 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/SliderUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/SliderUITests.cs new file mode 100644 index 00000000..6f8eb775 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/SliderUITests.cs @@ -0,0 +1,54 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/StepperUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/StepperUITests.cs new file mode 100644 index 00000000..bec1e22e --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/StepperUITests.cs @@ -0,0 +1,54 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/SwitchUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/SwitchUITests.cs new file mode 100644 index 00000000..344aae4a --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/SwitchUITests.cs @@ -0,0 +1,54 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/TimePickerUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/TimePickerUITests.cs new file mode 100644 index 00000000..63e6a29e --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/TimePickerUITests.cs @@ -0,0 +1,56 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("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.iOS.UITests/Tests/ToolbarItemTests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs new file mode 100644 index 00000000..ce846db9 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ToolbarItemTests.cs @@ -0,0 +1,102 @@ +using System; +using NUnit.Framework; +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("ToolbarItem")] + internal class ToolbarItemTests : BaseTestFixture + { + string btn1Id = "tb1"; + string btn4Id = "tb4"; + + static bool isSecondaryMenuOpen = false; + static void ShouldShowMenu () + { + if (App is AndroidApp) { + isSecondaryMenuOpen = true; + //show secondary menu + App.Tap (c => c.Class ("android.support.v7.widget.ActionMenuPresenter$OverflowMenuButton")); + } + } + + static void ShouldHideMenu () + { + if (App is AndroidApp && isSecondaryMenuOpen) { + isSecondaryMenuOpen = false; + App.Back (); + } + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.ToolbarItemGallery); + if (App is iOSApp) { + btn1Id = "menuIcon"; + btn4Id = "tb4"; + } + } + + [Test] + public void ToolbarButtonsClick () + { + ShouldHideMenu (); + App.Tap (c => c.Marked (btn1Id)); + } + + [Test] + public void ToolbarButtonsCommand () + { + ShouldShowMenu (); + if (App is AndroidApp) { + var btn = App.Query (c => c.Marked (btn4Id))[0]; + } + else { + App.Tap (c => c.Marked (btn4Id)); + } + } + + [Test] + public void ToolbarButtonsDisable () + { + ShouldHideMenu (); + var btn1 = App.Query (c => c.Marked (btn1Id)) [0]; + ShouldShowMenu (); + var btn2 = App.Query (c => c.Marked (btn4Id)) [0]; + Assert.False (btn1.Enabled, "Toolbar Item should be disable"); + //TODO: how to check Enable for the textview + //Assert.False (btn2.Enabled, "Toolbar Item should be disable"); + } + + [Test] + public void ToolbarButtonsExist () + { + ShouldHideMenu (); + var existsPrimary = App.Query (c => c.Marked (btn1Id)).Length; + var existsPrimary2 = App.Query (c => c.Marked ("tb2")).Length; + ShouldShowMenu (); + var existsSecondary = App.Query (c => c.Marked ("tb3")).Length; + var existsSecondary2 = App.Query (c => c.Marked (btn4Id)).Length; + Assert.True (existsPrimary > 0, "Toolbar Item 1 no name, not found"); + Assert.True (existsPrimary2 > 0, "Toolbar Item 2, not found"); + Assert.True (existsSecondary > 0, "Toolbar Item 1 no name, not found"); + Assert.True (existsSecondary2 > 0, "Toolbar Item 1, not found"); + } + + [Test] + public void ToolbarButtonsOrder () + { + ShouldHideMenu (); + 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); + } + + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs new file mode 100644 index 00000000..a11d1f66 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ViewUITests.cs @@ -0,0 +1,257 @@ +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 +{ + 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 () + { + //var remote = RemoteFactory.CreateRemote (App, "AnchorX", PlatformViewType); + //remote.GoTo (); + + ////App.LogPropertiesForView (remote.ViewQuery, true); + + //if (App is AndroidApp) { + // var anchorX = remote.GetProperty (View.AnchorXProperty); + // var viewWidth = remote.GetView ().Rect.Width; + // Assert.AreEqual (anchorX, 0.25 * viewWidth); + //} else if (App is iOSApp) { + // var anchorXMatrix = remote.GetProperty (View.AnchorXProperty); + // var viewWidth = remote.GetView ().Rect.Width; + // Assert.AreEqual (anchorXMatrix.M30, 0 - (viewWidth * 0.25f)); + //} + } + + // [Test] + // [UiTest (Test.VisualElement.AnchorY)] + // TODO: working on some views, others not + public virtual void _AnchorY () + { + //var remote = RemoteFactory.CreateRemote (App, "AnchorY", PlatformViewType); + //remote.GoTo (); + + //if (App is AndroidApp) { + // var anchorY = remote.GetProperty (View.AnchorYProperty); + // var viewHeight = remote.GetView ().Rect.Height; + // Assert.AreEqual (anchorY, viewHeight); + //} else if (App is iOSApp) { + // var anchorYMatrix = remote.GetProperty (View.AnchorYProperty); + // var viewHeight = remote.GetView ().Rect.Height; + // Assert.AreEqual (anchorYMatrix.M31, viewHeight / 2.0f); + //} + } + + // [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 (App, "BackgroundColor", PlatformViewType); +// remote.GoTo (); +// if (App is iOSApp) { +// var backgroundColor = remote.GetProperty (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 (View.IsEnabledProperty); + Assert.IsTrue (enabled); + + remote.TapStateButton (); + + enabled = remote.GetProperty (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 (); + + Assert.AreEqual (1, viewPre.Length); + + 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 (); + + float opacity = -1f; + opacity = remote.GetProperty (View.OpacityProperty); + Assert.AreEqual (0.5f, opacity); + } + + [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 (App is AndroidApp) { + var rotation = remote.GetProperty (View.RotationProperty); + Assert.AreEqual (10.0f, rotation); + } else if (App is iOSApp) { + var rotationMatrix = remote.GetProperty (View.RotationProperty); + Matrix generatedMatrix = NumericExtensions.CalculateRotationMatrixForDegrees (10, Axis.Z); + Assert.AreEqual (generatedMatrix, rotationMatrix); + } + } + + [Test] + [UiTest (typeof (VisualElement), "RotationX")] + public virtual void _RotationX () + { + var remote = new ViewContainerRemote (App, Test.VisualElement.RotationX, PlatformViewType); + remote.GoTo (); + + if (App is AndroidApp) { + var rotationX = remote.GetProperty (View.RotationXProperty); + Assert.AreEqual (33.0f, rotationX); + } else if (App is iOSApp) { + var rotationXMatrix = remote.GetProperty (View.RotationXProperty); + Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (33.0f, Axis.X); + Assert.AreEqual (matrix, rotationXMatrix); + } + } + + [Test] + [UiTest (typeof (VisualElement), "RotationY")] + public virtual void _RotationY () + { + var remote = new ViewContainerRemote (App, Test.VisualElement.RotationY, PlatformViewType); + remote.GoTo (); + + if (App is AndroidApp) { + var rotationY = remote.GetProperty (View.RotationYProperty); + Assert.AreEqual (10.0f, rotationY); + } else if (App is iOSApp) { + var rotationYMatrix = remote.GetProperty (View.RotationYProperty); + Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (10.0f, Axis.Y); + Assert.AreEqual (matrix, rotationYMatrix); + } + } + + [Test] + [UiTest (typeof (VisualElement), "Scale")] + public virtual void _Scale () + { + var remote = new ViewContainerRemote (App, Test.VisualElement.Scale, PlatformViewType); + remote.GoTo (); + + var scaleMatrix = remote.GetProperty (View.ScaleProperty); + Matrix generatedMatrix = NumericExtensions.BuildScaleMatrix (0.5f); + Assert.AreEqual (generatedMatrix, scaleMatrix); + } + + [Test] + [UiTest (typeof (VisualElement), "TranslationX")] + [Category ("ManualReview")] + public virtual void _TranslationX () + { + var remote = new ViewContainerRemote (App, Test.VisualElement.TranslationX, PlatformViewType); + remote.GoTo (); + } + + [Test] + [UiTest (typeof (VisualElement), "TranslationY")] + [Category ("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.iOS.UITests/Tests/WebViewUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs new file mode 100644 index 00000000..d4233cba --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Tests/WebViewUITests.cs @@ -0,0 +1,93 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Security.Cryptography; +using System.Threading; +using System.Reflection; + +using NUnit.Framework; + +using Xamarin.Forms.CustomAttributes; +using Xamarin.UITest.Android; +using Xamarin.UITest.Queries; +using Xamarin.UITest.iOS; + +namespace Xamarin.Forms.Core.UITests +{ + [TestFixture] + [Category ("WebView")] + internal class WebViewUITests : _ViewUITests + { + public WebViewUITests () + { + PlatformViewType = Views.WebView; + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.WebViewGallery); + } + + [Category ("ManualReview")] + public override void _IsEnabled () + { + Assert.Inconclusive ("Does not make sense for WebView"); + } + + [Test] + [Category ("ManualReview")] + 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 ("ManualReview")] + public override void _Opacity () {} + + [Test] + [Category ("ManualReview")] + public override void _Rotation () {} + + [Test] + [Category ("ManualReview")] + public override void _RotationX () {} + + [Test] + [Category ("ManualReview")] + public override void _RotationY () {} + + + [Test] + [Category ("ManualReview")] + public override void _TranslationX () {} + + [Test] + [Category ("ManualReview")] + public override void _TranslationY () {} + + [Test] + [Category ("ManualReview")] + 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 diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs new file mode 100644 index 00000000..c6f2508c --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +using NUnit.Framework; + +using Xamarin.UITest; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; +using Xamarin.UITest.Queries; +using System.Text.RegularExpressions; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class AppExtensions + { + public static AppRect ScreenBounds (this IApp app) + { + return app.Query (Queries.Root ()).First().Rect; + } + + public static void NavigateBack (this IApp app) + { + app.Tap (Queries.NavigationBarBackButton ()); + } + + public static void NavigateToGallery (this IApp app, string page) + { + var text = Regex.Match (page, "'(?[^']*)'").Groups["text"].Value; + app.EnterText (q => q.Raw ("* marked:'SearchBar'"), text); + //var searchBar = app.Query (q => q.Raw ("* marked:'SearchBar'")).Single (); + Thread.Sleep(10000); + + app.Tap (q => q.Raw ("* marked:'GoToTestButton'")); + app.WaitForNoElement (o => o.Raw ("* marked:'GoToTestButton'"), "Timed out", TimeSpan.FromMinutes(2)); + + //app.Screenshot ("Navigating to gallery ..."); + //var galleryListViewBounds = app.Query (Queries.GalleryListView)[0].Rect; + //app.ScrollForElement (page, new Drag (galleryListViewBounds, Drag.Direction.BottomToTop, Drag.DragLength.Long)); + //app.Tap (q => q.Raw (page)); + //app.Screenshot ("At gallery!"); + } + + public static void NavigateToTestCases (this IApp app, string testCase) + { + app.Tap (q => q.Button ("Go to Test Cases")); + app.WaitForElement (q => q.Raw ("* marked:'TestCasesIssueList'")); + + app.EnterText (q => q.Raw ("* marked:'SearchBarGo'"), testCase); + + app.WaitForElement (q => q.Raw ("* marked:'SearchButton'")); + app.Tap (q => q.Raw ("* marked:'SearchButton'")); + + //app.NavigateToTestCase(testCase); + } + + public static void NavigateToTestCase (this IApp app, string testCase) + { + string testCasesQuery = "* marked:'" + testCase + "'"; + var testCaseIssue = app.Query (q => q.Raw ("* marked:'TestCasesIssueList'")).FirstOrDefault (); + if (testCaseIssue != null) { + AppRect scrollRect = testCaseIssue.Rect; + app.ScrollForElement (testCasesQuery, new Drag (scrollRect, Drag.Direction.BottomToTop, Drag.DragLength.Long)); + app.Tap (q => q.Raw (testCasesQuery)); + } else { + Debug.WriteLine (string.Format ("Failed to find test case {0}", testCase)); + } + } + + public static bool RectsEqual (AppRect rectOne, AppRect rectTwo) + { + const float equalsTolerance = 0.1f; + + bool areEqual = + (Math.Abs (rectOne.X - rectTwo.X) < equalsTolerance) && + (Math.Abs (rectOne.Y - rectTwo.Y) < equalsTolerance) && + (Math.Abs (rectOne.Width - rectTwo.Width) < equalsTolerance) && + (Math.Abs (rectOne.Height - rectTwo.Height) < equalsTolerance) && + (Math.Abs (rectOne.CenterX - rectTwo.CenterX) < equalsTolerance) && + (Math.Abs (rectOne.CenterY - rectTwo.CenterY) < equalsTolerance); + + return areEqual; + } + + public static void WaitForAnimating (this IApp app, Func query) + { + // Right now only checks if bounds are moving + const int pollingRate = 200; + const int timeout = 5000; + var sw = new Stopwatch (); + + var previousState = app.Query (query).First ().Rect; + + sw.Start (); + while (true) { + + var newState = app.Query (query).First ().Rect; + + if (RectsEqual (previousState, newState)) + break; + + previousState = newState; + + if (sw.ElapsedMilliseconds >= timeout) + throw new Exception("Timed out"); + + Thread.Sleep (pollingRate); + } + sw.Stop (); + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/Drag.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/Drag.cs new file mode 100644 index 00000000..71b1fa03 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/Drag.cs @@ -0,0 +1,173 @@ +using System.Reflection.Emit; + +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal class Drag + { + internal enum DragLength + { + Long, + Medium, + Short + } + + internal enum Direction + { + TopToBottom, + BottomToTop, + RightToLeft, + LeftToRight + } + + AppRect dragBounds; + float xStart; + float yStart; + float xEnd; + float yEnd; + Direction dragDirection; + Direction oppositeDirection; + DragLength dragLength; + + public Drag (AppRect dragbounds, float xStart, float yStart, float xEnd, float yEnd, Direction direction) + { + dragBounds = dragbounds; + this.xStart = xStart; + this.yStart = yStart; + this.xEnd = xEnd; + this.yEnd = yEnd; + dragDirection = direction; + oppositeDirection = GetOppositeDirection (direction); + } + + public Drag (AppRect dragBounds, Direction direction, DragLength dragLength) + { + this.dragBounds = dragBounds; + dragDirection = direction; + this.dragLength = dragLength; + SetDragForBounds (dragDirection, dragLength); + } + + void SetDragForBounds (Direction direction, DragLength dragLength) + { + // percentage of bounds to scroll centered in element + float scrollPercentage; + + switch (dragLength) { + case DragLength.Long: + scrollPercentage = 0.8f; + break; + case DragLength.Medium: + scrollPercentage = 0.5f; + break; + default: + scrollPercentage = 0.2f; + break; + } + + if (direction == Direction.LeftToRight) { + yStart = dragBounds.CenterY; + yEnd = dragBounds.CenterY; + float xDisplacement = (dragBounds.CenterX + (dragBounds.Width / 2)) - dragBounds.X; + float insetForScroll = (xDisplacement - (xDisplacement * scrollPercentage)) / 2; + xStart = dragBounds.X + insetForScroll; + xEnd = (dragBounds.CenterX + (dragBounds.Width / 2)) - insetForScroll; + } else if (direction == Direction.RightToLeft) { + yStart = dragBounds.CenterY; + yEnd = dragBounds.CenterY; + float xDisplacement = (dragBounds.CenterX + (dragBounds.Width / 2)) - dragBounds.X; + float insetForScroll = (xDisplacement - (xDisplacement * scrollPercentage)) / 2; + xStart = (dragBounds.CenterX + (dragBounds.Width / 2)) - insetForScroll; + xEnd = dragBounds.X + insetForScroll; + } else if (direction == Direction.TopToBottom) { + xStart = dragBounds.CenterX; + xEnd = dragBounds.CenterX; + float yDisplacement = (dragBounds.CenterY + (dragBounds.Height / 2)) - dragBounds.Y; + float insetForScroll = (yDisplacement - (yDisplacement * scrollPercentage)) / 2; + yStart = dragBounds.Y + insetForScroll; + yEnd = (dragBounds.CenterY + (dragBounds.Height / 2)) - insetForScroll; + } else if (direction == Direction.BottomToTop) { + xStart = dragBounds.CenterX; + xEnd = dragBounds.CenterX; + float yDisplacement = (dragBounds.CenterY + (dragBounds.Height / 2)) - dragBounds.Y; + float insetForScroll = (yDisplacement - (yDisplacement * scrollPercentage)) / 2; + yStart = (dragBounds.CenterY + (dragBounds.Height / 2)) - insetForScroll; + yEnd = dragBounds.Y + insetForScroll; + + } + } + + Direction GetOppositeDirection (Direction direction) + { + switch (direction) { + case Direction.TopToBottom: + return Direction.BottomToTop; + case Direction.BottomToTop: + return Direction.TopToBottom; + case Direction.RightToLeft: + return Direction.LeftToRight; + case Direction.LeftToRight: + return Direction.RightToLeft; + default: + return Direction.TopToBottom; + } + } + + public AppRect DragBounds + { + get { return dragBounds; } + } + + public float XStart + { + get { return xStart; } + } + + public float YStart + { + get { return yStart; } + } + + public float XEnd + { + get { return xEnd; } + } + + public float YEnd + { + get { return yEnd; } + } + + public Direction DragDirection + { + get { return dragDirection; } + set + { + if (dragDirection == value) + return; + + dragDirection = value; + oppositeDirection = GetOppositeDirection (dragDirection); + OnDragDirectionChanged (); + } + } + + void OnDragDirectionChanged () + { + SetDragForBounds (dragDirection, dragLength); + } + + public Direction OppositeDirection + { + get { return oppositeDirection; } + private set + { + if (oppositeDirection == value) + return; + + oppositeDirection = value; + } + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/Gestures.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/Gestures.cs new file mode 100644 index 00000000..548ff06d --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/Gestures.cs @@ -0,0 +1,114 @@ +using System; +using System.Dynamic; +using System.Linq; +using System.Security.Cryptography; + +using Xamarin.UITest; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class Gestures + { + public static bool ScrollForElement (this IApp app, string query, Drag drag, int maxSteps = 25) + { + int count = 0; + + int centerTolerance = 50; + + Func elementQuery = q => q.Raw (query); + + // Visible elements + if (app.Query (elementQuery).Length > 1) { + throw new UITestQueryMultipleResultsException (query); + } + + // check to see if the element is visible already + if (app.Query (elementQuery).Length == 1) { + // centering an element whos CenterX is close to the bounding rectangle's center X can sometime register the swipe as a tap + float elementDistanceToDragCenter = Math.Abs (app.Query (elementQuery).First ().Rect.CenterY - drag.DragBounds.CenterY); + if (elementDistanceToDragCenter > centerTolerance) + app.CenterElementInView (elementQuery, drag.DragBounds, drag.DragDirection); + return true; + } + + // loop until element is seen + while (app.Query (elementQuery).Length == 0 && count < maxSteps) { + app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd); + count++; + } + + if (count != maxSteps) { + // centering an element whos CenterX is close to the bounding rectangle's center X can sometime register the swipe as a tap + float elementDistanceToDragCenter = Math.Abs (app.Query (elementQuery).First ().Rect.CenterY - drag.DragBounds.CenterY); + if (elementDistanceToDragCenter > centerTolerance) + app.CenterElementInView (elementQuery, drag.DragBounds, drag.DragDirection); + return true; + } + + count = 0; + drag.DragDirection = drag.OppositeDirection; + + while (app.Query (elementQuery).Length == 0 && count < maxSteps) { + app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd); + count++; + } + + if (count != maxSteps) { + app.CenterElementInView (elementQuery, drag.DragBounds, drag.DragDirection); + return true; + } + + return false; + } + + static void CenterElementInView (this IApp app, Func element, AppRect containingView, Drag.Direction direction) + { + // TODO Implement horizontal centering + + if (direction == Drag.Direction.BottomToTop || direction == Drag.Direction.TopToBottom) { + + var elementBounds = app.Query (element).First ().Rect; + + bool elementCenterBelowContainerCenter = elementBounds.CenterY > containingView.CenterY; + bool elementCenterAboveContainerCenter = elementBounds.CenterY < containingView.CenterY; + + var displacementToCenter = Math.Abs (elementBounds.CenterY - containingView.CenterY) / 2; + + // avoid drag as touch + if (displacementToCenter < 50) + return; + + if (elementCenterBelowContainerCenter) { + + var drag = new Drag ( + containingView, + containingView.CenterX, containingView.CenterY + displacementToCenter, + containingView.CenterX, containingView.CenterY - displacementToCenter, + Drag.Direction.BottomToTop + ); + + app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd); + + } else if (elementCenterAboveContainerCenter) { + + var drag = new Drag ( + containingView, + containingView.CenterX, containingView.CenterY - displacementToCenter, + containingView.CenterX, containingView.CenterY + displacementToCenter, + Drag.Direction.TopToBottom + ); + + app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd); + } + } + } + + public static void Pan (this IApp app, Drag drag) + { + app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/Logger.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/Logger.cs new file mode 100644 index 00000000..ed0041ae --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/Logger.cs @@ -0,0 +1,71 @@ +using System; +using System.IO; +using System.Reflection; + +using Xamarin.UITest.Queries; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class Logger + { + static StreamWriter queryWriter; + + public static void Init () + { + queryWriter = new StreamWriter ("../../Xamarin.Forms.Core-UITest-queries.log", false); + } + + public static void Log (string text) + { + queryWriter.Write (text); + } + + public static void LogLine (string text = "") + { + queryWriter.WriteLine (text); + } + + public static void Close () + { + queryWriter.Flush (); + queryWriter.Close (); + } + + public static void LogQueryResult (AppResult[] resultsForQuery) + { + foreach (AppResult result in resultsForQuery) + WriteAppResult (result); + } + + static void WriteAppResult (AppResult appResult) + { + var classText = string.Format (" {0, -10} : {1}", "Class", appResult.Class); + var descriptionText = string.Format (" {0, -10} : {1}", "Description", appResult.Description); + var enabledText = string.Format (" {0, -10} : {1}", "Enabled", appResult.Enabled); + var idText = string.Format (" {0, -10} : {1}", "Id", appResult.Id); + var labelText = string.Format (" {0, -10} : {1}", "Label", appResult.Id); + var textText = string.Format (" {0, -10} : {1}", "Text", appResult.Text); + + var rectText = string.Format (" {0, -10}", "Rect"); + var rectContentsText = string.Format (" [X:{0} Y:{1} W:{2} H:{3}] [CX:{4} CY:{5}]", + appResult.Rect.X, + appResult.Rect.Y, + appResult.Rect.Width, + appResult.Rect.Height, + appResult.Rect.CenterX, + appResult.Rect.CenterY + ); + + queryWriter.WriteLine (classText); + queryWriter.WriteLine (descriptionText); + queryWriter.WriteLine (enabledText); + queryWriter.WriteLine (idText); + queryWriter.WriteLine (labelText); + queryWriter.WriteLine (textText); + queryWriter.WriteLine (rectText); + queryWriter.WriteLine (rectContentsText); + queryWriter.WriteLine(); + } + + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/NumericExtensions.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/NumericExtensions.cs new file mode 100644 index 00000000..13a4b2bf --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/NumericExtensions.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.Remoting.Messaging; + +using NUnit.Framework; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; +using System.Globalization; + +namespace Xamarin.Forms.Core.UITests +{ + internal class Matrix : Object + { + public double M00, M01, M02, M03; + public double M10, M11, M12, M13; + public double M20, M21, M22, M23; + public double M30, M31, M32, M33; + + public void Log () { + + //Logger.LogLine (); + + //Logger.LogLine (string.Format ("{0,-3}, {1,-3}, {2,-3}, {3,-3}", M00, M01, M02, M03)); + //Logger.LogLine (string.Format ("{0,-3}, {1,-3}, {2,-3}, {3,-3}", M10, M11, M12, M13)); + //Logger.LogLine (string.Format ("{0,-3}, {1,-3}, {2,-3}, {3,-3}", M20, M21, M22, M23)); + //Logger.LogLine (string.Format ("{0,-3}, {1,-3}, {2,-3}, {3,-3}", M30, M31, M32, M33)); + + //Logger.LogLine (); + } + + public override bool Equals (object obj) + { + if (obj == null) + return false; + + var transform = obj as Matrix; + if ((Object)transform == null) + return false; + + const double tolerance = 0.01; + bool result = + Math.Abs (M00 - transform.M00) < tolerance && + Math.Abs (M01 - transform.M01) < tolerance && + Math.Abs (M02 - transform.M02) < tolerance && + Math.Abs (M03 - transform.M03) < tolerance && + Math.Abs (M10 - transform.M10) < tolerance && + Math.Abs (M11 - transform.M11) < tolerance && + Math.Abs (M12 - transform.M12) < tolerance && + Math.Abs (M13 - transform.M13) < tolerance && + Math.Abs (M20 - transform.M20) < tolerance && + Math.Abs (M21 - transform.M21) < tolerance && + Math.Abs (M22 - transform.M22) < tolerance && + Math.Abs (M23 - transform.M23) < tolerance && + Math.Abs (M30 - transform.M30) < tolerance && + Math.Abs (M31 - transform.M31) < tolerance && + Math.Abs (M32 - transform.M32) < tolerance && + Math.Abs (M33 - transform.M33) < tolerance; + + return result; + } + + public override int GetHashCode () + { + return 0; + } + } + + internal enum Axis + { + X, + Y, + Z + } + + internal static class NumericExtensions + { + public static double ToRadians(this float val) + { + return (Math.PI / 180.0) * val; + } + + public static Matrix CalculateRotationMatrixForDegrees (float degrees, Axis rotationAxis) + { + var angle = degrees.ToRadians (); + + var transform = new Matrix (); + if (rotationAxis == Axis.X) { + transform.M00 = 1; transform.M01 = 0; transform.M02 = 0; transform.M03 = 0; + transform.M10 = 0; transform.M11 = (float) Math.Cos (angle); transform.M12 = (float) Math.Sin (angle); transform.M13 = 0; + transform.M20 = 0; transform.M21 = -(float) Math.Sin (angle); transform.M22 = (float) Math.Cos (angle); transform.M23 = 0; + transform.M30 = 0; transform.M31 = 0; transform.M32 = 0; transform.M33 = 1; + } else if (rotationAxis == Axis.Y) { + transform.M00 = (float) Math.Cos (angle); transform.M01 = 0; transform.M02 = -(float) Math.Sin (angle); transform.M03 = 0; + transform.M10 = 0; transform.M11 = 1; transform.M12 = 0; transform.M13 = 0; + transform.M20 = (float) Math.Sin (angle); transform.M21 = 0; transform.M22 = (float) Math.Cos (angle); transform.M23 = 0; + transform.M30 = 0; transform.M31 = 0; transform.M32 = 0; transform.M33 = 1; + } else { + transform.M00 = (float) Math.Cos (angle); transform.M01 = (float) Math.Sin (angle); transform.M02 = 0; transform.M03 = 0; + transform.M10 = -(float) Math.Sin (angle); transform.M11 = (float) Math.Cos (angle); transform.M12 = 0; transform.M13 = 0; + transform.M20 = 0; transform.M21 = 0; transform.M22 = 1; transform.M23 = 0; + transform.M30 = 0; transform.M31 = 0; transform.M32 = 0; transform.M33 = 1; + } + + return transform; + } + + public static Matrix BuildScaleMatrix (float scale) + { + var transform = new Matrix (); + + transform.M00 = scale; transform.M01 = 0; transform.M02 = 0; transform.M03 = 0; + transform.M10 = 0; transform.M11 = scale; transform.M12 = 0; transform.M13 = 0; + transform.M20 = 0; transform.M21 = 0; transform.M22 = scale; transform.M23 = 0; + transform.M30 = 0; transform.M31 = 0; transform.M32 = 0; transform.M33 = 1; + + return transform; + } + + } + +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/ParsingUtils.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/ParsingUtils.cs new file mode 100644 index 00000000..6598e0f5 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/ParsingUtils.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.Remoting.Messaging; + +using NUnit.Framework; + +using Xamarin.UITest; +using Xamarin.UITest.Queries; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; +using System.Globalization; +using System.Text.RegularExpressions; +using System.IO; + +namespace Xamarin.Forms.Core.UITests +{ + + internal static class ParsingUtils + { + public static Font ParseUIFont (string font) + { + FontAttributes fontAttrs = FontAttributes.None; + + // Logger.LogLine ("TEST PARSING"); + + if (font.Contains ("font-weight: bold;")) { + // Logger.LogLine ("Found Bold"); + fontAttrs = FontAttributes.Bold; + } + + return new Font ().WithAttributes (fontAttrs); + } + + public static Color ParseUIColor (string backgroundColor) + { + var delimiters = new char[] { ' ' }; + string[] words = backgroundColor.Split (delimiters, StringSplitOptions.RemoveEmptyEntries); + return new Color (double.Parse (words[1]), double.Parse (words[2]), double.Parse (words[3]), double.Parse (words[4])); + } + + public static Point ParseCGPoint (object CGPoint) { + var point = new Point { X = 0, Y = 0 }; + return point; + } + + public static Matrix ParseCATransform3D (string CATransform3D) + { + // Logger.Log (CATransform3D); + char[] delimiters = { '<', ' ', '>' }; + string[] words = CATransform3D.Split (delimiters, StringSplitOptions.RemoveEmptyEntries); + + List numbers = new List (); + + // Each number is represented by 2 blocks returned by server + for (int i = 0; i < (words.Length - 1); i += 2) { + string word = words[i] + words[i + 1]; + var number = Int64.Parse (word, NumberStyles.HexNumber); + byte[] bytes = BitConverter.GetBytes (number); + byte[] reversedBytes = bytes.Reverse ().ToArray (); + double value = BitConverter.ToDouble (reversedBytes, 0); + numbers.Add (value); + } + + var transformationMatrix = new Matrix (); + transformationMatrix.M00 = numbers[0]; + transformationMatrix.M01 = numbers[1]; + transformationMatrix.M02 = numbers[2]; + transformationMatrix.M03 = numbers[3]; + transformationMatrix.M10 = numbers[4]; + transformationMatrix.M11 = numbers[5]; + transformationMatrix.M12 = numbers[6]; + transformationMatrix.M13 = numbers[7]; + transformationMatrix.M20 = numbers[8]; + transformationMatrix.M21 = numbers[9]; + transformationMatrix.M22 = numbers[10]; + transformationMatrix.M23 = numbers[11]; + transformationMatrix.M30 = numbers[12]; + transformationMatrix.M31 = numbers[13]; + transformationMatrix.M32 = numbers[14]; + transformationMatrix.M33 = numbers[15]; + + return transformationMatrix; + } + + } + +} \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/UITestCustomExceptions.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/UITestCustomExceptions.cs new file mode 100644 index 00000000..6969ac52 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/UITestCustomExceptions.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.UITest.Queries; +using System.Runtime.CompilerServices; + +namespace Xamarin.Forms.Core.UITests +{ + internal class UITestQueryNoResultException : Exception + { + readonly string message; + + public UITestQueryNoResultException (string query) + { + message = string.Format ("Found no elements for query with target: {0}", query); + } + + public override string Message + { + get { return message; } + } + } + + internal class UITestQuerySingleResultException : Exception + { + readonly string message; + + public UITestQuerySingleResultException (string query) + { + message = string.Format ("Found single element for query with target: {0}", query); + } + + public override string Message + { + get { return message; } + } + } + + internal class UITestQueryMultipleResultsException : Exception + { + readonly string message; + + public UITestQueryMultipleResultsException (string query) + { + message = string.Format ("Found muliple elements for query with target: {0}", query); + } + + public override string Message + { + get { return message; } + } + } + + internal class UITestRemoteException : Exception + { + readonly string message; + + public UITestRemoteException (string message) + { + this.message = message; + } + + public override string Message + { + get { return message; } + } + } + + internal class UITestRemoteQueryException : Exception + { + readonly string message; + + public UITestRemoteQueryException (string query) + { + message = string.Format ("Error for query with target: {0}", query); + } + + public override string Message + { + get { return message; } + } + } + + internal class UITestErrorException : Exception + { + readonly string message; + + public UITestErrorException (string message, [CallerMemberName] string caller = null) + { + message = string.Format ("Test error: {0}, {1}", caller, message); + } + + public override string Message + { + get { return message; } + } + } +} diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/ViewInspector.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/ViewInspector.cs new file mode 100644 index 00000000..288ee3d6 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/ViewInspector.cs @@ -0,0 +1,342 @@ +using System; +using System.Collections.Generic; + +using Xamarin.UITest; +using Xamarin.UITest.Android; +using Xamarin.UITest.iOS; +using System.Linq; + +namespace Xamarin.Forms.Core.UITests +{ + internal static class ViewInspector + { + public static void LogPropertiesForView (this IApp app, string query, bool isOnParent = false) + { + if (app is AndroidApp) { + LogPropertiesForAndroidView ((AndroidApp)app, query, isOnParent); + } else { + LogPropertiesForUIView ((iOSApp)app, query, isOnParent); + LogPropertiesForCALayer ((iOSApp)app, query, isOnParent); + } + } + + static void LogPropertiesForUIView (this iOSApp app, string query, bool isOnParent = false) { + + //Logger.LogLine ("--- UIView Properties ---"); + + var properties = new [] { + // just getters with no params, bools + "alpha", + "autoresizesSubviews", + "autoresizingMask", + "backgroundColor", + "bounds", + "center", + "clearsContextBeforeDrawing", + "clipsToBounds", + "contentMode", + "contentScaleFactor", + "exclusiveTouch", + "frame", + "gestureRecognizers", + "hidden", + "layer", + "motionEffects", + "multipleTouchEnabled", + "opaque", + "restorationIdentifier", + "subviews", + "superview", + "tag", + "tintAdjustmentMode", + "tintColor", + "transform", + "userInteractionEnabled", + "window" + }; + + if (isOnParent) + query = query + " parent * index:0"; + + foreach (var property in properties) { + object prop; + bool found = + MaybeGetProperty (app, query, property, out prop) || + MaybeGetProperty (app, query, property, out prop) || + MaybeGetProperty (app, query, property, out prop) || + MaybeGetProperty (app, query, property, out prop); + + //if (found) + // Logger.LogLine (string.Format ("{0,-30}: {1}", property, prop)); + } + + //Logger.LogLine(); + + } + + static void LogPropertiesForCALayer(this iOSApp app, string query, bool isOnParent = false) + { + // Logger.LogLine ("--- UIView.Layer Properties ---"); + + var properties = new[] { + "actions", + "anchorPoint", + "anchorPointZ", + "backgroundColor", + "backgroundFilters", + "borderColor", + "borderWidth", + "bounds", + "compositingFilter", + "contents", + "contentsCenter", + "contentsGravity", + "contentsRect", + "contentsScale", + "cornerRadius", + "delegate", + "doubleSided", + "drawsAsynchronously", + "edgeAntialiasingMask", + "filters", + "frame", + "geometryFlipped", + "hidden", + "magnificationFilter", + "mask", + "masksToBounds", + "minificationFilter", + "minificationFilterBias", + "name", + "needsDisplayOnBoundsChange", + "opacity", + "opaque", + "position", + "rasterizationScale", + "shadowColor", + "shadowOffset", + "shadowOpacity", + "shadowPath", + "shadowRadius", + "shouldRasterize", + "style", + "sublayers", + "sublayerTransform", + "superlayer", + "transform", + "visibleRect", + "zPosition" + }; + + if (isOnParent) + query = query + " parent * index:0"; + + foreach (var property in properties) + { + object prop; + bool found = + MaybeGetLayerProperty(app, query, property, out prop) || + MaybeGetLayerProperty(app, query, property, out prop) || + MaybeGetLayerProperty(app, query, property, out prop); + + //if (found) + // Logger.LogLine(string.Format("{0,-30}: {1}", property, prop)); + } + + //Logger.LogLine(); + + } + + static void LogPropertiesForAndroidView (this AndroidApp app, string query, bool isOnParent = false) + { + // Logger.LogLine( "--- Android View Properties ---"); + + var properties = new [] { + // just getters with no params, bools + //"getAccessibilityLiveRegion", + //"getAccessibilbityNodeProvider", + //"getAlpha", + //"getAnimation", + //"getApplicationWindowToken", + //"getBackground", + //"getBaseline", + //"getBottom", + //"getCameraDistance", + //"getClipBounds", + //"getContentDescription", + //"getContext", + //"getDefaultSize", + //"getDisplay", + //"getDrawableState", + //"getDrawingCache", + //"getDrawingCacheBackgroundColor", + //"getDrawingRect", + //"getDrawingTime", + //"getFilterTouchesWhenObscurred", + //"getFitsSystemWindows", + //"getFocusables", + //"getHandler", + //"getHeight", + //"getHitRect", + //"getHorizontalFadingEdgeLength", + //"getId", + //"getImportantForAccessibility", + //"getKeepScreenOn", + //"getKeyDispatcherState", + //"getLabelFor", + //"getLayerType", + //"getLayoutDirection", + //"getLayourParams", + //"getLeft", + "getMatrix", + //"getMeasuredHeight", + //"getMeasuredHeightAndState", + //"getMeasuredState", + //"getMeasuredWidth", + //"getMeasuredWidthAndState", + //"getMinimumHeight", + //"getMinimumWidth", + //"getNextFocusDownId", + //"getNextFocusForwardId", + //"getNextFocusLeftId", + //"getNextFocusRightId", + //"getNextFocusUpId", + //"getOnFocusChangedListener", + //"getOverScrollMethod", + //"getOverlay", + //"getPaddingBottom", + //"getPaddingEnd", + //"getPaddingLeft", + //"getPaddingRight", + //"getPaddingStart", + //"getPaddingTop", + //"getParent", + //"getParentForAccessibility", + //"getPivotX", + //"getPivotY", + //"getResources", + //"getRight", + //"getRootView", + //"getRotation", + //"getRotationX", + //"getRotationY", + "getScaleX", + "getScaleY", + //"getScrollBarDefaultDelayBeforeFade", + //"getScrollBarFadeDuration", + //"getScrollBarSize", + //"getScrollBarStyle", + //"getScrollX", + //"getScrollY", + //"getSolidColor", + //"getSystemUiVisibility", + //"getTag", + //"getTextAlignment", + //"getTextDirection", + //"getTop", + //"getTouchDelegate", + //"getTouchables", + //"getTranslationX", + //"getTranslationY", + //"getVerticalFadingEdgeLength", + //"getVerticalScrollbarPosition", + //"getVerticalScrollbarWidth", + //"getViewTreeObserver", + //"getVisibility", + //"getWidth", + //"getWindowId", + //"getWindowSystemUiVisbility", + //"getWindowToken", + //"getWindowVisibility", + //"getX", + //"getY", + //"hasFocus", + //"hasFocusable", + //"hasOnClickListener", + //"hasOverlappingRendering", + //"hasTransientState", + //"hasWindowFocus", + //"isActivated", + //"isAttachedToWindow", + //"isClickable", + //"isDirty", + //"isDrawingCacheEnabled", + //"isDuplicateParentStateEnabled", + //"isEnabled", + //"isFocusable", + //"isFocusableInTouchWindow", + //"isFocused", + //"isHapticFeedbackEnabled", + //"isHardwareAccelerated", + //"isHorizontalFadingEdgeEnabled", + //"isHovered", + //"idInEditMode", + //"isInLayout", + //"isInTouchMode", + //"isLaidOut", + //"isLayoutDirectionResolved", + //"isLayoutRequested", + //"isLongClickable", + //"isOpaque", + //"isPaddingRelative", + //"isPressed", + //"isSaveEnabled", + //"isSaveFromParentEnabled", + //"isScrollContainer", + //"isScrollBarFadingEnabled", + //"isSelected", + //"isShown", + //"isSoundEffectsEnabled", + //"isTextAlignmentResolved", + //"isTextDirectionResolved", + //"isVerticalFadingEdgeEnabled", + //"isVerticalScrollBarEnabled" + }; + + if (isOnParent) + query = query + " parent * index:0"; + + foreach (var property in properties) { + object prop; + bool found = + MaybeGetProperty (app, query, property, out prop) || + //MaybeGetProperty (app, query, property, out prop) || + MaybeGetProperty (app, query, property, out prop) || + MaybeGetProperty (app, query, property, out prop); + + //if (found) + // Logger.LogLine (string.Format ("{0,-30}: {1}", property, prop)); + } + + //Logger.LogLine(); + + } + + static bool MaybeGetLayerProperty (iOSApp app, string query, string property, out object result) + { + + try { + result = app.Query (q => q.Raw (query).Invoke ("layer").Invoke (property).Value ()).First (); + } catch { + result = null; + return false; + } + + return true; + } + + static bool MaybeGetProperty (IApp app, string query, string property, out object result) + { + + try { + result = app.Query (q => q.Raw (query).Invoke (property).Value ()).First (); + } catch { + result = null; + return false; + } + + return true; + } + } +} + diff --git a/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj b/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj new file mode 100644 index 00000000..2846ddc0 --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/Xamarin.Forms.Core.iOS.UITests.csproj @@ -0,0 +1,175 @@ + + + + + Debug + AnyCPU + {EADD8100-B3AE-4A31-92C4-267A64A1C6EB} + Library + Properties + Xamarin.Forms.Core.UITests + Xamarin.Forms.Core.iOS.UITests + v4.5 + 512 + ..\ + true + + + true + full + false + bin\Debug\ + TRACE;DEBUG;__IOS__;UITEST + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE;__IOS__;UITEST + prompt + 4 + + + true + bin\Turkey\ + TRACE;DEBUG;__IOS__;UITEST + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + + ..\packages\Xamarin.UITest.1.3.3\lib\Xamarin.UITest.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {57B8B73D-C3B5-4C42-869E-7B2F17D354AC} + Xamarin.Forms.Core + + + {4DCD0420-1168-4B77-86DB-6196EE4BD491} + Xamarin.Forms.CustomAttributes + + + {7d13bac2-c6a4-416a-b07e-c169b199e52b} + Xamarin.Forms.Maps + + + {67f9d3a8-f71e-4428-913f-c37ae82cdb24} + Xamarin.Forms.Platform + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Core.iOS.UITests/packages.config b/Xamarin.Forms.Core.iOS.UITests/packages.config new file mode 100644 index 00000000..031fa54c --- /dev/null +++ b/Xamarin.Forms.Core.iOS.UITests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file -- cgit v1.2.3