Skip to content

Commit 004abee

Browse files
committed
fix(popup): [iOS] Nested popup results in NRE
1 parent 1a2b5c4 commit 004abee

File tree

6 files changed

+153
-3
lines changed

6 files changed

+153
-3
lines changed

build/ios-uitest-run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ else
6161
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.ComboBoxTests' or \
6262
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Media_Animation' or \
6363
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.BorderTests' or \
64+
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.MenuFlyoutTests' or \
6465
class = 'SamplesApp.UITests.Windows_UI_Xaml_Shapes.Basics_Shapes_Tests' or \
6566
namespace = 'SamplesApp.UITests.Windows_UI_Xaml_Controls.ScrollViewerTests'
6667
"

src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/MenuFlyoutTests/MenuFlyoutTests.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,43 @@ public void MenuFlyoutItem_ClickTest()
4141

4242
[Test]
4343
[AutoRetry]
44+
public void MenuFlyoutItem_Hierarchy()
45+
{
46+
Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutTests.MenuFlyoutItem_Hierarchy");
47+
48+
_app.WaitForElement(_app.Marked("Help"));
49+
50+
TakeScreenshot("Initial");
51+
52+
_app.FastTap(_app.Marked("Help"));
53+
TakeScreenshot("menuShown");
54+
55+
_app.FastTap(_app.Marked("MenuViewHelp"));
56+
_app.WaitForText(_app.Marked("results"), "View Help");
57+
58+
_app.FastTap(_app.Marked("Help"));
59+
_app.WaitForElement(_app.Marked("MenuFeedback"));
60+
_app.FastTap(_app.Marked("MenuFeedback"));
61+
_app.WaitForElement(_app.Marked("MenuReportProblem"));
62+
_app.FastTap(_app.Marked("MenuReportProblem"));
63+
_app.WaitForText(_app.Marked("results"), "Report Problem");
64+
65+
66+
_app.FastTap(_app.Marked("Help"));
67+
_app.WaitForElement(_app.Marked("MenuFeedback"));
68+
_app.FastTap(_app.Marked("MenuFeedback"));
69+
_app.WaitForElement(_app.Marked("MenuSettings"));
70+
_app.FastTap(_app.Marked("MenuSettings"));
71+
_app.WaitForElement(_app.Marked("MenuAutoSave"));
72+
_app.FastTap(_app.Marked("MenuAutoSave"));
73+
_app.WaitForText(_app.Marked("results"), "Auto Save");
74+
75+
TakeScreenshot("AfterSuccess");
76+
}
77+
78+
[Test]
79+
[AutoRetry]
80+
[ActivePlatforms(Platform.Android, Platform.Browser)] // https://github.com/unoplatform/uno/issues/4795
4481
public void Simple_MenuFlyout()
4582
{
4683
Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuBarTests.SimpleMenuBar");
@@ -70,6 +107,7 @@ void Validate(string topMenu, string item, string expectedResult)
70107

71108
[Test]
72109
[AutoRetry]
110+
[ActivePlatforms(Platform.Android, Platform.Browser)] // https://github.com/unoplatform/uno/issues/4795
73111
public void Simple_MenuFlyout_Toggle()
74112
{
75113
Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuBarTests.SimpleMenuBar");
@@ -103,6 +141,7 @@ void Validate(string topMenu, string item, string expectedResult, bool initialCh
103141

104142
[Test]
105143
[AutoRetry]
144+
[ActivePlatforms(Platform.Android, Platform.Browser)] // https://github.com/unoplatform/uno/issues/4795
106145
public void Simple_SubMenuFlyout()
107146
{
108147
Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuBarTests.SimpleMenuBar");
@@ -129,7 +168,7 @@ public void Simple_SubMenuFlyout()
129168

130169
[Test]
131170
[AutoRetry]
132-
[ActivePlatforms(Platform.Browser, Platform.iOS)]
171+
[ActivePlatforms(Platform.Browser)] // https://github.com/unoplatform/uno/issues/4795
133172
public void Disabled_MenuFlyoutItem()
134173
{
135174
Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuBarTests.SimpleMenuBar");
@@ -159,6 +198,7 @@ public void Disabled_MenuFlyoutItem()
159198

160199
[Test]
161200
[AutoRetry]
201+
[ActivePlatforms(Platform.Android, Platform.Browser)] // https://github.com/unoplatform/uno/issues/4795
162202
public void Dismiss_MenuFlyout()
163203
{
164204
Run("UITests.Shared.Windows_UI_Xaml_Controls.MenuBarTests.SimpleMenuBar");

src/SamplesApp/UITests.Shared/UITests.Shared.projitems

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,10 @@
12811281
<SubType>Designer</SubType>
12821282
<Generator>MSBuild:Compile</Generator>
12831283
</Page>
1284+
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutTests\MenuFlyoutItem_Hierarchy.xaml">
1285+
<SubType>Designer</SubType>
1286+
<Generator>MSBuild:Compile</Generator>
1287+
</Page>
12841288
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutTests\MenuFlyout_IosNative.xaml">
12851289
<SubType>Designer</SubType>
12861290
<Generator>MSBuild:Compile</Generator>
@@ -4694,6 +4698,9 @@
46944698
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutTests\MenuFlyoutItem_Click.xaml.cs">
46954699
<DependentUpon>MenuFlyoutItem_Click.xaml</DependentUpon>
46964700
</Compile>
4701+
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutTests\MenuFlyoutItem_Hierarchy.xaml.cs">
4702+
<DependentUpon>MenuFlyoutItem_Hierarchy.xaml</DependentUpon>
4703+
</Compile>
46974704
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MenuFlyoutTests\MenuFlyout_IosNative.xaml.cs">
46984705
<DependentUpon>MenuFlyout_IosNative.xaml</DependentUpon>
46994706
</Compile>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<UserControl
2+
x:Class="UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutTests.MenuFlyoutItem_Hierarchy"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutItemTests"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300"
10+
d:DesignWidth="400">
11+
12+
<Grid>
13+
<Grid.RowDefinitions>
14+
<RowDefinition/>
15+
<RowDefinition/>
16+
</Grid.RowDefinitions>
17+
<TextBlock x:Name="results" Text="Starting..." />
18+
<Button Content="Help" AutomationProperties.AutomationId="Help">
19+
<Button.Flyout>
20+
<MenuFlyout>
21+
22+
<MenuFlyoutItem Text="View Help"
23+
AutomationProperties.AutomationId="MenuViewHelp"
24+
Click="{x:Bind OnItemClicked}"/>
25+
26+
<MenuFlyoutSubItem Text="Disabled"
27+
IsEnabled="False"
28+
AutomationProperties.AutomationId="MenuDisabled">
29+
<MenuFlyoutItem Text="Can't be seen"
30+
AutomationProperties.AutomationId="MenuCollapsed"
31+
Click="{x:Bind OnItemClicked}" />
32+
</MenuFlyoutSubItem>
33+
34+
<MenuFlyoutSubItem Text="Send Feedback"
35+
AutomationProperties.AutomationId="MenuFeedback">
36+
37+
<MenuFlyoutItem Text="Report Problem"
38+
AutomationProperties.AutomationId="MenuReportProblem"
39+
Click="{x:Bind OnItemClicked}"/>
40+
41+
<MenuFlyoutItem Text="Suggest Feature"
42+
AutomationProperties.AutomationId="MenuSuggestFeature"
43+
Click="{x:Bind OnItemClicked}"/>
44+
45+
<MenuFlyoutSubItem Text="Settings"
46+
AutomationProperties.AutomationId="MenuSettings">
47+
48+
<MenuFlyoutItem Text="Auto Save"
49+
AutomationProperties.AutomationId="MenuAutoSave"
50+
Click="{x:Bind OnItemClicked}" />
51+
52+
<MenuFlyoutItem Text="Start Up"
53+
AutomationProperties.AutomationId="MenuStartup"
54+
Click="{x:Bind OnItemClicked}"/>
55+
56+
<MenuFlyoutItem Text="Font and Colors"
57+
AutomationProperties.AutomationId="MenuFontsAndColors"
58+
Click="{x:Bind OnItemClicked}"/>
59+
</MenuFlyoutSubItem>
60+
</MenuFlyoutSubItem>
61+
</MenuFlyout>
62+
</Button.Flyout>
63+
</Button>
64+
65+
</Grid>
66+
</UserControl>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.Foundation;
7+
using Windows.Foundation.Collections;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Controls.Primitives;
11+
using Windows.UI.Xaml.Data;
12+
using Windows.UI.Xaml.Input;
13+
using Windows.UI.Xaml.Media;
14+
using Windows.UI.Xaml.Navigation;
15+
16+
namespace UITests.Shared.Windows_UI_Xaml_Controls.MenuFlyoutTests
17+
{
18+
[Uno.UI.Samples.Controls.SampleControlInfo("MenuFlyout", "MenuFlyoutItem_Hierarchy")]
19+
public sealed partial class MenuFlyoutItem_Hierarchy : UserControl
20+
{
21+
public MenuFlyoutItem_Hierarchy()
22+
{
23+
this.InitializeComponent();
24+
}
25+
26+
public void OnItemClicked(object sender, object args)
27+
{
28+
if(sender is MenuFlyoutItem item)
29+
{
30+
results.Text = item.Text;
31+
}
32+
}
33+
}
34+
}

src/Uno.UI/UI/Xaml/Controls/Popup/Popup.iOS.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ partial void OnPopupPanelChangedPartial(PopupPanel previousPanel, PopupPanel new
5656
newPanel.Background = GetPanelBackground();
5757

5858
RegisterPopupPanel();
59+
RegisterPopupPanelChild();
5960
}
6061
}
6162

@@ -64,6 +65,7 @@ private protected override void OnLoaded()
6465
base.OnLoaded();
6566

6667
RegisterPopupPanel();
68+
RegisterPopupPanelChild();
6769
}
6870

6971
private void RegisterPopupPanel()
@@ -77,14 +79,14 @@ private void RegisterPopupPanel()
7779
{
7880
MainWindow.AddSubview(PopupPanel);
7981
}
80-
81-
RegisterPopupPanelChild();
8282
}
8383

8484
private void RegisterPopupPanelChild(bool force = false)
8585
{
8686
if ((IsLoaded || force) && Child != null)
8787
{
88+
RegisterPopupPanel();
89+
8890
if (!PopupPanel.Children.Contains(Child))
8991
{
9092
PopupPanel.Children.Add(Child);

0 commit comments

Comments
 (0)