From 2600a02543159c1a36fa16a8225d83b5ff5ff80e Mon Sep 17 00:00:00 2001 From: "E.Z. Hart" Date: Wed, 30 Nov 2016 11:08:30 -0700 Subject: [PATCH] Fix Issue 774 test so it works with wrapped IApp on phone and tablet --- .../Issue774.cs | 47 +++++-------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue774.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue774.cs index 76e248061..642aa39fc 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue774.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue774.cs @@ -34,48 +34,25 @@ namespace Xamarin.Forms.Controls.Issues [Test] public void Issue774TestsDismissActionSheetAfterRotation () { + RunningApp.Tap(q => q.Button("Show ActionSheet")); + RunningApp.Screenshot("Show ActionSheet"); - RunningApp.Tap (q => q.Button ("Show ActionSheet")); - RunningApp.Screenshot ("Show ActionSheet"); + RunningApp.SetOrientationLandscape(); + RunningApp.Screenshot("Rotate Device"); - RunningApp.SetOrientationLandscape (); - RunningApp.Screenshot ("Rotate Device"); - - var app = (RunningApp as iOSApp); + // Wait for the action sheet element to show up + RunningApp.WaitForElement(q => q.Marked("What's up")); - if (app != null) { + var dismiss = RunningApp.Query("Dismiss"); - if (!app.Device.IsTablet) - RunningApp.Tap (q => q.Marked ("Dismiss")); - else // iPad does not have dismiss option - RunningApp.Tap (q => q.Marked ("Destroy")); + var target = dismiss.Length > 0 ? "Dismiss" : "Destroy"; - if(app.Device.IsTablet) - RunningApp.WaitForNoElement (q => q.Marked ("Destroy")); - else - RunningApp.WaitForNoElement (q => q.Marked ("Dismiss")); - RunningApp.Screenshot ("Dismiss ActionSheet"); + RunningApp.Tap(q => q.Marked(target)); + RunningApp.WaitForNoElement(q => q.Marked(target)); + + RunningApp.Screenshot("Dismiss ActionSheet"); -// App.SetOrientationPortrait (); -// App.Tap (q => q.Button ("Show ActionSheet")); -// App.Screenshot ("Rotate and show ActionSheet"); -// -// if (!app.Device.IsTablet) -// App.Tap (q => q.Button ("Dismiss")); -// else // iPad does not have dismiss option -// App.Tap (q => q.Marked ("Destroy")); -// -// if (app.Device.IsTablet) -// App.WaitForNoElement (q => q.Marked ("Destroy")); -// else // iPad does not have dismiss option -// App.WaitForNoElement (q => q.Marked ("Dismiss")); - - } - else - { - RunningApp.Tap(q => q.Marked("Dismiss")); - } } [TearDown]