-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wait for parent to get set before realizing titleview (#17360)
- Loading branch information
Showing
3 changed files
with
128 additions
and
3 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
src/Controls/samples/Controls.Sample.UITests/Issues/Issue17347.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 17347, "Setting a new TitleView on an already created page crashes iOS", PlatformAffected.iOS)] | ||
public class Issue17347 : TestContentPage | ||
{ | ||
protected override void Init() | ||
{ | ||
var navPage = new NavigationPage(new MainPage()); | ||
NavigatedTo += Issue16499_NavigatedTo; | ||
|
||
async void Issue16499_NavigatedTo(object sender, NavigatedToEventArgs e) | ||
{ | ||
NavigatedTo -= Issue16499_NavigatedTo; | ||
|
||
await Navigation.PushModalAsync(navPage); | ||
await navPage.Navigation.PushAsync(new MainPage()); | ||
await navPage.Navigation.PushAsync(new MainPage()); | ||
await navPage.Navigation.PopAsync(); | ||
await navPage.Navigation.PopAsync(); | ||
} | ||
} | ||
|
||
public partial class MainPage : ContentPage | ||
{ | ||
Label TopView; | ||
static int i = 0; | ||
protected override void OnAppearing() | ||
{ | ||
Content = new VerticalStackLayout() | ||
{ | ||
new Button() | ||
{ | ||
AutomationId = "PopMeButton", | ||
Command = new Command(async () => | ||
{ | ||
if (Navigation.NavigationStack.Count == 1) | ||
await Navigation.PopModalAsync(); | ||
else | ||
await Navigation.PopAsync(); | ||
}), | ||
Text = "Click to Pop This Page If Needed" | ||
} | ||
}; | ||
|
||
var increment = $"{i++}"; | ||
TopView = new() | ||
{ | ||
AutomationId = "TitleViewLabel" + increment | ||
}; | ||
|
||
TopView.SetBinding(Label.TextProperty, "AutomationId"); | ||
TopView.BindingContext = TopView; | ||
|
||
TopView.WidthRequest = App.Current.Windows[0].Page.Width / 2; | ||
NavigationPage.SetTitleView(this, TopView); | ||
NavigationPage.SetHasNavigationBar(this, true); | ||
NavigationPage.SetHasBackButton(this, false); | ||
base.OnAppearing(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Drawing; | ||
using Microsoft.Maui.Appium; | ||
using NUnit.Framework; | ||
using OpenQA.Selenium.Appium.MultiTouch; | ||
using TestUtils.Appium.UITests; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue17347 : _IssuesUITest | ||
{ | ||
public Issue17347(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "Setting a new TitleView on an already created page crashes iOS"; | ||
|
||
[Test] | ||
public void AppDoesntCrashWhenSettingNewTitleViewOnExistingPage() { | ||
try | ||
{ | ||
App.WaitForElement("TitleViewLabel4", timeout: TimeSpan.FromSeconds(4)); | ||
} | ||
finally | ||
{ | ||
App.Tap("PopMeButton"); | ||
} | ||
} | ||
} | ||
} |