summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Utilities
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-05-04 08:16:42 -0600
committerRui Marinho <me@ruimarinho.net>2016-05-04 15:16:42 +0100
commit8d383746caab00dd3ee0b62dc992a2a99c7a6d06 (patch)
tree37a7f814bc305bd8b6c44837bdbfc421ee1f9ddf /Xamarin.Forms.Core.iOS.UITests/Utilities
parent5b9094241b1d3da5419ed21be30bdcc07c469dbe (diff)
downloadxamarin-forms-8d383746caab00dd3ee0b62dc992a2a99c7a6d06.tar.gz
xamarin-forms-8d383746caab00dd3ee0b62dc992a2a99c7a6d06.tar.bz2
xamarin-forms-8d383746caab00dd3ee0b62dc992a2a99c7a6d06.zip
Remove empty UI tests (#160)
* Use WaitForElement instead of Thread.Sleep to cut down on idle time * Remove empty UI tests
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests/Utilities')
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs84
1 files changed, 6 insertions, 78 deletions
diff --git a/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs b/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs
index c6f2508c..481c3a5e 100644
--- a/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/Utilities/AppExtensions.cs
@@ -30,87 +30,15 @@ namespace Xamarin.Forms.Core.UITests
public static void NavigateToGallery (this IApp app, string page)
{
+ const string goToTestButtonQuery = "* marked:'GoToTestButton'";
+
var text = Regex.Match (page, "'(?<text>[^']*)'").Groups["text"].Value;
app.EnterText (q => q.Raw ("* marked:'SearchBar'"), text);
- //var searchBar = app.Query (q => q.Raw ("* marked:'SearchBar'")).Single ();
- Thread.Sleep(10000);
-
- app.Tap (q => q.Raw ("* marked:'GoToTestButton'"));
- app.WaitForNoElement (o => o.Raw ("* marked:'GoToTestButton'"), "Timed out", TimeSpan.FromMinutes(2));
-
- //app.Screenshot ("Navigating to gallery ...");
- //var galleryListViewBounds = app.Query (Queries.GalleryListView)[0].Rect;
- //app.ScrollForElement (page, new Drag (galleryListViewBounds, Drag.Direction.BottomToTop, Drag.DragLength.Long));
- //app.Tap (q => q.Raw (page));
- //app.Screenshot ("At gallery!");
- }
-
- public static void NavigateToTestCases (this IApp app, string testCase)
- {
- app.Tap (q => q.Button ("Go to Test Cases"));
- app.WaitForElement (q => q.Raw ("* marked:'TestCasesIssueList'"));
-
- app.EnterText (q => q.Raw ("* marked:'SearchBarGo'"), testCase);
-
- app.WaitForElement (q => q.Raw ("* marked:'SearchButton'"));
- app.Tap (q => q.Raw ("* marked:'SearchButton'"));
-
- //app.NavigateToTestCase(testCase);
- }
-
- public static void NavigateToTestCase (this IApp app, string testCase)
- {
- string testCasesQuery = "* marked:'" + testCase + "'";
- var testCaseIssue = app.Query (q => q.Raw ("* marked:'TestCasesIssueList'")).FirstOrDefault ();
- if (testCaseIssue != null) {
- AppRect scrollRect = testCaseIssue.Rect;
- app.ScrollForElement (testCasesQuery, new Drag (scrollRect, Drag.Direction.BottomToTop, Drag.DragLength.Long));
- app.Tap (q => q.Raw (testCasesQuery));
- } else {
- Debug.WriteLine (string.Format ("Failed to find test case {0}", testCase));
- }
- }
-
- public static bool RectsEqual (AppRect rectOne, AppRect rectTwo)
- {
- const float equalsTolerance = 0.1f;
-
- bool areEqual =
- (Math.Abs (rectOne.X - rectTwo.X) < equalsTolerance) &&
- (Math.Abs (rectOne.Y - rectTwo.Y) < equalsTolerance) &&
- (Math.Abs (rectOne.Width - rectTwo.Width) < equalsTolerance) &&
- (Math.Abs (rectOne.Height - rectTwo.Height) < equalsTolerance) &&
- (Math.Abs (rectOne.CenterX - rectTwo.CenterX) < equalsTolerance) &&
- (Math.Abs (rectOne.CenterY - rectTwo.CenterY) < equalsTolerance);
-
- return areEqual;
- }
-
- public static void WaitForAnimating (this IApp app, Func<AppQuery, AppQuery> query)
- {
- // Right now only checks if bounds are moving
- const int pollingRate = 200;
- const int timeout = 5000;
- var sw = new Stopwatch ();
-
- var previousState = app.Query (query).First ().Rect;
-
- sw.Start ();
- while (true) {
-
- var newState = app.Query (query).First ().Rect;
-
- if (RectsEqual (previousState, newState))
- break;
-
- previousState = newState;
-
- if (sw.ElapsedMilliseconds >= timeout)
- throw new Exception("Timed out");
+
+ app.WaitForElement(q => q.Raw(goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromSeconds(10));
- Thread.Sleep (pollingRate);
- }
- sw.Stop ();
+ app.Tap (q => q.Raw (goToTestButtonQuery));
+ app.WaitForNoElement (o => o.Raw (goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromMinutes(2));
}
}
}