diff options
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests/Tests')
54 files changed, 6193 insertions, 0 deletions
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<ViewContainerRemote> (App, "Color", PlatformViewType); +// remote.GoTo (); +// +// var color = remote.GetProperty<Color> (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<bool> (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<float> (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<float> (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<bool> (Button.FontProperty); + Assert.True (isBold); + } else { + var font = remote.GetProperty<Font> (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<string> (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<Color> (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<string> () { +// "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<string, string> () { +// { "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<string> () { +// "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<AppQuery, AppQuery> 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<AppQuery, AppQuery> 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<AppQuery, AppQuery> 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<AppQuery, AppQuery> 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<RootPageModel> rootPages; + + public RootGalleryUITests () + { + string[] ids = { + "Content", + "Nav->Content", + "MDP->Nav->Content", + "Tab->Content", + "Tab->MDP->Nav->Content", + "Tab->Nav->Content", + "Tab(Many)->Nav->Content", + "Nav->Tab->Content(BAD IDEA)", + "Nav->Tab(Many)->Content(BAD IDEA)", + "MDP->Nav->Tab->Content(BAD IDEA)" + }; + string[] modalIds = { + "(Modal)Content", + "(Modal)Nav->Content", + "(Modal)MDP->Nav->Content", + "(Modal)Tab->Content", + "(Modal)Tab->MDP->Nav->Content", + "(Modal)Tab->Nav->Content", + "(Modal)Tab(Many)->Nav->Content", + "(Modal)Nav->Tab->Content(BAD IDEA)", + "(Modal)Nav->Tab(Many)->Content(BAD IDEA)", + "(Modal)MDP->Nav->Tab->Content(BAD IDEA)", + }; + + rootPages = + (from id in ids + select new RootPageModel (id + "ButtonId", id + "PageId")).Union ( + from id in modalIds + select new RootPageModel (id + "ButtonId", id + "PageId",true)); + + } + + protected override void NavigateToGallery () + { + App.NavigateToGallery (GalleryQueries.RootPagesGallery); + } + + [Test] + [Ignore("Ignore while we dont't have a response from XTC team why this fails some times")] + public void VisitEachPage () + { + foreach (var page in rootPages) { + var scrollViewArea = App.Query (q => q.Marked ("ChoosePageScrollView")).First ().Rect; + App.ScrollForElement (string.Format("* marked:'{0}'", page.ButtonId), new Drag (scrollViewArea, Drag.Direction.BottomToTop, Drag.DragLength.Long)); + App.Tap (q => q.Marked (page.ButtonId)); + 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<StateViewContainerRemote> (App, "AnchorX", PlatformViewType); + //remote.GoTo (); + + ////App.LogPropertiesForView (remote.ViewQuery, true); + + //if (App is AndroidApp) { + // var anchorX = remote.GetProperty<float> (View.AnchorXProperty); + // var viewWidth = remote.GetView ().Rect.Width; + // Assert.AreEqual (anchorX, 0.25 * viewWidth); + //} else if (App is iOSApp) { + // var anchorXMatrix = remote.GetProperty<Matrix> (View.AnchorXProperty); + // var viewWidth = remote.GetView ().Rect.Width; + // Assert.AreEqual (anchorXMatrix.M30, 0 - (viewWidth * 0.25f)); + //} + } + + // [Test] + // [UiTest (Test.VisualElement.AnchorY)] + // TODO: working on some views, others not + public virtual void _AnchorY () + { + //var remote = RemoteFactory.CreateRemote<StateViewContainerRemote> (App, "AnchorY", PlatformViewType); + //remote.GoTo (); + + //if (App is AndroidApp) { + // var anchorY = remote.GetProperty<float> (View.AnchorYProperty); + // var viewHeight = remote.GetView ().Rect.Height; + // Assert.AreEqual (anchorY, viewHeight); + //} else if (App is iOSApp) { + // var anchorYMatrix = remote.GetProperty<Matrix> (View.AnchorYProperty); + // var viewHeight = remote.GetView ().Rect.Height; + // Assert.AreEqual (anchorYMatrix.M31, viewHeight / 2.0f); + //} + } + + // [Test] + // [UiTest (Test.VisualElement.BackgroundColor)] + // [UiTestBroken (BrokenReason.UITestBug, "UITest Issue #107")] + public virtual void _BackgroundColor () + { + //TODO: this was failing and is changing in next version of calabash (UI-Test-pre nuget) to a json rgb +// var remote = RemoteFactory.CreateRemote<ViewContainerRemote> (App, "BackgroundColor", PlatformViewType); +// remote.GoTo (); +// if (App is iOSApp) { +// var backgroundColor = remote.GetProperty<Color> (View.BackgroundColorProperty); +// Assert.AreEqual (Color.Blue, backgroundColor); +// } + + } + + [Test] + [UiTest (typeof(VisualElement), "Focus")] + public abstract void _Focus (); + + [Test] + [UiTest (typeof (VisualElement), "GestureRecognizers")] + public abstract void _GestureRecognizers (); + + //[Test] + [UiTest (typeof (VisualElement), "InputTransparent")] + public virtual void _InputTransparent () + { + //var remote = new LayeredViewContainerRemote (App, Test.VisualElement.InputTransparent, PlatformViewType); + //remote.GoTo (); + + //var hiddenButtonClickedLabelTextPre = remote.GetLayeredLabel ().Text; + //Assert.AreEqual ("Hidden Button (Not Clicked)", hiddenButtonClickedLabelTextPre); + + //remote.TapHiddenButton (); + + //var hiddenButtonClickedLabelTextPost = remote.GetLayeredLabel ().Text; + //var hiddenButtonClicked = hiddenButtonClickedLabelTextPost == "Hidden Button (Clicked)"; + + //// Allow tests to continue by dismissing DatePicker that should not show + //// Remove when InputTransparency works + //if (!hiddenButtonClicked && PlatformViewType == PlatformViews.DatePicker) + // remote.DismissPopOver (); + + //Assert.True (hiddenButtonClicked); + } + + [Test] + [UiTest (typeof (VisualElement), "IsEnabled")] + public virtual void _IsEnabled () + { + var propName = Test.VisualElement.IsEnabled.ToString (); + var remote = new StateViewContainerRemote (App, Test.VisualElement.IsEnabled, PlatformViewType); + remote.GoTo (); + + var enabled = remote.GetProperty<bool> (View.IsEnabledProperty); + Assert.IsTrue (enabled); + + remote.TapStateButton (); + + enabled = remote.GetProperty<bool> (View.IsEnabledProperty); + Assert.IsFalse (enabled); + + remote.TapStateButton (); + + var isEnabled = remote.GetStateLabel ().Text; + Assert.AreEqual ("True", isEnabled); + + remote.TapStateButton (); + + var isDisabled = remote.GetStateLabel ().Text; + Assert.AreEqual ("False", isDisabled); + } + + [Test] + [UiTest (typeof (VisualElement), "IsFocused")] + public abstract void _IsFocused (); + + [Test] + [UiTest (typeof (VisualElement), "IsVisible")] + public virtual void _IsVisible () + { + var remote = new StateViewContainerRemote (App, Test.VisualElement.IsVisible, PlatformViewType); + remote.GoTo (); + + var viewPre = remote.GetViews (); + + 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<float> (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<float> (View.RotationProperty); + Assert.AreEqual (10.0f, rotation); + } else if (App is iOSApp) { + var rotationMatrix = remote.GetProperty<Matrix> (View.RotationProperty); + Matrix generatedMatrix = NumericExtensions.CalculateRotationMatrixForDegrees (10, Axis.Z); + Assert.AreEqual (generatedMatrix, rotationMatrix); + } + } + + [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<float> (View.RotationXProperty); + Assert.AreEqual (33.0f, rotationX); + } else if (App is iOSApp) { + var rotationXMatrix = remote.GetProperty<Matrix> (View.RotationXProperty); + Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (33.0f, Axis.X); + Assert.AreEqual (matrix, rotationXMatrix); + } + } + + [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<float> (View.RotationYProperty); + Assert.AreEqual (10.0f, rotationY); + } else if (App is iOSApp) { + var rotationYMatrix = remote.GetProperty<Matrix> (View.RotationYProperty); + Matrix matrix = NumericExtensions.CalculateRotationMatrixForDegrees (10.0f, Axis.Y); + Assert.AreEqual (matrix, rotationYMatrix); + } + } + + [Test] + [UiTest (typeof (VisualElement), "Scale")] + public virtual void _Scale () + { + var remote = new ViewContainerRemote (App, Test.VisualElement.Scale, PlatformViewType); + remote.GoTo (); + + var scaleMatrix = remote.GetProperty<Matrix> (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 |