Skip to content

Commit

Permalink
Fix dotnet#22633 & UI Test (dotnet#22644)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo authored May 24, 2024
1 parent a7705a9 commit 2e308dc
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,8 @@ void UpdateApplyShadow(bool value)

void UpdatePageSpecifics()
{
ChildViewControllerForHomeIndicatorAutoHidden.SetNeedsUpdateOfHomeIndicatorAutoHidden();
ChildViewControllerForStatusBarHidden().SetNeedsStatusBarAppearanceUpdate();
ChildViewControllerForHomeIndicatorAutoHidden?.SetNeedsUpdateOfHomeIndicatorAutoHidden();
ChildViewControllerForStatusBarHidden()?.SetNeedsStatusBarAppearanceUpdate();
}

public override UIViewController ChildViewControllerForStatusBarHidden()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ public override UIViewController ChildViewControllerForHomeIndicatorAutoHidden

void UpdatePageSpecifics()
{
ChildViewControllerForHomeIndicatorAutoHidden.SetNeedsUpdateOfHomeIndicatorAutoHidden();
ChildViewControllerForStatusBarHidden().SetNeedsStatusBarAppearanceUpdate();
ChildViewControllerForHomeIndicatorAutoHidden?.SetNeedsUpdateOfHomeIndicatorAutoHidden();
ChildViewControllerForStatusBarHidden()?.SetNeedsStatusBarAppearanceUpdate();
}

void Reset()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue22633 : _IssuesUITest
{
public Issue22633(TestDevice device) : base(device)
{
}

public override string Issue => "[iOS] Crash on when initializing a TabbedPage without children";

[Test]
public void ExceptionShouldNotBeThrown()
{
App.WaitForElement("label");
}
}
}
6 changes: 6 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue22633.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue22633"
Title="Issue22633">
</TabbedPage>
38 changes: 38 additions & 0 deletions src/Controls/tests/TestCases/Issues/Issue22633.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;
using System.Threading.Tasks;

namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 22633, "[iOS] Crash on when initializing a TabbedPage without children", PlatformAffected.iOS)]
public partial class Issue22633 : TabbedPage
{
public Issue22633()
{
InitializeComponent();
}

protected override void OnAppearing()
{
base.OnAppearing();
_ = SimulateNavigationServiceAsync();
}

async Task SimulateNavigationServiceAsync()
{
// add a delay to simulate the navigation service
await Task.Delay(100);

Children.Add(new ContentPage
{
Title = "Page1",
Content = new VerticalStackLayout()
{
new Label() { AutomationId = "label", Text = "Hello, World!" }
}
});

Children.Add(new ContentPage { Title = "Page2" });
}
}

0 comments on commit 2e308dc

Please sign in to comment.