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 6 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
2 changes: 1 addition & 1 deletion doc/ReleaseNotes/_ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
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 @@ -433,6 +433,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 @@ -2821,6 +2825,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
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);
}
}
}