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 PopLifeCycle more reliable #21380

Merged
merged 3 commits into from
Mar 22, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,22 @@ public async Task PopLifeCycle(bool useMaui)
ContentPage pageDisappeared = null;

NavigationPage nav = new TestNavigationPage(useMaui, initialPage);

// Because of queued change propagation on BPs
// sometimes the appearing will fire a bit later than we expect.
// This ensures the first one fires before we move on
TaskCompletionSource waitForFirstAppearing = new TaskCompletionSource();
initialPage.Appearing += OnInitialPageAppearing;
void OnInitialPageAppearing(object sender, EventArgs e)
{
waitForFirstAppearing.SetResult();
initialPage.Appearing -= OnInitialPageAppearing;
}

_ = new TestWindow(nav);
nav.SendAppearing();

nav.SendAppearing();
await waitForFirstAppearing.Task;
initialPage.Appearing += (sender, _)
=> rootPageFiresAppearingAfterPop = (ContentPage)sender;

Expand Down
4 changes: 4 additions & 0 deletions src/Core/tests/UnitTests/Hosting/HostBuilderLoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public void CanAddLoggingProviders()
var mauiApp = builder.Build();

ILogger logger = mauiApp.Services.GetService<ILogger<HostBuilderLoggingTests>>();

// When running in parallel "build" might generate messages
// from the dispatcher so let's clear those up before starting our test
loggerProvider.Messages.Clear();
logger.LogError("An error");
Assert.Single(loggerProvider.Messages);
Assert.Equal("An error", loggerProvider.Messages[0]);
Expand Down
Loading