From 60acae7d16430310303e87043fbed261681b4164 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Mon, 14 Jan 2019 10:05:51 -0700 Subject: [PATCH 1/3] [ios] clear perfect value add ui test (#4968) - fixes #4957 --- .../Issue3652.cs | 45 ++++++++++++++++++- .../Renderers/LabelRenderer.cs | 2 + 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3652.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3652.cs index b9e163b1a..93f902139 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3652.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3652.cs @@ -2,6 +2,13 @@ using Xamarin.Forms.CustomAttributes; using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +using Xamarin.Forms.Core.UITests; +#endif + namespace Xamarin.Forms.Controls.Issues { [Preserve(AllMembers = true)] @@ -49,7 +56,7 @@ namespace Xamarin.Forms.Controls.Issues { var label = new Label(); label.SetBinding(Label.TextProperty, "Description"); - + label.AutomationId = "pandabear"; var menu = new MenuItem { Text = "Remove" }; menu.Command = new Command(() => ((ListItemViewModel)BindingContext).Remove.Execute((this, BindingContext))); ContextActions.Add(menu); @@ -102,5 +109,41 @@ namespace Xamarin.Forms.Controls.Issues public Command Remove => new Command(() => MessagingCenter.Send(this, "Remove", this)); } + +#if UITEST && !__WINDOWS__ + [Test] + public void TestRemovingContextMenuItems() + { + for(int i = 1; i <= 3; i++) + { + string searchFor = $"Remove me using the context menu. #{i}"; + RunningApp.WaitForElement(searchFor); + + RunningApp.ActivateContextMenu(searchFor); + RunningApp.WaitForElement(c => c.Marked("Remove")); + RunningApp.Tap(c => c.Marked("Remove")); + } + + + for (int i = 4; i <= 6; i++) + { + RunningApp.Tap("Add an item"); + string searchFor = $"Remove me using the context menu. #{i}"; + + RunningApp.ActivateContextMenu(searchFor); + RunningApp.WaitForElement(c => c.Marked("Remove")); + RunningApp.Tap(c => c.Marked("Remove")); + } + + + for (int i = 1; i <= 6; i++) + { + string searchFor = $"Remove me using the context menu. #{i}"; + RunningApp.WaitForNoElement(c => c.Marked("Remove")); + } + + } +#endif + } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs index ef0855419..ad4c08ecb 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs @@ -142,6 +142,8 @@ namespace Xamarin.Forms.Platform.MacOS protected override void OnElementChanged(ElementChangedEventArgs