summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-11-16 14:07:30 -0700
committerJason Smith <jason.smith@xamarin.com>2016-11-16 13:07:30 -0800
commit122f0e3e6060711d6c3b2b8523236b8a057434df (patch)
tree719b2a3f4a3146602e764ebeca3939b8788db1a8 /Xamarin.Forms.Controls
parentacc6efb3d7d502d0a40020ec86eaff4d018de8be (diff)
downloadxamarin-forms-122f0e3e6060711d6c3b2b8523236b8a057434df.tar.gz
xamarin-forms-122f0e3e6060711d6c3b2b8523236b8a057434df.tar.bz2
xamarin-forms-122f0e3e6060711d6c3b2b8523236b8a057434df.zip
Run multiple UI tests without restarting ControlGallery (#539)
* Allow UI tests to bypass "manual" navigation to isses pages * Add missing Preserve attribute * Make Issue198 test work with direct navigation * Remove empty UI tests * Fix error handling for iOS * Use navigation which works for subsequent TestNavigationPages on iOS * Fix race condition in 39530 test Remove master page nesting when doing direct nav for UI tests * Set up and run a single instance of Control Gallery for UI tests * Force NavigateToIssue to wait for main page appearing to deal with iOS timing * Move remaining UI tests into Issues namespace * Change the connection check URL so it'll work on iOS * Make Appearing Gallery tests work without restarting app * Prevent ContextActions tests from stepping on each other * Make context menu test more robust * Move ButtonExtensions back to Controls namespace * Have test 774 dismiss the action sheet before ending * Update UITest package to 2.0.0 stable * Make 2948 restore orientation when it's done * Null check on PageController before calling SendDisappearing * Adding a wait for the root page in the core tests * Add consecutive tests reset to prevent memory slog on older iOS devices
Diffstat (limited to 'Xamarin.Forms.Controls')
-rw-r--r--Xamarin.Forms.Controls/App.cs56
-rw-r--r--Xamarin.Forms.Controls/ControlGalleryPages/AppearingGalleryPage.cs4
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs1
3 files changed, 54 insertions, 7 deletions
diff --git a/Xamarin.Forms.Controls/App.cs b/Xamarin.Forms.Controls/App.cs
index 3af36ee3..fcf0b1f6 100644
--- a/Xamarin.Forms.Controls/App.cs
+++ b/Xamarin.Forms.Controls/App.cs
@@ -22,16 +22,14 @@ namespace Xamarin.Forms.Controls
static Dictionary<string, string> s_config;
readonly ITestCloudService _testCloudService;
+ public const string DefaultMainPageId = "ControlGalleryMainPage";
+
public App()
{
_testCloudService = DependencyService.Get<ITestCloudService>();
InitInsights();
- MainPage = new MasterDetailPage
- {
- Master = new ContentPage { Title = "Master", BackgroundColor = Color.Red },
- Detail = CoreGallery.GetMainPage()
- };
+ SetMainPage(CreateDefaultMainPage());
//// Uncomment to verify that there is no gray screen displayed between the blue splash and red MasterDetailPage.
//MainPage = new Bugzilla44596SplashPage(() =>
@@ -46,6 +44,16 @@ namespace Xamarin.Forms.Controls
//});
}
+ public Page CreateDefaultMainPage()
+ {
+ return new MasterDetailPage
+ {
+ AutomationId = DefaultMainPageId,
+ Master = new ContentPage { Title = "Master", BackgroundColor = Color.Red },
+ Detail = CoreGallery.GetMainPage()
+ };
+ }
+
protected override void OnAppLinkRequestReceived(Uri uri)
{
var appDomain = "http://" + AppName.ToLowerInvariant() + "/";
@@ -154,5 +162,43 @@ namespace Xamarin.Forms.Controls
text = await reader.ReadToEndAsync();
return text;
}
+
+ public bool NavigateToTestPage(string test)
+ {
+ try
+ {
+ // Create an instance of the main page
+ var root = CreateDefaultMainPage();
+
+ // Set up a delegate to handle the navigation to the test page
+ EventHandler toTestPage = null;
+
+ toTestPage = delegate(object sender, EventArgs e)
+ {
+ Current.MainPage.Navigation.PushModalAsync(TestCases.GetTestCases());
+ TestCases.TestCaseScreen.PageToAction[test]();
+ Current.MainPage.Appearing -= toTestPage;
+ };
+
+ // And set that delegate to run once the main page appears
+ root.Appearing += toTestPage;
+
+ SetMainPage(root);
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ Log.Warning("UITests", $"Error attempting to navigate directly to {test}: {ex}");
+
+ }
+
+ return false;
+ }
+
+ public void Reset()
+ {
+ SetMainPage(CreateDefaultMainPage());
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls/ControlGalleryPages/AppearingGalleryPage.cs b/Xamarin.Forms.Controls/ControlGalleryPages/AppearingGalleryPage.cs
index 0df2eeb3..21d91906 100644
--- a/Xamarin.Forms.Controls/ControlGalleryPages/AppearingGalleryPage.cs
+++ b/Xamarin.Forms.Controls/ControlGalleryPages/AppearingGalleryPage.cs
@@ -69,13 +69,13 @@ namespace Xamarin.Forms.Controls
{
page.Appearing += (object sender, EventArgs e) => {
_isAppearingFired++;
- App.AppearingMessages.Add ($"Appearing {page.Title}");
+ App.AppearingMessages.Insert (0, $"Appearing {page.Title}");
Debug.WriteLine ($"Appearing {page.Title}");
};
page.Disappearing += (object sender, EventArgs e) => {
_isDisappearingFired++;
- App.AppearingMessages.Add ($"Disappearing {page.Title}");
+ App.AppearingMessages.Insert (0, $"Disappearing {page.Title}");
Debug.WriteLine( $"Disappearing {page.Title}");
};
}
diff --git a/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs b/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs
index f8aba26b..8f272182 100644
--- a/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/MasterDetailPageTabletPage.cs
@@ -1,4 +1,5 @@
using System;
+using Xamarin.Forms.Controls.Issues;
namespace Xamarin.Forms.Controls
{