Update remaining test expectations with new behaviour

This commit is contained in:
Dean Herbert 2022-08-31 00:57:30 +09:00
parent a62ba9e0d9
commit 31a9980686
3 changed files with 11 additions and 3 deletions

View File

@ -110,7 +110,8 @@ public void TestImportantWhileClosed()
{ {
AddStep(@"simple #1", sendHelloNotification); AddStep(@"simple #1", sendHelloNotification);
AddAssert("Is visible", () => notificationOverlay.State.Value == Visibility.Visible); AddAssert("toast displayed", () => notificationOverlay.ToastCount == 1);
AddAssert("is not visible", () => notificationOverlay.State.Value == Visibility.Hidden);
checkDisplayedCount(1); checkDisplayedCount(1);
@ -183,7 +184,7 @@ protected override void Update()
} }
private void checkDisplayedCount(int expected) => private void checkDisplayedCount(int expected) =>
AddAssert($"Displayed count is {expected}", () => notificationOverlay.UnreadCount.Value == expected); AddUntilStep($"Displayed count is {expected}", () => notificationOverlay.UnreadCount.Value == expected);
private void sendDownloadProgress() private void sendDownloadProgress()
{ {

View File

@ -129,6 +129,8 @@ protected override void LoadComplete()
public IBindable<int> UnreadCount => unreadCount; public IBindable<int> UnreadCount => unreadCount;
public int ToastCount => toastTray.UnreadCount;
private readonly BindableInt unreadCount = new BindableInt(); private readonly BindableInt unreadCount = new BindableInt();
private int runningDepth; private int runningDepth;
@ -155,7 +157,10 @@ public void Post(Notification notification) => postScheduler.Add(() =>
playDebouncedSample(notification.PopInSampleName); playDebouncedSample(notification.PopInSampleName);
if (State.Value == Visibility.Hidden) if (State.Value == Visibility.Hidden)
{
toastTray.Post(notification); toastTray.Post(notification);
updateCounts();
}
else else
addPermanently(notification); addPermanently(notification);
}); });
@ -220,7 +225,7 @@ private void playDebouncedSample(string sampleName)
private void updateCounts() private void updateCounts()
{ {
unreadCount.Value = sections.Select(c => c.UnreadCount).Sum(); unreadCount.Value = sections.Select(c => c.UnreadCount).Sum() + toastTray.UnreadCount;
} }
private void markAllRead() private void markAllRead()

View File

@ -32,6 +32,8 @@ public class NotificationOverlayToastTray : CompositeDrawable
public Action<Notification>? ForwardNotificationToPermanentStore { get; set; } public Action<Notification>? ForwardNotificationToPermanentStore { get; set; }
public int UnreadCount => toastFlow.Count(n => !n.WasClosed && !n.Read);
private int runningDepth; private int runningDepth;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]