From ee42f74a5f8db35ef350f8a15165db795ea7946b Mon Sep 17 00:00:00 2001 From: pkar70 Date: Tue, 5 Nov 2019 21:32:05 +0000 Subject: [PATCH 1/8] MenuFlyoutItem_Click support --- doc/ReleaseNotes/_ReleaseNotes.md | 2 +- .../UnoSamples_Test_Click.cs | 40 +++++++++++++++++++ .../UITests.Shared/UITests.Shared.projitems | 7 ++++ .../MenuFlyoutItem_Click.xaml | 28 +++++++++++++ .../MenuFlyoutItem_Click.xaml.cs | 32 +++++++++++++++ .../Controls/MenuFlyout/MenuFlyout.Android.cs | 2 +- .../Controls/MenuFlyout/MenuFlyoutItem.cs | 2 +- 7 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs diff --git a/doc/ReleaseNotes/_ReleaseNotes.md b/doc/ReleaseNotes/_ReleaseNotes.md index 0e1eedeb1526..770a97c6c74a 100644 --- a/doc/ReleaseNotes/_ReleaseNotes.md +++ b/doc/ReleaseNotes/_ReleaseNotes.md @@ -3,7 +3,7 @@ ## Next version ### Features - +* MenuFlyoutItem.Click support * [#1970](https://github.com/unoplatform/uno/pull/1970) Added support for `AnalyticsInfo` properties on iOS, Android and WASM * [#1207] Implemented some `PackageId` properties * [#1919](https://github.com/unoplatform/uno/pull/1919) Support for `PathGeometry` on WASM. diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs new file mode 100644 index 000000000000..61ca6afcfb86 --- /dev/null +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using SamplesApp.UITests.TestFramework; +using Uno.UITest.Helpers; +using Uno.UITest.Helpers.Queries; + +namespace SamplesApp.UITests.Windows_UI_Xaml_Controls.MenuFlyoutItemTests +{ + [TestFixture] + class UnoSamples_Test_Click: SampleControlUITestBase + { + [Test] + [AutoRetry] + public void MenuFlyoutItem_ClickTest() + { + Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests.MenuFlyoutItem_Click"); + + _app.WaitForElement(_app.Marked("mfiButton")); + + TakeScreenshot("Initial"); + + // step 1: press button to show menu + _app.Tap(_app.Marked("mfiButton")); + + TakeScreenshot("menuShown"); + + // step 2: click MenuFlyoutItem + _app.Tap(_app.Marked("mfiItem")); + + // step 3: check result + _app.WaitForText(_app.Marked("mfiResult"), "success"); + + TakeScreenshot("AfterSuccess"); + } + } +} diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index 0b2f2d98a986..8fa7b3a8768a 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -433,6 +433,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -2821,6 +2825,9 @@ RotatedListView_WithRotatedItems.xaml + + MenuFlyoutItem_Click.xaml + Flyout_LargeContent.xaml diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml new file mode 100644 index 000000000000..6ad57e92f586 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs new file mode 100644 index 000000000000..cc935cde2ffe --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 + +namespace UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests +{ + public sealed partial class MenuFlyoutItem_Click : UserControl + { + public MenuFlyoutItem_Click() + { + this.InitializeComponent(); + } + + public void FlyoutItem_Click(object sender, object args) + { + mfiResult.Text = "success"; + } + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs index ca4d53263ced..a67ee165702c 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.Android.cs @@ -54,7 +54,7 @@ private void OnMenuItemClick(object sender, PopupMenu.MenuItemClickEventArgs e) var items = Items.OfType().Where(i => i.Visibility == Visibility.Visible).ToArray(); var item = items[e.Item.ItemId]; - item.Command.ExecuteIfPossible(item.CommandParameter); + item.InvokeClick(); } private View GetActualTarget() diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs index 45d71c8ce136..30b572d35a72 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs @@ -71,7 +71,7 @@ public string Text internal void InvokeClick() { Click?.Invoke(this, new RoutedEventArgs(this)); - Command.ExecuteIfPossible(); + Command.ExecuteIfPossible(this.CommandParameter); } } } From 86dc888372df7d2a5abfd7867484f3a432e57692 Mon Sep 17 00:00:00 2001 From: Piotr Karocki Date: Wed, 6 Nov 2019 09:14:44 +0100 Subject: [PATCH 2/8] Update MenuFlyoutItem_Click.xaml --- .../MenuFlyoutItem_Click.xaml | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml index 6ad57e92f586..cf9fc609ee6f 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml @@ -10,19 +10,31 @@ d:DesignWidth="400"> - + + + + + + From 3131ff3e7b16a4de52c929e4c03c1424d5706e07 Mon Sep 17 00:00:00 2001 From: Piotr Karocki Date: Wed, 6 Nov 2019 10:14:11 +0100 Subject: [PATCH 3/8] Update MenuFlyoutItem_Click.xaml.cs --- .../MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs index cc935cde2ffe..868cd398705d 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml.cs @@ -17,6 +17,7 @@ namespace UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests { + [Uno.UI.Samples.Controls.SampleControlInfo("MenuFlyoutItem", "MenuFlyoutItem_Click", description: "Testing click on MenuFlyoutItem")] public sealed partial class MenuFlyoutItem_Click : UserControl { public MenuFlyoutItem_Click() From 7cb8440882fe2133b9842321fe19f98e6ef152e1 Mon Sep 17 00:00:00 2001 From: Piotr Karocki Date: Wed, 6 Nov 2019 11:32:55 +0100 Subject: [PATCH 4/8] Update MenuFlyoutItem_Click.xaml --- .../MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml index cf9fc609ee6f..755efccfcbe8 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml @@ -26,14 +26,14 @@ --> - + + From a04831a364964982dff377f64868c51ee3ff0be2 Mon Sep 17 00:00:00 2001 From: Piotr Karocki Date: Wed, 6 Nov 2019 12:46:41 +0100 Subject: [PATCH 5/8] Update MenuFlyoutItem_Click.xaml --- .../MenuFlyoutItem_Click.xaml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml index 755efccfcbe8..b6436c407419 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml @@ -10,31 +10,20 @@ d:DesignWidth="400"> - - - - + - + - - + From 84759dc28a148bd72929a87541270b37f90271ee Mon Sep 17 00:00:00 2001 From: Piotr Karocki Date: Wed, 6 Nov 2019 13:18:54 +0100 Subject: [PATCH 6/8] Update MenuFlyoutItem_Click.xaml --- .../MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml index b6436c407419..e8681a64aa56 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/MenuFlyoutItem_Click.xaml @@ -19,7 +19,7 @@ - + From a107e4ad9885e87a237d6c3ea1ba17dd33649eb9 Mon Sep 17 00:00:00 2001 From: pkar70 Date: Tue, 12 Nov 2019 19:10:05 +0000 Subject: [PATCH 7/8] Same change for iOS --- src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs | 2 +- src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs index 951161578da9..acca56f76f66 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS7.iOS.cs @@ -40,7 +40,7 @@ private void ShowActionSheet(UIView placementTarget) if (item != null) { - item.Command.ExecuteIfPossible(item.CommandParameter); + item.InvokeClick(); Hide(); } }; diff --git a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs index 9ff7b2b4c3d0..35877a879dcb 100644 --- a/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs +++ b/src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyout.iOS8.iOS.cs @@ -30,7 +30,7 @@ private void ShowAlert(UIView placementTarget) true == (item.GetValue(IsDestructiveProperty) as bool?) ? UIAlertActionStyle.Destructive : UIAlertActionStyle.Default, _ => { - item.Command.ExecuteIfPossible(item.CommandParameter); + item.InvokeClick(); Hide(); } )) From 0b259046b3dd9d5cc0d5b1daa3a72f9ffbe64d0f Mon Sep 17 00:00:00 2001 From: Piotr Karocki Date: Tue, 19 Nov 2019 13:26:12 +0100 Subject: [PATCH 8/8] Disabling test for WASM --- .../MenuFlyoutItemTests/UnoSamples_Test_Click.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs index 61ca6afcfb86..4c6b92f87281 100644 --- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs +++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutItemTests/UnoSamples_Test_Click.cs @@ -15,6 +15,7 @@ class UnoSamples_Test_Click: SampleControlUITestBase { [Test] [AutoRetry] + [ActivePlatforms(Platform.Android, Platform.iOS)] public void MenuFlyoutItem_ClickTest() { Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests.MenuFlyoutItem_Click");