Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make MenuFlyoutItem.Click working #2029

Merged
merged 16 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/ReleaseNotes/_ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next version

### Features
* [#2029](https://github.com/unoplatform/uno/pull/2029) Support for MenuFlyoutItem.Click
* support /[file]/[name] format in ResourceLoader.GetForCurrentView().GetString()
* [#2039] Added support for Xaml type conversions using CreateFromStringAttribute.
* [#] Support for `Windows.Devices.Lights.Lamp` on iOS, Android.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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]
[ActivePlatforms(Platform.Android, Platform.iOS)]
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");
}
}
}
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutItemTests\MenuFlyoutItem_Click.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\PersonPictureTests\PersonPicturePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -2944,6 +2948,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ListView\RotatedListView_WithRotatedItems.xaml.cs">
<DependentUpon>RotatedListView_WithRotatedItems.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutItemTests\MenuFlyoutItem_Click.xaml.cs">
<DependentUpon>MenuFlyoutItem_Click.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Models\RotatedListViewViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Flyout\Flyout_LargeContent.xaml.cs">
<DependentUpon>Flyout_LargeContent.xaml</DependentUpon>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<UserControl
x:Class="UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests.MenuFlyoutItem_Click"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock x:Name="mfiResult" Text="Starting..." />
<AppBar x:Name="mfiCmdBar" Grid.Row="1">
<AppBarButton Icon="Pin" Label="Start" x:Name="mfiButton" >
<AppBarButton.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Name="mfiItem" Text="mfiItem" Click="FlyoutItem_Click" />
<MenuFlyoutItem Text="Item2" />
</MenuFlyout>
</AppBarButton.Flyout>
</AppBarButton>
</AppBar>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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
{
[Uno.UI.Samples.Controls.SampleControlInfo("MenuFlyoutItem", "MenuFlyoutItem_Click", description: "Testing click on MenuFlyoutItem")]
public sealed partial class MenuFlyoutItem_Click : UserControl
{
public MenuFlyoutItem_Click()
{
this.InitializeComponent();
}

public void FlyoutItem_Click(object sender, object args)
{
mfiResult.Text = "success";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void OnMenuItemClick(object sender, PopupMenu.MenuItemClickEventArgs e)
var items = Items.OfType<MenuFlyoutItem>().Where(i => i.Visibility == Visibility.Visible).ToArray();
var item = items[e.Item.ItemId];

item.Command.ExecuteIfPossible(item.CommandParameter);
item.InvokeClick();
pkar70 marked this conversation as resolved.
Show resolved Hide resolved
}

private View GetActualTarget()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void ShowActionSheet(UIView placementTarget)

if (item != null)
{
item.Command.ExecuteIfPossible(item.CommandParameter);
item.InvokeClick();
Hide();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
))
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Controls/MenuFlyout/MenuFlyoutItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public string Text
internal void InvokeClick()
{
Click?.Invoke(this, new RoutedEventArgs(this));
Command.ExecuteIfPossible();
Command.ExecuteIfPossible(this.CommandParameter);
}
}
}