/// </summary>
sealed partial class App
{
- /// <summary>
- /// Initializes the singleton application object. This is the first line of authored code
- /// executed, and as such is the logical equivalent of main() or WinMain().
- /// </summary>
- public App()
+ /// <summary>
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ /// </summary>
+ public App()
{
InitializeComponent();
Suspending += OnSuspending;
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
-
+ /* uncomment if you want to run tests without preloading
+ * issues list or change other behavior based on if tests
+ * are running in UI Harness
+ * if (!String.IsNullOrWhiteSpace(e.Arguments) &&
+ e.Arguments.Contains("RunningAsUITests"))
+ Controls.App.PreloadTestCasesIssuesList = false;*/
#if DEBUG
- if (System.Diagnostics.Debugger.IsAttached)
+ if (System.Diagnostics.Debugger.IsAttached)
{
// DebugSettings.EnableFrameRateCounter = true;
}
RunningApp.Screenshot("Text selection from char 2 length 3.");
RunningApp.Tap("CursorTextEntry");
- Assert.AreEqual("0", RunningApp.WaitForElement("SelectionLength")[0].Text);
+ Assert.AreEqual("0", RunningApp.WaitForElement("SelectionLength")[0].ReadText());
}
#if __IOS__
using System.Diagnostics;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
+using System.Threading.Tasks;
#if UITEST
using Xamarin.UITest;
RunningApp.Tap(q => q.Marked("FAST_TIMER"));
RunningApp.WaitForElement(q => q.Marked("COMPLETE"), timeout:TimeSpan.FromSeconds(2));
var result = RunningApp.WaitForElement(q => q.Marked("RESULT"))[0];
- var timerTicks = int.Parse(result.Text);
+ var timerTicks = int.Parse(result.ReadText());
//If fps > 50 then result must be 50. For small fps we use comparing with 35.
Assert.IsTrue(timerTicks > 35, $"Expected timer ticks are greater than 35. Actual: {timerTicks}");
RunningApp.Tap(q => q.Marked("SLOW_TIMER"));
RunningApp.WaitForElement(q => q.Marked("COMPLETE"), timeout:TimeSpan.FromSeconds(2));
result = RunningApp.WaitForElement(q => q.Marked("RESULT"))[0];
- timerTicks = int.Parse(result.Text);
+ timerTicks = int.Parse(result.ReadText());
Assert.IsTrue(timerTicks < 11, $"Expected timer ticks are less than 11. Actual: {timerTicks}");
}
#endif
[Test]
public void NoCrashFromDisposedBitmapWhenSwitchingPages()
{
- RunningApp.WaitForElement("Success");
+ RunningApp.WaitForElement("Success", timeout: TimeSpan.FromSeconds(20));
}
#endif
}
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2399, "Label Renderer Dispose never called")]
+
+#if __WINDOWS__
+ // this test works fine when ran manually but when executed through the test runner
+ // it fails. Not sure the difference
+ [NUnit.Framework.Category(Core.UITests.UITestCategories.ManualReview)]
+#endif
public class Issue2399 : TestNavigationPage
{
static AttachedStateEffectList AttachedStateEffects = new AttachedStateEffectList();
}
}
-#if UITEST && !__ANDROID__
+#if UITEST && __IOS__
[Test]
public void WaitForAllEffectsToDetach()
{
{
RunningApp.Tap($"TestSpan{i}");
RunningApp.TapCoordinates(target.X + 5, target.Y + 5);
+#if __WINDOWS__
+ RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2);
+#else
RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);
+#endif
RunningApp.WaitForElement($"{kGesture1}{i}");
RunningApp.Tap($"TestSpan5");
RunningApp.TapCoordinates(target.X + 5, target.Y + 5);
+
+#if __WINDOWS__
+ RunningApp.TapCoordinates(target.X + target.Width - 10, target.Y + 2);
+#else
RunningApp.TapCoordinates(target.X + target.CenterX, target.Y + 2);
+#endif
+
RunningApp.WaitForElement($"{kGesture1}4");
RunningApp.WaitForElement($"{kGesture2}4");
var element = RunningApp.WaitForElement(_paddingLabel).First();
bool usesSafeAreaInsets = false;
- if (element.Text != "25, 25, 25, 25")
+ if (element.ReadText() != "25, 25, 25, 25")
usesSafeAreaInsets = true;
- Assert.AreNotEqual(element.Text, "0, 0, 0, 0");
+ Assert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
if (!usesSafeAreaInsets)
- Assert.AreEqual(element.Text, "25, 25, 25, 25");
+ Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
// disable Safe Area Insets
RunningApp.Tap(_safeAreaAutomationId);
element = RunningApp.WaitForElement(_paddingLabel).First();
if (usesSafeAreaInsets)
- Assert.AreEqual(element.Text, "0, 0, 0, 0");
+ Assert.AreEqual(element.ReadText(), "0, 0, 0, 0");
else
- Assert.AreEqual(element.Text, "25, 25, 25, 25");
+ Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
// enable Safe Area insets
RunningApp.Tap(_safeAreaAutomationId);
RunningApp.WaitForElement($"{_safeAreaText}{true}");
element = RunningApp.WaitForElement(_paddingLabel).First();
- Assert.AreNotEqual(element.Text, "0, 0, 0, 0");
+ Assert.AreNotEqual(element.ReadText(), "0, 0, 0, 0");
if (!usesSafeAreaInsets)
- Assert.AreEqual(element.Text, "25, 25, 25, 25");
+ Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
// Set Padding and then disable safe area insets
RunningApp.Tap(_safeAreaAutomationId);
RunningApp.WaitForElement($"{_safeAreaText}{false}");
element = RunningApp.WaitForElement(_paddingLabel).First();
- Assert.AreEqual(element.Text, "25, 25, 25, 25");
+ Assert.AreEqual(element.ReadText(), "25, 25, 25, 25");
}
#endif
ScrollView scroll = null;
scroll = new ScrollView
{
+ AutomationId = "scrollView",
Content = new StackLayout
{
Children =
RunningApp.WaitForElement(_failedText);
RunningApp.Tap(_button1);
RunningApp.Tap(_button2);
+#if __WINDOWS__
+ var label = RunningApp.WaitForElement(_failedText);
+ Assert.AreEqual(0, label[0].Rect.Height);
+ Assert.AreEqual(0, label[0].Rect.Width);
+#else
RunningApp.WaitForNoElement(_failedText);
+#endif
}
#endif
}
#if UITEST
[NUnit.Framework.Category(UITestCategories.Image)]
[NUnit.Framework.Category(UITestCategories.ListView)]
+ [NUnit.Framework.Category(UITestCategories.UwpIgnore)]
#endif
public class Issue4597 : TestContentPage
{
protected override void Init()
{
- _image = new Image() { Source = _fileName, AutomationId = _fileName };
+ _image = new Image() { Source = _fileName, AutomationId = _fileName, ClassId = "Something" };
_button = new Button() { Image = _fileName, AutomationId = _fileName };
_imageButton = new ImageButton() { Source = _fileName, AutomationId = _fileName };
_listView = new ListView()
{
RunningApp.WaitForElement(_fileName);
var elementsBefore = RunningApp.WaitForElement(_fileName);
+#if !__WINDOWS__
var imageCell = RunningApp.Query(app => app.Marked(_theListView).Descendant()).Where(x => x.Class.Contains("Image")).FirstOrDefault();
+#endif
#if __IOS__
Assert.AreEqual(4, elementsBefore.Where(x => x.Class.Contains("Image")).Count());
-#else
+#elif __ANDROID__
Assert.AreEqual(3, elementsBefore.Length);
+#else
+ Assert.AreEqual(4, elementsBefore.Count());
#endif
+
+#if !__WINDOWS__
Assert.IsNotNull(imageCell);
+#endif
RunningApp.Tap("ClickMe");
RunningApp.WaitForElement(_appearText);
var elementsAfter = RunningApp.WaitForElement(_fileName);
+
+#if !__WINDOWS__
var imageCellAfter = RunningApp.Query(app => app.Marked(_theListView).Descendant()).Where(x => x.Class.Contains("Image")).FirstOrDefault();
Assert.IsNull(imageCellAfter);
-#if __IOS__
- Assert.AreEqual(0, elementsAfter.Where(x => x.Class.Contains("Image")).Count());
#endif
-#if __ANDROID__
- foreach(var newElement in elementsAfter)
+#if __IOS__
+ Assert.AreEqual(0, elementsAfter.Where(x => x.Class.Contains("Image")).Count());
+#elif __ANDROID__
+ foreach (var newElement in elementsAfter)
{
foreach(var oldElement in elementsBefore)
{
}
}
}
+#else
+ //can't validate if images have vanished until this is resolved
+ Assert.Inconclusive(@"https://github.com/xamarin/Xamarin.Forms/issues/4731");
#endif
}
#endif
public const string DefaultMainPageId = "ControlGalleryMainPage";
+ public static bool PreloadTestCasesIssuesList { get; set; } = true;
public App()
{
_testCloudService = DependencyService.Get<ITestCloudService>();
_filter = filter;
PageToAction.Clear();
+ if(String.IsNullOrWhiteSpace(filter) && !Controls.App.PreloadTestCasesIssuesList)
+ {
+ if (_section != null)
+ {
+ Root.Remove(_section);
+ }
+ return;
+ }
var issueCells = Enumerable.Empty<TextCell>();
}
catch (InvalidOperationException)
{
+ ProcessException();
+ }
+ catch(WebDriverException)
+ {
+ ProcessException();
+ }
+
+ void ProcessException()
+ {
// Some elements aren't "clickable" from an automation perspective (e.g., Frame renders as a Border
// with content in it; if the content is just a TextBlock, we'll end up here)
// and Tap in that spot
PointF p = ElementToClickablePoint(element);
TapCoordinates(p.X, p.Y);
+
}
}
{
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", "0d4424f6-1e29-4476-ac00-ba22c3789cb6_ph1m9x8skttmg!App");
+ options.AddAdditionalCapability("appArguments", "RunningAsUITests");
Session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), options);
Assert.IsNotNull(Session);
Session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);