Skip to content
Merged
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
24 changes: 20 additions & 4 deletions src/Controls/tests/Core.UnitTests/PageTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
using Xunit;
Expand Down Expand Up @@ -295,13 +296,15 @@ public void BusyNotSentWhenNotVisible()
}

[Fact]
public void BusySentWhenBusyPageAppears()
public async Task BusySentWhenBusyPageAppears()
{
TaskCompletionSource tcs = new TaskCompletionSource();
var sent = false;
MessagingCenter.Subscribe<Page, bool>(this, Page.BusySetSignalName, (p, b) =>
{
Assert.True(b);
sent = true;
tcs.SetResult();
});

var page = new ContentPage { IsBusy = true, IsPlatformEnabled = true };
Expand All @@ -310,12 +313,15 @@ public void BusySentWhenBusyPageAppears()

_ = new TestWindow(page);

await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));

Assert.True(sent, "Busy message not sent when visible");
}

[Fact]
public void BusySentWhenBusyPageDisappears()
public async Task BusySentWhenBusyPageDisappears()
{
TaskCompletionSource tcs = new TaskCompletionSource();
var page = new ContentPage { IsBusy = true };
_ = new TestWindow(page);
((IPageController)page).SendAppearing();
Expand All @@ -325,18 +331,26 @@ public void BusySentWhenBusyPageDisappears()
{
Assert.False(b);
sent = true;
tcs.SetResult();
});

((IPageController)page).SendDisappearing();

await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));

Assert.True(sent, "Busy message not sent when visible");
}

[Fact]
public void BusySentWhenVisiblePageSetToBusy()
public async Task BusySentWhenVisiblePageSetToBusy()
{
var sent = false;
MessagingCenter.Subscribe<Page, bool>(this, Page.BusySetSignalName, (p, b) => sent = true);
TaskCompletionSource tcs = new TaskCompletionSource();
MessagingCenter.Subscribe<Page, bool>(this, Page.BusySetSignalName, (p, b) =>
{
sent = true;
tcs.SetResult();
});

var page = new ContentPage();
_ = new TestWindow(page);
Expand All @@ -346,6 +360,8 @@ public void BusySentWhenVisiblePageSetToBusy()

page.IsBusy = true;

await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));

Assert.True(sent, "Busy message not sent when visible");
}

Expand Down
Loading