summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.macOS.UITests
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core.macOS.UITests')
-rw-r--r--Xamarin.Forms.Core.macOS.UITests/MacOSApp.cs702
-rw-r--r--Xamarin.Forms.Core.macOS.UITests/Properties/AssemblyInfo.cs26
-rw-r--r--Xamarin.Forms.Core.macOS.UITests/Xamarin.Forms.Core.macOS.UITests.csproj232
-rw-r--r--Xamarin.Forms.Core.macOS.UITests/packages.config10
4 files changed, 970 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.macOS.UITests/MacOSApp.cs b/Xamarin.Forms.Core.macOS.UITests/MacOSApp.cs
new file mode 100644
index 00000000..08c3118d
--- /dev/null
+++ b/Xamarin.Forms.Core.macOS.UITests/MacOSApp.cs
@@ -0,0 +1,702 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using Xamarin.UITest;
+using Xamarin.UITest.Desktop;
+using Xamarin.UITest.Queries;
+using System.Linq;
+using System.Diagnostics;
+using System.Threading;
+using System.Drawing;
+
+namespace Xamarin.Forms.Core.macOS.UITests
+{
+ public static class MacOSAppExtensions
+ {
+ public static UITest.Queries.AppResult ToUITestResult(this UITest.Desktop.AppResult result)
+ {
+ return new UITest.Queries.AppResult
+ {
+ Id = result.Id ?? result.TestId,
+ Label = result.Label,
+ Text = result.Text ?? result.Value,
+ Enabled = result.Enabled,
+ Class = result.Class,
+ Rect = new UITest.Queries.AppRect
+ {
+ X = result.Rect.X,
+ Y = result.Rect.Y,
+ Width = result.Rect.Width,
+ Height = result.Rect.Height,
+ CenterX = result.Rect.CenterX,
+ CenterY = result.Rect.CenterY
+ }
+ };
+ }
+ }
+
+
+ public class MacOSApp : Xamarin.UITest.IApp
+ {
+ string _backButtonIdentifier = "NSBackButton";
+ static CocoaApp _cocoaApp;
+ public MacOSApp(CocoaApp app)
+ {
+ _cocoaApp = app;
+ }
+ public IDevice Device
+ {
+ get
+ {
+ return null;
+ }
+ }
+
+ public AppPrintHelper Print
+ {
+ get
+ {
+ return null;
+ }
+ }
+
+ public ITestServer TestServer
+ {
+ get
+ {
+ return null;
+ }
+ }
+
+ public void Back()
+ {
+ Tap(_backButtonIdentifier);
+ }
+
+ public void ClearText()
+ {
+ _cocoaApp.ClearText();
+ }
+
+ public void ClearText(string marked)
+ {
+ var textField = _cocoaApp.QueryById(marked).FirstOrDefault((arg) => arg.Class.Contains("SearchField") || arg.Class.Contains("TextField"));
+ ClearText(textField.Rect.CenterX, textField.Rect.CenterY);
+ }
+
+ public void ClearText(Func<AppQuery, AppWebQuery> query)
+ {
+
+ }
+
+ public void ClearText(Func<AppQuery, AppQuery> query)
+ {
+ var queryStr = query(new AppQuery(QueryPlatform.iOS)).ToString();
+
+ var isMarked = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bmarked\b");
+ if (isMarked)
+ {
+ var markedWord = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bmarked\b:'");
+ var isAll = markedWord[0].Trim() == "*";
+ var marked = markedWord[1].Replace("'", "");
+ ClearText(marked);
+ }
+ }
+
+ public void DismissKeyboard()
+ {
+
+ }
+
+ public void DoubleTap(string marked)
+ {
+
+ }
+
+ public void DoubleTap(Func<AppQuery, AppQuery> query)
+ {
+
+ }
+
+ public void DoubleTapCoordinates(float x, float y)
+ {
+
+ }
+
+ public void DragAndDrop(string from, string to)
+ {
+
+ }
+
+ public void DragAndDrop(Func<AppQuery, AppQuery> from, Func<AppQuery, AppQuery> to)
+ {
+
+ }
+
+ public void DragCoordinates(float fromX, float fromY, float toX, float toY)
+ {
+
+ }
+
+ public void EnterText(string text)
+ {
+ var all = _cocoaApp.Query();
+ var staticText = _cocoaApp.QueryByType("StaticText");
+ var textFields = _cocoaApp.QueryByType("Textfield");
+ var textField = staticText.Union(textFields).FirstOrDefault();
+ EnterText(text, textField.Rect.CenterX, textField.Rect.CenterY);
+ }
+
+ public void EnterText(Func<AppQuery, AppWebQuery> query, string text)
+ {
+
+ }
+
+ public void EnterText(string marked, string text)
+ {
+ var textField = _cocoaApp.QueryById(marked).FirstOrDefault((arg) => arg.Class.Contains("SearchField") || arg.Class.Contains("TextField"));
+ EnterText(text, textField.Rect.CenterX, textField.Rect.CenterY);
+ }
+
+ public void EnterText(Func<AppQuery, AppQuery> query, string text)
+ {
+ string markedWord = string.Empty;
+ int indexMarked = 0;
+
+ if (ExtractInfo(query, out markedWord, out indexMarked))
+ EnterText(markedWord, indexMarked, text);
+ }
+
+ public UITest.Queries.AppResult[] Flash(string marked)
+ {
+ var resulr = new List<Xamarin.UITest.Queries.AppResult>();
+ return resulr.ToArray();
+ }
+
+ public UITest.Queries.AppResult[] Flash(Func<AppQuery, AppQuery> query = null)
+ {
+ var resulr = new List<Xamarin.UITest.Queries.AppResult>();
+ return resulr.ToArray();
+ }
+
+ public object Invoke(string methodName, object[] arguments)
+ {
+ return null;
+ }
+
+ public object Invoke(string methodName, object argument = null)
+ {
+ return null;
+ }
+
+ public void PinchToZoomIn(string marked, TimeSpan? duration = default(TimeSpan?))
+ {
+
+ }
+
+ public void PinchToZoomIn(Func<AppQuery, AppQuery> query, TimeSpan? duration = default(TimeSpan?))
+ {
+
+ }
+
+ public void PinchToZoomInCoordinates(float x, float y, TimeSpan? duration)
+ {
+
+ }
+
+ public void PinchToZoomOut(string marked, TimeSpan? duration = default(TimeSpan?))
+ {
+
+ }
+
+ public void PinchToZoomOut(Func<AppQuery, AppQuery> query, TimeSpan? duration = default(TimeSpan?))
+ {
+
+ }
+
+ public void PinchToZoomOutCoordinates(float x, float y, TimeSpan? duration)
+ {
+
+ }
+
+ public void PressEnter()
+ {
+ _cocoaApp.SendKey(13, KeyModifier.None);
+ }
+
+ public void PressVolumeDown()
+ {
+
+ }
+
+ public void PressVolumeUp()
+ {
+
+ }
+
+ public AppWebResult[] Query(Func<Xamarin.UITest.Queries.AppQuery, Xamarin.UITest.Queries.AppWebQuery> query)
+ {
+ var resulr = new List<Xamarin.UITest.Queries.AppWebResult>();
+ return resulr.ToArray();
+ }
+
+ public string[] Query(Func<Xamarin.UITest.Queries.AppQuery, Xamarin.UITest.Queries.InvokeJSAppQuery> query)
+ {
+ return new List<string>().ToArray();
+ }
+
+ public UITest.Queries.AppResult[] Query(string marked)
+ {
+ var results = new List<Xamarin.UITest.Queries.AppResult>();
+ var allResults = _cocoaApp.Query();
+ var allResultsById = _cocoaApp.QueryById(marked);
+ foreach (var result in allResultsById)
+ results.Add(result.ToUITestResult());
+ var allResultsByText = _cocoaApp.QueryByText(marked);
+ foreach (var result in allResultsByText)
+ results.Add(result.ToUITestResult());
+ return results.ToArray();
+ }
+
+ public UITest.Queries.AppResult[] Query(Func<UITest.Queries.AppQuery, UITest.Queries.AppQuery> query = null)
+ {
+ var queryStr = query(new AppQuery(QueryPlatform.iOS)).ToString();
+ var results = new List<Xamarin.UITest.Queries.AppResult>();
+ var isMarked = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bmarked\b");
+ var isText = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\btext\b");
+ if (isMarked)
+ {
+ var markedWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bmarked\b:'");
+ var isAll = markedWords[0].Trim() == "*";
+ var markedWord = markedWords[1].Remove(markedWords[1].Length - 1).Trim();
+ return Query(markedWord);
+ }
+ if (isText)
+ {
+ var textWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\btext\b:'");
+ var isAll = textWords[0].Trim() == "*";
+ var textWord = textWords[1].Remove(textWords[1].Length - 1).Trim();
+ return Query(textWord);
+ }
+ else if (queryStr.Contains("* index:0"))
+ {
+ var allREsults = _cocoaApp.Query();
+ var result = allREsults[0].Children[0];
+ results.Add(result.ToUITestResult());
+ }
+ else if (queryStr.Contains("* index:7"))
+ {
+ var allREsults = _cocoaApp.Query();
+ var result = allREsults[0].Children[0].Children[0].Children[1];
+ results.Add(result.ToUITestResult());
+ }
+
+ return results.ToArray();
+ }
+
+ public T[] Query<T>(Func<UITest.Queries.AppQuery, UITest.Queries.AppTypedSelector<T>> query)
+ {
+
+ var results = new List<T>();
+ var queryStr = query(new AppQuery(QueryPlatform.iOS)).ToString();
+ var isMarked = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bmarked\b");
+ if (isMarked)
+ {
+ var markedWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bmarked\b:'");
+ var isAll = markedWords[0].Trim() == "*";
+ var markedWord = markedWords[1].Replace("'", "");
+ var ss = Query(markedWord);
+
+ }
+ else if (queryStr.Contains("* index:0"))
+ {
+
+ var allREsults = _cocoaApp.Query();
+ var result = allREsults[0].Children[0];
+ // results.Add(result.ToUITestResult());
+ }
+ else if (queryStr.Contains("* index:7"))
+ {
+ var allREsults = _cocoaApp.Query();
+ var result = allREsults[0].Children[0].Children[0].Children[1];
+ // results.Add(result.ToUITestResult());
+ }
+
+ return results.ToArray();
+ }
+
+ public void Repl()
+ {
+
+ }
+
+ public FileInfo Screenshot(string title)
+ {
+ return null;
+ }
+
+ public void ScrollDown(string withinMarked, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void ScrollDown(Func<AppQuery, AppQuery> withinQuery = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void ScrollDownTo(Func<AppQuery, AppQuery> toQuery, Func<AppQuery, AppQuery> withinQuery = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollDownTo(Func<AppQuery, AppWebQuery> toQuery, Func<AppQuery, AppQuery> withinQuery = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollDownTo(Func<AppQuery, AppWebQuery> toQuery, string withinMarked, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollDownTo(string toMarked, string withinMarked = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollTo(string toMarked, string withinMarked = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollUp(string withinMarked, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void ScrollUp(Func<AppQuery, AppQuery> query = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void ScrollUpTo(Func<AppQuery, AppWebQuery> toQuery, string withinMarked, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollUpTo(Func<AppQuery, AppQuery> toQuery, Func<AppQuery, AppQuery> withinQuery = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollUpTo(Func<AppQuery, AppWebQuery> toQuery, Func<AppQuery, AppQuery> withinQuery = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void ScrollUpTo(string toMarked, string withinMarked = null, ScrollStrategy strategy = ScrollStrategy.Auto, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true, TimeSpan? timeout = default(TimeSpan?))
+ {
+
+ }
+
+ public void SetOrientationLandscape()
+ {
+
+ }
+
+ public void SetOrientationPortrait()
+ {
+
+ }
+
+ public void SetSliderValue(Func<AppQuery, AppQuery> query, double value)
+ {
+
+ }
+
+ public void SetSliderValue(string marked, double value)
+ {
+
+ }
+
+ public void SwipeLeft()
+ {
+
+ }
+
+ public void SwipeLeftToRight(double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void SwipeLeftToRight(Func<AppQuery, AppQuery> query, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void SwipeLeftToRight(Func<AppQuery, AppWebQuery> query, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SwipeLeftToRight(string marked, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void SwipeRight()
+ {
+
+ }
+
+ public void SwipeRightToLeft(double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void SwipeRightToLeft(Func<AppQuery, AppWebQuery> query, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SwipeRightToLeft(Func<AppQuery, AppQuery> query, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void SwipeRightToLeft(string marked, double swipePercentage = 0.67, int swipeSpeed = 500, bool withInertia = true)
+ {
+
+ }
+
+ public void Tap(Func<AppQuery, AppWebQuery> query)
+ {
+
+ }
+
+ public void Tap(string marked)
+ {
+ Tap(marked, 0);
+ }
+
+ public void Tap(Func<AppQuery, AppQuery> query)
+ {
+ string markedWord = string.Empty;
+ int indexMarked = 0;
+
+ if (ExtractInfo(query, out markedWord, out indexMarked))
+ Tap(markedWord, indexMarked);
+ }
+
+ public void TapCoordinates(float x, float y)
+ {
+
+ }
+
+ public void TouchAndHold(string marked)
+ {
+ TouchAndHold(marked, 0);
+ }
+
+ void TouchAndHold(string marked, int index)
+ {
+ var safeIndex = Math.Max(index, 0);
+ var queryById = _cocoaApp.QueryById(marked.Trim())[safeIndex];
+ TouchAndHoldCoordinates(queryById.Rect.CenterX, queryById.Rect.CenterY);
+
+ }
+
+ public void TouchAndHold(Func<AppQuery, AppQuery> query)
+ {
+ string markedWord = string.Empty;
+ int indexMarked = 0;
+
+ if (ExtractInfo(query, out markedWord, out indexMarked))
+ TouchAndHold(markedWord, indexMarked);
+ }
+
+ public void TouchAndHoldCoordinates(float x, float y)
+ {
+ _cocoaApp.RightClick(x, y);
+ Thread.Sleep(1000);
+ }
+
+ public void WaitFor(Func<bool> predicate, string timeoutMessage = "Timed out waiting...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+
+ }
+
+ public AppWebResult[] WaitForElement(Func<AppQuery, AppWebQuery> query, string timeoutMessage = "Timed out waiting for element...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+ var resulr = new List<Xamarin.UITest.Queries.AppWebResult>();
+ return resulr.ToArray();
+ }
+
+ public UITest.Queries.AppResult[] WaitForElement(string marked, string timeoutMessage = "Timed out waiting for element...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+ var results = new List<Xamarin.UITest.Queries.AppResult>();
+
+ var queryById = _cocoaApp.QueryById(marked);
+ foreach (var res in queryById)
+ {
+ results.Add(res.ToUITestResult());
+ }
+ Stopwatch s = new Stopwatch();
+ s.Start();
+ bool foundElement = false;
+ while (s.Elapsed < timeout && !foundElement)
+ {
+ var allResultsById = _cocoaApp.QueryById(marked);
+ foreach (var res in queryById)
+ {
+ results.Add(res.ToUITestResult());
+ }
+ foundElement = results.Count > 0;
+ System.Diagnostics.Debug.WriteLine(foundElement);
+ }
+ s.Stop();
+
+ return results.ToArray();
+ }
+
+ public UITest.Queries.AppResult[] WaitForElement(Func<AppQuery, AppQuery> query, string timeoutMessage = "Timed out waiting for element...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+ var queryStr = query(new AppQuery(QueryPlatform.iOS)).ToString();
+ var isMarked = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bmarked\b");
+ if (isMarked)
+ {
+ var markedWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bmarked\b:'");
+ var isAll = markedWords[0].Trim() == "*";
+ var markedWord = markedWords[1].Replace("'", "").Trim();
+ return WaitForElement(markedWord, timeoutMessage, timeout, retryFrequency, postTimeout);
+ }
+ return new List<Xamarin.UITest.Queries.AppResult>().ToArray();
+ }
+
+ public void WaitForNoElement(Func<AppQuery, AppWebQuery> query, string timeoutMessage = "Timed out waiting for no element...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+
+
+ }
+
+ public void WaitForNoElement(string marked, string timeoutMessage = "Timed out waiting for no element...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+ Stopwatch s = new Stopwatch();
+ s.Start();
+ bool noElement = false;
+ while (s.Elapsed < timeout && !noElement)
+ {
+ var allResultsById = _cocoaApp.QueryById(marked);
+ noElement = allResultsById.Length == 0;
+ System.Diagnostics.Debug.WriteLine(noElement);
+ }
+ s.Stop();
+ if (s.Elapsed < timeout && !noElement)
+ throw (new Exception(timeoutMessage));
+
+ }
+
+ public void WaitForNoElement(Func<AppQuery, AppQuery> query, string timeoutMessage = "Timed out waiting for no element...", TimeSpan? timeout = default(TimeSpan?), TimeSpan? retryFrequency = default(TimeSpan?), TimeSpan? postTimeout = default(TimeSpan?))
+ {
+ var queryStr = query(new AppQuery(QueryPlatform.iOS)).ToString();
+ var isMarked = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bmarked\b");
+ if (isMarked)
+ {
+ var markedWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bmarked\b:'");
+ var isAll = markedWords[0].Trim() == "*";
+ var markedWord = markedWords[1].Replace("'", "").Trim();
+ WaitForNoElement(markedWord, timeoutMessage, timeout, retryFrequency, postTimeout);
+ }
+ }
+
+ static bool ExtractInfo(Func<AppQuery, AppQuery> query, out string markedWord, out int indexMarked)
+ {
+ indexMarked = 0;
+ markedWord = string.Empty;
+ var isSuccess = false;
+ var queryStr = query(new AppQuery(QueryPlatform.iOS)).ToString();
+ var isIndex = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bindex\b");
+ if (isIndex)
+ {
+ var indexWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bindex\b:");
+ var indexWord = indexWords[1];
+ int.TryParse(indexWord, out indexMarked);
+ queryStr = indexWords[0].Trim();
+ }
+ var isMarked = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\bmarked\b");
+ if (isMarked)
+ {
+ var markedWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\bmarked\b:'");
+ var isAll = markedWords[0].Trim() == "*";
+ markedWord = markedWords[1].Replace("'", "").Trim();
+ isSuccess = true;
+
+ }
+ var isText = System.Text.RegularExpressions.Regex.IsMatch(queryStr, @"\btext\b");
+ if (isText)
+ {
+ var markedWords = System.Text.RegularExpressions.Regex.Split(queryStr, @"\btext\b:'");
+ var isAll = markedWords[0].Trim() == "*";
+ markedWord = markedWords[1].Replace("'", "").Trim();
+ isSuccess = true;
+ }
+ return isSuccess;
+ }
+
+ void Tap(string marked, int index)
+ {
+ var safeIndex = Math.Max(index, 0);
+ var queryById = _cocoaApp.QueryById(marked.Trim())[safeIndex];
+ _cocoaApp.Click(queryById.Rect.CenterX, queryById.Rect.CenterY);
+ Thread.Sleep(1000);
+ }
+
+ static void EnterText(string marked, int index, string text)
+ {
+ UITest.Desktop.AppResult textField = null;
+ var safeIndex = Math.Max(index, 0);
+ var textFields = _cocoaApp.QueryById(marked).Where((arg) => arg.Class.Contains("SearchField") || arg.Class.Contains("TextField"));
+ if (textFields.Count() > 0)
+ {
+ textField = textFields.ElementAt(safeIndex);
+ }
+ else
+ {
+ var markedField = _cocoaApp.QueryById(marked);
+ if (markedField.Length > 0)
+ {
+ textField = markedField[0];
+ }
+ else
+ {
+
+ var allTextFields = _cocoaApp.QueryByType("TextField");
+ textField = allTextFields[0];
+ }
+ }
+
+ if (textField != null)
+ EnterText(text, textField.Rect.CenterX, textField.Rect.CenterY);
+
+ }
+
+ static void EnterText(string text, float x, float y)
+ {
+ _cocoaApp.Click(x, y);
+ _cocoaApp.Click(x, y);
+ Thread.Sleep(500);
+ _cocoaApp.EnterText(text);
+ Thread.Sleep(500);
+ }
+
+ static void ClearText(float x, float y)
+ {
+ _cocoaApp.Click(x, y);
+ _cocoaApp.Click(x, y);
+ Thread.Sleep(500);
+ _cocoaApp.ClearText();
+ Thread.Sleep(500);
+ }
+ }
+}
diff --git a/Xamarin.Forms.Core.macOS.UITests/Properties/AssemblyInfo.cs b/Xamarin.Forms.Core.macOS.UITests/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..ae37f172
--- /dev/null
+++ b/Xamarin.Forms.Core.macOS.UITests/Properties/AssemblyInfo.cs
@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Xamarin.Forms.Core.macOS.UITests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/Xamarin.Forms.Core.macOS.UITests/Xamarin.Forms.Core.macOS.UITests.csproj b/Xamarin.Forms.Core.macOS.UITests/Xamarin.Forms.Core.macOS.UITests.csproj
new file mode 100644
index 00000000..e70ae03b
--- /dev/null
+++ b/Xamarin.Forms.Core.macOS.UITests/Xamarin.Forms.Core.macOS.UITests.csproj
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{9DB0CABB-24CC-4538-88EC-6E0A0FE40248}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Xamarin.Forms.Core.macOS.UITests</RootNamespace>
+ <AssemblyName>Xamarin.Forms.Core.macOS.UITests</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;__MACOS__;UITEST</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Interfaces">
+ <HintPath>..\packages\ServiceStack.Interfaces.4.5.4\lib\portable-wp80+sl5+net45+win8+wpa81+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Text">
+ <HintPath>..\packages\ServiceStack.Text.4.5.4\lib\net45\ServiceStack.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Client">
+ <HintPath>..\packages\ServiceStack.Client.4.5.4\lib\net45\ServiceStack.Client.dll</HintPath>
+ </Reference>
+ <Reference Include="Xamarin.UITest.Desktop">
+ <HintPath>..\packages\Xamarin.UITest.Desktop.0.0.7\lib\net45\Xamarin.UITest.Desktop.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.Composition" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.IO.Compression" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Numerics" />
+ <Reference Include="System.Reactive.Core" />
+ <Reference Include="System.Reactive.Interfaces" />
+ <Reference Include="System.Reactive.Linq" />
+ <Reference Include="System.Reactive.PlatformServices" />
+ <Reference Include="System.Reactive.Windows.Threading" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.Windows" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="WindowsBase" />
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Xamarin.UITest">
+ <HintPath>..\packages\Xamarin.UITest.2.0.5\lib\Xamarin.UITest.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ActionSheetUITests.cs">
+ <Link>Tests\ActionSheetUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\BaseTestFixture.cs">
+ <Link>BaseTestFixture.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\UITestCategories.cs">
+ <Link>UITestCategories.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Queries.cs">
+ <Link>Queries.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\AppExtensions.cs">
+ <Link>Utilities\AppExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\PlatformQueries.cs">
+ <Link>PlatformQueries.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\Drag.cs">
+ <Link>Utilities\Drag.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\Gestures.cs">
+ <Link>Utilities\Gestures.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\UITestCustomExceptions.cs">
+ <Link>Utilities\UITestCustomExceptions.cs</Link>
+ </Compile>
+ <Compile Include="MacOSApp.cs" />
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ActivityIndicatorUITests.cs">
+ <Link>Tests\ActivityIndicatorUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ViewUITests.cs">
+ <Link>Tests\ViewUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Remotes\BaseViewContainerRemote.cs">
+ <Link>Remotes\BaseViewContainerRemote.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Remotes\EventViewContainerRemote.cs">
+ <Link>Remotes\EventViewContainerRemote.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Remotes\LayeredViewContainerRemote.cs">
+ <Link>Remotes\LayeredViewContainerRemote.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Remotes\StateViewContainerRemote.cs">
+ <Link>Remotes\StateViewContainerRemote.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Remotes\ViewContainerRemote.cs">
+ <Link>Remotes\ViewContainerRemote.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\ViewInspector.cs">
+ <Link>Utilities\ViewInspector.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\Logger.cs">
+ <Link>Utilities\Logger.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\NumericExtensions.cs">
+ <Link>Utilities\NumericExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Utilities\ParsingUtils.cs">
+ <Link>Utilities\ParsingUtils.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\AppearingUITests.cs">
+ <Link>Tests\AppearingUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\AutomationIDUITests.cs">
+ <Link>Tests\AutomationIDUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\BoxViewUITests.cs">
+ <Link>Tests\BoxViewUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ButtonUITests.cs">
+ <Link>Tests\ButtonUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ContextActionsUITests.cs">
+ <Link>Tests\ContextActionsUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\DatePickerUITests.cs">
+ <Link>Tests\DatePickerUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\DisplayAlertUITests.cs">
+ <Link>Tests\DisplayAlertUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\EditorUITests.cs">
+ <Link>Tests\EditorUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\EntryUITests.cs">
+ <Link>Tests\EntryUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\FrameUITests.cs">
+ <Link>Tests\FrameUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ImageUITests.cs">
+ <Link>Tests\ImageUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\LabelUITests.cs">
+ <Link>Tests\LabelUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\Legacy-CellsUITests.cs">
+ <Link>Tests\Legacy-CellsUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\Legacy-UnevenListTests.cs">
+ <Link>Tests\Legacy-UnevenListTests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\PickerUITests.cs">
+ <Link>Tests\PickerUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ProgressBarUITests.cs">
+ <Link>Tests\ProgressBarUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\RootGalleryUITests.cs">
+ <Link>Tests\RootGalleryUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ScrollViewUITests.cs">
+ <Link>Tests\ScrollViewUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\SearchBarUITests.cs">
+ <Link>Tests\SearchBarUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\SliderUITests.cs">
+ <Link>Tests\SliderUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\StepperUITests.cs">
+ <Link>Tests\StepperUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\SwitchUITests.cs">
+ <Link>Tests\SwitchUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\TimePickerUITests.cs">
+ <Link>Tests\TimePickerUITests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\ToolbarItemTests.cs">
+ <Link>Tests\ToolbarItemTests.cs</Link>
+ </Compile>
+ <Compile Include="..\Xamarin.Forms.Core.iOS.UITests\Tests\WebViewUITests.cs">
+ <Link>Tests\WebViewUITests.cs</Link>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Tests\" />
+ <Folder Include="Utilities\" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Xamarin.Forms.CustomAttributes\Xamarin.Forms.CustomAttributes.csproj">
+ <Project>{4DCD0420-1168-4B77-86DB-6196EE4BD491}</Project>
+ <Name>Xamarin.Forms.CustomAttributes</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj">
+ <Project>{57B8B73D-C3B5-4C42-869E-7B2F17D354AC}</Project>
+ <Name>Xamarin.Forms.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Xamarin.Forms.Maps\Xamarin.Forms.Maps.csproj">
+ <Project>{7D13BAC2-C6A4-416A-B07E-C169B199E52B}</Project>
+ <Name>Xamarin.Forms.Maps</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="..\Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems" Label="Shared" Condition="Exists('..\Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems')" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="..\packages\Xamarin.UITest.Desktop.0.0.7\build\Xamarin.UITest.Desktop.targets" Condition="Exists('..\packages\Xamarin.UITest.Desktop.0.0.7\build\Xamarin.UITest.Desktop.targets')" />
+</Project> \ No newline at end of file
diff --git a/Xamarin.Forms.Core.macOS.UITests/packages.config b/Xamarin.Forms.Core.macOS.UITests/packages.config
new file mode 100644
index 00000000..49c66041
--- /dev/null
+++ b/Xamarin.Forms.Core.macOS.UITests/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
+ <package id="NUnit" version="2.6.4" targetFramework="net45" />
+ <package id="ServiceStack.Client" version="4.5.4" targetFramework="net45" />
+ <package id="ServiceStack.Interfaces" version="4.5.4" targetFramework="net45" />
+ <package id="ServiceStack.Text" version="4.5.4" targetFramework="net45" />
+ <package id="Xamarin.UITest" version="2.0.5" targetFramework="net45" />
+ <package id="Xamarin.UITest.Desktop" version="0.0.7" targetFramework="net45" />
+</packages> \ No newline at end of file